From 64c9d2969e853513f818d681d36f75141f857b9b Mon Sep 17 00:00:00 2001 From: Will Gittoes Date: Mon, 10 Dec 2018 11:40:25 +1100 Subject: [PATCH] Add OpenTracing service tag --- src/span.cpp | 5 +++++ test/span_test.cpp | 3 ++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/span.cpp b/src/span.cpp index 6925a93e..f94fd346 100644 --- a/src/span.cpp +++ b/src/span.cpp @@ -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 @@ -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); diff --git a/test/span_test.cpp b/test/span_test.cpp index 5b4270eb..83c1feae 100644 --- a/test/span_test.cpp +++ b/test/span_test.cpp @@ -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({"service.name", "service"})); + span.SetTag(service_tag_key, "new service"); span.SetTag("tag with no special meaning", "ayy lmao"); span.FinishWithOptions(finish_options);