diff --git a/api/include/opentelemetry/common/string_util.h b/api/include/opentelemetry/common/string_util.h
index 04479d5594..00f80db992 100644
--- a/api/include/opentelemetry/common/string_util.h
+++ b/api/include/opentelemetry/common/string_util.h
@@ -5,6 +5,20 @@
#include "opentelemetry/nostd/string_view.h"
+/** DJB2 hash function below is near-perfect hash used by several systems.
+ * Ref. http://www.cse.yorku.ca/~oz/hash.html
+ *
+ * String to hash
+ * Initial offset
+ * 32 bit code
+ */
+constexpr uint32_t hashCode(const char *str, uint32_t h = 0)
+{
+ return (uint32_t)(!str[h] ? 5381 : ((uint32_t)hashCode(str, h + 1) * (uint32_t)33) ^ str[h]);
+}
+#define OTEL_CPP_CONST_UINT32_T(x) std::integral_constant::value
+#define OTEL_CPP_CONST_HASHCODE(name) OTEL_CPP_CONST_UINT32_T(hashCode(#name))
+
OPENTELEMETRY_BEGIN_NAMESPACE
namespace common
{
diff --git a/exporters/jaeger/src/recordable.cc b/exporters/jaeger/src/recordable.cc
index 074abb8f6f..3e3661623e 100644
--- a/exporters/jaeger/src/recordable.cc
+++ b/exporters/jaeger/src/recordable.cc
@@ -1,7 +1,8 @@
// Copyright The OpenTelemetry Authors
// SPDX-License-Identifier: Apache-2.0
-#include
+#include "opentelemetry/exporters/jaeger/recordable.h"
+#include "opentelemetry/sdk/resource/semantic_conventions.h"
OPENTELEMETRY_BEGIN_NAMESPACE
namespace exporter
@@ -9,6 +10,8 @@ namespace exporter
namespace jaeger
{
+using namespace opentelemetry::sdk::resource;
+
Recordable::Recordable() : span_{new thrift::Span} {}
void Recordable::PopulateAttribute(nostd::string_view key, const common::AttributeValue &value)
@@ -117,9 +120,9 @@ void Recordable::SetResource(const opentelemetry::sdk::resource::Resource &resou
{
// only service.name attribute is supported by specs as of now.
auto attributes = resource.GetAttributes();
- if (attributes.find("service.name") != attributes.end())
+ if (attributes.find(OTEL_CPP_GET_ATTR(AttrServiceName)) != attributes.end())
{
- service_name_ = nostd::get(attributes["service.name"]);
+ service_name_ = nostd::get(attributes[OTEL_CPP_GET_ATTR(AttrServiceName)]);
}
}
diff --git a/exporters/zipkin/src/recordable.cc b/exporters/zipkin/src/recordable.cc
index 00d9f63499..bbdc85c548 100644
--- a/exporters/zipkin/src/recordable.cc
+++ b/exporters/zipkin/src/recordable.cc
@@ -2,6 +2,7 @@
// SPDX-License-Identifier: Apache-2.0
#include "opentelemetry/exporters/zipkin/recordable.h"
+#include "opentelemetry/sdk/resource/semantic_conventions.h"
#include