diff --git a/pkg/ingester/otlp/ingest_handler.go b/pkg/ingester/otlp/ingest_handler.go index 71ab6b1826..90cb9e1502 100644 --- a/pkg/ingester/otlp/ingest_handler.go +++ b/pkg/ingester/otlp/ingest_handler.go @@ -6,6 +6,10 @@ import ( "net/http" "strings" + model2 "github.com/prometheus/common/model" + + "github.com/grafana/pyroscope/pkg/model" + "connectrpc.com/connect" "github.com/go-kit/log" "github.com/go-kit/log/level" @@ -159,13 +163,17 @@ func getServiceNameFromAttributes(attrs []v1.KeyValue) string { func getDefaultLabels() []*typesv1.LabelPair { return []*typesv1.LabelPair{ { - Name: "__name__", + Name: model2.MetricNameLabel, Value: "process_cpu", }, { - Name: "__delta__", + Name: model.LabelNameDelta, Value: "false", }, + { + Name: model.LabelNameOTEL, + Value: "true", + }, { Name: "pyroscope_spy", Value: "unknown", diff --git a/pkg/model/labels.go b/pkg/model/labels.go index 666074d128..f009573baa 100644 --- a/pkg/model/labels.go +++ b/pkg/model/labels.go @@ -24,6 +24,7 @@ const ( LabelNameProfileType = "__profile_type__" LabelNameServiceNamePrivate = "__service_name__" LabelNameDelta = "__delta__" + LabelNameOTEL = "__otel__" LabelNameProfileName = pmodel.MetricNameLabel LabelNamePeriodType = "__period_type__" LabelNamePeriodUnit = "__period_unit__" diff --git a/pkg/model/profile.go b/pkg/model/profile.go index 6d4c00aac0..9f16ad2fd5 100644 --- a/pkg/model/profile.go +++ b/pkg/model/profile.go @@ -70,13 +70,15 @@ func NewSpanSelector(spans []string) (SpanSelector, error) { return m, nil } -func StacktracePartitionFromProfile(lbls []Labels, p *profilev1.Profile) uint64 { - return xxhash.Sum64String(stacktracePartitionKeyFromProfile(lbls, p)) +func StacktracePartitionFromProfile(lbls []Labels, p *profilev1.Profile, otel bool) uint64 { + return xxhash.Sum64String(stacktracePartitionKeyFromProfile(lbls, p, otel)) } -func stacktracePartitionKeyFromProfile(lbls []Labels, p *profilev1.Profile) string { - // take the first mapping (which is the main binary's file basename) - if len(p.Mapping) > 0 { +func stacktracePartitionKeyFromProfile(lbls []Labels, p *profilev1.Profile, otel bool) string { + // Take the first mapping (which is the main binary's file basename) + // OTEL (at least from ebpf profiler at the time of writing) mappings are unreliable and ordered unpredictably and + // have no VA addresses (only relative to the shared object base) + if len(p.Mapping) > 0 && !otel { if filenameID := p.Mapping[0].Filename; filenameID > 0 { if filename := extractMappingFilename(p.StringTable[filenameID]); filename != "" { return filename diff --git a/pkg/phlaredb/head.go b/pkg/phlaredb/head.go index 24239e7489..00908457e2 100644 --- a/pkg/phlaredb/head.go +++ b/pkg/phlaredb/head.go @@ -194,6 +194,8 @@ func (h *Head) Ingest(ctx context.Context, p *profilev1.Profile, id uuid.UUID, e delta := phlaremodel.Labels(externalLabels).Get(phlaremodel.LabelNameDelta) != "false" externalLabels = phlaremodel.Labels(externalLabels).Delete(phlaremodel.LabelNameDelta) + otel := phlaremodel.Labels(externalLabels).Get(phlaremodel.LabelNameOTEL) == "true" + externalLabels = phlaremodel.Labels(externalLabels).Delete(phlaremodel.LabelNameOTEL) enforceLabelOrder := phlaremodel.Labels(externalLabels).Get(phlaremodel.LabelNameOrder) == phlaremodel.LabelOrderEnforced externalLabels = phlaremodel.Labels(externalLabels).Delete(phlaremodel.LabelNameOrder) @@ -207,7 +209,7 @@ func (h *Head) Ingest(ctx context.Context, p *profilev1.Profile, id uuid.UUID, e } // determine the stacktraces partition ID - partition := phlaremodel.StacktracePartitionFromProfile(lbls, p) + partition := phlaremodel.StacktracePartitionFromProfile(lbls, p, otel) metricName := phlaremodel.Labels(externalLabels).Get(model.MetricNameLabel)