Skip to content

Commit

Permalink
Remove trace_api and metrics/noop.h scope resolution
Browse files Browse the repository at this point in the history
  • Loading branch information
Karen Xu committed Oct 18, 2020
1 parent 29898c7 commit 3f73296
Show file tree
Hide file tree
Showing 16 changed files with 100 additions and 396 deletions.
131 changes: 63 additions & 68 deletions api/include/opentelemetry/metrics/noop.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@

#include <memory>

// TODO: Create generic short pattern for opentelemetry::common and opentelemetry::trace and others
// as necessary

OPENTELEMETRY_BEGIN_NAMESPACE
namespace metrics
{
Expand Down Expand Up @@ -297,36 +300,36 @@ class NoopMeter : public Meter
* @param enabled a boolean that turns the metric instrument on and off.
* @return
*/
opentelemetry::nostd::shared_ptr<Counter<short>> NewShortCounter(nostd::string_view name,
nostd::string_view description,
nostd::string_view unit,
const bool enabled) override
nostd::shared_ptr<Counter<short>> NewShortCounter(nostd::string_view name,
nostd::string_view description,
nostd::string_view unit,
const bool enabled) override
{
return nostd::shared_ptr<Counter<short>>{
new NoopCounter<short>(name, description, unit, enabled)};
}

opentelemetry::nostd::shared_ptr<Counter<int>> NewIntCounter(nostd::string_view name,
nostd::string_view description,
nostd::string_view unit,
const bool enabled) override
nostd::shared_ptr<Counter<int>> NewIntCounter(nostd::string_view name,
nostd::string_view description,
nostd::string_view unit,
const bool enabled) override
{
return nostd::shared_ptr<Counter<int>>{new NoopCounter<int>(name, description, unit, enabled)};
}

opentelemetry::nostd::shared_ptr<Counter<float>> NewFloatCounter(nostd::string_view name,
nostd::string_view description,
nostd::string_view unit,
const bool enabled) override
nostd::shared_ptr<Counter<float>> NewFloatCounter(nostd::string_view name,
nostd::string_view description,
nostd::string_view unit,
const bool enabled) override
{
return nostd::shared_ptr<Counter<float>>{
new NoopCounter<float>(name, description, unit, enabled)};
}

opentelemetry::nostd::shared_ptr<Counter<double>> NewDoubleCounter(nostd::string_view name,
nostd::string_view description,
nostd::string_view unit,
const bool enabled) override
nostd::shared_ptr<Counter<double>> NewDoubleCounter(nostd::string_view name,
nostd::string_view description,
nostd::string_view unit,
const bool enabled) override
{
return nostd::shared_ptr<Counter<double>>{
new NoopCounter<double>(name, description, unit, enabled)};
Expand All @@ -342,41 +345,37 @@ class NoopMeter : public Meter
* @param enabled a boolean that turns the metric instrument on and off.
* @return
*/
opentelemetry::nostd::shared_ptr<UpDownCounter<short>> NewShortUpDownCounter(
nostd::string_view name,
nostd::string_view description,
nostd::string_view unit,
const bool enabled) override
nostd::shared_ptr<UpDownCounter<short>> NewShortUpDownCounter(nostd::string_view name,
nostd::string_view description,
nostd::string_view unit,
const bool enabled) override
{
return nostd::shared_ptr<UpDownCounter<short>>{
new NoopUpDownCounter<short>(name, description, unit, enabled)};
}

opentelemetry::nostd::shared_ptr<UpDownCounter<int>> NewIntUpDownCounter(
nostd::string_view name,
nostd::string_view description,
nostd::string_view unit,
const bool enabled) override
nostd::shared_ptr<UpDownCounter<int>> NewIntUpDownCounter(nostd::string_view name,
nostd::string_view description,
nostd::string_view unit,
const bool enabled) override
{
return nostd::shared_ptr<UpDownCounter<int>>{
new NoopUpDownCounter<int>(name, description, unit, enabled)};
}

opentelemetry::nostd::shared_ptr<UpDownCounter<float>> NewFloatUpDownCounter(
nostd::string_view name,
nostd::string_view description,
nostd::string_view unit,
const bool enabled) override
nostd::shared_ptr<UpDownCounter<float>> NewFloatUpDownCounter(nostd::string_view name,
nostd::string_view description,
nostd::string_view unit,
const bool enabled) override
{
return nostd::shared_ptr<UpDownCounter<float>>{
new NoopUpDownCounter<float>(name, description, unit, enabled)};
}

opentelemetry::nostd::shared_ptr<UpDownCounter<double>> NewDoubleUpDownCounter(
nostd::string_view name,
nostd::string_view description,
nostd::string_view unit,
const bool enabled) override
nostd::shared_ptr<UpDownCounter<double>> NewDoubleUpDownCounter(nostd::string_view name,
nostd::string_view description,
nostd::string_view unit,
const bool enabled) override
{
return nostd::shared_ptr<UpDownCounter<double>>{
new NoopUpDownCounter<double>(name, description, unit, enabled)};
Expand All @@ -392,41 +391,37 @@ class NoopMeter : public Meter
* @param enabled a boolean that turns the metric instrument on and off.
* @return
*/
opentelemetry::nostd::shared_ptr<ValueRecorder<short>> NewShortValueRecorder(
nostd::string_view name,
nostd::string_view description,
nostd::string_view unit,
const bool enabled) override
nostd::shared_ptr<ValueRecorder<short>> NewShortValueRecorder(nostd::string_view name,
nostd::string_view description,
nostd::string_view unit,
const bool enabled) override
{
return nostd::shared_ptr<ValueRecorder<short>>{
new NoopValueRecorder<short>(name, description, unit, enabled)};
}

opentelemetry::nostd::shared_ptr<ValueRecorder<int>> NewIntValueRecorder(
nostd::string_view name,
nostd::string_view description,
nostd::string_view unit,
const bool enabled) override
nostd::shared_ptr<ValueRecorder<int>> NewIntValueRecorder(nostd::string_view name,
nostd::string_view description,
nostd::string_view unit,
const bool enabled) override
{
return nostd::shared_ptr<ValueRecorder<int>>{
new NoopValueRecorder<int>(name, description, unit, enabled)};
}

opentelemetry::nostd::shared_ptr<ValueRecorder<float>> NewFloatValueRecorder(
nostd::string_view name,
nostd::string_view description,
nostd::string_view unit,
const bool enabled) override
nostd::shared_ptr<ValueRecorder<float>> NewFloatValueRecorder(nostd::string_view name,
nostd::string_view description,
nostd::string_view unit,
const bool enabled) override
{
return nostd::shared_ptr<ValueRecorder<float>>{
new NoopValueRecorder<float>(name, description, unit, enabled)};
}

opentelemetry::nostd::shared_ptr<ValueRecorder<double>> NewDoubleValueRecorder(
nostd::string_view name,
nostd::string_view description,
nostd::string_view unit,
const bool enabled) override
nostd::shared_ptr<ValueRecorder<double>> NewDoubleValueRecorder(nostd::string_view name,
nostd::string_view description,
nostd::string_view unit,
const bool enabled) override
{
return nostd::shared_ptr<ValueRecorder<double>>{
new NoopValueRecorder<double>(name, description, unit, enabled)};
Expand All @@ -442,7 +437,7 @@ class NoopMeter : public Meter
* @param enabled a boolean that turns the metric instrument on and off.
* @return
*/
opentelemetry::nostd::shared_ptr<SumObserver<short>> NewShortSumObserver(
nostd::shared_ptr<SumObserver<short>> NewShortSumObserver(
nostd::string_view name,
nostd::string_view description,
nostd::string_view unit,
Expand All @@ -453,7 +448,7 @@ class NoopMeter : public Meter
new NoopSumObserver<short>(name, description, unit, enabled, callback)};
}

opentelemetry::nostd::shared_ptr<SumObserver<int>> NewIntSumObserver(
nostd::shared_ptr<SumObserver<int>> NewIntSumObserver(
nostd::string_view name,
nostd::string_view description,
nostd::string_view unit,
Expand All @@ -464,7 +459,7 @@ class NoopMeter : public Meter
new NoopSumObserver<int>(name, description, unit, enabled, callback)};
}

opentelemetry::nostd::shared_ptr<SumObserver<float>> NewFloatSumObserver(
nostd::shared_ptr<SumObserver<float>> NewFloatSumObserver(
nostd::string_view name,
nostd::string_view description,
nostd::string_view unit,
Expand All @@ -475,7 +470,7 @@ class NoopMeter : public Meter
new NoopSumObserver<float>(name, description, unit, enabled, callback)};
}

opentelemetry::nostd::shared_ptr<SumObserver<double>> NewDoubleSumObserver(
nostd::shared_ptr<SumObserver<double>> NewDoubleSumObserver(
nostd::string_view name,
nostd::string_view description,
nostd::string_view unit,
Expand All @@ -496,7 +491,7 @@ class NoopMeter : public Meter
* @param enabled a boolean that turns the metric instrument on and off.
* @return
*/
opentelemetry::nostd::shared_ptr<UpDownSumObserver<short>> NewShortUpDownSumObserver(
nostd::shared_ptr<UpDownSumObserver<short>> NewShortUpDownSumObserver(
nostd::string_view name,
nostd::string_view description,
nostd::string_view unit,
Expand All @@ -507,7 +502,7 @@ class NoopMeter : public Meter
new NoopUpDownSumObserver<short>(name, description, unit, enabled, callback)};
}

opentelemetry::nostd::shared_ptr<UpDownSumObserver<int>> NewIntUpDownSumObserver(
nostd::shared_ptr<UpDownSumObserver<int>> NewIntUpDownSumObserver(
nostd::string_view name,
nostd::string_view description,
nostd::string_view unit,
Expand All @@ -518,7 +513,7 @@ class NoopMeter : public Meter
new NoopUpDownSumObserver<int>(name, description, unit, enabled, callback)};
}

opentelemetry::nostd::shared_ptr<UpDownSumObserver<float>> NewFloatUpDownSumObserver(
nostd::shared_ptr<UpDownSumObserver<float>> NewFloatUpDownSumObserver(
nostd::string_view name,
nostd::string_view description,
nostd::string_view unit,
Expand All @@ -529,7 +524,7 @@ class NoopMeter : public Meter
new NoopUpDownSumObserver<float>(name, description, unit, enabled, callback)};
}

opentelemetry::nostd::shared_ptr<UpDownSumObserver<double>> NewDoubleUpDownSumObserver(
nostd::shared_ptr<UpDownSumObserver<double>> NewDoubleUpDownSumObserver(
nostd::string_view name,
nostd::string_view description,
nostd::string_view unit,
Expand All @@ -550,7 +545,7 @@ class NoopMeter : public Meter
* @param enabled a boolean that turns the metric instrument on and off.
* @return
*/
opentelemetry::nostd::shared_ptr<ValueObserver<short>> NewShortValueObserver(
nostd::shared_ptr<ValueObserver<short>> NewShortValueObserver(
nostd::string_view name,
nostd::string_view description,
nostd::string_view unit,
Expand All @@ -561,7 +556,7 @@ class NoopMeter : public Meter
new NoopValueObserver<short>(name, description, unit, enabled, callback)};
}

opentelemetry::nostd::shared_ptr<ValueObserver<int>> NewIntValueObserver(
nostd::shared_ptr<ValueObserver<int>> NewIntValueObserver(
nostd::string_view name,
nostd::string_view description,
nostd::string_view unit,
Expand All @@ -572,7 +567,7 @@ class NoopMeter : public Meter
new NoopValueObserver<int>(name, description, unit, enabled, callback)};
}

opentelemetry::nostd::shared_ptr<ValueObserver<float>> NewFloatValueObserver(
nostd::shared_ptr<ValueObserver<float>> NewFloatValueObserver(
nostd::string_view name,
nostd::string_view description,
nostd::string_view unit,
Expand All @@ -583,7 +578,7 @@ class NoopMeter : public Meter
new NoopValueObserver<float>(name, description, unit, enabled, callback)};
}

opentelemetry::nostd::shared_ptr<ValueObserver<double>> NewDoubleValueObserver(
nostd::shared_ptr<ValueObserver<double>> NewDoubleValueObserver(
nostd::string_view name,
nostd::string_view description,
nostd::string_view unit,
Expand Down
2 changes: 0 additions & 2 deletions api/test/metrics/noop_metrics_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@ OPENTELEMETRY_BEGIN_NAMESPACE
using opentelemetry::metrics::Meter;
using opentelemetry::metrics::NoopMeter;

namespace metrics_api = opentelemetry::metrics;

void Callback(opentelemetry::metrics::ObserverResult<int> result)
{
std::map<std::string, std::string> labels = {{"key", "value"}};
Expand Down
7 changes: 5 additions & 2 deletions ext/include/opentelemetry/ext/zpages/threadsafe_span_data.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@
using opentelemetry::sdk::trace::AttributeConverter;
using opentelemetry::sdk::trace::SpanDataAttributeValue;
using opentelemetry::sdk::trace::SpanDataEvent;
namespace trace_api = opentelemetry::trace;

// TODO: Create generic short pattern for opentelemetry::common and opentelemetry::trace and others
// as necessary

OPENTELEMETRY_BEGIN_NAMESPACE
namespace ext
Expand Down Expand Up @@ -137,7 +139,8 @@ class ThreadsafeSpanData final : public opentelemetry::sdk::trace::Recordable
attributes_[std::string(key)] = nostd::visit(converter_, value);
}

void SetStatus(trace_api::CanonicalCode code, nostd::string_view description) noexcept override
void SetStatus(opentelemetry::trace::CanonicalCode code,
nostd::string_view description) noexcept override
{
std::lock_guard<std::mutex> lock(mutex_);
status_code_ = code;
Expand Down
5 changes: 3 additions & 2 deletions sdk/include/opentelemetry/sdk/trace/recordable.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,11 @@

#include <map>

// TODO: Create generic short pattern for opentelemetry::common and opentelemetry::trace

OPENTELEMETRY_BEGIN_NAMESPACE
namespace sdk
{
namespace trace_api = opentelemetry::trace;
namespace trace
{
/**
Expand Down Expand Up @@ -99,7 +100,7 @@ class Recordable
* @param code the status code
* @param description a description of the status
*/
virtual void SetStatus(trace_api::CanonicalCode code,
virtual void SetStatus(opentelemetry::trace::CanonicalCode code,
nostd::string_view description) noexcept = 0;

/**
Expand Down
10 changes: 1 addition & 9 deletions sdk/include/opentelemetry/sdk/trace/sampler.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,20 +65,12 @@ class Sampler
* @since 0.1.0
*/

<<<<<<< HEAD
virtual SamplingResult ShouldSample(
const trace_api::SpanContext *parent_context,
const trace_api::SpanContext &parent_context,
trace_api::TraceId trace_id,
nostd::string_view name,
trace_api::SpanKind span_kind,
const opentelemetry::common::KeyValueIterable &attributes) noexcept = 0;
=======
virtual SamplingResult ShouldSample(const trace_api::SpanContext &parent_context,
trace_api::TraceId trace_id,
nostd::string_view name,
trace_api::SpanKind span_kind,
const trace_api::KeyValueIterable &attributes) noexcept = 0;
>>>>>>> origin/master

/**
* Returns the sampler name or short description with the configuration.
Expand Down
11 changes: 6 additions & 5 deletions sdk/include/opentelemetry/sdk/trace/samplers/always_off.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,12 @@ class AlwaysOffSampler : public Sampler
/**
* @return Returns DROP always
*/
SamplingResult ShouldSample(const trace_api::SpanContext & /*parent_context*/,
trace_api::TraceId /*trace_id*/,
nostd::string_view /*name*/,
trace_api::SpanKind /*span_kind*/,
const opentelemetry::common::KeyValueIterable & /*attributes*/) noexcept override
SamplingResult ShouldSample(
const trace_api::SpanContext & /*parent_context*/,
trace_api::TraceId /*trace_id*/,
nostd::string_view /*name*/,
trace_api::SpanKind /*span_kind*/,
const opentelemetry::common::KeyValueIterable & /*attributes*/) noexcept override
{
return {Decision::DROP, nullptr};
}
Expand Down
11 changes: 6 additions & 5 deletions sdk/include/opentelemetry/sdk/trace/samplers/parent.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,12 @@ class ParentBasedSampler : public Sampler
* delegateSampler for root spans
* @return Returns DROP always
*/
SamplingResult ShouldSample(const trace_api::SpanContext &parent_context,
trace_api::TraceId trace_id,
nostd::string_view name,
trace_api::SpanKind span_kind,
const opentelemetry::common::KeyValueIterable &attributes) noexcept override;
SamplingResult ShouldSample(
const trace_api::SpanContext &parent_context,
trace_api::TraceId trace_id,
nostd::string_view name,
trace_api::SpanKind span_kind,
const opentelemetry::common::KeyValueIterable &attributes) noexcept override;

/**
* @return Description MUST be ParentBased{delegate_sampler_.getDescription()}
Expand Down
Loading

0 comments on commit 3f73296

Please sign in to comment.