Skip to content

Commit

Permalink
add sampler header file
Browse files Browse the repository at this point in the history
  • Loading branch information
Oliver Zhang committed Jun 17, 2020
1 parent 49eee20 commit bc14502
Showing 1 changed file with 56 additions and 0 deletions.
56 changes: 56 additions & 0 deletions sdk/include/opentelemetry/sdk/trace/sampler.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
#pragma once

#include "opentelemetry/version.h"
#include "opentelemetry/common/attribute_value.h"

#include <memory>
#include <map>
#include <string>

OPENTELEMETRY_BEGIN_NAMESPACE
namespace sdk
{
namespace trace
{
class Sampler
{
public:
/**
* Initialize a new tracer.
* @param processor The span processor for this tracer. This must not be a
* nullptr.
*/
virtual Decision shouldSample();

/**
* Returns the description of this {@code Sampler}. This may be displayed on debug pages or in the
* logs.
*
* <p>Example: "ProbabilitySampler{0.000100}"
*
* @return the description of this {@code Sampler}.
*/
virtual std::string getDescription();
};

class Decision
{
public:
/**
* Return sampling decision whether span should be sampled or not.
*
* @return sampling 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.
*/
virtual std::map<std::string, common::AttributeValue> getAttributes();
};
} // namespace trace
} // namespace sdk
OPENTELEMETRY_END_NAMESPACE

0 comments on commit bc14502

Please sign in to comment.