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

Jaeger exporter: extend supported attributes types #1106

Merged
merged 14 commits into from
Dec 6, 2021
112 changes: 108 additions & 4 deletions exporters/jaeger/src/recordable.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/common/global_log_handler.h"
#include "opentelemetry/sdk/resource/experimental_semantic_conventions.h"

OPENTELEMETRY_BEGIN_NAMESPACE
Expand All @@ -19,7 +20,23 @@ void JaegerRecordable::PopulateAttribute(nostd::string_view key,
const common::AttributeValue &value,
std::vector<thrift::Tag> &tags)
{
if (nostd::holds_alternative<int64_t>(value))
if (nostd::holds_alternative<int>(value))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shouldn't we be comparing only for the supported types from here:

So, int, uint64_t are not valid attribute types.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks, removed unsupported types

{
AddTag(std::string{key}, int64_t{nostd::get<int>(value)}, tags);
}
else if (nostd::holds_alternative<int32_t>(value))
{
AddTag(std::string{key}, int64_t{nostd::get<int32_t>(value)}, tags);
}
else if (nostd::holds_alternative<uint32_t>(value))
{
AddTag(std::string{key}, int64_t{nostd::get<uint32_t>(value)}, tags);
}
else if (nostd::holds_alternative<uint64_t>(value))
{
AddTag(std::string{key}, std::to_string(nostd::get<uint64_t>(value)), tags);
}
else if (nostd::holds_alternative<int64_t>(value))
{
AddTag(std::string{key}, nostd::get<int64_t>(value), tags);
}
Expand All @@ -39,14 +56,97 @@ void JaegerRecordable::PopulateAttribute(nostd::string_view key,
{
AddTag(std::string{key}, std::string{nostd::get<nostd::string_view>(value)}, tags);
}
// TODO: extend other AttributeType to the types supported by Jaeger.
else if (nostd::holds_alternative<nostd::span<const int>>(value))
{
for (const auto &val : nostd::get<nostd::span<const int>>(value))
{
AddTag(std::string{key}, int64_t{val}, tags);
}
}
else if (nostd::holds_alternative<nostd::span<const uint8_t>>(value))
{
for (const auto &val : nostd::get<nostd::span<const uint8_t>>(value))
{
AddTag(std::string{key}, int64_t{val}, tags);
}
}
else if (nostd::holds_alternative<nostd::span<const bool>>(value))
{
for (const auto &val : nostd::get<nostd::span<const bool>>(value))
{
AddTag(std::string{key}, val, tags);
}
}
else if (nostd::holds_alternative<nostd::span<const int>>(value))
{
for (const auto &val : nostd::get<nostd::span<const int>>(value))
{
AddTag(std::string{key}, int64_t{val}, tags);
}
}
else if (nostd::holds_alternative<nostd::span<const int64_t>>(value))
{
for (const auto &val : nostd::get<nostd::span<const int64_t>>(value))
{
AddTag(std::string{key}, val, tags);
}
}
else if (nostd::holds_alternative<nostd::span<const unsigned int>>(value))
{
for (const auto &val : nostd::get<nostd::span<const unsigned int>>(value))
{
AddTag(std::string{key}, int64_t{val}, tags);
}
}
else if (nostd::holds_alternative<nostd::span<const uint64_t>>(value))
{
for (const auto &val : nostd::get<nostd::span<const uint64_t>>(value))
{
AddTag(std::string{key}, std::to_string(val), tags);
}
}
else if (nostd::holds_alternative<nostd::span<const double>>(value))
{
for (const auto &val : nostd::get<nostd::span<const double>>(value))
{
AddTag(std::string{key}, val, tags);
}
}
else if (nostd::holds_alternative<nostd::span<const nostd::string_view>>(value))
{
for (const auto &val : nostd::get<nostd::span<const nostd::string_view>>(value))
{
AddTag(std::string{key}, std::string{val}, tags);
}
}
else
{
OTEL_INTERNAL_LOG_ERROR(
"[TRACE JAEGER Exporter] SetAttribute() failed, attribute type not supported ");
}
}

void JaegerRecordable::PopulateAttribute(nostd::string_view key,
const sdk::common::OwnedAttributeValue &value,
std::vector<thrift::Tag> &tags)
{
if (nostd::holds_alternative<int64_t>(value))
if (nostd::holds_alternative<int>(value))
{
AddTag(std::string{key}, int64_t{nostd::get<int>(value)}, tags);
}
else if (nostd::holds_alternative<int32_t>(value))
{
AddTag(std::string{key}, int64_t{nostd::get<int32_t>(value)}, tags);
}
else if (nostd::holds_alternative<uint32_t>(value))
{
AddTag(std::string{key}, int64_t{nostd::get<uint32_t>(value)}, tags);
}
else if (nostd::holds_alternative<uint64_t>(value))
reyang marked this conversation as resolved.
Show resolved Hide resolved
{
AddTag(std::string{key}, std::to_string(nostd::get<uint64_t>(value)), tags);
}
else if (nostd::holds_alternative<int64_t>(value))
{
AddTag(std::string{key}, nostd::get<int64_t>(value), tags);
}
Expand All @@ -62,7 +162,11 @@ void JaegerRecordable::PopulateAttribute(nostd::string_view key,
{
AddTag(std::string{key}, std::string{nostd::get<std::string>(value)}, tags);
}
// TODO: extend other OwnedAttributeType to the types supported by Jaeger.
else
{
OTEL_INTERNAL_LOG_ERROR(
"[TRACE JAEGER Exporter] SetAttribute() failed, attribute type not supported ");
}
}

void JaegerRecordable::SetIdentity(const trace::SpanContext &span_context,
Expand Down