Skip to content

Commit 4fe660b

Browse files
committed
[exporter/elasticsearch] Profiling: Duplicate events if count > 1
1 parent f945dfd commit 4fe660b

File tree

3 files changed

+40
-6
lines changed

3 files changed

+40
-6
lines changed
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# Use this changelog template to create an entry for release notes.
2+
3+
# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix'
4+
change_type: enhancement
5+
6+
# The name of the component, or a single word describing the area of concern, (e.g. filelogreceiver)
7+
component: elasticsearchexporter
8+
9+
# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
10+
note: Profiling: Duplicate events with count > 1
11+
12+
# Mandatory: One or more tracking issues related to the change. You can use the PR number here if no issue exists.
13+
issues: [40946]
14+
15+
# (Optional) One or more lines of additional information to render under the primary note.
16+
# These lines will be padded with 2 spaces and then inserted directly into the document.
17+
# Use pipe (|) for multiline entries.
18+
subtext: Having all events with count=1 enables random sampling on the read path.
19+
20+
# If your change doesn't affect end users or the exported elements of any package,
21+
# you should instead start your pull request title with [chore] or use the "Skip Changelog" label.
22+
# Optional: The change log or logs in which this entry should be included.
23+
# e.g. '[user]' or '[user, api]'
24+
# Include 'user' if the change is relevant to end users.
25+
# Include 'api' if there is a change to a library API.
26+
# Default: '[user]'
27+
change_logs: [user]

exporter/elasticsearchexporter/internal/serializer/otelserializer/serializeprofiles/transform.go

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -133,12 +133,11 @@ func stackPayloads(dic pprofile.ProfilesDictionary, resource pcommon.Resource, s
133133
t := sample.TimestampsUnixNano().At(j)
134134
event.TimeStamp = newUnixTime64(t)
135135

136+
count := 1
136137
if j < sample.Value().Len() {
137-
event.Count = uint16(sample.Value().At(j))
138-
} else {
139-
event.Count = 1 // restore default
138+
count = int(sample.Value().At(j))
140139
}
141-
if event.Count > 0 {
140+
for range count {
142141
stackPayload = append(stackPayload, StackPayload{
143142
StackTraceEvent: event,
144143
})
@@ -214,7 +213,7 @@ func stackTraceEvent(dic pprofile.ProfilesDictionary, traceID string, sample ppr
214213
EcsVersion: EcsVersion{V: EcsVersionString},
215214
HostID: hostMetadata[string(semconv.HostIDKey)],
216215
StackTraceID: traceID,
217-
Count: 1, // TODO: Check whether count can be dropped with nanosecond timestamps
216+
Count: 1, // Elasticsearch v9.2+ doesn't read the count value any more.
218217
}
219218

220219
// Store event-specific attributes.

exporter/elasticsearchexporter/internal/serializer/otelserializer/serializeprofiles/transform_test.go

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -503,7 +503,15 @@ func TestStackPayloads(t *testing.T) {
503503
EcsVersion: EcsVersion{V: EcsVersionString},
504504
TimeStamp: 1000000000,
505505
StackTraceID: wantedTraceID,
506-
Count: 2,
506+
Count: 1,
507+
},
508+
},
509+
{
510+
StackTraceEvent: StackTraceEvent{
511+
EcsVersion: EcsVersion{V: EcsVersionString},
512+
TimeStamp: 1000000000,
513+
StackTraceID: wantedTraceID,
514+
Count: 1,
507515
},
508516
},
509517
},

0 commit comments

Comments
 (0)