AWS SDK for C++

AWS SDK for C++ Version 1.11.440

Loading...
Searching...
No Matches
TraceAdapters.h
1
5#pragma once
6
7#include <smithy/Smithy_EXPORTS.h>
8#include <smithy/tracing/Tracer.h>
9#include <opentelemetry/nostd/shared_ptr.h>
10#include <opentelemetry/trace/tracer.h>
11#include <opentelemetry/trace/span_metadata.h>
12#include <opentelemetry/trace/scope.h>
13#include <memory>
14#include <utility>
15
16namespace smithy {
17 namespace components {
18 namespace tracing {
22 class OtelSpanAdapter final : public TraceSpan {
23 public:
25 opentelemetry::nostd::shared_ptr<opentelemetry::trace::Span> span,
26 opentelemetry::trace::Scope scope) :
27 TraceSpan(std::move(name)), otelSpan(std::move(span)), otelScope(std::move(scope)) {}
28
29 ~OtelSpanAdapter() override;
30
31 void emitEvent(Aws::String name, const Aws::Map<Aws::String, Aws::String> &attributes) override;
32
33 void setAttribute(Aws::String key, Aws::String value) override;
34
35 void setStatus(TraceSpanStatus status) override;
36
37 void end() override;
38
39 private:
40 opentelemetry::trace::StatusCode convertStatusCode(TraceSpanStatus status);
41
42 opentelemetry::nostd::shared_ptr<opentelemetry::trace::Span> otelSpan;
43 opentelemetry::trace::Scope otelScope;
44 };
45
49 class OtelTracerAdapter final : public Tracer {
50 public:
51 explicit OtelTracerAdapter(opentelemetry::nostd::shared_ptr<opentelemetry::trace::Tracer> tracer) :
52 otelTracer(std::move(tracer)) {}
53
54 std::shared_ptr<TraceSpan> CreateSpan(Aws::String name,
55 const Aws::Map<Aws::String, Aws::String> &attributes,
56 SpanKind spanKind) override;
57
58 private:
59 opentelemetry::trace::SpanKind convertSpanKind(SpanKind status);
60
61 opentelemetry::nostd::shared_ptr<opentelemetry::trace::Tracer> otelTracer;
62 };
63
64 }
65 }
66}
void emitEvent(Aws::String name, const Aws::Map< Aws::String, Aws::String > &attributes) override
OtelSpanAdapter(Aws::String name, opentelemetry::nostd::shared_ptr< opentelemetry::trace::Span > span, opentelemetry::trace::Scope scope)
void setStatus(TraceSpanStatus status) override
void setAttribute(Aws::String key, Aws::String value) override
std::shared_ptr< TraceSpan > CreateSpan(Aws::String name, const Aws::Map< Aws::String, Aws::String > &attributes, SpanKind spanKind) override
OtelTracerAdapter(opentelemetry::nostd::shared_ptr< opentelemetry::trace::Tracer > tracer)
std::map< K, V, std::less< K >, Aws::Allocator< std::pair< const K, V > > > Map
Definition AWSMap.h:20
std::basic_string< char, std::char_traits< char >, Aws::Allocator< char > > String
Definition AWSString.h:97