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

Add OpenTracing service tag #73

Closed
wants to merge 1 commit into from
Closed
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: 5 additions & 0 deletions src/span.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ namespace {
const std::string datadog_span_type_tag = "span.type";
const std::string datadog_resource_name_tag = "resource.name";
const std::string datadog_service_name_tag = "service.name";
const std::string ot_service_name_tag = "service"; // No constant yet in ::ot::ext
const std::string http_url_tag = "http.url";
const std::string operation_name_tag = "operation";
} // namespace
Expand Down Expand Up @@ -140,7 +141,11 @@ void Span::FinishWithOptions(
span_->resource = tag->second;
span_->meta.erase(tag);
}
// Check for service tag in either datadog_service_name_tag or ot_service_name_tag.
tag = span_->meta.find(datadog_service_name_tag);
if (tag == span_->meta.end()) {
tag = span_->meta.find(ot_service_name_tag);
}
if (tag != span_->meta.end()) {
span_->service = tag->second;
span_->meta.erase(tag);
Expand Down
3 changes: 2 additions & 1 deletion test/span_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,8 @@ TEST_CASE("span") {
""};
span.SetTag("span.type", "new type");
span.SetTag("resource.name", "new resource");
span.SetTag("service.name", "new service");
auto service_tag_key = GENERATE(values<std::string>({"service.name", "service"}));
span.SetTag(service_tag_key, "new service");
span.SetTag("tag with no special meaning", "ayy lmao");

span.FinishWithOptions(finish_options);
Expand Down