From 668fa4836cc3f387334d09ff85c5430be143af4f Mon Sep 17 00:00:00 2001 From: Jonas Kunz Date: Wed, 7 Feb 2024 14:51:00 +0100 Subject: [PATCH] Added support for elastic.profiler_stack_trace_ids OTel attribute (#202) Maps the Otel attribute elastic.profiler_stack_trace_ids to the new ES field transaction.profiler_stack_trace_ids, which will use counted_keyword as type. --- .../modeldecoder/rumv3/transaction_test.go | 2 +- .../modeldecoder/v2/transaction_test.go | 15 ++ input/otlp/traces.go | 15 +- input/otlp/traces_test.go | 20 +++ model/modeljson/internal/marshal_fastjson.go | 17 +++ model/modeljson/internal/transaction.go | 31 +++-- model/modeljson/transaction.pb.json.go | 15 +- model/modeljson/transaction.pb.json_test.go | 21 +-- model/modelpb/transaction.pb.go | 129 ++++++++++-------- model/modelpb/transaction_vtproto.pb.go | 56 ++++++++ model/proto/transaction.proto | 1 + 11 files changed, 230 insertions(+), 92 deletions(-) diff --git a/input/elasticapm/internal/modeldecoder/rumv3/transaction_test.go b/input/elasticapm/internal/modeldecoder/rumv3/transaction_test.go index 95fd6a60..721fa357 100644 --- a/input/elasticapm/internal/modeldecoder/rumv3/transaction_test.go +++ b/input/elasticapm/internal/modeldecoder/rumv3/transaction_test.go @@ -189,7 +189,7 @@ func TestDecodeMapToTransactionModel(t *testing.T) { exceptions := func(key string) bool { for _, s := range []string{ // values not set for RUM v3 - "Kind", "representative_count", "message", "dropped_spans_stats", + "Kind", "representative_count", "message", "dropped_spans_stats", "profiler_stack_trace_ids", // Not set for transaction events: "AggregatedDuration", "AggregatedDuration.Count", diff --git a/input/elasticapm/internal/modeldecoder/v2/transaction_test.go b/input/elasticapm/internal/modeldecoder/v2/transaction_test.go index bf94dd79..e1e4859a 100644 --- a/input/elasticapm/internal/modeldecoder/v2/transaction_test.go +++ b/input/elasticapm/internal/modeldecoder/v2/transaction_test.go @@ -268,6 +268,8 @@ func TestDecodeMapToTransactionModel(t *testing.T) { "representative_count", // Kind is tested further down "Kind", + // profiler_stack_trace_ids are supplied as OTel-attributes + "profiler_stack_trace_ids", // Not set for transaction events, tested in metricset decoding: "AggregatedDuration", @@ -636,6 +638,19 @@ func TestDecodeMapToTransactionModel(t *testing.T) { mapToTransactionModel(&input, &event) assert.Equal(t, "CLIENT", event.Span.Kind) }) + + t.Run("elastic-profiling-ids", func(t *testing.T) { + var input transaction + var event modelpb.APMEvent + modeldecodertest.SetStructValues(&input, modeldecodertest.DefaultValues()) + attrs := map[string]interface{}{ + "elastic.profiler_stack_trace_ids": []interface{}{"id1", "id2"}, + } + input.OTel.Attributes = attrs + + mapToTransactionModel(&input, &event) + assert.Equal(t, []string{"id1", "id2"}, event.Transaction.ProfilerStackTraceIds) + }) }) t.Run("labels", func(t *testing.T) { var input transaction diff --git a/input/otlp/traces.go b/input/otlp/traces.go index 3b1b486e..29dd1145 100644 --- a/input/otlp/traces.go +++ b/input/otlp/traces.go @@ -41,6 +41,7 @@ import ( "math" "net" "net/url" + "slices" "strconv" "strings" "time" @@ -275,7 +276,19 @@ func TranslateTransaction( k := replaceDots(kDots) switch v.Type() { case pcommon.ValueTypeSlice: - setLabel(k, event, ifaceAttributeValue(v)) + switch kDots { + case "elastic.profiler_stack_trace_ids": + var vSlice = v.Slice() + event.Transaction.ProfilerStackTraceIds = slices.Grow(event.Transaction.ProfilerStackTraceIds, vSlice.Len()) + for i := 0; i < vSlice.Len(); i++ { + var idVal = vSlice.At(i) + if idVal.Type() == pcommon.ValueTypeStr { + event.Transaction.ProfilerStackTraceIds = append(event.Transaction.ProfilerStackTraceIds, idVal.Str()) + } + } + default: + setLabel(k, event, ifaceAttributeValue(v)) + } case pcommon.ValueTypeBool: setLabel(k, event, ifaceAttributeValue(v)) case pcommon.ValueTypeDouble: diff --git a/input/otlp/traces_test.go b/input/otlp/traces_test.go index 84e29643..42eca9cf 100644 --- a/input/otlp/traces_test.go +++ b/input/otlp/traces_test.go @@ -949,6 +949,26 @@ func TestArrayLabels(t *testing.T) { }, modelpb.NumericLabels(spanEvent.NumericLabels)) } +func TestProfilerStackTraceIds(t *testing.T) { + validIds := []interface{}{"myId1", "myId2"} + badValueTypes := []interface{}{42, 68, "valid"} + + tx1 := transformTransactionWithAttributes(t, map[string]interface{}{ + "elastic.profiler_stack_trace_ids": validIds, + }) + assert.Equal(t, []string{"myId1", "myId2"}, tx1.Transaction.ProfilerStackTraceIds) + + tx2 := transformTransactionWithAttributes(t, map[string]interface{}{ + "elastic.profiler_stack_trace_ids": badValueTypes, + }) + assert.Equal(t, []string{"valid"}, tx2.Transaction.ProfilerStackTraceIds) + + tx3 := transformTransactionWithAttributes(t, map[string]interface{}{ + "elastic.profiler_stack_trace_ids": "bad type", + }) + assert.Equal(t, []string(nil), tx3.Transaction.ProfilerStackTraceIds) +} + func TestConsumeTracesExportTimestamp(t *testing.T) { traces, otelSpans := newTracesSpans() diff --git a/model/modeljson/internal/marshal_fastjson.go b/model/modeljson/internal/marshal_fastjson.go index e316d732..702d9187 100644 --- a/model/modeljson/internal/marshal_fastjson.go +++ b/model/modeljson/internal/marshal_fastjson.go @@ -3365,6 +3365,23 @@ func (v *Transaction) MarshalFastJSON(w *fastjson.Writer) error { } w.String(v.Name) } + if v.ProfilerStackTraceIds != nil { + const prefix = ",\"profiler_stack_trace_ids\":" + if first { + first = false + w.RawString(prefix[1:]) + } else { + w.RawString(prefix) + } + w.RawByte('[') + for i, v := range v.ProfilerStackTraceIds { + if i != 0 { + w.RawByte(',') + } + w.String(v) + } + w.RawByte(']') + } if v.RepresentativeCount != 0 { const prefix = ",\"representative_count\":" if first { diff --git a/model/modeljson/internal/transaction.go b/model/modeljson/internal/transaction.go index b1070353..8a4dd4e3 100644 --- a/model/modeljson/internal/transaction.go +++ b/model/modeljson/internal/transaction.go @@ -18,21 +18,22 @@ package modeljson type Transaction struct { - SpanCount SpanCount `json:"span_count,omitempty"` - UserExperience *UserExperience `json:"experience,omitempty"` - Custom KeyValueSlice `json:"custom,omitempty"` - Marks map[string]map[string]float64 `json:"marks,omitempty"` - Message *Message `json:"message,omitempty"` - Type string `json:"type,omitempty"` - Name string `json:"name,omitempty"` - Result string `json:"result,omitempty"` - ID string `json:"id,omitempty"` - DurationHistogram Histogram `json:"duration.histogram,omitempty"` - DroppedSpansStats []DroppedSpanStats `json:"dropped_spans_stats,omitempty"` - DurationSummary SummaryMetric `json:"duration.summary,omitempty"` - RepresentativeCount float64 `json:"representative_count,omitempty"` - Sampled bool `json:"sampled,omitempty"` - Root bool `json:"root,omitempty"` + SpanCount SpanCount `json:"span_count,omitempty"` + UserExperience *UserExperience `json:"experience,omitempty"` + Custom KeyValueSlice `json:"custom,omitempty"` + Marks map[string]map[string]float64 `json:"marks,omitempty"` + Message *Message `json:"message,omitempty"` + Type string `json:"type,omitempty"` + Name string `json:"name,omitempty"` + Result string `json:"result,omitempty"` + ID string `json:"id,omitempty"` + DurationHistogram Histogram `json:"duration.histogram,omitempty"` + DroppedSpansStats []DroppedSpanStats `json:"dropped_spans_stats,omitempty"` + ProfilerStackTraceIds []string `json:"profiler_stack_trace_ids,omitempty"` + DurationSummary SummaryMetric `json:"duration.summary,omitempty"` + RepresentativeCount float64 `json:"representative_count,omitempty"` + Sampled bool `json:"sampled,omitempty"` + Root bool `json:"root,omitempty"` } type SpanCount struct { diff --git a/model/modeljson/transaction.pb.json.go b/model/modeljson/transaction.pb.json.go index 23d4f232..d1ee4ac7 100644 --- a/model/modeljson/transaction.pb.json.go +++ b/model/modeljson/transaction.pb.json.go @@ -26,13 +26,14 @@ import ( func TransactionModelJSON(e *modelpb.Transaction, out *modeljson.Transaction, metricset bool) { *out = modeljson.Transaction{ - ID: e.Id, - Type: e.Type, - Name: e.Name, - Result: e.Result, - Sampled: e.Sampled, - Root: e.Root, - RepresentativeCount: e.RepresentativeCount, + ID: e.Id, + Type: e.Type, + Name: e.Name, + Result: e.Result, + Sampled: e.Sampled, + Root: e.Root, + RepresentativeCount: e.RepresentativeCount, + ProfilerStackTraceIds: e.ProfilerStackTraceIds, } if e.Custom != nil { diff --git a/model/modeljson/transaction.pb.json_test.go b/model/modeljson/transaction.pb.json_test.go index c0781c65..8da00924 100644 --- a/model/modeljson/transaction.pb.json_test.go +++ b/model/modeljson/transaction.pb.json_test.go @@ -106,9 +106,10 @@ func TestTransactionToModelJSON(t *testing.T) { Count: 6, Sum: 7, }, - RepresentativeCount: 8, - Sampled: true, - Root: true, + RepresentativeCount: 8, + Sampled: true, + Root: true, + ProfilerStackTraceIds: []string{"foo", "foo", "bar"}, }, expectedNoMetricset: &modeljson.Transaction{ SpanCount: modeljson.SpanCount{ @@ -134,9 +135,10 @@ func TestTransactionToModelJSON(t *testing.T) { Count: 6, Sum: 7, }, - RepresentativeCount: 8, - Sampled: true, - Root: true, + RepresentativeCount: 8, + Sampled: true, + Root: true, + ProfilerStackTraceIds: []string{"foo", "foo", "bar"}, }, expectedMetricset: &modeljson.Transaction{ SpanCount: modeljson.SpanCount{ @@ -174,9 +176,10 @@ func TestTransactionToModelJSON(t *testing.T) { Count: 6, Sum: 7, }, - RepresentativeCount: 8, - Sampled: true, - Root: true, + RepresentativeCount: 8, + Sampled: true, + Root: true, + ProfilerStackTraceIds: []string{"foo", "foo", "bar"}, }, }, } diff --git a/model/modelpb/transaction.pb.go b/model/modelpb/transaction.pb.go index fa898656..5b38ef02 100644 --- a/model/modelpb/transaction.pb.go +++ b/model/modelpb/transaction.pb.go @@ -43,21 +43,22 @@ type Transaction struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - SpanCount *SpanCount `protobuf:"bytes,1,opt,name=span_count,json=spanCount,proto3" json:"span_count,omitempty"` - UserExperience *UserExperience `protobuf:"bytes,2,opt,name=user_experience,json=userExperience,proto3" json:"user_experience,omitempty"` - Custom []*KeyValue `protobuf:"bytes,3,rep,name=custom,proto3" json:"custom,omitempty"` - Marks map[string]*TransactionMark `protobuf:"bytes,4,rep,name=marks,proto3" json:"marks,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` - Message *Message `protobuf:"bytes,5,opt,name=message,proto3" json:"message,omitempty"` - Type string `protobuf:"bytes,6,opt,name=type,proto3" json:"type,omitempty"` - Name string `protobuf:"bytes,7,opt,name=name,proto3" json:"name,omitempty"` - Result string `protobuf:"bytes,8,opt,name=result,proto3" json:"result,omitempty"` - Id string `protobuf:"bytes,9,opt,name=id,proto3" json:"id,omitempty"` - DurationHistogram *Histogram `protobuf:"bytes,10,opt,name=duration_histogram,json=durationHistogram,proto3" json:"duration_histogram,omitempty"` - DroppedSpansStats []*DroppedSpanStats `protobuf:"bytes,11,rep,name=dropped_spans_stats,json=droppedSpansStats,proto3" json:"dropped_spans_stats,omitempty"` - DurationSummary *SummaryMetric `protobuf:"bytes,12,opt,name=duration_summary,json=durationSummary,proto3" json:"duration_summary,omitempty"` - RepresentativeCount float64 `protobuf:"fixed64,13,opt,name=representative_count,json=representativeCount,proto3" json:"representative_count,omitempty"` - Sampled bool `protobuf:"varint,14,opt,name=sampled,proto3" json:"sampled,omitempty"` - Root bool `protobuf:"varint,15,opt,name=root,proto3" json:"root,omitempty"` + SpanCount *SpanCount `protobuf:"bytes,1,opt,name=span_count,json=spanCount,proto3" json:"span_count,omitempty"` + UserExperience *UserExperience `protobuf:"bytes,2,opt,name=user_experience,json=userExperience,proto3" json:"user_experience,omitempty"` + Custom []*KeyValue `protobuf:"bytes,3,rep,name=custom,proto3" json:"custom,omitempty"` + Marks map[string]*TransactionMark `protobuf:"bytes,4,rep,name=marks,proto3" json:"marks,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` + Message *Message `protobuf:"bytes,5,opt,name=message,proto3" json:"message,omitempty"` + Type string `protobuf:"bytes,6,opt,name=type,proto3" json:"type,omitempty"` + Name string `protobuf:"bytes,7,opt,name=name,proto3" json:"name,omitempty"` + Result string `protobuf:"bytes,8,opt,name=result,proto3" json:"result,omitempty"` + Id string `protobuf:"bytes,9,opt,name=id,proto3" json:"id,omitempty"` + DurationHistogram *Histogram `protobuf:"bytes,10,opt,name=duration_histogram,json=durationHistogram,proto3" json:"duration_histogram,omitempty"` + DroppedSpansStats []*DroppedSpanStats `protobuf:"bytes,11,rep,name=dropped_spans_stats,json=droppedSpansStats,proto3" json:"dropped_spans_stats,omitempty"` + DurationSummary *SummaryMetric `protobuf:"bytes,12,opt,name=duration_summary,json=durationSummary,proto3" json:"duration_summary,omitempty"` + RepresentativeCount float64 `protobuf:"fixed64,13,opt,name=representative_count,json=representativeCount,proto3" json:"representative_count,omitempty"` + Sampled bool `protobuf:"varint,14,opt,name=sampled,proto3" json:"sampled,omitempty"` + Root bool `protobuf:"varint,15,opt,name=root,proto3" json:"root,omitempty"` + ProfilerStackTraceIds []string `protobuf:"bytes,16,rep,name=profiler_stack_trace_ids,json=profilerStackTraceIds,proto3" json:"profiler_stack_trace_ids,omitempty"` } func (x *Transaction) Reset() { @@ -197,6 +198,13 @@ func (x *Transaction) GetRoot() bool { return false } +func (x *Transaction) GetProfilerStackTraceIds() []string { + if x != nil { + return x.ProfilerStackTraceIds + } + return nil +} + type SpanCount struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache @@ -387,7 +395,7 @@ var file_transaction_proto_rawDesc = []byte{ 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x0d, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x0f, 0x6d, 0x65, 0x74, 0x72, 0x69, 0x63, 0x73, 0x65, 0x74, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x0e, 0x6b, 0x65, 0x79, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x2e, - 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0xa5, 0x06, 0x0a, 0x0b, 0x54, 0x72, 0x61, 0x6e, 0x73, 0x61, + 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0xde, 0x06, 0x0a, 0x0b, 0x54, 0x72, 0x61, 0x6e, 0x73, 0x61, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x38, 0x0a, 0x0a, 0x73, 0x70, 0x61, 0x6e, 0x5f, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x19, 0x2e, 0x65, 0x6c, 0x61, 0x73, 0x74, 0x69, 0x63, 0x2e, 0x61, 0x70, 0x6d, 0x2e, 0x76, 0x31, 0x2e, 0x53, 0x70, 0x61, 0x6e, 0x43, @@ -432,50 +440,53 @@ var file_transaction_proto_rawDesc = []byte{ 0x6f, 0x75, 0x6e, 0x74, 0x12, 0x18, 0x0a, 0x07, 0x73, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x64, 0x18, 0x0e, 0x20, 0x01, 0x28, 0x08, 0x52, 0x07, 0x73, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x64, 0x12, 0x12, 0x0a, 0x04, 0x72, 0x6f, 0x6f, 0x74, 0x18, 0x0f, 0x20, 0x01, 0x28, 0x08, 0x52, 0x04, 0x72, 0x6f, - 0x6f, 0x74, 0x1a, 0x59, 0x0a, 0x0a, 0x4d, 0x61, 0x72, 0x6b, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, - 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, - 0x65, 0x79, 0x12, 0x35, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, - 0x0b, 0x32, 0x1f, 0x2e, 0x65, 0x6c, 0x61, 0x73, 0x74, 0x69, 0x63, 0x2e, 0x61, 0x70, 0x6d, 0x2e, - 0x76, 0x31, 0x2e, 0x54, 0x72, 0x61, 0x6e, 0x73, 0x61, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x4d, 0x61, - 0x72, 0x6b, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x22, 0x61, 0x0a, - 0x09, 0x53, 0x70, 0x61, 0x6e, 0x43, 0x6f, 0x75, 0x6e, 0x74, 0x12, 0x1d, 0x0a, 0x07, 0x64, 0x72, - 0x6f, 0x70, 0x70, 0x65, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0d, 0x48, 0x00, 0x52, 0x07, 0x64, - 0x72, 0x6f, 0x70, 0x70, 0x65, 0x64, 0x88, 0x01, 0x01, 0x12, 0x1d, 0x0a, 0x07, 0x73, 0x74, 0x61, - 0x72, 0x74, 0x65, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0d, 0x48, 0x01, 0x52, 0x07, 0x73, 0x74, - 0x61, 0x72, 0x74, 0x65, 0x64, 0x88, 0x01, 0x01, 0x42, 0x0a, 0x0a, 0x08, 0x5f, 0x64, 0x72, 0x6f, - 0x70, 0x70, 0x65, 0x64, 0x42, 0x0a, 0x0a, 0x08, 0x5f, 0x73, 0x74, 0x61, 0x72, 0x74, 0x65, 0x64, - 0x22, 0xa9, 0x01, 0x0a, 0x0f, 0x54, 0x72, 0x61, 0x6e, 0x73, 0x61, 0x63, 0x74, 0x69, 0x6f, 0x6e, - 0x4d, 0x61, 0x72, 0x6b, 0x12, 0x55, 0x0a, 0x0c, 0x6d, 0x65, 0x61, 0x73, 0x75, 0x72, 0x65, 0x6d, - 0x65, 0x6e, 0x74, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x31, 0x2e, 0x65, 0x6c, 0x61, + 0x6f, 0x74, 0x12, 0x37, 0x0a, 0x18, 0x70, 0x72, 0x6f, 0x66, 0x69, 0x6c, 0x65, 0x72, 0x5f, 0x73, + 0x74, 0x61, 0x63, 0x6b, 0x5f, 0x74, 0x72, 0x61, 0x63, 0x65, 0x5f, 0x69, 0x64, 0x73, 0x18, 0x10, + 0x20, 0x03, 0x28, 0x09, 0x52, 0x15, 0x70, 0x72, 0x6f, 0x66, 0x69, 0x6c, 0x65, 0x72, 0x53, 0x74, + 0x61, 0x63, 0x6b, 0x54, 0x72, 0x61, 0x63, 0x65, 0x49, 0x64, 0x73, 0x1a, 0x59, 0x0a, 0x0a, 0x4d, + 0x61, 0x72, 0x6b, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, + 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x35, 0x0a, 0x05, 0x76, + 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1f, 0x2e, 0x65, 0x6c, 0x61, 0x73, 0x74, 0x69, 0x63, 0x2e, 0x61, 0x70, 0x6d, 0x2e, 0x76, 0x31, 0x2e, 0x54, 0x72, 0x61, 0x6e, - 0x73, 0x61, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x4d, 0x61, 0x72, 0x6b, 0x2e, 0x4d, 0x65, 0x61, 0x73, - 0x75, 0x72, 0x65, 0x6d, 0x65, 0x6e, 0x74, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, 0x0c, 0x6d, - 0x65, 0x61, 0x73, 0x75, 0x72, 0x65, 0x6d, 0x65, 0x6e, 0x74, 0x73, 0x1a, 0x3f, 0x0a, 0x11, 0x4d, - 0x65, 0x61, 0x73, 0x75, 0x72, 0x65, 0x6d, 0x65, 0x6e, 0x74, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, - 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, - 0x65, 0x79, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, - 0x01, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x22, 0x8e, 0x02, 0x0a, - 0x10, 0x44, 0x72, 0x6f, 0x70, 0x70, 0x65, 0x64, 0x53, 0x70, 0x61, 0x6e, 0x53, 0x74, 0x61, 0x74, - 0x73, 0x12, 0x40, 0x0a, 0x1c, 0x64, 0x65, 0x73, 0x74, 0x69, 0x6e, 0x61, 0x74, 0x69, 0x6f, 0x6e, - 0x5f, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x5f, 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, - 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x1a, 0x64, 0x65, 0x73, 0x74, 0x69, 0x6e, 0x61, - 0x74, 0x69, 0x6f, 0x6e, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x52, 0x65, 0x73, 0x6f, 0x75, - 0x72, 0x63, 0x65, 0x12, 0x2e, 0x0a, 0x13, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x5f, 0x74, - 0x61, 0x72, 0x67, 0x65, 0x74, 0x5f, 0x74, 0x79, 0x70, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, - 0x52, 0x11, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x54, 0x61, 0x72, 0x67, 0x65, 0x74, 0x54, - 0x79, 0x70, 0x65, 0x12, 0x2e, 0x0a, 0x13, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x5f, 0x74, - 0x61, 0x72, 0x67, 0x65, 0x74, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, - 0x52, 0x11, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x54, 0x61, 0x72, 0x67, 0x65, 0x74, 0x4e, - 0x61, 0x6d, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x6f, 0x75, 0x74, 0x63, 0x6f, 0x6d, 0x65, 0x18, 0x04, - 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x6f, 0x75, 0x74, 0x63, 0x6f, 0x6d, 0x65, 0x12, 0x3e, 0x0a, - 0x08, 0x64, 0x75, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x05, 0x20, 0x01, 0x28, 0x0b, 0x32, - 0x22, 0x2e, 0x65, 0x6c, 0x61, 0x73, 0x74, 0x69, 0x63, 0x2e, 0x61, 0x70, 0x6d, 0x2e, 0x76, 0x31, - 0x2e, 0x41, 0x67, 0x67, 0x72, 0x65, 0x67, 0x61, 0x74, 0x65, 0x64, 0x44, 0x75, 0x72, 0x61, 0x74, - 0x69, 0x6f, 0x6e, 0x52, 0x08, 0x64, 0x75, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x42, 0x2b, 0x5a, - 0x29, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x65, 0x6c, 0x61, 0x73, - 0x74, 0x69, 0x63, 0x2f, 0x61, 0x70, 0x6d, 0x2d, 0x64, 0x61, 0x74, 0x61, 0x2f, 0x6d, 0x6f, 0x64, - 0x65, 0x6c, 0x2f, 0x6d, 0x6f, 0x64, 0x65, 0x6c, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, - 0x6f, 0x33, + 0x73, 0x61, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x4d, 0x61, 0x72, 0x6b, 0x52, 0x05, 0x76, 0x61, 0x6c, + 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x22, 0x61, 0x0a, 0x09, 0x53, 0x70, 0x61, 0x6e, 0x43, 0x6f, + 0x75, 0x6e, 0x74, 0x12, 0x1d, 0x0a, 0x07, 0x64, 0x72, 0x6f, 0x70, 0x70, 0x65, 0x64, 0x18, 0x01, + 0x20, 0x01, 0x28, 0x0d, 0x48, 0x00, 0x52, 0x07, 0x64, 0x72, 0x6f, 0x70, 0x70, 0x65, 0x64, 0x88, + 0x01, 0x01, 0x12, 0x1d, 0x0a, 0x07, 0x73, 0x74, 0x61, 0x72, 0x74, 0x65, 0x64, 0x18, 0x02, 0x20, + 0x01, 0x28, 0x0d, 0x48, 0x01, 0x52, 0x07, 0x73, 0x74, 0x61, 0x72, 0x74, 0x65, 0x64, 0x88, 0x01, + 0x01, 0x42, 0x0a, 0x0a, 0x08, 0x5f, 0x64, 0x72, 0x6f, 0x70, 0x70, 0x65, 0x64, 0x42, 0x0a, 0x0a, + 0x08, 0x5f, 0x73, 0x74, 0x61, 0x72, 0x74, 0x65, 0x64, 0x22, 0xa9, 0x01, 0x0a, 0x0f, 0x54, 0x72, + 0x61, 0x6e, 0x73, 0x61, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x4d, 0x61, 0x72, 0x6b, 0x12, 0x55, 0x0a, + 0x0c, 0x6d, 0x65, 0x61, 0x73, 0x75, 0x72, 0x65, 0x6d, 0x65, 0x6e, 0x74, 0x73, 0x18, 0x01, 0x20, + 0x03, 0x28, 0x0b, 0x32, 0x31, 0x2e, 0x65, 0x6c, 0x61, 0x73, 0x74, 0x69, 0x63, 0x2e, 0x61, 0x70, + 0x6d, 0x2e, 0x76, 0x31, 0x2e, 0x54, 0x72, 0x61, 0x6e, 0x73, 0x61, 0x63, 0x74, 0x69, 0x6f, 0x6e, + 0x4d, 0x61, 0x72, 0x6b, 0x2e, 0x4d, 0x65, 0x61, 0x73, 0x75, 0x72, 0x65, 0x6d, 0x65, 0x6e, 0x74, + 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, 0x0c, 0x6d, 0x65, 0x61, 0x73, 0x75, 0x72, 0x65, 0x6d, + 0x65, 0x6e, 0x74, 0x73, 0x1a, 0x3f, 0x0a, 0x11, 0x4d, 0x65, 0x61, 0x73, 0x75, 0x72, 0x65, 0x6d, + 0x65, 0x6e, 0x74, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, + 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x14, 0x0a, 0x05, 0x76, + 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x01, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, + 0x65, 0x3a, 0x02, 0x38, 0x01, 0x22, 0x8e, 0x02, 0x0a, 0x10, 0x44, 0x72, 0x6f, 0x70, 0x70, 0x65, + 0x64, 0x53, 0x70, 0x61, 0x6e, 0x53, 0x74, 0x61, 0x74, 0x73, 0x12, 0x40, 0x0a, 0x1c, 0x64, 0x65, + 0x73, 0x74, 0x69, 0x6e, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, + 0x65, 0x5f, 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, + 0x52, 0x1a, 0x64, 0x65, 0x73, 0x74, 0x69, 0x6e, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x53, 0x65, 0x72, + 0x76, 0x69, 0x63, 0x65, 0x52, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x12, 0x2e, 0x0a, 0x13, + 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x5f, 0x74, 0x61, 0x72, 0x67, 0x65, 0x74, 0x5f, 0x74, + 0x79, 0x70, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x11, 0x73, 0x65, 0x72, 0x76, 0x69, + 0x63, 0x65, 0x54, 0x61, 0x72, 0x67, 0x65, 0x74, 0x54, 0x79, 0x70, 0x65, 0x12, 0x2e, 0x0a, 0x13, + 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x5f, 0x74, 0x61, 0x72, 0x67, 0x65, 0x74, 0x5f, 0x6e, + 0x61, 0x6d, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x11, 0x73, 0x65, 0x72, 0x76, 0x69, + 0x63, 0x65, 0x54, 0x61, 0x72, 0x67, 0x65, 0x74, 0x4e, 0x61, 0x6d, 0x65, 0x12, 0x18, 0x0a, 0x07, + 0x6f, 0x75, 0x74, 0x63, 0x6f, 0x6d, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x6f, + 0x75, 0x74, 0x63, 0x6f, 0x6d, 0x65, 0x12, 0x3e, 0x0a, 0x08, 0x64, 0x75, 0x72, 0x61, 0x74, 0x69, + 0x6f, 0x6e, 0x18, 0x05, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x22, 0x2e, 0x65, 0x6c, 0x61, 0x73, 0x74, + 0x69, 0x63, 0x2e, 0x61, 0x70, 0x6d, 0x2e, 0x76, 0x31, 0x2e, 0x41, 0x67, 0x67, 0x72, 0x65, 0x67, + 0x61, 0x74, 0x65, 0x64, 0x44, 0x75, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x08, 0x64, 0x75, + 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x42, 0x2b, 0x5a, 0x29, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, + 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x65, 0x6c, 0x61, 0x73, 0x74, 0x69, 0x63, 0x2f, 0x61, 0x70, 0x6d, + 0x2d, 0x64, 0x61, 0x74, 0x61, 0x2f, 0x6d, 0x6f, 0x64, 0x65, 0x6c, 0x2f, 0x6d, 0x6f, 0x64, 0x65, + 0x6c, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( diff --git a/model/modelpb/transaction_vtproto.pb.go b/model/modelpb/transaction_vtproto.pb.go index 214574ef..c2cafefe 100644 --- a/model/modelpb/transaction_vtproto.pb.go +++ b/model/modelpb/transaction_vtproto.pb.go @@ -77,6 +77,11 @@ func (m *Transaction) CloneVT() *Transaction { } r.DroppedSpansStats = tmpContainer } + if rhs := m.ProfilerStackTraceIds; rhs != nil { + tmpContainer := make([]string, len(rhs)) + copy(tmpContainer, rhs) + r.ProfilerStackTraceIds = tmpContainer + } if len(m.unknownFields) > 0 { r.unknownFields = make([]byte, len(m.unknownFields)) copy(r.unknownFields, m.unknownFields) @@ -186,6 +191,17 @@ func (m *Transaction) MarshalToSizedBufferVT(dAtA []byte) (int, error) { i -= len(m.unknownFields) copy(dAtA[i:], m.unknownFields) } + if len(m.ProfilerStackTraceIds) > 0 { + for iNdEx := len(m.ProfilerStackTraceIds) - 1; iNdEx >= 0; iNdEx-- { + i -= len(m.ProfilerStackTraceIds[iNdEx]) + copy(dAtA[i:], m.ProfilerStackTraceIds[iNdEx]) + i = encodeVarint(dAtA, i, uint64(len(m.ProfilerStackTraceIds[iNdEx]))) + i-- + dAtA[i] = 0x1 + i-- + dAtA[i] = 0x82 + } + } if m.Root { i-- if m.Root { @@ -525,9 +541,11 @@ func (m *Transaction) ResetVT() { } f1 := m.DroppedSpansStats[:0] m.DurationSummary.ReturnToVTPool() + f2 := m.ProfilerStackTraceIds[:0] m.Reset() m.Custom = f0 m.DroppedSpansStats = f1 + m.ProfilerStackTraceIds = f2 } } func (m *Transaction) ReturnToVTPool() { @@ -679,6 +697,12 @@ func (m *Transaction) SizeVT() (n int) { if m.Root { n += 2 } + if len(m.ProfilerStackTraceIds) > 0 { + for _, s := range m.ProfilerStackTraceIds { + l = len(s) + n += 2 + l + sov(uint64(l)) + } + } n += len(m.unknownFields) return n } @@ -1346,6 +1370,38 @@ func (m *Transaction) UnmarshalVT(dAtA []byte) error { } } m.Root = bool(v != 0) + case 16: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ProfilerStackTraceIds", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLength + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.ProfilerStackTraceIds = append(m.ProfilerStackTraceIds, string(dAtA[iNdEx:postIndex])) + iNdEx = postIndex default: iNdEx = preIndex skippy, err := skip(dAtA[iNdEx:]) diff --git a/model/proto/transaction.proto b/model/proto/transaction.proto index 631b48c6..6e44b145 100644 --- a/model/proto/transaction.proto +++ b/model/proto/transaction.proto @@ -42,6 +42,7 @@ message Transaction { double representative_count = 13; bool sampled = 14; bool root = 15; + repeated string profiler_stack_trace_ids = 16; } message SpanCount {