From 8bd65dd5fadb3b1a4431a3b8474bd9468078ad3b Mon Sep 17 00:00:00 2001 From: Florian Lehner Date: Tue, 24 Sep 2024 08:12:08 +0200 Subject: [PATCH 1/5] reporter: use semantic convention to report frame type With https://github.com/open-telemetry/semantic-conventions/pull/1188 a semantic convention for frame types was defined and https://github.com/open-telemetry/opentelemetry-proto/pull/578 removed Location.type_index from the OTel profiling signal in favor of the semantic convention. Update the reporter to use this semantic convention. Signed-off-by: Florian Lehner --- libpf/interpretertype.go | 4 ++-- libpf/libpf_test.go | 2 +- reporter/otlp_reporter.go | 8 +++++--- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/libpf/interpretertype.go b/libpf/interpretertype.go index 48db6474..392bb701 100644 --- a/libpf/interpretertype.go +++ b/libpf/interpretertype.go @@ -55,13 +55,13 @@ var interpreterTypeToString = map[InterpreterType]string{ UnknownInterp: "unknown", PHP: "php", PHPJIT: "phpjit", - Python: "python", + Python: "cpython", Native: "native", Kernel: "kernel", HotSpot: "jvm", Ruby: "ruby", Perl: "perl", - V8: "v8", + V8: "v8js", Dotnet: "dotnet", APMInt: "apm-integration", } diff --git a/libpf/libpf_test.go b/libpf/libpf_test.go index cc76f09c..a1303e84 100644 --- a/libpf/libpf_test.go +++ b/libpf/libpf_test.go @@ -29,7 +29,7 @@ func TestTraceType(t *testing.T) { ty: PythonFrame, isErr: false, interp: Python, - str: "python", + str: "cpython", }, { ty: NativeFrame.Error(), diff --git a/reporter/otlp_reporter.go b/reporter/otlp_reporter.go index f23968e9..a60973e7 100644 --- a/reporter/otlp_reporter.go +++ b/reporter/otlp_reporter.go @@ -547,13 +547,15 @@ func (r *OTLPReporter) getProfile() (profile *profiles.Profile, startTS, endTS u // Walk every frame of the trace. for i := range traceInfo.frameTypes { + frameAttributes := addProfileAttributes(profile, []attrKeyValue{ + {key: "profile.frame.type", value: traceInfo.frameTypes[i].String()}, + }, attributeMap) + loc := &profiles.Location{ // Id - Optional element we do not use. - TypeIndex: getStringMapIndex(stringMap, - traceInfo.frameTypes[i].String()), Address: uint64(traceInfo.linenos[i]), // IsFolded - Optional element we do not use. - // Attributes - Optional element we do not use. + Attributes: frameAttributes, } switch frameKind := traceInfo.frameTypes[i]; frameKind { From dfeddf9ad2686a3f0e73e485b343c90ea3787ef7 Mon Sep 17 00:00:00 2001 From: Florian Lehner Date: Thu, 3 Oct 2024 10:33:19 +0200 Subject: [PATCH 2/5] fixup: add new devfiler version Signed-off-by: Florian Lehner --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 775d4247..03c65082 100644 --- a/README.md +++ b/README.md @@ -87,9 +87,9 @@ devfiler spins up a local server that listens on `0.0.0.0:11000`. To run it, simply download and unpack the archive from the following URL: -https://upload.elastic.co/d/783f2fc7bcf34bd4ba5aa85676710d171ac574f8e6e99c85addabe9202673fdc +https://upload.elastic.co/d/87e7697991940ec37f0c6e39ac38d213f65e8dc1ef9dbedff6aab9cba0adfaba -Authentication token: `801c759135b8bdb2` +Authentication token: `c74dfc4db2212015` The archive contains a build for each of the following platforms: From d49c23daea54bf9975ccb3bf8d04e27b17c377ea Mon Sep 17 00:00:00 2001 From: Florian Lehner Date: Mon, 14 Oct 2024 14:36:54 +0200 Subject: [PATCH 3/5] fixup: drop -error and jitt suffix Signed-off-by: Florian Lehner --- libpf/frametype.go | 5 ----- libpf/frametype_test.go | 8 +++++--- libpf/interpretertype.go | 24 ++++++++++++++---------- libpf/libpf_test.go | 2 +- 4 files changed, 20 insertions(+), 19 deletions(-) diff --git a/libpf/frametype.go b/libpf/frametype.go index cc3cf045..30ec130d 100644 --- a/libpf/frametype.go +++ b/libpf/frametype.go @@ -4,8 +4,6 @@ package libpf // import "go.opentelemetry.io/ebpf-profiler/libpf" import ( - "fmt" - "go.opentelemetry.io/ebpf-profiler/support" ) @@ -98,9 +96,6 @@ func (ty FrameType) String() string { return abortFrameName default: interp := ty.Interpreter() - if ty.IsError() { - return fmt.Sprintf("%s-error", interp) - } return interp.String() } } diff --git a/libpf/frametype_test.go b/libpf/frametype_test.go index 0cec0938..52dc0b93 100644 --- a/libpf/frametype_test.go +++ b/libpf/frametype_test.go @@ -14,8 +14,10 @@ func TestFrameTypeFromString(t *testing.T) { for _, ft := range []FrameType{ unknownFrame, PHPFrame, PythonFrame, NativeFrame, KernelFrame, HotSpotFrame, RubyFrame, PerlFrame, V8Frame, DotnetFrame, AbortFrame} { - name := ft.String() - result := FrameTypeFromString(name) - require.Equal(t, ft, result) + t.Run(ft.String(), func(t *testing.T) { + name := ft.String() + result := FrameTypeFromString(name) + require.Equal(t, ft, result) + }) } } diff --git a/libpf/interpretertype.go b/libpf/interpretertype.go index 9a22624d..d6be8137 100644 --- a/libpf/interpretertype.go +++ b/libpf/interpretertype.go @@ -54,22 +54,26 @@ func (i InterpreterType) Frame() FrameType { var interpreterTypeToString = map[InterpreterType]string{ UnknownInterp: "unknown", PHP: "php", - PHPJIT: "phpjit", - Python: "cpython", - Native: "native", - Kernel: "kernel", - HotSpot: "jvm", - Ruby: "ruby", - Perl: "perl", - V8: "v8js", - Dotnet: "dotnet", - APMInt: "apm-integration", + // OTel SemConv does not differentiate between jitted code and interpreted code. + PHPJIT: "php", + Python: "cpython", + Native: "native", + Kernel: "kernel", + HotSpot: "jvm", + Ruby: "ruby", + Perl: "perl", + V8: "v8js", + Dotnet: "dotnet", + APMInt: "apm-integration", } var stringToInterpreterType = make(map[string]InterpreterType, len(interpreterTypeToString)) func init() { for k, v := range interpreterTypeToString { + if k == PHPJIT { + continue + } stringToInterpreterType[v] = k } } diff --git a/libpf/libpf_test.go b/libpf/libpf_test.go index a1303e84..d2f0e938 100644 --- a/libpf/libpf_test.go +++ b/libpf/libpf_test.go @@ -35,7 +35,7 @@ func TestTraceType(t *testing.T) { ty: NativeFrame.Error(), isErr: true, interp: Native, - str: "native-error", + str: "native", }, } From 6a493db7d9a985ee60e414c8488d981867987820 Mon Sep 17 00:00:00 2001 From: Florian Lehner Date: Mon, 14 Oct 2024 14:38:20 +0200 Subject: [PATCH 4/5] fixup: filter APMInt frames Signed-off-by: Florian Lehner --- libpf/interpretertype.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libpf/interpretertype.go b/libpf/interpretertype.go index d6be8137..c8c66bb3 100644 --- a/libpf/interpretertype.go +++ b/libpf/interpretertype.go @@ -71,7 +71,7 @@ var stringToInterpreterType = make(map[string]InterpreterType, len(interpreterTy func init() { for k, v := range interpreterTypeToString { - if k == PHPJIT { + if k == PHPJIT || k == APMInt { continue } stringToInterpreterType[v] = k From 97c97279d508a9450d98efcc91a10c3c06747b3e Mon Sep 17 00:00:00 2001 From: Florian Lehner Date: Tue, 15 Oct 2024 17:20:39 +0200 Subject: [PATCH 5/5] Update libpf/interpretertype.go Co-authored-by: Christos Kalkanis --- libpf/interpretertype.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libpf/interpretertype.go b/libpf/interpretertype.go index c8c66bb3..d6be8137 100644 --- a/libpf/interpretertype.go +++ b/libpf/interpretertype.go @@ -71,7 +71,7 @@ var stringToInterpreterType = make(map[string]InterpreterType, len(interpreterTy func init() { for k, v := range interpreterTypeToString { - if k == PHPJIT || k == APMInt { + if k == PHPJIT { continue } stringToInterpreterType[v] = k