Skip to content

Commit

Permalink
Add nullptr check
Browse files Browse the repository at this point in the history
  • Loading branch information
mbrobbel committed Sep 27, 2023
1 parent 2d49291 commit f428ab7
Showing 1 changed file with 15 additions and 9 deletions.
24 changes: 15 additions & 9 deletions exporters/otlp/src/otlp_recordable_utils.cc
Original file line number Diff line number Diff line change
Expand Up @@ -77,21 +77,27 @@ void OtlpRecordableUtils::PopulateRequest(
{
// Add the resource
auto resource_spans = request->add_resource_spans();
proto::resource::v1::Resource resource_proto;
OtlpPopulateAttributeUtils::PopulateAttribute(&resource_proto, *input_resource_spans.first);
*resource_spans->mutable_resource() = resource_proto;
resource_spans->set_schema_url(input_resource_spans.first->GetSchemaURL());
if (input_resource_spans.first)
{
proto::resource::v1::Resource resource_proto;
OtlpPopulateAttributeUtils::PopulateAttribute(&resource_proto, *input_resource_spans.first);
*resource_spans->mutable_resource() = resource_proto;
resource_spans->set_schema_url(input_resource_spans.first->GetSchemaURL());
}

// Add all scope spans
for (auto &input_scope_spans : input_resource_spans.second)
{
// Add the instrumentation scope
auto scope_spans = resource_spans->add_scope_spans();
proto::common::v1::InstrumentationScope instrumentation_scope_proto;
instrumentation_scope_proto.set_name(input_scope_spans.first->GetName());
instrumentation_scope_proto.set_version(input_scope_spans.first->GetVersion());
*scope_spans->mutable_scope() = instrumentation_scope_proto;
scope_spans->set_schema_url(input_scope_spans.first->GetSchemaURL());
if (input_scope_spans.first)
{
proto::common::v1::InstrumentationScope instrumentation_scope_proto;
instrumentation_scope_proto.set_name(input_scope_spans.first->GetName());
instrumentation_scope_proto.set_version(input_scope_spans.first->GetVersion());
*scope_spans->mutable_scope() = instrumentation_scope_proto;
scope_spans->set_schema_url(input_scope_spans.first->GetSchemaURL());
}

// Add all spans to this scope spans
for (auto &input_span : input_scope_spans.second)
Expand Down

0 comments on commit f428ab7

Please sign in to comment.