Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove reference to deprecated InstrumentationLibrary in OTLP #1469

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class OtlpRecordable final : public opentelemetry::sdk::trace::Recordable
const std::string GetResourceSchemaURL() const noexcept;
const std::string GetInstrumentationLibrarySchemaURL() const noexcept;

proto::common::v1::InstrumentationLibrary GetProtoInstrumentationLibrary() const noexcept;
proto::common::v1::InstrumentationScope GetProtoInstrumentationScope() const noexcept;

void SetIdentity(const opentelemetry::trace::SpanContext &span_context,
opentelemetry::trace::SpanId parent_span_id) noexcept override;
Expand Down
10 changes: 5 additions & 5 deletions exporters/otlp/src/otlp_recordable.cc
Original file line number Diff line number Diff line change
Expand Up @@ -62,16 +62,16 @@ const std::string OtlpRecordable::GetInstrumentationLibrarySchemaURL() const noe
return schema_url;
}

proto::common::v1::InstrumentationLibrary OtlpRecordable::GetProtoInstrumentationLibrary()
proto::common::v1::InstrumentationScope OtlpRecordable::GetProtoInstrumentationScope()
const noexcept
{
proto::common::v1::InstrumentationLibrary instrumentation_library;
proto::common::v1::InstrumentationScope instrumentation_scope;
if (instrumentation_library_)
{
instrumentation_library.set_name(instrumentation_library_->GetName());
instrumentation_library.set_version(instrumentation_library_->GetVersion());
instrumentation_scope.set_name(instrumentation_library_->GetName());
instrumentation_scope.set_version(instrumentation_library_->GetVersion());
}
return instrumentation_library;
return instrumentation_scope;
}

void OtlpRecordable::SetResource(const sdk::resource::Resource &resource) noexcept
Expand Down
10 changes: 5 additions & 5 deletions exporters/otlp/src/otlp_recordable_utils.cc
Original file line number Diff line number Diff line change
Expand Up @@ -59,13 +59,13 @@ void OtlpRecordableUtils::PopulateRequest(
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();
auto resource_span = request->add_resource_spans();
auto scope_spans = resource_span->add_scope_spans();

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

instrumentation_lib->set_schema_url(rec->GetInstrumentationLibrarySchemaURL());
scope_spans->set_schema_url(rec->GetInstrumentationLibrarySchemaURL());

*resource_span->mutable_resource() = rec->ProtoResource();
resource_span->set_schema_url(rec->GetResourceSchemaURL());
Expand Down
11 changes: 5 additions & 6 deletions exporters/otlp/test/otlp_http_exporter_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -141,10 +141,10 @@ TEST_F(OtlpHttpExporterTestPeer, ExportJsonIntegrationTest)
.WillOnce([&mock_session,
report_trace_id](opentelemetry::ext::http::client::EventHandler &callback) {
auto check_json = nlohmann::json::parse(mock_session->GetRequest()->body_, nullptr, false);
auto resource_span = *check_json["resource_spans"].begin();
auto instrumentation_library_span = *resource_span["instrumentation_library_spans"].begin();
auto span = *instrumentation_library_span["spans"].begin();
auto received_trace_id = span["trace_id"].get<std::string>();
auto resource_span = *check_json["resource_spans"].begin();
auto scope_span = *resource_span["scope_spans"].begin();
auto span = *scope_span["spans"].begin();
auto received_trace_id = span["trace_id"].get<std::string>();
EXPECT_EQ(received_trace_id, report_trace_id);

auto custom_header = mock_session->GetRequest()->headers_.find("Custom-Header-Key");
Expand Down Expand Up @@ -222,8 +222,7 @@ TEST_F(OtlpHttpExporterTestPeer, ExportBinaryIntegrationTest)
opentelemetry::proto::collector::trace::v1::ExportTraceServiceRequest request_body;
request_body.ParseFromArray(&mock_session->GetRequest()->body_[0],
static_cast<int>(mock_session->GetRequest()->body_.size()));
auto received_trace_id =
request_body.resource_spans(0).instrumentation_library_spans(0).spans(0).trace_id();
auto received_trace_id = request_body.resource_spans(0).scope_spans(0).spans(0).trace_id();
EXPECT_EQ(received_trace_id, report_trace_id);

auto custom_header = mock_session->GetRequest()->headers_.find("Custom-Header-Key");
Expand Down
2 changes: 1 addition & 1 deletion exporters/otlp/test/otlp_recordable_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ TEST(OtlpRecordable, SetInstrumentationLibrary)
OtlpRecordable rec;
auto inst_lib = trace_sdk::InstrumentationLibrary::Create("test", "v1");
rec.SetInstrumentationLibrary(*inst_lib);
auto proto_instr_libr = rec.GetProtoInstrumentationLibrary();
auto proto_instr_libr = rec.GetProtoInstrumentationScope();
EXPECT_EQ(proto_instr_libr.name(), inst_lib->GetName());
EXPECT_EQ(proto_instr_libr.version(), inst_lib->GetVersion());
}
Expand Down