Skip to content

Commit

Permalink
Fix sharing resource in batched exported spans (#1386)
Browse files Browse the repository at this point in the history
Co-authored-by: Lalit Kumar Bhasin <[email protected]>
  • Loading branch information
ThomsonTan and lalitb authored May 11, 2022
1 parent 95effbd commit 88e23ad
Showing 1 changed file with 6 additions and 12 deletions.
18 changes: 6 additions & 12 deletions exporters/otlp/src/otlp_recordable_utils.cc
Original file line number Diff line number Diff line change
Expand Up @@ -259,25 +259,19 @@ void OtlpRecordableUtils::PopulateRequest(
return;
}

auto resource_span = request->add_resource_spans();
auto instrumentation_lib = resource_span->add_instrumentation_library_spans();
bool first_pass = true;

for (auto &recordable : spans)
{
auto rec = std::unique_ptr<OtlpRecordable>(static_cast<OtlpRecordable *>(recordable.release()));
auto resource_span = request->add_resource_spans();
auto instrumentation_lib = resource_span->add_instrumentation_library_spans();

*instrumentation_lib->add_spans() = std::move(rec->span());
*instrumentation_lib->mutable_instrumentation_library() = rec->GetProtoInstrumentationLibrary();

if (first_pass)
{
instrumentation_lib->set_schema_url(rec->GetInstrumentationLibrarySchemaURL());
instrumentation_lib->set_schema_url(rec->GetInstrumentationLibrarySchemaURL());

*resource_span->mutable_resource() = rec->ProtoResource();
resource_span->set_schema_url(rec->GetResourceSchemaURL());

first_pass = false;
}
*resource_span->mutable_resource() = rec->ProtoResource();
resource_span->set_schema_url(rec->GetResourceSchemaURL());
}
}

Expand Down

1 comment on commit 88e23ad

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Performance Alert ⚠️

Possible performance regression was detected for benchmark 'OpenTelemetry-cpp exporters Benchmark'.
Benchmark result of this commit is worse than the previous benchmark result exceeding threshold 2.

Benchmark suite Current: 88e23ad Previous: 95effbd Ratio
BM_OtlpExporterEmptySpans 109.39343664995776 ns/iter 39.84578695187141 ns/iter 2.75

This comment was automatically generated by workflow using github-action-benchmark.

Please sign in to comment.