Skip to content

Commit f718fd3

Browse files
committed
fix(otel): do not use mappings for otel profile partitioning
1 parent ad56611 commit f718fd3

File tree

4 files changed

+19
-8
lines changed

4 files changed

+19
-8
lines changed

pkg/ingester/otlp/ingest_handler.go

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ package otlp
33
import (
44
"context"
55
"fmt"
6+
"github.com/grafana/pyroscope/pkg/model"
7+
model2 "github.com/prometheus/common/model"
68
"net/http"
79
"strings"
810

@@ -159,13 +161,17 @@ func getServiceNameFromAttributes(attrs []v1.KeyValue) string {
159161
func getDefaultLabels() []*typesv1.LabelPair {
160162
return []*typesv1.LabelPair{
161163
{
162-
Name: "__name__",
164+
Name: model2.MetricNameLabel,
163165
Value: "process_cpu",
164166
},
165167
{
166-
Name: "__delta__",
168+
Name: model.LabelNameDelta,
167169
Value: "false",
168170
},
171+
{
172+
Name: model.LabelNameOTEL,
173+
Value: "true",
174+
},
169175
{
170176
Name: "pyroscope_spy",
171177
Value: "unknown",

pkg/model/labels.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ const (
2424
LabelNameProfileType = "__profile_type__"
2525
LabelNameServiceNamePrivate = "__service_name__"
2626
LabelNameDelta = "__delta__"
27+
LabelNameOTEL = "__otel__"
2728
LabelNameProfileName = pmodel.MetricNameLabel
2829
LabelNamePeriodType = "__period_type__"
2930
LabelNamePeriodUnit = "__period_unit__"

pkg/model/profile.go

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -70,13 +70,15 @@ func NewSpanSelector(spans []string) (SpanSelector, error) {
7070
return m, nil
7171
}
7272

73-
func StacktracePartitionFromProfile(lbls []Labels, p *profilev1.Profile) uint64 {
74-
return xxhash.Sum64String(stacktracePartitionKeyFromProfile(lbls, p))
73+
func StacktracePartitionFromProfile(lbls []Labels, p *profilev1.Profile, otel bool) uint64 {
74+
return xxhash.Sum64String(stacktracePartitionKeyFromProfile(lbls, p, otel))
7575
}
7676

77-
func stacktracePartitionKeyFromProfile(lbls []Labels, p *profilev1.Profile) string {
78-
// take the first mapping (which is the main binary's file basename)
79-
if len(p.Mapping) > 0 {
77+
func stacktracePartitionKeyFromProfile(lbls []Labels, p *profilev1.Profile, otel bool) string {
78+
// Take the first mapping (which is the main binary's file basename)
79+
// OTEL (at least from ebpf profiler at the time of writing) mappings are unreliable and ordered unpredictably and
80+
// have no VA addresses (only relative to the shared object base)
81+
if len(p.Mapping) > 0 && !otel {
8082
if filenameID := p.Mapping[0].Filename; filenameID > 0 {
8183
if filename := extractMappingFilename(p.StringTable[filenameID]); filename != "" {
8284
return filename

pkg/phlaredb/head.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,8 @@ func (h *Head) Ingest(ctx context.Context, p *profilev1.Profile, id uuid.UUID, e
194194

195195
delta := phlaremodel.Labels(externalLabels).Get(phlaremodel.LabelNameDelta) != "false"
196196
externalLabels = phlaremodel.Labels(externalLabels).Delete(phlaremodel.LabelNameDelta)
197+
otel := phlaremodel.Labels(externalLabels).Get(phlaremodel.LabelNameOTEL) != "false"
198+
externalLabels = phlaremodel.Labels(externalLabels).Delete(phlaremodel.LabelNameOTEL)
197199

198200
enforceLabelOrder := phlaremodel.Labels(externalLabels).Get(phlaremodel.LabelNameOrder) == phlaremodel.LabelOrderEnforced
199201
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
207209
}
208210

209211
// determine the stacktraces partition ID
210-
partition := phlaremodel.StacktracePartitionFromProfile(lbls, p)
212+
partition := phlaremodel.StacktracePartitionFromProfile(lbls, p, otel)
211213

212214
metricName := phlaremodel.Labels(externalLabels).Get(model.MetricNameLabel)
213215

0 commit comments

Comments
 (0)