]> git.proxmox.com Git - ceph.git/blob - ceph/src/jaegertracing/opentelemetry-cpp/api/include/opentelemetry/trace/span_context_kv_iterable.h
2cbff8d65a575e0fd79c89acd990b94ac3a2336f
[ceph.git] / ceph / src / jaegertracing / opentelemetry-cpp / api / include / opentelemetry / trace / span_context_kv_iterable.h
1 // Copyright The OpenTelemetry Authors
2 // SPDX-License-Identifier: Apache-2.0
3
4 #pragma once
5
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"
10
11 OPENTELEMETRY_BEGIN_NAMESPACE
12 namespace trace
13 {
14 /**
15 * Supports internal iteration over a collection of SpanContext/key-value pairs.
16 */
17 class SpanContextKeyValueIterable
18 {
19 public:
20 virtual ~SpanContextKeyValueIterable() = default;
21
22 /**
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
27 */
28 virtual bool ForEachKeyValue(
29 nostd::function_ref<bool(SpanContext, const opentelemetry::common::KeyValueIterable &)>
30 callback) const noexcept = 0;
31 /**
32 * @return the number of key-value pairs
33 */
34 virtual size_t size() const noexcept = 0;
35 };
36
37 /**
38 * @brief Null Span context that does not carry any information.
39 */
40 class NullSpanContext : public SpanContextKeyValueIterable
41 {
42 public:
43 bool ForEachKeyValue(
44 nostd::function_ref<bool(SpanContext, const opentelemetry::common::KeyValueIterable &)>
45 /* callback */) const noexcept override
46 {
47 return true;
48 }
49
50 size_t size() const noexcept override { return 0; };
51 };
52
53 } // namespace trace
54 OPENTELEMETRY_END_NAMESPACE