-
Notifications
You must be signed in to change notification settings - Fork 417
/
span.h
63 lines (48 loc) · 1.98 KB
/
span.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#pragma once
#include <mutex>
#include "opentelemetry/sdk/trace/tracer.h"
#include "opentelemetry/version.h"
OPENTELEMETRY_BEGIN_NAMESPACE
namespace sdk
{
namespace trace
{
namespace trace_api = opentelemetry::trace;
class Span final : public trace_api::Span
{
public:
Span(std::shared_ptr<Tracer> &&tracer,
nostd::string_view name,
const opentelemetry::common::KeyValueIterable &attributes,
const trace_api::SpanContextKeyValueIterable &links,
const trace_api::StartSpanOptions &options,
const trace_api::SpanContext &parent_span_context,
const nostd::shared_ptr<opentelemetry::trace::TraceState> trace_state =
trace_api::TraceState::GetDefault(),
const bool sampled = false) noexcept;
~Span() override;
// trace_api::Span
void SetAttribute(nostd::string_view key,
const opentelemetry::common::AttributeValue &value) noexcept override;
void AddEvent(nostd::string_view name) noexcept override;
void AddEvent(nostd::string_view name,
opentelemetry::common::SystemTimestamp timestamp) noexcept override;
void AddEvent(nostd::string_view name,
opentelemetry::common::SystemTimestamp timestamp,
const opentelemetry::common::KeyValueIterable &attributes) noexcept override;
void SetStatus(trace_api::StatusCode code, nostd::string_view description) noexcept override;
void UpdateName(nostd::string_view name) noexcept override;
void End(const trace_api::EndSpanOptions &options = {}) noexcept override;
bool IsRecording() const noexcept override;
trace_api::SpanContext GetContext() const noexcept override { return *span_context_.get(); }
private:
std::shared_ptr<Tracer> tracer_;
mutable std::mutex mu_;
std::unique_ptr<Recordable> recordable_;
opentelemetry::common::SteadyTimestamp start_steady_time;
std::unique_ptr<trace_api::SpanContext> span_context_;
bool has_ended_;
};
} // namespace trace
} // namespace sdk
OPENTELEMETRY_END_NAMESPACE