Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion sdk/include/opentelemetry/sdk/trace/sampler.h
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ class Sampler
*
* @return the description of this Sampler.
*/
virtual std::string GetDescription() const noexcept = 0;
virtual nostd::string_view GetDescription() const noexcept = 0;
};
} // namespace trace
} // namespace sdk
Expand Down
20 changes: 8 additions & 12 deletions sdk/include/opentelemetry/sdk/trace/samplers/always_off.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,23 +19,19 @@ class AlwaysOffSampler : public Sampler
/**
* @return Returns NOT_RECORD always
*/
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 override
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 override
{
return { Decision::NOT_RECORD, nullptr };
return {Decision::NOT_RECORD, nullptr};
}

/**
* @return Description MUST be AlwaysOffSampler
*/
std::string GetDescription() const noexcept override
{
return "AlwaysOffSampler";
}
nostd::string_view GetDescription() const noexcept override { return "AlwaysOffSampler"; }
};
} // namespace trace
} // namespace sdk
Expand Down
2 changes: 1 addition & 1 deletion sdk/include/opentelemetry/sdk/trace/samplers/always_on.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class AlwaysOnSampler : public Sampler
/**
* @return Description MUST be AlwaysOnSampler
*/
inline std::string GetDescription() const noexcept override { return "AlwaysOnSampler"; }
inline nostd::string_view GetDescription() const noexcept override { return "AlwaysOnSampler"; }
};
} // namespace trace
} // namespace sdk
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class ParentOrElseSampler : public Sampler
/**
* @return Description MUST be ParentOrElse{delegate_sampler_.getDescription()}
*/
std::string GetDescription() const noexcept override;
nostd::string_view GetDescription() const noexcept override;

private:
const std::shared_ptr<Sampler> delegate_sampler_;
Expand Down
4 changes: 2 additions & 2 deletions sdk/include/opentelemetry/sdk/trace/samplers/probability.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,10 @@ class ProbabilitySampler : public Sampler
/**
* @return Description MUST be ProbabilitySampler{0.000100}
*/
std::string GetDescription() const noexcept override;
nostd::string_view GetDescription() const noexcept override;

private:
std::string sampler_description_;
std::string description_;
const uint64_t threshold_;
};
} // namespace trace
Expand Down
4 changes: 2 additions & 2 deletions sdk/src/trace/samplers/parent_or_else.cc
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ namespace trace
{
ParentOrElseSampler::ParentOrElseSampler(std::shared_ptr<Sampler> delegate_sampler) noexcept
: delegate_sampler_(delegate_sampler),
description_("ParentOrElse{" + delegate_sampler->GetDescription() + "}")
description_("ParentOrElse{" + std::string{delegate_sampler->GetDescription()} + "}")
{}

SamplingResult ParentOrElseSampler::ShouldSample(
Expand All @@ -32,7 +32,7 @@ SamplingResult ParentOrElseSampler::ShouldSample(
return {Decision::NOT_RECORD, nullptr};
}

std::string ParentOrElseSampler::GetDescription() const noexcept
nostd::string_view ParentOrElseSampler::GetDescription() const noexcept
{
return description_;
}
Expand Down
6 changes: 3 additions & 3 deletions sdk/src/trace/samplers/probability.cc
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ ProbabilitySampler::ProbabilitySampler(double probability)
{
if (probability > 1.0) probability = 1.0;
if (probability < 0.0) probability = 0.0;
sampler_description_ = "ProbabilitySampler{" + std::to_string(probability) + "}";
description_ = "ProbabilitySampler{" + std::to_string(probability) + "}";
}

SamplingResult ProbabilitySampler::ShouldSample(
Expand Down Expand Up @@ -105,9 +105,9 @@ SamplingResult ProbabilitySampler::ShouldSample(
return { Decision::NOT_RECORD, nullptr };
}

std::string ProbabilitySampler::GetDescription() const noexcept
nostd::string_view ProbabilitySampler::GetDescription() const noexcept
{
return sampler_description_;
return description_;
}
} // namespace trace
} // namespace sdk
Expand Down
2 changes: 1 addition & 1 deletion sdk/test/trace/tracer_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class MockSampler final : public Sampler
{{"sampling_attr1", 123}, {"sampling_attr2", "string"}}))};
}

std::string GetDescription() const noexcept override { return "MockSampler"; }
nostd::string_view GetDescription() const noexcept override { return "MockSampler"; }
};

/**
Expand Down