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

reporing instumentation library as tags in jaeger span #864

Merged
merged 2 commits into from
Jun 16, 2021
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
5 changes: 4 additions & 1 deletion exporters/jaeger/src/recordable.cc
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,10 @@ void Recordable::AddEvent(nostd::string_view name,
void Recordable::SetInstrumentationLibrary(
const opentelemetry::sdk::instrumentationlibrary::InstrumentationLibrary
&instrumentation_library) noexcept
{}
{
AddTag("otel.library.name", instrumentation_library.GetName());
AddTag("otel.library.version", instrumentation_library.GetVersion());
}

void Recordable::AddLink(const trace::SpanContext &span_context,
const common::KeyValueIterable &attributes) noexcept
Expand Down
24 changes: 24 additions & 0 deletions exporters/jaeger/test/jaeger_recordable_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// SPDX-License-Identifier: Apache-2.0

#include "opentelemetry/exporters/jaeger/recordable.h"
#include "opentelemetry/sdk/instrumentationlibrary/instrumentation_library.h"
#include "opentelemetry/sdk/trace/simple_processor.h"
#include "opentelemetry/sdk/trace/span_data.h"
#include "opentelemetry/sdk/trace/tracer_provider.h"
Expand All @@ -15,6 +16,7 @@ namespace sdktrace = opentelemetry::sdk::trace;

using namespace jaegertracing;
using namespace opentelemetry::exporter::jaeger;
using namespace opentelemetry::sdk::instrumentationlibrary;

TEST(JaegerSpanRecordable, SetIdentity)
{
Expand Down Expand Up @@ -120,3 +122,25 @@ TEST(JaegerSpanRecordable, SetStatus)
EXPECT_EQ(tags[2].vType, thrift::TagType::STRING);
EXPECT_EQ(tags[2].vStr, error_description);
}

TEST(JaegerSpanRecordable, SetInstrumentationLibrary)
{
opentelemetry::exporter::jaeger::Recordable rec;

std::string library_name = "opentelemetry-cpp";
std::string library_version = "0.1.0";
auto instrumentation_library = InstrumentationLibrary::create(library_name, library_version);

rec.SetInstrumentationLibrary(*instrumentation_library);

auto tags = rec.Tags();
EXPECT_EQ(tags.size(), 2);

EXPECT_EQ(tags[0].key, "otel.library.name");
EXPECT_EQ(tags[0].vType, thrift::TagType::STRING);
EXPECT_EQ(tags[0].vStr, library_name);

EXPECT_EQ(tags[1].key, "otel.library.version");
EXPECT_EQ(tags[1].vType, thrift::TagType::STRING);
EXPECT_EQ(tags[1].vStr, library_version);
}