]> git.proxmox.com Git - ceph.git/blob - ceph/src/jaegertracing/opentelemetry-cpp/api/include/opentelemetry/trace/default_span.h
update ceph source to reef 18.1.2
[ceph.git] / ceph / src / jaegertracing / opentelemetry-cpp / api / include / opentelemetry / trace / default_span.h
1 // Copyright The OpenTelemetry Authors
2 // SPDX-License-Identifier: Apache-2.0
3
4 #pragma once
5 #include "opentelemetry/common/attribute_value.h"
6 #include "opentelemetry/trace/canonical_code.h"
7 #include "opentelemetry/trace/span.h"
8 #include "opentelemetry/trace/span_context.h"
9
10 OPENTELEMETRY_BEGIN_NAMESPACE
11 namespace trace
12 {
13
14 /**
15 * DefaultSpan provides a non-operational Span that propagates
16 * the tracer context by wrapping it inside the Span object.
17 */
18
19 class DefaultSpan : public Span
20 {
21 public:
22 // Returns an invalid span.
23 static DefaultSpan GetInvalid() { return DefaultSpan(SpanContext::GetInvalid()); }
24
25 trace::SpanContext GetContext() const noexcept { return span_context_; }
26
27 bool IsRecording() const noexcept { return false; }
28
29 void SetAttribute(nostd::string_view /* key */,
30 const common::AttributeValue & /* value */) noexcept
31 {}
32
33 void AddEvent(nostd::string_view /* name */) noexcept {}
34
35 void AddEvent(nostd::string_view /* name */, common::SystemTimestamp /* timestamp */) noexcept {}
36
37 void AddEvent(nostd::string_view /* name */,
38 common::SystemTimestamp /* timestamp */,
39 const common::KeyValueIterable & /* attributes */) noexcept
40 {}
41
42 void AddEvent(nostd::string_view name, const common::KeyValueIterable &attributes) noexcept
43 {
44 this->AddEvent(name, std::chrono::system_clock::now(), attributes);
45 }
46
47 void SetStatus(StatusCode /* status */, nostd::string_view /* description */) noexcept {}
48
49 void UpdateName(nostd::string_view /* name */) noexcept {}
50
51 void End(const EndSpanOptions & /* options */ = {}) noexcept {}
52
53 nostd::string_view ToString() const noexcept { return "DefaultSpan"; }
54
55 DefaultSpan(SpanContext span_context) noexcept : span_context_(span_context) {}
56
57 // movable and copiable
58 DefaultSpan(DefaultSpan &&spn) noexcept : span_context_(spn.GetContext()) {}
59 DefaultSpan(const DefaultSpan &spn) noexcept : span_context_(spn.GetContext()) {}
60
61 private:
62 SpanContext span_context_;
63 };
64
65 } // namespace trace
66 OPENTELEMETRY_END_NAMESPACE