diff --git a/.chloggen/elasticsearchexporter-profiling-duplicate-events.yaml b/.chloggen/elasticsearchexporter-profiling-duplicate-events.yaml new file mode 100644 index 0000000000000..518106ea97f80 --- /dev/null +++ b/.chloggen/elasticsearchexporter-profiling-duplicate-events.yaml @@ -0,0 +1,27 @@ +# Use this changelog template to create an entry for release notes. + +# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix' +change_type: enhancement + +# The name of the component, or a single word describing the area of concern, (e.g. filelogreceiver) +component: elasticsearchexporter + +# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`). +note: Duplicate profiling events with count values larger than 1 + +# Mandatory: One or more tracking issues related to the change. You can use the PR number here if no issue exists. +issues: [40946] + +# (Optional) One or more lines of additional information to render under the primary note. +# These lines will be padded with 2 spaces and then inserted directly into the document. +# Use pipe (|) for multiline entries. +subtext: Having all events with count=1 enables random sampling on the read path. + +# If your change doesn't affect end users or the exported elements of any package, +# you should instead start your pull request title with [chore] or use the "Skip Changelog" label. +# Optional: The change log or logs in which this entry should be included. +# e.g. '[user]' or '[user, api]' +# Include 'user' if the change is relevant to end users. +# Include 'api' if there is a change to a library API. +# Default: '[user]' +change_logs: [user] diff --git a/exporter/elasticsearchexporter/internal/serializer/otelserializer/serializeprofiles/transform.go b/exporter/elasticsearchexporter/internal/serializer/otelserializer/serializeprofiles/transform.go index 5b0bcbe131383..a5cda56962b70 100644 --- a/exporter/elasticsearchexporter/internal/serializer/otelserializer/serializeprofiles/transform.go +++ b/exporter/elasticsearchexporter/internal/serializer/otelserializer/serializeprofiles/transform.go @@ -140,12 +140,11 @@ func stackPayloads(dic pprofile.ProfilesDictionary, resource pcommon.Resource, s t := sample.TimestampsUnixNano().At(j) event.TimeStamp = newUnixTime64(t) + count := 1 if j < sample.Value().Len() { - event.Count = uint16(sample.Value().At(j)) - } else { - event.Count = 1 // restore default + count = int(sample.Value().At(j)) } - if event.Count > 0 { + for range count { stackPayload = append(stackPayload, StackPayload{ StackTraceEvent: event, }) @@ -221,7 +220,7 @@ func stackTraceEvent(dic pprofile.ProfilesDictionary, traceID string, sample ppr EcsVersion: EcsVersion{V: EcsVersionString}, HostID: hostMetadata[string(semconv.HostIDKey)], StackTraceID: traceID, - Count: 1, // TODO: Check whether count can be dropped with nanosecond timestamps + Count: 1, // Elasticsearch v9.2+ doesn't read the count value any more. Frequency: frequency, } diff --git a/exporter/elasticsearchexporter/internal/serializer/otelserializer/serializeprofiles/transform_test.go b/exporter/elasticsearchexporter/internal/serializer/otelserializer/serializeprofiles/transform_test.go index 6ed602e9ffdcc..b159e663c6aa6 100644 --- a/exporter/elasticsearchexporter/internal/serializer/otelserializer/serializeprofiles/transform_test.go +++ b/exporter/elasticsearchexporter/internal/serializer/otelserializer/serializeprofiles/transform_test.go @@ -509,7 +509,16 @@ func TestStackPayloads(t *testing.T) { TimeStamp: 1000000000, StackTraceID: wantedTraceID, Frequency: 20, - Count: 2, + Count: 1, + }, + }, + { + StackTraceEvent: StackTraceEvent{ + EcsVersion: EcsVersion{V: EcsVersionString}, + TimeStamp: 1000000000, + StackTraceID: wantedTraceID, + Frequency: 20, + Count: 1, }, }, },