From b5d066d7504b65d30633c944e507d4f6d5af8a07 Mon Sep 17 00:00:00 2001 From: Oliver Zhang Date: Tue, 23 Jun 2020 23:10:09 +0000 Subject: [PATCH 01/39] minor fix --- sdk/include/opentelemetry/sdk/trace/sampler.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sdk/include/opentelemetry/sdk/trace/sampler.h b/sdk/include/opentelemetry/sdk/trace/sampler.h index 2cf24b4b40..c1236908ab 100644 --- a/sdk/include/opentelemetry/sdk/trace/sampler.h +++ b/sdk/include/opentelemetry/sdk/trace/sampler.h @@ -38,7 +38,7 @@ struct SamplingResult { Decision decision; // A set of span Attributes that will also be added to the Span. Can be nullptr. - std::unique_ptr> attributes; + std::unique_ptr> attributes; }; /** From abba0e301c13ae8b65037b617960ffea66996d7d Mon Sep 17 00:00:00 2001 From: Oliver Zhang Date: Wed, 24 Jun 2020 01:34:51 +0000 Subject: [PATCH 02/39] modify namespace --- sdk/include/opentelemetry/sdk/trace/sampler.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sdk/include/opentelemetry/sdk/trace/sampler.h b/sdk/include/opentelemetry/sdk/trace/sampler.h index c1236908ab..93599b18e7 100644 --- a/sdk/include/opentelemetry/sdk/trace/sampler.h +++ b/sdk/include/opentelemetry/sdk/trace/sampler.h @@ -70,7 +70,7 @@ class Sampler trace_api::TraceId trace_id, nostd::string_view name, trace_api::SpanKind span_kind, - const KeyValueIterable &attributes) noexcept = 0; + const trace_api::KeyValueIterable &attributes) noexcept = 0; /** * Returns the sampler name or short description with the configuration. From 641f18a851554affd0487c0d2d80334153b9d027 Mon Sep 17 00:00:00 2001 From: Oliver Zhang Date: Wed, 17 Jun 2020 02:03:21 +0000 Subject: [PATCH 03/39] add sampler header file --- sdk/include/opentelemetry/sdk/trace/sampler.h | 87 +++++++------------ 1 file changed, 29 insertions(+), 58 deletions(-) diff --git a/sdk/include/opentelemetry/sdk/trace/sampler.h b/sdk/include/opentelemetry/sdk/trace/sampler.h index 93599b18e7..cb884cc14b 100644 --- a/sdk/include/opentelemetry/sdk/trace/sampler.h +++ b/sdk/include/opentelemetry/sdk/trace/sampler.h @@ -1,12 +1,10 @@ #pragma once -#include "opentelemetry/common/attribute_value.h" -#include "opentelemetry/trace/span.h" -#include "opentelemetry/trace/trace_id.h" #include "opentelemetry/version.h" +#include "opentelemetry/common/attribute_value.h" -#include #include +#include #include OPENTELEMETRY_BEGIN_NAMESPACE @@ -14,71 +12,44 @@ namespace sdk { namespace trace { -namespace trace_api = opentelemetry::trace; - -/** - * A sampling Decision for a Span to be created. - */ -enum class Decision +class Sampler { - // IsRecording() == false, span will not be recorded and all events and attributes will be - // dropped. - NOT_RECORD, - // IsRecording() == true, but Sampled flag MUST NOT be set. - RECORD, - // IsRecording() == true AND Sampled flag` MUST be set. - RECORD_AND_SAMPLE -}; +public: + /** + * Initialize a new tracer. + * @param processor The span processor for this tracer. This must not be a + * nullptr. + */ + virtual Decision shouldSample(); -/** - * The output of ShouldSample. - * It contains a sampling Decision and a set of Span Attributes. - */ -struct SamplingResult -{ - Decision decision; - // A set of span Attributes that will also be added to the Span. Can be nullptr. - std::unique_ptr> attributes; + /** + * Returns the description of this {@code Sampler}. This may be displayed on debug pages or in the + * logs. + * + *

Example: "ProbabilitySampler{0.000100}" + * + * @return the description of this {@code Sampler}. + */ + virtual std::string getDescription(); }; -/** - * The Sampler interface allows users to create custom samplers which will return a - * SamplingResult based on information that is typically available just before the Span was created. - */ -class Sampler +class Decision { public: - // TODO: Remove this placeholder with real class - class SpanContext; - virtual ~Sampler() = default; /** - * Called during Span creation to make a sampling decision. + * Return sampling decision whether span should be sampled or not. * - * @param parent_context a const pointer of the SpanContext of a parent Span. - * null if this is a root span. - * @param trace_id the TraceId for the new Span. This will be identical to that in - * the parentContext, unless this is a root span. - * @param name the name of the new Span. - * @param spanKind the trace_api::SpanKind of the Span. - * @param attributes list of AttributeValue with their keys. - * @param links TODO: Collection of links that will be associated with the Span to be created. - * @return sampling result whether span should be sampled or not. - * @since 0.1.0 + * @return sampling decision. */ - - virtual SamplingResult ShouldSample(const SpanContext *parent_context, - trace_api::TraceId trace_id, - nostd::string_view name, - trace_api::SpanKind span_kind, - const trace_api::KeyValueIterable &attributes) noexcept = 0; + virtual bool isSampled(); /** - * Returns the sampler name or short description with the configuration. - * This may be displayed on debug pages or in the logs. - * - * @return the description of this Sampler. - */ - virtual std::string GetDescription() const noexcept = 0; + * Return tags which will be attached to the span. + * + * @return attributes added to span. These attributes should be added to the span only for root + * span or when sampling decision {@link #isSampled()} changes from false to true. + */ + virtual std::map getAttributes(); }; } // namespace trace } // namespace sdk From 850b463e5bbb528211c09cbbc9d3fd7c3ef136e9 Mon Sep 17 00:00:00 2001 From: Oliver Zhang Date: Wed, 17 Jun 2020 02:51:09 +0000 Subject: [PATCH 04/39] add param and comments --- sdk/include/opentelemetry/sdk/trace/sampler.h | 44 ++++++++++++++----- 1 file changed, 33 insertions(+), 11 deletions(-) diff --git a/sdk/include/opentelemetry/sdk/trace/sampler.h b/sdk/include/opentelemetry/sdk/trace/sampler.h index cb884cc14b..784628a529 100644 --- a/sdk/include/opentelemetry/sdk/trace/sampler.h +++ b/sdk/include/opentelemetry/sdk/trace/sampler.h @@ -1,10 +1,13 @@ #pragma once -#include "opentelemetry/version.h" #include "opentelemetry/common/attribute_value.h" +#include "opentelemetry/trace/span.h" +#include "opentelemetry/trace/trace_id.h" +#include "opentelemetry/trace/tracer.h" +#include "opentelemetry/version.h" -#include #include +#include #include OPENTELEMETRY_BEGIN_NAMESPACE @@ -12,15 +15,31 @@ namespace sdk { namespace trace { +namespace trace_api = opentelemetry::trace; class Sampler { public: + virtual ~Sampler() = default; /** - * Initialize a new tracer. - * @param processor The span processor for this tracer. This must not be a - * nullptr. + * Called during Span creation to make a sampling decision. + * + * @param parentContext TODO: the parent span's SpanContext. null if this is a root + * span. + * @param traceId the TraceId for the new Span. This will be identical to that in + * the parentContext, unless this is a root span. + * @param name the name of the new Span. + * @param parentLinks TODO: the parentLinks associated with the new Span. + * @param spanKind the trace_api::SpanKind of the Span. + * @param attributes list of AttributeValue with their keys. + * @return sampling decision whether span should be sampled or not. + * @since 0.1.0 */ - virtual Decision shouldSample(); + + virtual Decision shouldSample( + trace_api::TraceId trace_id, + std::string name, + trace_api::SpanKind span_kind, + std::map attributes) noexcept = 0; /** * Returns the description of this {@code Sampler}. This may be displayed on debug pages or in the @@ -36,6 +55,7 @@ class Sampler class Decision { public: + virtual ~Decision() = default; /** * Return sampling decision whether span should be sampled or not. * @@ -44,13 +64,15 @@ class Decision virtual bool isSampled(); /** - * Return tags which will be attached to the span. - * - * @return attributes added to span. These attributes should be added to the span only for root - * span or when sampling decision {@link #isSampled()} changes from false to true. - */ + * Return tags which will be attached to the span. + * + * @return attributes added to span. These attributes should be added to the span only for root + * span or when sampling decision isSampled() changes from false to true. + */ virtual std::map getAttributes(); }; + +class } // namespace trace } // namespace sdk OPENTELEMETRY_END_NAMESPACE From 66a079cdfdcaeed2777d6add0670202b5989b346 Mon Sep 17 00:00:00 2001 From: Oliver Zhang Date: Wed, 17 Jun 2020 15:07:57 +0000 Subject: [PATCH 05/39] change class definition --- sdk/include/opentelemetry/sdk/trace/sampler.h | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/sdk/include/opentelemetry/sdk/trace/sampler.h b/sdk/include/opentelemetry/sdk/trace/sampler.h index 784628a529..22ec6d52f1 100644 --- a/sdk/include/opentelemetry/sdk/trace/sampler.h +++ b/sdk/include/opentelemetry/sdk/trace/sampler.h @@ -35,7 +35,7 @@ class Sampler * @since 0.1.0 */ - virtual Decision shouldSample( + virtual SamplingResult ShouldSample( trace_api::TraceId trace_id, std::string name, trace_api::SpanKind span_kind, @@ -49,30 +49,29 @@ class Sampler * * @return the description of this {@code Sampler}. */ - virtual std::string getDescription(); + virtual std::string GetDescription() const noexcept = 0; }; -class Decision +class SamplingResult { public: - virtual ~Decision() = default; + // TODO: add Decision enum + virtual ~SamplingResult() = default; /** * Return sampling decision whether span should be sampled or not. * - * @return sampling decision. + * @return TODO: Decision. */ - virtual bool isSampled(); + virtual bool GetDecision(); /** - * Return tags which will be attached to the span. + * Return attributes which will be attached to the span. * * @return attributes added to span. These attributes should be added to the span only for root * span or when sampling decision isSampled() changes from false to true. */ - virtual std::map getAttributes(); + virtual std::map GetAttributes(); }; - -class } // namespace trace } // namespace sdk OPENTELEMETRY_END_NAMESPACE From e454c10b37ed9413899c4047d018127be6a0b45f Mon Sep 17 00:00:00 2001 From: Oliver Zhang Date: Wed, 17 Jun 2020 17:22:53 +0000 Subject: [PATCH 06/39] add Decision enum --- sdk/include/opentelemetry/sdk/trace/sampler.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/sdk/include/opentelemetry/sdk/trace/sampler.h b/sdk/include/opentelemetry/sdk/trace/sampler.h index 22ec6d52f1..8d21b7cc5f 100644 --- a/sdk/include/opentelemetry/sdk/trace/sampler.h +++ b/sdk/include/opentelemetry/sdk/trace/sampler.h @@ -54,6 +54,8 @@ class Sampler class SamplingResult { +private: + enum Decision {NOT_RECORD, RECORD, RECORD_AND_SAMPLE}; public: // TODO: add Decision enum virtual ~SamplingResult() = default; @@ -62,7 +64,7 @@ class SamplingResult * * @return TODO: Decision. */ - virtual bool GetDecision(); + virtual Decision GetDecision() const noexcept = 0; /** * Return attributes which will be attached to the span. @@ -70,7 +72,7 @@ class SamplingResult * @return attributes added to span. These attributes should be added to the span only for root * span or when sampling decision isSampled() changes from false to true. */ - virtual std::map GetAttributes(); + virtual std::map GetAttributes() const noexcept = 0; }; } // namespace trace } // namespace sdk From 692b1a94460180f6c2447aba0133992f1a4f5f17 Mon Sep 17 00:00:00 2001 From: Oliver Zhang Date: Wed, 17 Jun 2020 17:22:53 +0000 Subject: [PATCH 07/39] add Decision enum --- sdk/include/opentelemetry/sdk/trace/sampler.h | 24 +++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/sdk/include/opentelemetry/sdk/trace/sampler.h b/sdk/include/opentelemetry/sdk/trace/sampler.h index 8d21b7cc5f..374c333acd 100644 --- a/sdk/include/opentelemetry/sdk/trace/sampler.h +++ b/sdk/include/opentelemetry/sdk/trace/sampler.h @@ -1,6 +1,8 @@ #pragma once #include "opentelemetry/common/attribute_value.h" +#include "opentelemetry/nostd/string_view.h" +#include "opentelemetry/sdk/common/atomic_shared_ptr.h" #include "opentelemetry/trace/span.h" #include "opentelemetry/trace/trace_id.h" #include "opentelemetry/trace/tracer.h" @@ -18,26 +20,33 @@ namespace trace namespace trace_api = opentelemetry::trace; class Sampler { +private: + // Placeholder + class SpanContext + {}; + public: virtual ~Sampler() = default; /** * Called during Span creation to make a sampling decision. * - * @param parentContext TODO: the parent span's SpanContext. null if this is a root + * @param parent_context TODO: the parent span's SpanContext. null if this is a root * span. * @param traceId the TraceId for the new Span. This will be identical to that in * the parentContext, unless this is a root span. * @param name the name of the new Span. * @param parentLinks TODO: the parentLinks associated with the new Span. * @param spanKind the trace_api::SpanKind of the Span. - * @param attributes list of AttributeValue with their keys. + * @param attributes TODO: current map is a placeholder. + * list of AttributeValue with their keys. * @return sampling decision whether span should be sampled or not. * @since 0.1.0 */ virtual SamplingResult ShouldSample( + std::shared_ptr parent_context, trace_api::TraceId trace_id, - std::string name, + nostd::string_view name, trace_api::SpanKind span_kind, std::map attributes) noexcept = 0; @@ -55,7 +64,13 @@ class Sampler class SamplingResult { private: - enum Decision {NOT_RECORD, RECORD, RECORD_AND_SAMPLE}; + enum Decision + { + NOT_RECORD, + RECORD, + RECORD_AND_SAMPLE + }; + public: // TODO: add Decision enum virtual ~SamplingResult() = default; @@ -69,6 +84,7 @@ class SamplingResult /** * Return attributes which will be attached to the span. * + * TODO: Change return value to nostd::span> * @return attributes added to span. These attributes should be added to the span only for root * span or when sampling decision isSampled() changes from false to true. */ From ae423f0b4fc3318eca24822cb9ec7b7c4b283431 Mon Sep 17 00:00:00 2001 From: Oliver Zhang Date: Wed, 17 Jun 2020 19:51:41 +0000 Subject: [PATCH 08/39] minor tweaks --- sdk/include/opentelemetry/sdk/trace/sampler.h | 35 ++++++++----------- 1 file changed, 15 insertions(+), 20 deletions(-) diff --git a/sdk/include/opentelemetry/sdk/trace/sampler.h b/sdk/include/opentelemetry/sdk/trace/sampler.h index 374c333acd..52ee1f7824 100644 --- a/sdk/include/opentelemetry/sdk/trace/sampler.h +++ b/sdk/include/opentelemetry/sdk/trace/sampler.h @@ -1,6 +1,7 @@ #pragma once #include "opentelemetry/common/attribute_value.h" +#include "opentelemetry/nostd/span.h" #include "opentelemetry/nostd/string_view.h" #include "opentelemetry/sdk/common/atomic_shared_ptr.h" #include "opentelemetry/trace/span.h" @@ -30,16 +31,16 @@ class Sampler /** * Called during Span creation to make a sampling decision. * - * @param parent_context TODO: the parent span's SpanContext. null if this is a root - * span. - * @param traceId the TraceId for the new Span. This will be identical to that in + * @param parent_context TODO: a shared pointer of the SpanContext of a parent Span. + * null if this is a root span. + * @param trace_id the TraceId for the new Span. This will be identical to that in * the parentContext, unless this is a root span. * @param name the name of the new Span. - * @param parentLinks TODO: the parentLinks associated with the new Span. * @param spanKind the trace_api::SpanKind of the Span. * @param attributes TODO: current map is a placeholder. * list of AttributeValue with their keys. - * @return sampling decision whether span should be sampled or not. + * @param links TODO: Collection of links that will be associated with the Span to be created. + * @return sampling result whether span should be sampled or not. * @since 0.1.0 */ @@ -51,44 +52,38 @@ class Sampler std::map attributes) noexcept = 0; /** - * Returns the description of this {@code Sampler}. This may be displayed on debug pages or in the - * logs. + * Returns the sampler name or short description with the configuration. + * This may be displayed on debug pages or in the logs. * - *

Example: "ProbabilitySampler{0.000100}" - * - * @return the description of this {@code Sampler}. + * @return the description of this Sampler. */ virtual std::string GetDescription() const noexcept = 0; }; class SamplingResult { -private: +public: enum Decision { NOT_RECORD, RECORD, RECORD_AND_SAMPLE }; - -public: - // TODO: add Decision enum virtual ~SamplingResult() = default; /** - * Return sampling decision whether span should be sampled or not. + * Return sampling decision. * - * @return TODO: Decision. + * @return Decision. */ virtual Decision GetDecision() const noexcept = 0; /** * Return attributes which will be attached to the span. * - * TODO: Change return value to nostd::span> - * @return attributes added to span. These attributes should be added to the span only for root - * span or when sampling decision isSampled() changes from false to true. + * @return the immutable list of attributes added to span. */ - virtual std::map GetAttributes() const noexcept = 0; + virtual nostd::span> GetAttributes() const + noexcept = 0; }; } // namespace trace } // namespace sdk From 1bf4267734058fc08abb6f55f91da4339fe4b596 Mon Sep 17 00:00:00 2001 From: Oliver Zhang Date: Wed, 17 Jun 2020 02:03:21 +0000 Subject: [PATCH 09/39] add sampler header file --- sdk/include/opentelemetry/sdk/trace/sampler.h | 78 ++++++------------- 1 file changed, 22 insertions(+), 56 deletions(-) diff --git a/sdk/include/opentelemetry/sdk/trace/sampler.h b/sdk/include/opentelemetry/sdk/trace/sampler.h index 52ee1f7824..cb884cc14b 100644 --- a/sdk/include/opentelemetry/sdk/trace/sampler.h +++ b/sdk/include/opentelemetry/sdk/trace/sampler.h @@ -1,16 +1,10 @@ #pragma once -#include "opentelemetry/common/attribute_value.h" -#include "opentelemetry/nostd/span.h" -#include "opentelemetry/nostd/string_view.h" -#include "opentelemetry/sdk/common/atomic_shared_ptr.h" -#include "opentelemetry/trace/span.h" -#include "opentelemetry/trace/trace_id.h" -#include "opentelemetry/trace/tracer.h" #include "opentelemetry/version.h" +#include "opentelemetry/common/attribute_value.h" -#include #include +#include #include OPENTELEMETRY_BEGIN_NAMESPACE @@ -18,72 +12,44 @@ namespace sdk { namespace trace { -namespace trace_api = opentelemetry::trace; class Sampler { -private: - // Placeholder - class SpanContext - {}; - public: - virtual ~Sampler() = default; /** - * Called during Span creation to make a sampling decision. - * - * @param parent_context TODO: a shared pointer of the SpanContext of a parent Span. - * null if this is a root span. - * @param trace_id the TraceId for the new Span. This will be identical to that in - * the parentContext, unless this is a root span. - * @param name the name of the new Span. - * @param spanKind the trace_api::SpanKind of the Span. - * @param attributes TODO: current map is a placeholder. - * list of AttributeValue with their keys. - * @param links TODO: Collection of links that will be associated with the Span to be created. - * @return sampling result whether span should be sampled or not. - * @since 0.1.0 + * Initialize a new tracer. + * @param processor The span processor for this tracer. This must not be a + * nullptr. */ - - virtual SamplingResult ShouldSample( - std::shared_ptr parent_context, - trace_api::TraceId trace_id, - nostd::string_view name, - trace_api::SpanKind span_kind, - std::map attributes) noexcept = 0; + virtual Decision shouldSample(); /** - * Returns the sampler name or short description with the configuration. - * This may be displayed on debug pages or in the logs. + * Returns the description of this {@code Sampler}. This may be displayed on debug pages or in the + * logs. + * + *

Example: "ProbabilitySampler{0.000100}" * - * @return the description of this Sampler. + * @return the description of this {@code Sampler}. */ - virtual std::string GetDescription() const noexcept = 0; + virtual std::string getDescription(); }; -class SamplingResult +class Decision { public: - enum Decision - { - NOT_RECORD, - RECORD, - RECORD_AND_SAMPLE - }; - virtual ~SamplingResult() = default; /** - * Return sampling decision. + * Return sampling decision whether span should be sampled or not. * - * @return Decision. + * @return sampling decision. */ - virtual Decision GetDecision() const noexcept = 0; + virtual bool isSampled(); /** - * Return attributes which will be attached to the span. - * - * @return the immutable list of attributes added to span. - */ - virtual nostd::span> GetAttributes() const - noexcept = 0; + * Return tags which will be attached to the span. + * + * @return attributes added to span. These attributes should be added to the span only for root + * span or when sampling decision {@link #isSampled()} changes from false to true. + */ + virtual std::map getAttributes(); }; } // namespace trace } // namespace sdk From 71534c9f46c6cd1ad527aa41cbc6172e589356c8 Mon Sep 17 00:00:00 2001 From: Oliver Zhang Date: Wed, 17 Jun 2020 02:51:09 +0000 Subject: [PATCH 10/39] add param and comments --- sdk/include/opentelemetry/sdk/trace/sampler.h | 44 ++++++++++++++----- 1 file changed, 33 insertions(+), 11 deletions(-) diff --git a/sdk/include/opentelemetry/sdk/trace/sampler.h b/sdk/include/opentelemetry/sdk/trace/sampler.h index cb884cc14b..784628a529 100644 --- a/sdk/include/opentelemetry/sdk/trace/sampler.h +++ b/sdk/include/opentelemetry/sdk/trace/sampler.h @@ -1,10 +1,13 @@ #pragma once -#include "opentelemetry/version.h" #include "opentelemetry/common/attribute_value.h" +#include "opentelemetry/trace/span.h" +#include "opentelemetry/trace/trace_id.h" +#include "opentelemetry/trace/tracer.h" +#include "opentelemetry/version.h" -#include #include +#include #include OPENTELEMETRY_BEGIN_NAMESPACE @@ -12,15 +15,31 @@ namespace sdk { namespace trace { +namespace trace_api = opentelemetry::trace; class Sampler { public: + virtual ~Sampler() = default; /** - * Initialize a new tracer. - * @param processor The span processor for this tracer. This must not be a - * nullptr. + * Called during Span creation to make a sampling decision. + * + * @param parentContext TODO: the parent span's SpanContext. null if this is a root + * span. + * @param traceId the TraceId for the new Span. This will be identical to that in + * the parentContext, unless this is a root span. + * @param name the name of the new Span. + * @param parentLinks TODO: the parentLinks associated with the new Span. + * @param spanKind the trace_api::SpanKind of the Span. + * @param attributes list of AttributeValue with their keys. + * @return sampling decision whether span should be sampled or not. + * @since 0.1.0 */ - virtual Decision shouldSample(); + + virtual Decision shouldSample( + trace_api::TraceId trace_id, + std::string name, + trace_api::SpanKind span_kind, + std::map attributes) noexcept = 0; /** * Returns the description of this {@code Sampler}. This may be displayed on debug pages or in the @@ -36,6 +55,7 @@ class Sampler class Decision { public: + virtual ~Decision() = default; /** * Return sampling decision whether span should be sampled or not. * @@ -44,13 +64,15 @@ class Decision virtual bool isSampled(); /** - * Return tags which will be attached to the span. - * - * @return attributes added to span. These attributes should be added to the span only for root - * span or when sampling decision {@link #isSampled()} changes from false to true. - */ + * Return tags which will be attached to the span. + * + * @return attributes added to span. These attributes should be added to the span only for root + * span or when sampling decision isSampled() changes from false to true. + */ virtual std::map getAttributes(); }; + +class } // namespace trace } // namespace sdk OPENTELEMETRY_END_NAMESPACE From 9e6d9f482ce179b50e68f6cda3dad01b4d910c6c Mon Sep 17 00:00:00 2001 From: Oliver Zhang Date: Wed, 17 Jun 2020 15:07:57 +0000 Subject: [PATCH 11/39] change class definition --- sdk/include/opentelemetry/sdk/trace/sampler.h | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/sdk/include/opentelemetry/sdk/trace/sampler.h b/sdk/include/opentelemetry/sdk/trace/sampler.h index 784628a529..22ec6d52f1 100644 --- a/sdk/include/opentelemetry/sdk/trace/sampler.h +++ b/sdk/include/opentelemetry/sdk/trace/sampler.h @@ -35,7 +35,7 @@ class Sampler * @since 0.1.0 */ - virtual Decision shouldSample( + virtual SamplingResult ShouldSample( trace_api::TraceId trace_id, std::string name, trace_api::SpanKind span_kind, @@ -49,30 +49,29 @@ class Sampler * * @return the description of this {@code Sampler}. */ - virtual std::string getDescription(); + virtual std::string GetDescription() const noexcept = 0; }; -class Decision +class SamplingResult { public: - virtual ~Decision() = default; + // TODO: add Decision enum + virtual ~SamplingResult() = default; /** * Return sampling decision whether span should be sampled or not. * - * @return sampling decision. + * @return TODO: Decision. */ - virtual bool isSampled(); + virtual bool GetDecision(); /** - * Return tags which will be attached to the span. + * Return attributes which will be attached to the span. * * @return attributes added to span. These attributes should be added to the span only for root * span or when sampling decision isSampled() changes from false to true. */ - virtual std::map getAttributes(); + virtual std::map GetAttributes(); }; - -class } // namespace trace } // namespace sdk OPENTELEMETRY_END_NAMESPACE From 358da8d5eadc589dcfd8fe3601c09cb8c4b6cb2a Mon Sep 17 00:00:00 2001 From: Oliver Zhang Date: Wed, 17 Jun 2020 17:22:53 +0000 Subject: [PATCH 12/39] add Decision enum --- sdk/include/opentelemetry/sdk/trace/sampler.h | 28 +++++++++++++++---- 1 file changed, 23 insertions(+), 5 deletions(-) diff --git a/sdk/include/opentelemetry/sdk/trace/sampler.h b/sdk/include/opentelemetry/sdk/trace/sampler.h index 22ec6d52f1..374c333acd 100644 --- a/sdk/include/opentelemetry/sdk/trace/sampler.h +++ b/sdk/include/opentelemetry/sdk/trace/sampler.h @@ -1,6 +1,8 @@ #pragma once #include "opentelemetry/common/attribute_value.h" +#include "opentelemetry/nostd/string_view.h" +#include "opentelemetry/sdk/common/atomic_shared_ptr.h" #include "opentelemetry/trace/span.h" #include "opentelemetry/trace/trace_id.h" #include "opentelemetry/trace/tracer.h" @@ -18,26 +20,33 @@ namespace trace namespace trace_api = opentelemetry::trace; class Sampler { +private: + // Placeholder + class SpanContext + {}; + public: virtual ~Sampler() = default; /** * Called during Span creation to make a sampling decision. * - * @param parentContext TODO: the parent span's SpanContext. null if this is a root + * @param parent_context TODO: the parent span's SpanContext. null if this is a root * span. * @param traceId the TraceId for the new Span. This will be identical to that in * the parentContext, unless this is a root span. * @param name the name of the new Span. * @param parentLinks TODO: the parentLinks associated with the new Span. * @param spanKind the trace_api::SpanKind of the Span. - * @param attributes list of AttributeValue with their keys. + * @param attributes TODO: current map is a placeholder. + * list of AttributeValue with their keys. * @return sampling decision whether span should be sampled or not. * @since 0.1.0 */ virtual SamplingResult ShouldSample( + std::shared_ptr parent_context, trace_api::TraceId trace_id, - std::string name, + nostd::string_view name, trace_api::SpanKind span_kind, std::map attributes) noexcept = 0; @@ -54,6 +63,14 @@ class Sampler class SamplingResult { +private: + enum Decision + { + NOT_RECORD, + RECORD, + RECORD_AND_SAMPLE + }; + public: // TODO: add Decision enum virtual ~SamplingResult() = default; @@ -62,15 +79,16 @@ class SamplingResult * * @return TODO: Decision. */ - virtual bool GetDecision(); + virtual Decision GetDecision() const noexcept = 0; /** * Return attributes which will be attached to the span. * + * TODO: Change return value to nostd::span> * @return attributes added to span. These attributes should be added to the span only for root * span or when sampling decision isSampled() changes from false to true. */ - virtual std::map GetAttributes(); + virtual std::map GetAttributes() const noexcept = 0; }; } // namespace trace } // namespace sdk From b31c615cf55d14dde9f2166497189c49dd9d0efe Mon Sep 17 00:00:00 2001 From: Oliver Zhang Date: Wed, 17 Jun 2020 17:22:53 +0000 Subject: [PATCH 13/39] add Decision enum --- sdk/include/opentelemetry/sdk/trace/sampler.h | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/sdk/include/opentelemetry/sdk/trace/sampler.h b/sdk/include/opentelemetry/sdk/trace/sampler.h index 374c333acd..dee3d7a2ce 100644 --- a/sdk/include/opentelemetry/sdk/trace/sampler.h +++ b/sdk/include/opentelemetry/sdk/trace/sampler.h @@ -63,16 +63,13 @@ class Sampler class SamplingResult { -private: +public: enum Decision { NOT_RECORD, RECORD, RECORD_AND_SAMPLE }; - -public: - // TODO: add Decision enum virtual ~SamplingResult() = default; /** * Return sampling decision whether span should be sampled or not. From d2713a0c3a1aa13c74426dd94c65688779b4bcbb Mon Sep 17 00:00:00 2001 From: Oliver Zhang Date: Wed, 17 Jun 2020 19:51:41 +0000 Subject: [PATCH 14/39] minor tweaks --- sdk/include/opentelemetry/sdk/trace/sampler.h | 30 +++++++++---------- 1 file changed, 14 insertions(+), 16 deletions(-) diff --git a/sdk/include/opentelemetry/sdk/trace/sampler.h b/sdk/include/opentelemetry/sdk/trace/sampler.h index dee3d7a2ce..52ee1f7824 100644 --- a/sdk/include/opentelemetry/sdk/trace/sampler.h +++ b/sdk/include/opentelemetry/sdk/trace/sampler.h @@ -1,6 +1,7 @@ #pragma once #include "opentelemetry/common/attribute_value.h" +#include "opentelemetry/nostd/span.h" #include "opentelemetry/nostd/string_view.h" #include "opentelemetry/sdk/common/atomic_shared_ptr.h" #include "opentelemetry/trace/span.h" @@ -30,16 +31,16 @@ class Sampler /** * Called during Span creation to make a sampling decision. * - * @param parent_context TODO: the parent span's SpanContext. null if this is a root - * span. - * @param traceId the TraceId for the new Span. This will be identical to that in + * @param parent_context TODO: a shared pointer of the SpanContext of a parent Span. + * null if this is a root span. + * @param trace_id the TraceId for the new Span. This will be identical to that in * the parentContext, unless this is a root span. * @param name the name of the new Span. - * @param parentLinks TODO: the parentLinks associated with the new Span. * @param spanKind the trace_api::SpanKind of the Span. * @param attributes TODO: current map is a placeholder. * list of AttributeValue with their keys. - * @return sampling decision whether span should be sampled or not. + * @param links TODO: Collection of links that will be associated with the Span to be created. + * @return sampling result whether span should be sampled or not. * @since 0.1.0 */ @@ -51,12 +52,10 @@ class Sampler std::map attributes) noexcept = 0; /** - * Returns the description of this {@code Sampler}. This may be displayed on debug pages or in the - * logs. + * Returns the sampler name or short description with the configuration. + * This may be displayed on debug pages or in the logs. * - *

Example: "ProbabilitySampler{0.000100}" - * - * @return the description of this {@code Sampler}. + * @return the description of this Sampler. */ virtual std::string GetDescription() const noexcept = 0; }; @@ -72,20 +71,19 @@ class SamplingResult }; virtual ~SamplingResult() = default; /** - * Return sampling decision whether span should be sampled or not. + * Return sampling decision. * - * @return TODO: Decision. + * @return Decision. */ virtual Decision GetDecision() const noexcept = 0; /** * Return attributes which will be attached to the span. * - * TODO: Change return value to nostd::span> - * @return attributes added to span. These attributes should be added to the span only for root - * span or when sampling decision isSampled() changes from false to true. + * @return the immutable list of attributes added to span. */ - virtual std::map GetAttributes() const noexcept = 0; + virtual nostd::span> GetAttributes() const + noexcept = 0; }; } // namespace trace } // namespace sdk From f00f02dadf9a0437a89c474cfe3ed5a111ebe196 Mon Sep 17 00:00:00 2001 From: Nick Holbrook Date: Fri, 19 Jun 2020 10:51:40 -0400 Subject: [PATCH 15/39] Add AlwaysOffSampler header file --- .../sdk/trace/always_off_sampler.h | 52 +++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 sdk/include/opentelemetry/sdk/trace/always_off_sampler.h diff --git a/sdk/include/opentelemetry/sdk/trace/always_off_sampler.h b/sdk/include/opentelemetry/sdk/trace/always_off_sampler.h new file mode 100644 index 0000000000..b23ffd2091 --- /dev/null +++ b/sdk/include/opentelemetry/sdk/trace/always_off_sampler.h @@ -0,0 +1,52 @@ +#pragma once + +#include "opentelemetry/sdk/trace/sampler.h" + +OPENTELEMETRY_BEGIN_NAMESPACE +namespace sdk +{ +namespace trace +{ +namespace trace_api = opentelemetry::trace; +/** + * The always off sampler always returns NOT_RECORD, effectively disabling + * tracing functionality. + */ +class AlwaysOffSampler : public Sampler +{ +public: + SamplingResult ShouldSample( + std::shared_ptr parent_context, + trace_api::TraceId trace_id, + nostd::string_view name, + trace_api::SpanKind span_kind, + nostd::span> attributes) noexcept override + { + return _result; + } + + std::string GetDescription() const noexcept override + { + return "AlwaysOffSampler"; + } + +private: + SamplingResult _result = AlwaysOffSamplingResultImpl(); +}; + +class AlwaysOffSamplingResultImpl : public SamplingResult +{ +public: + Decision GetDecision() const noexcept override + { + return NOT_RECORD; + } + + nostd::span> GetAttributes() const noexcept override + { + return nostd::span(); + } +}; +} // namespace trace +} // namespace sdk +OPENTELEMETRY_END_NAMESPACE \ No newline at end of file From d1e27aea0f06c9ade487cfd84102d3715463de5c Mon Sep 17 00:00:00 2001 From: Nick Holbrook Date: Mon, 22 Jun 2020 07:29:11 -0400 Subject: [PATCH 16/39] Add AlwaysOffSampler --- .../sdk/trace/always_off_sampler.h | 36 +++++---------- sdk/src/trace/always_off_sampler.cc | 44 +++++++++++++++++++ 2 files changed, 56 insertions(+), 24 deletions(-) create mode 100644 sdk/src/trace/always_off_sampler.cc diff --git a/sdk/include/opentelemetry/sdk/trace/always_off_sampler.h b/sdk/include/opentelemetry/sdk/trace/always_off_sampler.h index b23ffd2091..f6a035b740 100644 --- a/sdk/include/opentelemetry/sdk/trace/always_off_sampler.h +++ b/sdk/include/opentelemetry/sdk/trace/always_off_sampler.h @@ -15,37 +15,25 @@ namespace trace_api = opentelemetry::trace; class AlwaysOffSampler : public Sampler { public: + explicit AlwaysOffSampler() noexcept; + + /** + * @return Returns NOT_RECORD always + */ SamplingResult ShouldSample( std::shared_ptr parent_context, trace_api::TraceId trace_id, nostd::string_view name, trace_api::SpanKind span_kind, - nostd::span> attributes) noexcept override - { - return _result; - } - - std::string GetDescription() const noexcept override - { - return "AlwaysOffSampler"; - } + const nostd::span &attributes) noexcept override; + + /** + * @return Description MUST be AlwaysOffSampler + */ + std::string GetDescription() const noexcept override; private: - SamplingResult _result = AlwaysOffSamplingResultImpl(); -}; - -class AlwaysOffSamplingResultImpl : public SamplingResult -{ -public: - Decision GetDecision() const noexcept override - { - return NOT_RECORD; - } - - nostd::span> GetAttributes() const noexcept override - { - return nostd::span(); - } + SamplingResult sampling_result_; }; } // namespace trace } // namespace sdk diff --git a/sdk/src/trace/always_off_sampler.cc b/sdk/src/trace/always_off_sampler.cc new file mode 100644 index 0000000000..97f3f0fb94 --- /dev/null +++ b/sdk/src/trace/always_off_sampler.cc @@ -0,0 +1,44 @@ +#include "opentelemetry/sdk/trace/always_off_sampler.h" + +OPENTELEMETRY_BEGIN_NAMESPACE +namespace sdk +{ +namespace trace +{ +namespace trace_api = opentelemetry::trace; + +AlwaysOffSampler::AlwaysOffSampler() noexcept + : sampling_result_(new AlwaysOffSamplingResultImpl()) {} + +SamplingResult AlwaysOffSampler::ShouldSample( + std::shared_ptr parent_context, + trace_api::TraceId trace_id, + nostd::string_view name, + trace_api::SpanKind span_kind, + const nostd::span &attributes) noexcept override + { + return sampling_result_; + } + +std::string GetDescription() const noexcept override +{ + return "AlwaysOffSampler"; +} + +class AlwaysOffSamplingResultImpl : public SamplingResult +{ +public: + Decision GetDecision() const noexcept override + { + return decision_; + } + + nostd::span GetAttributes() const noexcept override + { + return attributes_; + } + +private: + Decision decision_ = NOT_RECORD; + nostd::span attributes_ = nostd::span(); +}; \ No newline at end of file From 65efdb49ebd04161be866ff5677970c8485a51cf Mon Sep 17 00:00:00 2001 From: Nick Holbrook Date: Mon, 22 Jun 2020 07:59:17 -0400 Subject: [PATCH 17/39] Updated Decision enum usage --- sdk/src/trace/always_off_sampler.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sdk/src/trace/always_off_sampler.cc b/sdk/src/trace/always_off_sampler.cc index 97f3f0fb94..834a375789 100644 --- a/sdk/src/trace/always_off_sampler.cc +++ b/sdk/src/trace/always_off_sampler.cc @@ -39,6 +39,6 @@ class AlwaysOffSamplingResultImpl : public SamplingResult } private: - Decision decision_ = NOT_RECORD; + Decision decision_ = Decision::NOT_RECORD; nostd::span attributes_ = nostd::span(); }; \ No newline at end of file From 099061a69fde448cac185077b6ecb3a21c5ed402 Mon Sep 17 00:00:00 2001 From: Nick Holbrook Date: Mon, 22 Jun 2020 07:59:37 -0400 Subject: [PATCH 18/39] Add AlwaysOffSampler test --- sdk/test/trace/always_off_sampler_test.cc | 34 +++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 sdk/test/trace/always_off_sampler_test.cc diff --git a/sdk/test/trace/always_off_sampler_test.cc b/sdk/test/trace/always_off_sampler_test.cc new file mode 100644 index 0000000000..fd8839203f --- /dev/null +++ b/sdk/test/trace/always_off_sampler_test.cc @@ -0,0 +1,34 @@ +#include "opentelemetry/sdk/trace/always_off_sampler.h" + +#include + +using namespace opentelemetry::sdk::trace; + +// Placeholder +class MockSpanContext +{} + +TEST(AlwaysOffSampler, MockSpanContext) +{ + Sampler sampler(new AlwaysOffSampler()); + // Placeholder + MockSpanContext context(new MockSpanContext()); + + constexpr uint8_t buf[] = {1, 2, 3, 4, 5, 6, 7, 8, 8, 7, 6, 5, 4, 3, 2, 1} + opentelemetry::trace::TraceId trace_id(buf); + + ASSERT_EQ("AlwaysOffSampler", sampler.GetDescription()); + + auto sampling_result = sampler.ShouldSample( + context, trace_id, "Test", SpanKind.kInternal, nostd::span()); + + ASSERT_NE(nullptr, sampling_result); + + auto decision = sampling_result.GetDecision(); + + ASSERT_EQ(Decision::NOT_RECORD, decision); + + auto attributes = sampling_result.GetAttributes(); + + ASSERT_EQ(nostd::span(), attributes); +} \ No newline at end of file From b913858a5591b155929cddded1333c00e3ce1321 Mon Sep 17 00:00:00 2001 From: Nick Holbrook Date: Mon, 22 Jun 2020 08:27:49 -0400 Subject: [PATCH 19/39] Move test order for improved readability --- sdk/test/trace/always_off_sampler_test.cc | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/sdk/test/trace/always_off_sampler_test.cc b/sdk/test/trace/always_off_sampler_test.cc index fd8839203f..22008f3232 100644 --- a/sdk/test/trace/always_off_sampler_test.cc +++ b/sdk/test/trace/always_off_sampler_test.cc @@ -11,14 +11,15 @@ class MockSpanContext TEST(AlwaysOffSampler, MockSpanContext) { Sampler sampler(new AlwaysOffSampler()); + + ASSERT_EQ("AlwaysOffSampler", sampler.GetDescription()); + // Placeholder MockSpanContext context(new MockSpanContext()); constexpr uint8_t buf[] = {1, 2, 3, 4, 5, 6, 7, 8, 8, 7, 6, 5, 4, 3, 2, 1} opentelemetry::trace::TraceId trace_id(buf); - ASSERT_EQ("AlwaysOffSampler", sampler.GetDescription()); - auto sampling_result = sampler.ShouldSample( context, trace_id, "Test", SpanKind.kInternal, nostd::span()); From 719be6657ac65abbd247f68c882283b129468828 Mon Sep 17 00:00:00 2001 From: Nick Holbrook Date: Mon, 22 Jun 2020 13:58:53 -0400 Subject: [PATCH 20/39] Fixed various syntax issues --- sdk/test/trace/always_off_sampler_test.cc | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/sdk/test/trace/always_off_sampler_test.cc b/sdk/test/trace/always_off_sampler_test.cc index 22008f3232..29db6277ad 100644 --- a/sdk/test/trace/always_off_sampler_test.cc +++ b/sdk/test/trace/always_off_sampler_test.cc @@ -10,20 +10,17 @@ class MockSpanContext TEST(AlwaysOffSampler, MockSpanContext) { - Sampler sampler(new AlwaysOffSampler()); + AlwaysOffSampler sampler(); ASSERT_EQ("AlwaysOffSampler", sampler.GetDescription()); // Placeholder - MockSpanContext context(new MockSpanContext()); + MockSpanContext context(); - constexpr uint8_t buf[] = {1, 2, 3, 4, 5, 6, 7, 8, 8, 7, 6, 5, 4, 3, 2, 1} - opentelemetry::trace::TraceId trace_id(buf); + opentelemetry::trace::TraceId trace_id(); auto sampling_result = sampler.ShouldSample( - context, trace_id, "Test", SpanKind.kInternal, nostd::span()); - - ASSERT_NE(nullptr, sampling_result); + context, trace_id, "Test", SpanKind::kInternal, nostd::span()); auto decision = sampling_result.GetDecision(); From d2a6a559533f0c1e917b024b674fd0460da1dbd3 Mon Sep 17 00:00:00 2001 From: Nick Holbrook Date: Tue, 23 Jun 2020 09:09:52 -0400 Subject: [PATCH 21/39] Add test to BUILD --- sdk/test/trace/BUILD | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/sdk/test/trace/BUILD b/sdk/test/trace/BUILD index 6748cde17f..f07ee5440a 100644 --- a/sdk/test/trace/BUILD +++ b/sdk/test/trace/BUILD @@ -41,3 +41,14 @@ cc_test( "@com_google_googletest//:gtest_main", ], ) + +cc_test( + name = "always_off_sampler_test", + srcs = [ + "always_off_sampler_test.cc" + ], + deps = [ + "//sdk/src/trace", + "@com_google_googletest//:gtest_main", + ] +) From 90bd031ba832e5e86ec2841d22b9ae358536d6d6 Mon Sep 17 00:00:00 2001 From: Nick Holbrook Date: Tue, 23 Jun 2020 10:52:08 -0400 Subject: [PATCH 22/39] Update AlwaysOffSampler to new sampler spec --- .../sdk/trace/always_off_sampler.h | 7 +- sdk/include/opentelemetry/sdk/trace/sampler.h | 74 +++++++++---------- sdk/src/trace/always_off_sampler.cc | 36 +++------ 3 files changed, 49 insertions(+), 68 deletions(-) diff --git a/sdk/include/opentelemetry/sdk/trace/always_off_sampler.h b/sdk/include/opentelemetry/sdk/trace/always_off_sampler.h index f6a035b740..8501878649 100644 --- a/sdk/include/opentelemetry/sdk/trace/always_off_sampler.h +++ b/sdk/include/opentelemetry/sdk/trace/always_off_sampler.h @@ -15,13 +15,11 @@ namespace trace_api = opentelemetry::trace; class AlwaysOffSampler : public Sampler { public: - explicit AlwaysOffSampler() noexcept; - /** * @return Returns NOT_RECORD always */ SamplingResult ShouldSample( - std::shared_ptr parent_context, + const SpanContext *parent_context, trace_api::TraceId trace_id, nostd::string_view name, trace_api::SpanKind span_kind, @@ -31,9 +29,6 @@ class AlwaysOffSampler : public Sampler * @return Description MUST be AlwaysOffSampler */ std::string GetDescription() const noexcept override; - -private: - SamplingResult sampling_result_; }; } // namespace trace } // namespace sdk diff --git a/sdk/include/opentelemetry/sdk/trace/sampler.h b/sdk/include/opentelemetry/sdk/trace/sampler.h index 52ee1f7824..a2f139947b 100644 --- a/sdk/include/opentelemetry/sdk/trace/sampler.h +++ b/sdk/include/opentelemetry/sdk/trace/sampler.h @@ -19,25 +19,51 @@ namespace sdk namespace trace { namespace trace_api = opentelemetry::trace; -class Sampler +/** + * NOT_RECORD - IsRecording() == false, + * span will not be recorded and all events and attributes will be dropped. + * RECORD - IsRecording() == true, but Sampled flag MUST NOT be set. + * RECORD_AND_SAMPLED - IsRecording() == true AND Sampled flag` MUST be set. + */ +enum class Decision { -private: - // Placeholder - class SpanContext - {}; + NOT_RECORD, + RECORD, + RECORD_AND_SAMPLE +}; +/** + * A placeholder for common::AttributeKeyValue + * A key/value pair that can be used to set attributes. + */ +struct AttributeKeyValue { + nostd::string_view key; + common::AttributeValue value; +}; + +struct SamplingResult +{ + Decision decision; + // TODO: Change AttributeKeyValue to common::AttributeKeyValue + std::unique_ptr> attributes; +}; + +class Sampler +{ public: + // Placeholder + class SpanContext; virtual ~Sampler() = default; /** * Called during Span creation to make a sampling decision. * - * @param parent_context TODO: a shared pointer of the SpanContext of a parent Span. + * @param parent_context TODO: a shared pointer of the SpanContext of a parent Span. * null if this is a root span. * @param trace_id the TraceId for the new Span. This will be identical to that in * the parentContext, unless this is a root span. * @param name the name of the new Span. * @param spanKind the trace_api::SpanKind of the Span. - * @param attributes TODO: current map is a placeholder. + * @param attributes TODO: Change AttributeKeyValue to common::AttributeKeyValue * list of AttributeValue with their keys. * @param links TODO: Collection of links that will be associated with the Span to be created. * @return sampling result whether span should be sampled or not. @@ -45,46 +71,20 @@ class Sampler */ virtual SamplingResult ShouldSample( - std::shared_ptr parent_context, + const SpanContext *parent_context, trace_api::TraceId trace_id, nostd::string_view name, trace_api::SpanKind span_kind, - std::map attributes) noexcept = 0; + const nostd::span &attributes) noexcept = 0; /** - * Returns the sampler name or short description with the configuration. + * Returns the sampler name or short description with the configuration. * This may be displayed on debug pages or in the logs. * * @return the description of this Sampler. */ virtual std::string GetDescription() const noexcept = 0; }; - -class SamplingResult -{ -public: - enum Decision - { - NOT_RECORD, - RECORD, - RECORD_AND_SAMPLE - }; - virtual ~SamplingResult() = default; - /** - * Return sampling decision. - * - * @return Decision. - */ - virtual Decision GetDecision() const noexcept = 0; - - /** - * Return attributes which will be attached to the span. - * - * @return the immutable list of attributes added to span. - */ - virtual nostd::span> GetAttributes() const - noexcept = 0; -}; } // namespace trace } // namespace sdk -OPENTELEMETRY_END_NAMESPACE +OPENTELEMETRY_END_NAMESPACE \ No newline at end of file diff --git a/sdk/src/trace/always_off_sampler.cc b/sdk/src/trace/always_off_sampler.cc index 834a375789..cd18f80016 100644 --- a/sdk/src/trace/always_off_sampler.cc +++ b/sdk/src/trace/always_off_sampler.cc @@ -7,38 +7,24 @@ namespace trace { namespace trace_api = opentelemetry::trace; -AlwaysOffSampler::AlwaysOffSampler() noexcept - : sampling_result_(new AlwaysOffSamplingResultImpl()) {} - SamplingResult AlwaysOffSampler::ShouldSample( - std::shared_ptr parent_context, + const SpanContext *parent_context, trace_api::TraceId trace_id, nostd::string_view name, trace_api::SpanKind span_kind, - const nostd::span &attributes) noexcept override + const nostd::span &attributes) noexcept { - return sampling_result_; + return + { + Decision::NOT_RECORD, + std::unique_ptr>(new nostd::span()) + }; } -std::string GetDescription() const noexcept override +std::string AlwaysOffSampler::GetDescription() const noexcept { return "AlwaysOffSampler"; } - -class AlwaysOffSamplingResultImpl : public SamplingResult -{ -public: - Decision GetDecision() const noexcept override - { - return decision_; - } - - nostd::span GetAttributes() const noexcept override - { - return attributes_; - } - -private: - Decision decision_ = Decision::NOT_RECORD; - nostd::span attributes_ = nostd::span(); -}; \ No newline at end of file +} // namespace trace +} // namespace sdk +OPENTELEMETRY_END_NAMESPACE \ No newline at end of file From b04a0c1b14932ceabf6d0b283b490a8dccf01a10 Mon Sep 17 00:00:00 2001 From: Nick Holbrook Date: Tue, 23 Jun 2020 10:58:34 -0400 Subject: [PATCH 23/39] Update AlwaysOffSampler tests --- sdk/test/trace/CMakeLists.txt | 2 +- sdk/test/trace/always_off_sampler_test.cc | 31 ++++++++++------------- 2 files changed, 14 insertions(+), 19 deletions(-) diff --git a/sdk/test/trace/CMakeLists.txt b/sdk/test/trace/CMakeLists.txt index 5bca38440a..e332fa633b 100644 --- a/sdk/test/trace/CMakeLists.txt +++ b/sdk/test/trace/CMakeLists.txt @@ -1,5 +1,5 @@ foreach(testname tracer_provider_test span_data_test simple_processor_test - tracer_test) + tracer_test always_on_sampler_test) add_executable(${testname} "${testname}.cc") target_link_libraries(${testname} ${GTEST_BOTH_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT} opentelemetry_trace) diff --git a/sdk/test/trace/always_off_sampler_test.cc b/sdk/test/trace/always_off_sampler_test.cc index 29db6277ad..d5235bb725 100644 --- a/sdk/test/trace/always_off_sampler_test.cc +++ b/sdk/test/trace/always_off_sampler_test.cc @@ -1,32 +1,27 @@ #include "opentelemetry/sdk/trace/always_off_sampler.h" +#include "opentelemetry/nostd/span.h" #include using namespace opentelemetry::sdk::trace; +using namespace opentelemetry::nostd; -// Placeholder -class MockSpanContext -{} - -TEST(AlwaysOffSampler, MockSpanContext) +TEST(AlwaysOffSampler, ShouldSample) { - AlwaysOffSampler sampler(); - - ASSERT_EQ("AlwaysOffSampler", sampler.GetDescription()); - - // Placeholder - MockSpanContext context(); + AlwaysOffSampler sampler; - opentelemetry::trace::TraceId trace_id(); + opentelemetry::trace::TraceId trace_id; auto sampling_result = sampler.ShouldSample( - context, trace_id, "Test", SpanKind::kInternal, nostd::span()); + nullptr, trace_id, "Test", trace_api::SpanKind::kInternal, span()); - auto decision = sampling_result.GetDecision(); + ASSERT_EQ(Decision::NOT_RECORD, sampling_result.decision); + ASSERT_EQ(0, sampling_result.attributes->size()); +} - ASSERT_EQ(Decision::NOT_RECORD, decision); - - auto attributes = sampling_result.GetAttributes(); +TEST(AlwaysOffSampler, GetDescription) +{ + AlwaysOffSampler sampler; - ASSERT_EQ(nostd::span(), attributes); + ASSERT_EQ("AlwaysOffSampler", sampler.GetDescription()); } \ No newline at end of file From 139d09d44c308d7d1fbee1240f9c9506d95c5387 Mon Sep 17 00:00:00 2001 From: Nick Holbrook Date: Tue, 23 Jun 2020 12:22:45 -0400 Subject: [PATCH 24/39] Fix typo with test name --- sdk/test/trace/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sdk/test/trace/CMakeLists.txt b/sdk/test/trace/CMakeLists.txt index e332fa633b..052b7e2a86 100644 --- a/sdk/test/trace/CMakeLists.txt +++ b/sdk/test/trace/CMakeLists.txt @@ -1,5 +1,5 @@ foreach(testname tracer_provider_test span_data_test simple_processor_test - tracer_test always_on_sampler_test) + tracer_test always_off_sampler_test) add_executable(${testname} "${testname}.cc") target_link_libraries(${testname} ${GTEST_BOTH_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT} opentelemetry_trace) From 1930b63308191edf1a7be46e20c40117367317b7 Mon Sep 17 00:00:00 2001 From: Nick Holbrook Date: Tue, 23 Jun 2020 12:50:29 -0400 Subject: [PATCH 25/39] Add AlwaysOnSampler to cmake file --- sdk/src/trace/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sdk/src/trace/CMakeLists.txt b/sdk/src/trace/CMakeLists.txt index 455665be68..81120ab80b 100644 --- a/sdk/src/trace/CMakeLists.txt +++ b/sdk/src/trace/CMakeLists.txt @@ -1 +1 @@ -add_library(opentelemetry_trace tracer_provider.cc tracer.cc span.cc) +add_library(opentelemetry_trace tracer_provider.cc tracer.cc span.cc always_off_sampler.cc) From 33564d46049113983d711d6317284afe290c3f88 Mon Sep 17 00:00:00 2001 From: Nick Holbrook Date: Tue, 23 Jun 2020 15:01:36 -0400 Subject: [PATCH 26/39] Modify AlwaysOffSampler to set attributes to nullptr --- sdk/src/trace/always_off_sampler.cc | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/sdk/src/trace/always_off_sampler.cc b/sdk/src/trace/always_off_sampler.cc index cd18f80016..0cd0e79b7d 100644 --- a/sdk/src/trace/always_off_sampler.cc +++ b/sdk/src/trace/always_off_sampler.cc @@ -14,11 +14,7 @@ SamplingResult AlwaysOffSampler::ShouldSample( trace_api::SpanKind span_kind, const nostd::span &attributes) noexcept { - return - { - Decision::NOT_RECORD, - std::unique_ptr>(new nostd::span()) - }; + return { Decision::NOT_RECORD, nullptr }; } std::string AlwaysOffSampler::GetDescription() const noexcept From 99631fe7bacbed04c40a05e9ee670fb942bc713e Mon Sep 17 00:00:00 2001 From: Nick Holbrook Date: Tue, 23 Jun 2020 15:09:13 -0400 Subject: [PATCH 27/39] Fix sampler test --- sdk/test/trace/always_off_sampler_test.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sdk/test/trace/always_off_sampler_test.cc b/sdk/test/trace/always_off_sampler_test.cc index d5235bb725..3bf20de807 100644 --- a/sdk/test/trace/always_off_sampler_test.cc +++ b/sdk/test/trace/always_off_sampler_test.cc @@ -16,7 +16,7 @@ TEST(AlwaysOffSampler, ShouldSample) nullptr, trace_id, "Test", trace_api::SpanKind::kInternal, span()); ASSERT_EQ(Decision::NOT_RECORD, sampling_result.decision); - ASSERT_EQ(0, sampling_result.attributes->size()); + ASSERT_EQ(nullptr, sampling_result.attributes); } TEST(AlwaysOffSampler, GetDescription) From 7332c4f599fd8b2a6c51c182a6ece905cdf833c7 Mon Sep 17 00:00:00 2001 From: Nick Holbrook Date: Wed, 24 Jun 2020 09:34:46 -0400 Subject: [PATCH 28/39] Update data type --- sdk/include/opentelemetry/sdk/trace/always_off_sampler.h | 2 +- sdk/include/opentelemetry/sdk/trace/sampler.h | 2 +- sdk/src/trace/always_off_sampler.cc | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/sdk/include/opentelemetry/sdk/trace/always_off_sampler.h b/sdk/include/opentelemetry/sdk/trace/always_off_sampler.h index 8501878649..c630c2926c 100644 --- a/sdk/include/opentelemetry/sdk/trace/always_off_sampler.h +++ b/sdk/include/opentelemetry/sdk/trace/always_off_sampler.h @@ -23,7 +23,7 @@ class AlwaysOffSampler : public Sampler trace_api::TraceId trace_id, nostd::string_view name, trace_api::SpanKind span_kind, - const nostd::span &attributes) noexcept override; + const trace_api::KeyValueIterable &attributes) noexcept override; /** * @return Description MUST be AlwaysOffSampler diff --git a/sdk/include/opentelemetry/sdk/trace/sampler.h b/sdk/include/opentelemetry/sdk/trace/sampler.h index a2f139947b..2912ed4f78 100644 --- a/sdk/include/opentelemetry/sdk/trace/sampler.h +++ b/sdk/include/opentelemetry/sdk/trace/sampler.h @@ -75,7 +75,7 @@ class Sampler trace_api::TraceId trace_id, nostd::string_view name, trace_api::SpanKind span_kind, - const nostd::span &attributes) noexcept = 0; + const trace_api::KeyValueIterable &attributes) noexcept = 0; /** * Returns the sampler name or short description with the configuration. diff --git a/sdk/src/trace/always_off_sampler.cc b/sdk/src/trace/always_off_sampler.cc index 0cd0e79b7d..fe9552f2fb 100644 --- a/sdk/src/trace/always_off_sampler.cc +++ b/sdk/src/trace/always_off_sampler.cc @@ -12,7 +12,7 @@ SamplingResult AlwaysOffSampler::ShouldSample( trace_api::TraceId trace_id, nostd::string_view name, trace_api::SpanKind span_kind, - const nostd::span &attributes) noexcept + const trace_api::KeyValueIterable &attributes) noexcept { return { Decision::NOT_RECORD, nullptr }; } From 69050ed4c339743059ae81d9e7c480822d10ac34 Mon Sep 17 00:00:00 2001 From: Nick Holbrook Date: Wed, 24 Jun 2020 09:35:08 -0400 Subject: [PATCH 29/39] Update AlwaysOffSampler unit test --- sdk/test/trace/always_off_sampler_test.cc | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/sdk/test/trace/always_off_sampler_test.cc b/sdk/test/trace/always_off_sampler_test.cc index 3bf20de807..5df78b6b33 100644 --- a/sdk/test/trace/always_off_sampler_test.cc +++ b/sdk/test/trace/always_off_sampler_test.cc @@ -1,19 +1,19 @@ #include "opentelemetry/sdk/trace/always_off_sampler.h" -#include "opentelemetry/nostd/span.h" #include -using namespace opentelemetry::sdk::trace; -using namespace opentelemetry::nostd; +using opentelemetry::sdk::trace::AlwaysOffSampler; +using opentelemetry::sdk::trace::Decision; TEST(AlwaysOffSampler, ShouldSample) { AlwaysOffSampler sampler; opentelemetry::trace::TraceId trace_id; + opentelemetry::trace::KeyValueIterableView> view; + opentelemetry::trace::SpanKind span_kind = opentelemetry::trace::SpanKind::kInternal; - auto sampling_result = sampler.ShouldSample( - nullptr, trace_id, "Test", trace_api::SpanKind::kInternal, span()); + auto sampling_result = sampler.ShouldSample(nullptr, trace_id, "Test", span_kind, view); ASSERT_EQ(Decision::NOT_RECORD, sampling_result.decision); ASSERT_EQ(nullptr, sampling_result.attributes); From e6295f98e940a7953e390ad0a52b55154ee874a1 Mon Sep 17 00:00:00 2001 From: Nick Holbrook Date: Wed, 24 Jun 2020 09:55:51 -0400 Subject: [PATCH 30/39] Fix AlwaysOffSampler unit test --- sdk/test/trace/always_off_sampler_test.cc | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/sdk/test/trace/always_off_sampler_test.cc b/sdk/test/trace/always_off_sampler_test.cc index 5df78b6b33..9da845758d 100644 --- a/sdk/test/trace/always_off_sampler_test.cc +++ b/sdk/test/trace/always_off_sampler_test.cc @@ -10,10 +10,13 @@ TEST(AlwaysOffSampler, ShouldSample) AlwaysOffSampler sampler; opentelemetry::trace::TraceId trace_id; - opentelemetry::trace::KeyValueIterableView> view; opentelemetry::trace::SpanKind span_kind = opentelemetry::trace::SpanKind::kInternal; - auto sampling_result = sampler.ShouldSample(nullptr, trace_id, "Test", span_kind, view); + using M = std::map; + M m1 = {{}}; + opentelemetry::trace::KeyValueIterableView view{m1}; + + auto sampling_result = sampler.ShouldSample(nullptr, trace_id, "", span_kind, view); ASSERT_EQ(Decision::NOT_RECORD, sampling_result.decision); ASSERT_EQ(nullptr, sampling_result.attributes); From fc12f51edf98e489984d54d8c548cbd1c6595b31 Mon Sep 17 00:00:00 2001 From: Nick Holbrook Date: Wed, 24 Jun 2020 10:26:31 -0400 Subject: [PATCH 31/39] Move AlwaysOffSampler implementation to header file --- .../sdk/trace/always_off_sampler.h | 10 +++++-- sdk/src/trace/always_off_sampler.cc | 26 ------------------- 2 files changed, 8 insertions(+), 28 deletions(-) delete mode 100644 sdk/src/trace/always_off_sampler.cc diff --git a/sdk/include/opentelemetry/sdk/trace/always_off_sampler.h b/sdk/include/opentelemetry/sdk/trace/always_off_sampler.h index c630c2926c..a376b573dd 100644 --- a/sdk/include/opentelemetry/sdk/trace/always_off_sampler.h +++ b/sdk/include/opentelemetry/sdk/trace/always_off_sampler.h @@ -23,12 +23,18 @@ class AlwaysOffSampler : public Sampler trace_api::TraceId trace_id, nostd::string_view name, trace_api::SpanKind span_kind, - const trace_api::KeyValueIterable &attributes) noexcept override; + const trace_api::KeyValueIterable &attributes) noexcept override + { + return { Decision::NOT_RECORD, nullptr }; + } /** * @return Description MUST be AlwaysOffSampler */ - std::string GetDescription() const noexcept override; + std::string GetDescription() const noexcept override + { + return "AlwaysOffSampler"; + } }; } // namespace trace } // namespace sdk diff --git a/sdk/src/trace/always_off_sampler.cc b/sdk/src/trace/always_off_sampler.cc deleted file mode 100644 index fe9552f2fb..0000000000 --- a/sdk/src/trace/always_off_sampler.cc +++ /dev/null @@ -1,26 +0,0 @@ -#include "opentelemetry/sdk/trace/always_off_sampler.h" - -OPENTELEMETRY_BEGIN_NAMESPACE -namespace sdk -{ -namespace trace -{ -namespace trace_api = opentelemetry::trace; - -SamplingResult AlwaysOffSampler::ShouldSample( - const SpanContext *parent_context, - trace_api::TraceId trace_id, - nostd::string_view name, - trace_api::SpanKind span_kind, - const trace_api::KeyValueIterable &attributes) noexcept - { - return { Decision::NOT_RECORD, nullptr }; - } - -std::string AlwaysOffSampler::GetDescription() const noexcept -{ - return "AlwaysOffSampler"; -} -} // namespace trace -} // namespace sdk -OPENTELEMETRY_END_NAMESPACE \ No newline at end of file From 7b100cb2d15545dde735fd90436fdabe50d3cc4d Mon Sep 17 00:00:00 2001 From: Nick Holbrook Date: Wed, 24 Jun 2020 10:38:26 -0400 Subject: [PATCH 32/39] Remove file reference from cmake file --- sdk/src/trace/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sdk/src/trace/CMakeLists.txt b/sdk/src/trace/CMakeLists.txt index 81120ab80b..455665be68 100644 --- a/sdk/src/trace/CMakeLists.txt +++ b/sdk/src/trace/CMakeLists.txt @@ -1 +1 @@ -add_library(opentelemetry_trace tracer_provider.cc tracer.cc span.cc always_off_sampler.cc) +add_library(opentelemetry_trace tracer_provider.cc tracer.cc span.cc) From 298b5b2daf4395033281b379cb8e264c175c6665 Mon Sep 17 00:00:00 2001 From: Nick Holbrook Date: Thu, 25 Jun 2020 12:30:03 -0400 Subject: [PATCH 33/39] Update bazel version to 3.3.0 --- .bazelversion | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.bazelversion b/.bazelversion index 944880fa15..15a2799817 100644 --- a/.bazelversion +++ b/.bazelversion @@ -1 +1 @@ -3.2.0 +3.3.0 From 6cf3542419cbf847e0ff349f085e57e7fda811a8 Mon Sep 17 00:00:00 2001 From: Nick Holbrook Date: Fri, 26 Jun 2020 08:50:54 -0400 Subject: [PATCH 34/39] Add newline at end of files --- sdk/include/opentelemetry/sdk/trace/always_off_sampler.h | 2 +- sdk/include/opentelemetry/sdk/trace/sampler.h | 2 +- sdk/test/trace/always_off_sampler_test.cc | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/sdk/include/opentelemetry/sdk/trace/always_off_sampler.h b/sdk/include/opentelemetry/sdk/trace/always_off_sampler.h index a376b573dd..d9d63d91d7 100644 --- a/sdk/include/opentelemetry/sdk/trace/always_off_sampler.h +++ b/sdk/include/opentelemetry/sdk/trace/always_off_sampler.h @@ -38,4 +38,4 @@ class AlwaysOffSampler : public Sampler }; } // namespace trace } // namespace sdk -OPENTELEMETRY_END_NAMESPACE \ No newline at end of file +OPENTELEMETRY_END_NAMESPACE diff --git a/sdk/include/opentelemetry/sdk/trace/sampler.h b/sdk/include/opentelemetry/sdk/trace/sampler.h index 2912ed4f78..179c84b1b0 100644 --- a/sdk/include/opentelemetry/sdk/trace/sampler.h +++ b/sdk/include/opentelemetry/sdk/trace/sampler.h @@ -87,4 +87,4 @@ class Sampler }; } // namespace trace } // namespace sdk -OPENTELEMETRY_END_NAMESPACE \ No newline at end of file +OPENTELEMETRY_END_NAMESPACE diff --git a/sdk/test/trace/always_off_sampler_test.cc b/sdk/test/trace/always_off_sampler_test.cc index 9da845758d..dffd419deb 100644 --- a/sdk/test/trace/always_off_sampler_test.cc +++ b/sdk/test/trace/always_off_sampler_test.cc @@ -27,4 +27,4 @@ TEST(AlwaysOffSampler, GetDescription) AlwaysOffSampler sampler; ASSERT_EQ("AlwaysOffSampler", sampler.GetDescription()); -} \ No newline at end of file +} From 61c95a99c18b5506885ebad89bd9d02f1a4917db Mon Sep 17 00:00:00 2001 From: Nick Holbrook Date: Fri, 26 Jun 2020 11:11:00 -0400 Subject: [PATCH 35/39] Reformat to unname unused parameters --- .../opentelemetry/sdk/trace/always_off_sampler.h | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/sdk/include/opentelemetry/sdk/trace/always_off_sampler.h b/sdk/include/opentelemetry/sdk/trace/always_off_sampler.h index d9d63d91d7..0547068280 100644 --- a/sdk/include/opentelemetry/sdk/trace/always_off_sampler.h +++ b/sdk/include/opentelemetry/sdk/trace/always_off_sampler.h @@ -19,11 +19,11 @@ class AlwaysOffSampler : public Sampler * @return Returns NOT_RECORD always */ SamplingResult ShouldSample( - const SpanContext *parent_context, - trace_api::TraceId trace_id, - nostd::string_view name, - trace_api::SpanKind span_kind, - const trace_api::KeyValueIterable &attributes) noexcept override + const SpanContext * /*parent_context*/, + trace_api::TraceId /*trace_id*/, + nostd::string_view /*name*/, + trace_api::SpanKind /*span_kind*/, + const trace_api::KeyValueIterable & /*attributes*/) noexcept override { return { Decision::NOT_RECORD, nullptr }; } From 788e3261ff488078c418b26d72f45bed7a2f3ee7 Mon Sep 17 00:00:00 2001 From: Nick Holbrook Date: Fri, 26 Jun 2020 15:18:00 -0400 Subject: [PATCH 36/39] Revert sampler changes --- sdk/include/opentelemetry/sdk/trace/sampler.h | 36 +++++++++---------- 1 file changed, 16 insertions(+), 20 deletions(-) diff --git a/sdk/include/opentelemetry/sdk/trace/sampler.h b/sdk/include/opentelemetry/sdk/trace/sampler.h index e0837f5662..f048a36a90 100644 --- a/sdk/include/opentelemetry/sdk/trace/sampler.h +++ b/sdk/include/opentelemetry/sdk/trace/sampler.h @@ -1,12 +1,8 @@ #pragma once #include "opentelemetry/common/attribute_value.h" -#include "opentelemetry/nostd/span.h" -#include "opentelemetry/nostd/string_view.h" -#include "opentelemetry/sdk/common/atomic_shared_ptr.h" #include "opentelemetry/trace/span.h" #include "opentelemetry/trace/trace_id.h" -#include "opentelemetry/trace/tracer.h" #include "opentelemetry/version.h" #include @@ -19,28 +15,25 @@ namespace sdk namespace trace { namespace trace_api = opentelemetry::trace; + /** - * NOT_RECORD - IsRecording() == false, - * span will not be recorded and all events and attributes will be dropped. - * RECORD - IsRecording() == true, but Sampled flag MUST NOT be set. - * RECORD_AND_SAMPLED - IsRecording() == true AND Sampled flag` MUST be set. + * A sampling Decision for a Span to be created. */ enum class Decision { + // IsRecording() == false, span will not be recorded and all events and attributes will be + // dropped. NOT_RECORD, + // IsRecording() == true, but Sampled flag MUST NOT be set. RECORD, + // IsRecording() == true AND Sampled flag` MUST be set. RECORD_AND_SAMPLE }; /** - * A placeholder for common::AttributeKeyValue - * A key/value pair that can be used to set attributes. + * The output of ShouldSample. + * It contains a sampling Decision and a set of Span Attributes. */ -struct AttributeKeyValue { - nostd::string_view key; - common::AttributeValue value; -}; - struct SamplingResult { Decision decision; @@ -48,23 +41,26 @@ struct SamplingResult std::unique_ptr> attributes; }; +/** + * The Sampler interface allows users to create custom samplers which will return a + * SamplingResult based on information that is typically available just before the Span was created. + */ class Sampler { public: - // Placeholder + // TODO: Remove this placeholder with real class class SpanContext; virtual ~Sampler() = default; /** * Called during Span creation to make a sampling decision. * - * @param parent_context TODO: a shared pointer of the SpanContext of a parent Span. + * @param parent_context a const pointer of the SpanContext of a parent Span. * null if this is a root span. * @param trace_id the TraceId for the new Span. This will be identical to that in * the parentContext, unless this is a root span. * @param name the name of the new Span. * @param spanKind the trace_api::SpanKind of the Span. - * @param attributes TODO: Change AttributeKeyValue to common::AttributeKeyValue - * list of AttributeValue with their keys. + * @param attributes list of AttributeValue with their keys. * @param links TODO: Collection of links that will be associated with the Span to be created. * @return sampling result whether span should be sampled or not. * @since 0.1.0 @@ -86,4 +82,4 @@ class Sampler }; } // namespace trace } // namespace sdk -OPENTELEMETRY_END_NAMESPACE +OPENTELEMETRY_END_NAMESPACE \ No newline at end of file From 13e522bbd430a46c17f2037036166ca90d25bd95 Mon Sep 17 00:00:00 2001 From: Nick Holbrook Date: Fri, 26 Jun 2020 15:22:54 -0400 Subject: [PATCH 37/39] Add newline at end of file --- sdk/include/opentelemetry/sdk/trace/sampler.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sdk/include/opentelemetry/sdk/trace/sampler.h b/sdk/include/opentelemetry/sdk/trace/sampler.h index f048a36a90..93599b18e7 100644 --- a/sdk/include/opentelemetry/sdk/trace/sampler.h +++ b/sdk/include/opentelemetry/sdk/trace/sampler.h @@ -82,4 +82,4 @@ class Sampler }; } // namespace trace } // namespace sdk -OPENTELEMETRY_END_NAMESPACE \ No newline at end of file +OPENTELEMETRY_END_NAMESPACE From e822c2b05a464a76eef6329f2b00ade1f85c408c Mon Sep 17 00:00:00 2001 From: Nick Holbrook Date: Fri, 26 Jun 2020 15:32:01 -0400 Subject: [PATCH 38/39] Move AlwaysOffSampler --- .../sdk/trace/{always_off_sampler.h => samplers/always_off.h} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename sdk/include/opentelemetry/sdk/trace/{always_off_sampler.h => samplers/always_off.h} (100%) diff --git a/sdk/include/opentelemetry/sdk/trace/always_off_sampler.h b/sdk/include/opentelemetry/sdk/trace/samplers/always_off.h similarity index 100% rename from sdk/include/opentelemetry/sdk/trace/always_off_sampler.h rename to sdk/include/opentelemetry/sdk/trace/samplers/always_off.h From a3f1cabc297a47c0656a38437008d46f839bcf88 Mon Sep 17 00:00:00 2001 From: Nick Holbrook Date: Fri, 26 Jun 2020 15:41:58 -0400 Subject: [PATCH 39/39] Update sampler import --- sdk/test/trace/always_off_sampler_test.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sdk/test/trace/always_off_sampler_test.cc b/sdk/test/trace/always_off_sampler_test.cc index dffd419deb..2c892fcfa7 100644 --- a/sdk/test/trace/always_off_sampler_test.cc +++ b/sdk/test/trace/always_off_sampler_test.cc @@ -1,4 +1,4 @@ -#include "opentelemetry/sdk/trace/always_off_sampler.h" +#include "opentelemetry/sdk/trace/samplers/always_off.h" #include