Skip to content

Commit

Permalink
add param and comments
Browse files Browse the repository at this point in the history
  • Loading branch information
Oliver Zhang committed Jun 17, 2020
1 parent bc14502 commit f705b35
Showing 1 changed file with 33 additions and 11 deletions.
44 changes: 33 additions & 11 deletions sdk/include/opentelemetry/sdk/trace/sampler.h
Original file line number Diff line number Diff line change
@@ -1,26 +1,45 @@
#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 <memory>
#include <map>
#include <memory>
#include <string>

OPENTELEMETRY_BEGIN_NAMESPACE
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<std::string, common::AttributeValue> attributes) noexcept = 0;

/**
* Returns the description of this {@code Sampler}. This may be displayed on debug pages or in the
Expand All @@ -36,6 +55,7 @@ class Sampler
class Decision
{
public:
virtual ~Decision() = default;
/**
* Return sampling decision whether span should be sampled or not.
*
Expand All @@ -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<std::string, common::AttributeValue> getAttributes();
};

class
} // namespace trace
} // namespace sdk
OPENTELEMETRY_END_NAMESPACE

0 comments on commit f705b35

Please sign in to comment.