Skip to content

Commit

Permalink
format, added test case for default span on GetContext
Browse files Browse the repository at this point in the history
  • Loading branch information
Tianlin-Zhao committed Aug 20, 2020
1 parent 8aa9b7f commit 1c89300
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 1 deletion.
1 change: 1 addition & 0 deletions api/include/opentelemetry/trace/span.h
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,7 @@ class Span
virtual void End(const EndSpanOptions &options = {}) noexcept = 0;

virtual trace::SpanContext GetContext() const noexcept = 0;

// Returns true if this Span is recording tracing events (e.g. SetAttribute,
// AddEvent).
virtual bool IsRecording() const noexcept = 0;
Expand Down
6 changes: 6 additions & 0 deletions api/include/opentelemetry/trace/span_context.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ class SpanContext final

SpanContext(bool sampled_flag, bool has_remote_parent) noexcept
: trace_flags_(trace::TraceFlags((uint8_t)sampled_flag)), remote_parent_(has_remote_parent){};

SpanContext(TraceId trace_id,
SpanId span_id,
TraceFlags trace_flags,
Expand All @@ -44,9 +45,11 @@ class SpanContext final
trace_flags_ = trace_flags;
remote_parent_ = has_remote_parent;
}

SpanContext(SpanContext &&ctx)
: trace_id_(ctx.trace_id()), span_id_(ctx.span_id()), trace_flags_(ctx.trace_flags())
{}

SpanContext(const SpanContext &ctx)
: trace_id_(ctx.trace_id()), span_id_(ctx.span_id()), trace_flags_(ctx.trace_flags())
{}
Expand All @@ -58,6 +61,7 @@ class SpanContext final
trace_flags_ = ctx.trace_flags_;
return *this;
};

SpanContext &operator=(SpanContext &&ctx)
{
trace_id_ = ctx.trace_id_;
Expand All @@ -73,7 +77,9 @@ class SpanContext final
}

const TraceId &trace_id() const noexcept { return trace_id_; }

const SpanId &span_id() const noexcept { return span_id_; }

const TraceFlags &trace_flags() const noexcept { return trace_flags_; }

bool IsValid() const noexcept { return trace_id_.IsValid() && span_id_.IsValid(); }
Expand Down
2 changes: 1 addition & 1 deletion api/test/trace/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ load("//bazel:otel_cc_benchmark.bzl", "otel_cc_benchmark")
cc_test(
name = "default_span_test",
srcs = [
"defaultspan_test.cc",
"default_span_test.cc",
],
deps = [
"//api",
Expand Down
File renamed without changes.

0 comments on commit 1c89300

Please sign in to comment.