Skip to content

Commit

Permalink
Rename getSpanIdAsHex to getSpanId
Browse files Browse the repository at this point in the history
See envoyproxy#34314

Signed-off-by: Ashish Banerjee <ashish.banerjee@solo.io>
  • Loading branch information
ashishb-solo committed May 29, 2024
1 parent 7344695 commit 5681b5f
Show file tree
Hide file tree
Showing 20 changed files with 24 additions and 24 deletions.
2 changes: 1 addition & 1 deletion envoy/tracing/trace_driver.h
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ class Span {
* Retrieve the span's identifier.
* @return span ID as a hex string
*/
virtual std::string getSpanIdAsHex() const PURE;
virtual std::string getSpanId() const PURE;
};

/**
Expand Down
2 changes: 1 addition & 1 deletion source/common/tracing/null_span_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class NullSpan : public Span {
void setBaggage(absl::string_view, absl::string_view) override {}
std::string getBaggage(absl::string_view) override { return EMPTY_STRING; }
std::string getTraceIdAsHex() const override { return EMPTY_STRING; }
std::string getSpanIdAsHex() const override { return EMPTY_STRING; }
std::string getSpanId() const override { return EMPTY_STRING; }
SpanPtr spawnChild(const Config&, const std::string&, SystemTime) override {
return SpanPtr{new NullSpan()};
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ void AccessLog::emitLog(const Formatter::HttpFormatterContext& log_context,
auto trace_id = absl::StrCat(Hex::uint64ToHex(0), trace_id_hex);
*log_entry.mutable_trace_id() = absl::HexStringToBytes(trace_id);
}
std::string span_id_hex = log_context.activeSpan().getSpanIdAsHex();
std::string span_id_hex = log_context.activeSpan().getSpanId();
if (!span_id_hex.empty()) {
*log_entry.mutable_span_id() = absl::HexStringToBytes(span_id_hex);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ class OpenTracingSpan : public Tracing::Span, Logger::Loggable<Logger::Id::traci

// TODO(#34412): This method is unimplemented for OpenTracing.
std::string getTraceIdAsHex() const override { return EMPTY_STRING; };
std::string getSpanIdAsHex() const override { return EMPTY_STRING; };
std::string getSpanId() const override { return EMPTY_STRING; };

private:
OpenTracingDriver& driver_;
Expand Down
2 changes: 1 addition & 1 deletion source/extensions/tracers/datadog/span.cc
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ std::string Span::getTraceIdAsHex() const {
return absl::StrCat(absl::Hex(span_->id()));
}

std::string Span::getSpanIdAsHex() const {
std::string Span::getSpanId() const {
// TODO(#34412): This method is not yet implemented for Datadog.
return EMPTY_STRING;
}
Expand Down
2 changes: 1 addition & 1 deletion source/extensions/tracers/datadog/span.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ class Span : public Tracing::Span {
std::string getBaggage(absl::string_view key) override;
void setBaggage(absl::string_view key, absl::string_view value) override;
std::string getTraceIdAsHex() const override;
std::string getSpanIdAsHex() const override;
std::string getSpanId() const override;

private:
datadog::tracing::Optional<datadog::tracing::Span> span_;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ class Span : public Tracing::Span {
std::string getBaggage(absl::string_view) override { return EMPTY_STRING; };

std::string getTraceIdAsHex() const override;
std::string getSpanIdAsHex() const override;
std::string getSpanId() const override;

private:
::opencensus::trace::Span span_;
Expand Down Expand Up @@ -237,7 +237,7 @@ void Span::injectContext(Tracing::TraceContext& trace_context, const Tracing::Up
}
}

std::string Span::getSpanIdAsHex() const { return EMPTY_STRING; }
std::string Span::getSpanId() const { return EMPTY_STRING; }

std::string Span::getTraceIdAsHex() const {
const auto& ctx = span_.context();
Expand Down
2 changes: 1 addition & 1 deletion source/extensions/tracers/opentelemetry/tracer.h
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ class Span : Logger::Loggable<Logger::Id::tracing>, public Tracing::Span {

std::string getTraceIdAsHex() const override { return absl::BytesToHexString(span_.trace_id()); };

std::string getSpanIdAsHex() const override { return absl::BytesToHexString(span_.span_id()); };
std::string getSpanId() const override { return absl::BytesToHexString(span_.span_id()); };

OTelSpanKind spankind() const { return span_.kind(); }

Expand Down
2 changes: 1 addition & 1 deletion source/extensions/tracers/skywalking/tracer.h
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ class Span : public Tracing::Span {
std::string getBaggage(absl::string_view) override { return EMPTY_STRING; }
void setBaggage(absl::string_view, absl::string_view) override {}
std::string getTraceIdAsHex() const override { return EMPTY_STRING; }
std::string getSpanIdAsHex() const override { return EMPTY_STRING; }
std::string getSpanId() const override { return EMPTY_STRING; }

const TracingContextPtr tracingContext() { return tracing_context_; }
const TracingSpanPtr spanEntity() { return span_entity_; }
Expand Down
2 changes: 1 addition & 1 deletion source/extensions/tracers/xray/tracer.h
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ class Span : public Tracing::Span, Logger::Loggable<Logger::Id::config> {
std::string getTraceIdAsHex() const override { return EMPTY_STRING; };

// TODO(#34412): This method is unimplemented for X-Ray.
std::string getSpanIdAsHex() const override { return EMPTY_STRING; };
std::string getSpanId() const override { return EMPTY_STRING; };

/**
* Creates a child span.
Expand Down
2 changes: 1 addition & 1 deletion source/extensions/tracers/zipkin/zipkin_tracer_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ class ZipkinSpan : public Tracing::Span {
std::string getTraceIdAsHex() const override { return span_.traceIdAsHexString(); };

// TODO(#34412): This method is unimplemented for Zipkin.
std::string getSpanIdAsHex() const override { return EMPTY_STRING; };
std::string getSpanId() const override { return EMPTY_STRING; };

/**
* @return a reference to the Zipkin::Span object.
Expand Down
2 changes: 1 addition & 1 deletion test/common/tracing/tracer_impl_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ TEST(NullTracerTest, BasicFunctionality) {
span_ptr->setBaggage("key", "value");
ASSERT_EQ("", span_ptr->getBaggage("baggage_key"));
ASSERT_EQ(span_ptr->getTraceIdAsHex(), "");
ASSERT_EQ(span_ptr->getSpanIdAsHex(), "");
ASSERT_EQ(span_ptr->getSpanId(), "");
span_ptr->injectContext(trace_context, upstream_context);
span_ptr->log(SystemTime(), "fake_event");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ TEST_F(AccessLogTest, TraceId) {
NiceMock<Tracing::MockSpan> active_span;

EXPECT_CALL(active_span, getTraceIdAsHex()).WillOnce(Return("404142434445464748494a4b4c4d4e4f"));
EXPECT_CALL(active_span, getSpanIdAsHex()).WillOnce(Return("4041424344454647"));
EXPECT_CALL(active_span, getSpanId()).WillOnce(Return("4041424344454647"));
expectLog(R"EOF(
span_id: "QEFCQ0RFRkc="
trace_id: "QEFCQ0RFRkdISUpLTE1OTw=="
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,7 @@ TEST_F(OpenTracingDriverTest, GetTraceId) {
// This method is unimplemented and a noop.
ASSERT_EQ(first_span->getTraceIdAsHex(), "");
// This method is unimplemented and a noop.
ASSERT_EQ(first_span->getSpanIdAsHex(), "");
ASSERT_EQ(first_span->getSpanId(), "");
}

TEST_F(OpenTracingDriverTest, ExtractUsingForeach) {
Expand Down
4 changes: 2 additions & 2 deletions test/extensions/tracers/datadog/span_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -389,7 +389,7 @@ TEST_F(DatadogTracerSpanTest, Baggage) {
TEST_F(DatadogTracerSpanTest, GetTraceIdAsHex) {
Span span{std::move(span_)};
EXPECT_EQ("cafebabe", span.getTraceIdAsHex());
EXPECT_EQ("", span.getSpanIdAsHex());
EXPECT_EQ("", span.getSpanId());
}

TEST_F(DatadogTracerSpanTest, NoOpMode) {
Expand Down Expand Up @@ -431,7 +431,7 @@ TEST_F(DatadogTracerSpanTest, NoOpMode) {
EXPECT_EQ("", span.getBaggage("foo"));
span.setBaggage("foo", "bar");
EXPECT_EQ("", span.getTraceIdAsHex());
EXPECT_EQ("", span.getSpanIdAsHex());
EXPECT_EQ("", span.getSpanId());
}

} // namespace
Expand Down
4 changes: 2 additions & 2 deletions test/extensions/tracers/opencensus/tracer_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ TEST(OpenCensusTracerTest, Span) {
ASSERT_NE(span->getTraceIdAsHex(), "");

// Span id should be empty since this is not yet supported.
ASSERT_EQ(span->getSpanIdAsHex(), "");
ASSERT_EQ(span->getSpanId(), "");
}

// Retrieve SpanData from the OpenCensus trace exporter.
Expand Down Expand Up @@ -225,7 +225,7 @@ void testIncomingHeaders(
// Check contents via public API.
// Trace id is set via context propagation headers.
EXPECT_EQ(span->getTraceIdAsHex(), "404142434445464748494a4b4c4d4e4f");
EXPECT_EQ(span->getSpanIdAsHex(), "");
EXPECT_EQ(span->getSpanId(), "");
}

// Retrieve SpanData from the OpenCensus trace exporter.
Expand Down
2 changes: 1 addition & 1 deletion test/extensions/tracers/skywalking/tracer_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ TEST_F(TracerTest, TracerTestCreateNewSpanWithNoPropagationHeaders) {
span->setBaggage("FakeStringAndNothingToDo", "FakeStringAndNothingToDo");
// These two methods are unimplemented and a noop.
ASSERT_EQ(span->getTraceIdAsHex(), "");
ASSERT_EQ(span->getSpanIdAsHex(), "");
ASSERT_EQ(span->getSpanId(), "");
// Test whether the basic functions of Span are normal.
EXPECT_FALSE(span->spanEntity()->skipAnalysis());
span->setSampled(false);
Expand Down
2 changes: 1 addition & 1 deletion test/extensions/tracers/xray/tracer_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -390,7 +390,7 @@ TEST_F(XRayTracerTest, GetTraceId) {
EXPECT_EQ(span->getTraceIdAsHex(), "");

// This method is unimplemented and a noop.
EXPECT_EQ(span->getSpanIdAsHex(), "");
EXPECT_EQ(span->getSpanId(), "");
}

TEST_F(XRayTracerTest, ChildSpanHasParentInfo) {
Expand Down
4 changes: 2 additions & 2 deletions test/extensions/tracers/zipkin/zipkin_tracer_impl_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -726,7 +726,7 @@ TEST_F(ZipkinDriverTest, ZipkinSpanTest) {
Tracing::SpanPtr span6 = driver_->startSpan(config_, request_headers_, stream_info_,
operation_name_, {Tracing::Reason::Sampling, true});
EXPECT_EQ(span6->getTraceIdAsHex(), "0000000000000000");
EXPECT_EQ(span6->getSpanIdAsHex(), "");
EXPECT_EQ(span6->getSpanId(), "");
}

TEST_F(ZipkinDriverTest, ZipkinSpanContextFromB3HeadersTest) {
Expand Down Expand Up @@ -800,7 +800,7 @@ TEST_F(ZipkinDriverTest, ZipkinSpanContextFromB3Headers128TraceIdTest) {
EXPECT_EQ(parent_id, zipkin_span->span().parentIdAsHexString());
EXPECT_TRUE(zipkin_span->span().sampled());
EXPECT_EQ(trace_id, zipkin_span->getTraceIdAsHex());
EXPECT_EQ("", zipkin_span->getSpanIdAsHex());
EXPECT_EQ("", zipkin_span->getSpanId());
}

TEST_F(ZipkinDriverTest, ZipkinSpanContextFromInvalidTraceIdB3HeadersTest) {
Expand Down
2 changes: 1 addition & 1 deletion test/mocks/tracing/mocks.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class MockSpan : public Span {
MOCK_METHOD(void, setBaggage, (absl::string_view key, absl::string_view value));
MOCK_METHOD(std::string, getBaggage, (absl::string_view key));
MOCK_METHOD(std::string, getTraceIdAsHex, (), (const));
MOCK_METHOD(std::string, getSpanIdAsHex, (), (const));
MOCK_METHOD(std::string, getSpanId, (), (const));

SpanPtr spawnChild(const Config& config, const std::string& name,
SystemTime start_time) override {
Expand Down

0 comments on commit 5681b5f

Please sign in to comment.