1 // Copyright The OpenTelemetry Authors
2 // SPDX-License-Identifier: Apache-2.0
6 #include "opentelemetry/common/attribute_value.h"
7 #include "opentelemetry/common/key_value_iterable_view.h"
8 #include "opentelemetry/nostd/function_ref.h"
9 #include "opentelemetry/version.h"
11 OPENTELEMETRY_BEGIN_NAMESPACE
15 * Supports internal iteration over a collection of SpanContext/key-value pairs.
17 class SpanContextKeyValueIterable
20 virtual ~SpanContextKeyValueIterable() = default;
23 * Iterate over SpanContext/key-value pairs
24 * @param callback a callback to invoke for each key-value for each SpanContext.
25 * If the callback returns false, the iteration is aborted.
26 * @return true if every SpanContext/key-value pair was iterated over
28 virtual bool ForEachKeyValue(
29 nostd::function_ref
<bool(SpanContext
, const opentelemetry::common::KeyValueIterable
&)>
30 callback
) const noexcept
= 0;
32 * @return the number of key-value pairs
34 virtual size_t size() const noexcept
= 0;
38 * @brief Null Span context that does not carry any information.
40 class NullSpanContext
: public SpanContextKeyValueIterable
44 nostd::function_ref
<bool(SpanContext
, const opentelemetry::common::KeyValueIterable
&)>
45 /* callback */) const noexcept override
50 size_t size() const noexcept override
{ return 0; };
54 OPENTELEMETRY_END_NAMESPACE