AWS SDK for C++

AWS SDK for C++ Version 1.11.440

Loading...
Searching...
No Matches
TelemetryProvider.h
1
5#pragma once
6
7#include <smithy/Smithy_EXPORTS.h>
8#include <smithy/tracing/TracerProvider.h>
9#include <smithy/tracing/MeterProvider.h>
10#include <aws/core/utils/memory/AWSMemory.h>
11#include <utility>
12#include <mutex>
13
14namespace smithy {
15 namespace components {
16 namespace tracing {
21 class SMITHY_API TelemetryProvider {
22 public:
33 std::function<void()> init,
34 std::function<void()> shutdown) :
35 m_tracerProvider(std::move(tracerProvider)),
36 m_meterProvider(std::move(meterProvider)),
37 m_init(std::move(init)),
38 m_shutdown(std::move(shutdown))
39 {
40 RunInit();
41 }
42
44 RunShutDown();
45 }
46
54 std::shared_ptr<Tracer>
56 return m_tracerProvider->GetTracer(std::move(scope), attributes);
57 }
58
66 std::shared_ptr<Meter>
68 return m_meterProvider->GetMeter(std::move(scope), attributes);
69 }
70
75 void RunInit() {
76 std::call_once(m_initFlag, m_init);
77 }
78
83 void RunShutDown() {
84 std::call_once(m_shutdownFlag, m_shutdown);
85 }
86
87 private:
88 std::once_flag m_initFlag;
89 std::once_flag m_shutdownFlag;
90 const Aws::UniquePtr<TracerProvider> m_tracerProvider;
91 const Aws::UniquePtr<MeterProvider> m_meterProvider;
92 const std::function<void()> m_init;
93 const std::function<void()> m_shutdown;
94 };
95 }
96 }
97}
TelemetryProvider(Aws::UniquePtr< TracerProvider > tracerProvider, Aws::UniquePtr< MeterProvider > meterProvider, std::function< void()> init, std::function< void()> shutdown)
std::shared_ptr< Tracer > getTracer(Aws::String scope, const Aws::Map< Aws::String, Aws::String > &attributes)
std::shared_ptr< Meter > getMeter(Aws::String scope, const Aws::Map< Aws::String, Aws::String > &attributes)
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
std::unique_ptr< T, D > UniquePtr
Definition AWSMemory.h:255