Skip to content

Commit

Permalink
Merge pull request #12 from Tianlin-Zhao/origin/propagators
Browse files Browse the repository at this point in the history
Origin/propagators
  • Loading branch information
Tianlin-Zhao authored Aug 1, 2020
2 parents 2f081d8 + 19a4cd5 commit 28e4d0a
Show file tree
Hide file tree
Showing 8 changed files with 49 additions and 35 deletions.
2 changes: 0 additions & 2 deletions api/include/opentelemetry/plugin/detail/tracer_handle.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@ class TracerHandle
{
public:
virtual ~TracerHandle() = default;

virtual trace::Tracer &tracer() const noexcept = 0;
};
} // namespace plugin
OPENTELEMETRY_END_NAMESPACE
13 changes: 0 additions & 13 deletions api/include/opentelemetry/trace/default_span.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
#include "opentelemetry/trace/canonical_code.h"
#include "opentelemetry/common/attribute_value.h"
#include "opentelemetry/trace/span.h"
//#include "opentelemetry/trace/tracer.h"

#define pass
OPENTELEMETRY_BEGIN_NAMESPACE
Expand Down Expand Up @@ -67,20 +66,8 @@ class DefaultSpan: public Span {
DefaultSpan(DefaultSpan&& spn) : span_context_(spn.GetContext()) {}
DefaultSpan(const DefaultSpan& spn) : span_context_(spn.GetContext()) {}

// This is an invalid implementation
trace::Tracer &tracer() const noexcept {
trace::Tracer tracer = trace::Tracer();
return tracer; // Invalid tracer
}

// Creates an instance of this class with spancontext.
static DefaultSpan Create(SpanContext span_context) {
return DefaultSpan(span_context);
}

private:
SpanContext span_context_;
trace::Tracer tracer_;
};
}
OPENTELEMETRY_END_NAMESPACE
40 changes: 40 additions & 0 deletions api/include/opentelemetry/trace/default_tracer.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
#pragma once
#include "opentelemetry/trace/tracer.h"
#include "opentelemetry/nostd/unique_ptr.h"
#include "opentelemetry/trace/span.h"
#include "opentelemetry/trace/default_span.h"

#define pass
OPENTELEMETRY_BEGIN_NAMESPACE
namespace trace {
class DefaultTracer: public Tracer {
public:
~DefaultTracer() = default;

/**
* Starts a span.
*
* Optionally sets attributes at Span creation from the given key/value pairs.
*
* Attributes will be processed in order, previous attributes with the same
* key will be overwritten.
*/
nostd::unique_ptr<Span> StartSpan(nostd::string_view name,
const KeyValueIterable &attributes,
const StartSpanOptions &options = {}) noexcept
{
return nostd::unique_ptr<Span>(new DefaultSpan::GetInvalid());
}

void ForceFlushWithMicroseconds(uint64_t timeout) noexcept
{
pass;
}

void CloseWithMicroseconds(uint64_t timeout) noexcept
{
pass;
}
};
}
OPENTELEMETRY_END_NAMESPACE
12 changes: 1 addition & 11 deletions api/include/opentelemetry/trace/propagation/http_trace_context.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
#include <iostream>
#include <array>
#include <exception>
#include "opentelemetry/trace/propagation/http_text_format.h"
#include "opentelemetry/trace/span_context.h"
#include "opentelemetry/trace/trace_state.h"
#include "opentelemetry/trace/key_value_iterable.h"
Expand All @@ -27,6 +26,7 @@
#include "opentelemetry/nostd/shared_ptr.h"
#include "opentelemetry/nostd/variant.h"
#include "opentelemetry/nostd/span.h"
#include "opentelemetry/trace/propagation/http_text_format.h"
#include "opentelemetry/trace/default_span.h"

OPENTELEMETRY_BEGIN_NAMESPACE
Expand Down Expand Up @@ -304,16 +304,6 @@ class HttpTraceContext : public HTTPTextFormat<T> {
return context_from_parent_header;
}
}
const nostd::string_view kTraceParent = "traceparent";
const nostd::string_view kTraceState = "tracestate";
const int kVersionBytes = 2;
const int kTraceIdBytes = 32;
const int kSpanIdBytes = 16;
const int kTraceFlagBytes = 2;
const int kTraceDelimiterBytes = 3;
const int kHeaderSize = kVersionBytes + kTraceIdBytes + kSpanIdBytes + kTraceFlagBytes + kTraceDelimiterBytes;
const int kTraceStateMaxMembers = 32;
const int kHeaderElementLengths[4] = {2,32,16,2};
};
}
} // namespace trace
Expand Down
5 changes: 1 addition & 4 deletions api/include/opentelemetry/trace/span.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
#include "opentelemetry/nostd/string_view.h"
#include "opentelemetry/trace/canonical_code.h"
#include "opentelemetry/trace/key_value_iterable_view.h"
#include "opentelemetry/trace/tracer.h"
#include "opentelemetry/version.h"

OPENTELEMETRY_BEGIN_NAMESPACE
Expand Down Expand Up @@ -56,7 +55,7 @@ struct EndSpanOptions
};

class Tracer;

class DefaultTracer;
/**
* A Span represents a single operation within a Trace.
*/
Expand Down Expand Up @@ -153,8 +152,6 @@ class Span
// Returns true if this Span is recording tracing events (e.g. SetAttribute,
// AddEvent).
virtual bool IsRecording() const noexcept = 0;

virtual trace::Tracer &tracer() const noexcept = 0;
};
} // namespace trace
OPENTELEMETRY_END_NAMESPACE
5 changes: 2 additions & 3 deletions api/include/opentelemetry/trace/tracer.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,6 @@

#include <chrono>

class Span;
struct StartSpanOptions;

OPENTELEMETRY_BEGIN_NAMESPACE
namespace trace
{
Expand All @@ -19,6 +16,7 @@ namespace trace
* This class provides methods for manipulating the context, creating spans, and controlling spans'
* lifecycles.
*/

class Tracer
{
public:
Expand All @@ -31,6 +29,7 @@ class Tracer
* Attributes will be processed in order, previous attributes with the same
* key will be overwritten.
*/

virtual nostd::unique_ptr<Span> StartSpan(nostd::string_view name,
const KeyValueIterable &attributes,
const StartSpanOptions &options = {}) noexcept = 0;
Expand Down
Empty file.
7 changes: 5 additions & 2 deletions api/test/trace/propagation/http_text_format_test.cc
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
#include "opentelemetry/trace/propagation/http_text_format.h"
#include "opentelemetry/trace/propagation/http_trace_context.h"
#include "opentelemetry/context/context.h"
#include "opentelemetry/trace/span.h"
#include "opentelemetry/trace/default_span.h"
#include "opentelemetry/trace/span_context.h"
#include "opentelemetry/nostd/string_view.h"
#include "opentelemetry/trace/tracer.h"
#include "opentelemetry/nostd/span.h"
#include "opentelemetry/nostd/shared_ptr.h"
#include "opentelemetry/trace/trace_id.h"
Expand All @@ -16,6 +15,10 @@

#include <gtest/gtest.h>

#include "opentelemetry/trace/default_span.h"
#include "opentelemetry/trace/propagation/http_text_format.h"
#include "opentelemetry/trace/propagation/http_trace_context.h"

using namespace opentelemetry;

static nostd::string_view Getter(const std::map<std::string,std::string> &carrier, nostd::string_view trace_type = "traceparent") {
Expand Down

0 comments on commit 28e4d0a

Please sign in to comment.