From b2f5e19277a95e91b25b77ef51dbcba3cf1395c8 Mon Sep 17 00:00:00 2001 From: Tommy Reilly Date: Mon, 11 Nov 2024 22:59:09 -0500 Subject: [PATCH] Fix errors against parca-dev/opentelemetry-ebpf-profile HEAD --- main.go | 29 +++++++++++------------------ reporter/parca_reporter.go | 11 +++++++++-- 2 files changed, 20 insertions(+), 20 deletions(-) diff --git a/main.go b/main.go index 592ba08084..182f5f6dc1 100644 --- a/main.go +++ b/main.go @@ -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" @@ -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" @@ -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 { @@ -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 @@ -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 { diff --git a/reporter/parca_reporter.go b/reporter/parca_reporter.go index ee6caeb1f3..58ec3d8255 100644 --- a/reporter/parca_reporter.go +++ b/reporter/parca_reporter.go @@ -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) { @@ -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) @@ -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.