Skip to content

Commit

Permalink
Rename bswap_64 to otel_bswap_64 to avoid clash with macro (#875) (#876)
Browse files Browse the repository at this point in the history
  • Loading branch information
lidavidm authored Jun 24, 2021
1 parent ae6d810 commit 0a3320e
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,13 @@ namespace jaeger

# if defined(__clang__) || \
(defined(__GNUC__) && ((__GNUC__ == 4 && __GNUC_MINOR__ >= 8) || __GNUC__ >= 5))
inline uint64_t bswap_64(uint64_t host_int)
inline uint64_t otel_bswap_64(uint64_t host_int)
{
return __builtin_bswap64(host_int);
}

# elif defined(_MSC_VER)
inline uint64_t bswap_64(uint64_t host_int)
inline uint64_t otel_bswap_64(uint64_t host_int)
{
return _byteswap_uint64(host_int);
}
Expand Down
8 changes: 4 additions & 4 deletions exporters/jaeger/src/recordable.cc
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,13 @@ void Recordable::SetIdentity(const trace::SpanContext &span_context,
// https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/trace/sdk_exporters/jaeger.md#ids
#if JAEGER_IS_LITTLE_ENDIAN == 1
span_->__set_traceIdHigh(
bswap_64(*(reinterpret_cast<const int64_t *>(span_context.trace_id().Id().data()))));
otel_bswap_64(*(reinterpret_cast<const int64_t *>(span_context.trace_id().Id().data()))));
span_->__set_traceIdLow(
bswap_64(*(reinterpret_cast<const int64_t *>(span_context.trace_id().Id().data()) + 1)));
otel_bswap_64(*(reinterpret_cast<const int64_t *>(span_context.trace_id().Id().data()) + 1)));
span_->__set_spanId(
bswap_64(*(reinterpret_cast<const int64_t *>(span_context.span_id().Id().data()))));
otel_bswap_64(*(reinterpret_cast<const int64_t *>(span_context.span_id().Id().data()))));
span_->__set_parentSpanId(
bswap_64(*(reinterpret_cast<const int64_t *>(parent_span_id.Id().data()))));
otel_bswap_64(*(reinterpret_cast<const int64_t *>(parent_span_id.Id().data()))));
#else
span_->__set_traceIdLow(
*(reinterpret_cast<const int64_t *>(span_context.trace_id().Id().data())));
Expand Down
10 changes: 5 additions & 5 deletions exporters/jaeger/test/jaeger_recordable_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,10 @@ TEST(JaegerSpanRecordable, SetIdentity)
std::unique_ptr<thrift::Span> span{rec.Span()};

#if JAEGER_IS_LITTLE_ENDIAN == 1
EXPECT_EQ(span->traceIdLow, opentelemetry::exporter::jaeger::bswap_64(trace_id_val[1]));
EXPECT_EQ(span->traceIdHigh, opentelemetry::exporter::jaeger::bswap_64(trace_id_val[0]));
EXPECT_EQ(span->spanId, opentelemetry::exporter::jaeger::bswap_64(span_id_val));
EXPECT_EQ(span->parentSpanId, opentelemetry::exporter::jaeger::bswap_64(parent_span_id_val));
EXPECT_EQ(span->traceIdLow, opentelemetry::exporter::jaeger::otel_bswap_64(trace_id_val[1]));
EXPECT_EQ(span->traceIdHigh, opentelemetry::exporter::jaeger::otel_bswap_64(trace_id_val[0]));
EXPECT_EQ(span->spanId, opentelemetry::exporter::jaeger::otel_bswap_64(span_id_val));
EXPECT_EQ(span->parentSpanId, opentelemetry::exporter::jaeger::otel_bswap_64(parent_span_id_val));
#else
EXPECT_EQ(span->traceIdLow, trace_id_val[0]);
EXPECT_EQ(span->traceIdHigh, trace_id_val[1]);
Expand Down Expand Up @@ -143,4 +143,4 @@ TEST(JaegerSpanRecordable, SetInstrumentationLibrary)
EXPECT_EQ(tags[1].key, "otel.library.version");
EXPECT_EQ(tags[1].vType, thrift::TagType::STRING);
EXPECT_EQ(tags[1].vStr, library_version);
}
}

0 comments on commit 0a3320e

Please sign in to comment.