Skip to content

Commit

Permalink
Fix errors against parca-dev/opentelemetry-ebpf-profile HEAD
Browse files Browse the repository at this point in the history
  • Loading branch information
gnurizen committed Nov 12, 2024
1 parent afdda5a commit b2f5e19
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 20 deletions.
29 changes: 11 additions & 18 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,6 @@ import (
"github.com/apache/arrow/go/v16/arrow/memory"
"github.com/armon/circbuf"
"github.com/common-nighthawk/go-figure"
"go.opentelemetry.io/ebpf-profiler/host"
otelmetrics "go.opentelemetry.io/ebpf-profiler/metrics"
otelreporter "go.opentelemetry.io/ebpf-profiler/reporter"
"go.opentelemetry.io/ebpf-profiler/times"
"go.opentelemetry.io/ebpf-profiler/tracehandler"
"go.opentelemetry.io/ebpf-profiler/tracer"
tracertypes "go.opentelemetry.io/ebpf-profiler/tracer/types"
"go.opentelemetry.io/ebpf-profiler/util"
"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/client_golang/prometheus/collectors"
"github.com/prometheus/client_golang/prometheus/promauto"
Expand All @@ -41,6 +33,14 @@ import (
"github.com/tklauser/numcpus"
"github.com/zcalusic/sysinfo"
"go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp"
"go.opentelemetry.io/ebpf-profiler/host"
otelmetrics "go.opentelemetry.io/ebpf-profiler/metrics"
otelreporter "go.opentelemetry.io/ebpf-profiler/reporter"
"go.opentelemetry.io/ebpf-profiler/times"
"go.opentelemetry.io/ebpf-profiler/tracehandler"
"go.opentelemetry.io/ebpf-profiler/tracer"
tracertypes "go.opentelemetry.io/ebpf-profiler/tracer/types"
"go.opentelemetry.io/ebpf-profiler/util"
"go.opentelemetry.io/otel/trace"
"go.opentelemetry.io/otel/trace/noop"
"golang.org/x/sys/unix"
Expand Down Expand Up @@ -249,10 +249,6 @@ func mainWithExitCode() flags.ExitCode {
return flags.Failure(fmt.Sprintf("Failed to probe eBPF syscall: %v", err))
}

if err = tracer.ProbeTracepoint(); err != nil {
log.Warnf("Failed to probe tracepoint: %v. Parca-agent may fail to run on some kernel versions.", err)
}

externalLabels := reporter.Labels{}
if len(f.Metadata.ExternalLabels) > 0 {
for name, value := range f.Metadata.ExternalLabels {
Expand Down Expand Up @@ -317,7 +313,7 @@ func mainWithExitCode() flags.ExitCode {
return flags.Failure("Failed to start reporting: %v", err)
}
otelmetrics.SetReporter(parcaReporter)
parcaReporter.Run(mainCtx)
parcaReporter.Start(mainCtx)
var rep otelreporter.Reporter = parcaReporter

// Load the eBPF code and map definitions
Expand All @@ -340,11 +336,8 @@ func mainWithExitCode() flags.ExitCode {
log.Printf("eBPF tracer loaded")
defer trc.Close()

// Initial scan of /proc filesystem to list currently-active PIDs and have them processed.
if err = trc.StartPIDEventProcessor(mainCtx); err != nil {
log.Errorf("Failed to list processes from /proc: %v", err)
}
log.Debug("Completed initial PID listing")
// Start watching for PID events.
trc.StartPIDEventProcessor(mainCtx)

// Attach our tracer to the perf event
if err := trc.AttachTracer(); err != nil {
Expand Down
11 changes: 9 additions & 2 deletions reporter/parca_reporter.go
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,13 @@ func (r *ParcaReporter) ReportFramesForTrace(_ *libpf.Trace) {}
func (r *ParcaReporter) ReportCountForTrace(_ libpf.TraceHash, _ uint16, _ *reporter.TraceEventMeta) {
}

// ExecutableKnown returns true if the metadata of the Executable specified by fileID is
// cached in the reporter.
func (r *ParcaReporter) ExecutableKnown(fileID libpf.FileID) bool {
_, known := r.executables.Get(fileID)
return known
}

// ExecutableMetadata accepts a fileID with the corresponding filename
// and caches this information.
func (r *ParcaReporter) ExecutableMetadata(args *reporter.ExecutableMetadataArgs) {
Expand Down Expand Up @@ -526,7 +533,7 @@ func New(
return r, nil
}

func (r *ParcaReporter) Run(mainCtx context.Context) (reporter.Reporter, error) {
func (r *ParcaReporter) Start(mainCtx context.Context) error {
// Create a child context for reporting features
ctx, cancelReporting := context.WithCancel(mainCtx)

Expand Down Expand Up @@ -564,7 +571,7 @@ func (r *ParcaReporter) Run(mainCtx context.Context) (reporter.Reporter, error)
cancelReporting()
}()

return r, nil
return nil
}

// reportDataToBackend creates and sends out an arrow record for a Parca backend.
Expand Down

0 comments on commit b2f5e19

Please sign in to comment.