Skip to content

Commit

Permalink
[chore] [exporter/splunkhec] Fix dropped events caused by refactoring (
Browse files Browse the repository at this point in the history
…open-telemetry#22103)

Fix the events in multi-batch use cases caused by the recent refactoring. No changelog entry is needed since the bug is not released yet.
  • Loading branch information
dmitryax committed May 19, 2023
1 parent 626e645 commit cf69bb0
Show file tree
Hide file tree
Showing 3 changed files with 201 additions and 67 deletions.
6 changes: 6 additions & 0 deletions exporter/splunkhecexporter/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -184,8 +184,10 @@ func (c *client) fillLogsBuffer(logs plog.Logs, bs *bufferState, is iterState) (
for i := is.resource; i < logs.ResourceLogs().Len(); i++ {
rl := logs.ResourceLogs().At(i)
for j := is.library; j < rl.ScopeLogs().Len(); j++ {
is.library = 0 // Reset library index for next resource.
sl := rl.ScopeLogs().At(j)
for k := is.record; k < sl.LogRecords().Len(); k++ {
is.record = 0 // Reset record index for next library.
logRecord := sl.LogRecords().At(k)

if c.config.ExportRaw {
Expand Down Expand Up @@ -233,8 +235,10 @@ func (c *client) fillMetricsBuffer(metrics pmetric.Metrics, bs *bufferState, is
for i := is.resource; i < metrics.ResourceMetrics().Len(); i++ {
rm := metrics.ResourceMetrics().At(i)
for j := is.library; j < rm.ScopeMetrics().Len(); j++ {
is.library = 0 // Reset library index for next resource.
sm := rm.ScopeMetrics().At(j)
for k := is.record; k < sm.Metrics().Len(); k++ {
is.record = 0 // Reset record index for next library.
metric := sm.Metrics().At(k)

// Parsing metric record to Splunk event.
Expand Down Expand Up @@ -289,8 +293,10 @@ func (c *client) fillTracesBuffer(traces ptrace.Traces, bs *bufferState, is iter
for i := is.resource; i < traces.ResourceSpans().Len(); i++ {
rs := traces.ResourceSpans().At(i)
for j := is.library; j < rs.ScopeSpans().Len(); j++ {
is.library = 0 // Reset library index for next resource.
ss := rs.ScopeSpans().At(j)
for k := is.record; k < ss.Spans().Len(); k++ {
is.record = 0 // Reset record index for next library.
span := ss.Spans().At(k)

// Parsing span record to Splunk event.
Expand Down
Loading

0 comments on commit cf69bb0

Please sign in to comment.