]> git.proxmox.com Git - ceph.git/blame - ceph/src/jaegertracing/opentelemetry-cpp/examples/plugin/plugin/tracer.cc
update ceph source to reef 18.1.2
[ceph.git] / ceph / src / jaegertracing / opentelemetry-cpp / examples / plugin / plugin / tracer.cc
CommitLineData
1e59de90
TL
1// Copyright The OpenTelemetry Authors
2// SPDX-License-Identifier: Apache-2.0
3
4#include "tracer.h"
5#include "opentelemetry/nostd/unique_ptr.h"
6
7#include <iostream>
8#include <memory>
9
10namespace nostd = opentelemetry::nostd;
11namespace common = opentelemetry::common;
12namespace trace = opentelemetry::trace;
13namespace context = opentelemetry::context;
14
15namespace
16{
17class Span final : public trace::Span
18{
19public:
20 Span(std::shared_ptr<Tracer> &&tracer,
21 nostd::string_view name,
22 const common::KeyValueIterable & /*attributes*/,
23 const trace::SpanContextKeyValueIterable & /*links*/,
24 const trace::StartSpanOptions & /*options*/) noexcept
25 : tracer_{std::move(tracer)}, name_{name}, span_context_{trace::SpanContext::GetInvalid()}
26 {
27 std::cout << "StartSpan: " << name << "\n";
28 }
29
30 ~Span() { std::cout << "~Span\n"; }
31
32 // opentelemetry::trace::Span
33 void SetAttribute(nostd::string_view /*name*/,
34 const common::AttributeValue & /*value*/) noexcept override
35 {}
36
37 void AddEvent(nostd::string_view /*name*/) noexcept override {}
38
39 void AddEvent(nostd::string_view /*name*/,
40 common::SystemTimestamp /*timestamp*/) noexcept override
41 {}
42
43 void AddEvent(nostd::string_view /*name*/,
44 common::SystemTimestamp /*timestamp*/,
45 const common::KeyValueIterable & /*attributes*/) noexcept override
46 {}
47
48 void SetStatus(trace::StatusCode /*code*/, nostd::string_view /*description*/) noexcept override
49 {}
50
51 void UpdateName(nostd::string_view /*name*/) noexcept override {}
52
53 void End(const trace::EndSpanOptions & /*options*/) noexcept override {}
54
55 bool IsRecording() const noexcept override { return true; }
56
57 trace::SpanContext GetContext() const noexcept override { return span_context_; }
58
59private:
60 std::shared_ptr<Tracer> tracer_;
61 std::string name_;
62 trace::SpanContext span_context_;
63};
64} // namespace
65
66Tracer::Tracer(nostd::string_view /*output*/) {}
67
68nostd::shared_ptr<trace::Span> Tracer::StartSpan(nostd::string_view name,
69 const common::KeyValueIterable &attributes,
70 const trace::SpanContextKeyValueIterable &links,
71 const trace::StartSpanOptions &options) noexcept
72{
73 return nostd::shared_ptr<trace::Span>{
74 new (std::nothrow) Span{this->shared_from_this(), name, attributes, links, options}};
75}