17namespace Azure {
namespace Core {
namespace Tracing {
namespace _internal {
29 class ServiceSpan final :
public Span {
31 std::shared_ptr<Span> m_span;
33 friend class TracingContextFactory;
34 ServiceSpan() =
default;
35 explicit ServiceSpan(std::shared_ptr<Span> span) : m_span(span) {}
37 ServiceSpan(
const ServiceSpan&) =
delete;
38 ServiceSpan& operator=(ServiceSpan
const&) =
delete;
40 ServiceSpan& operator=(ServiceSpan&&) noexcept = default;
43 ServiceSpan(ServiceSpan&& that) = default;
53 void End() { End({}); }
62 void SetStatus(Azure::Core::Tracing::_internal::SpanStatus
const& status)
64 SetStatus(status, {});
67 Azure::Core::Tracing::_internal::SpanStatus
const& status,
68 std::string
const& description)
override
72 m_span->SetStatus(status, description);
81 void AddAttributes(AttributeSet
const& attributeToAdd)
override
85 m_span->AddAttributes(attributeToAdd);
95 void AddAttribute(std::string
const& attributeName, std::string
const& attributeValue)
override
99 m_span->AddAttribute(attributeName, attributeValue);
112 void AddEvent(std::string
const& eventName, AttributeSet
const& eventAttributes)
override
116 m_span->AddEvent(eventName, eventAttributes);
127 void AddEvent(std::string
const& eventName)
override
131 m_span->AddEvent(eventName);
141 void AddEvent(std::exception
const& exception)
override
145 m_span->AddEvent(exception);
146 m_span->SetStatus(SpanStatus::Error, {});
160 m_span->PropagateToHttpHeaders(request);
171 class TracingContextFactory final {
173 std::string m_serviceName;
174 std::string m_packageName;
175 std::string m_packageVersion;
176 std::shared_ptr<Azure::Core::Tracing::_internal::Tracer> m_serviceTracer;
200 TracingContextFactory(
201 Azure::Core::_internal::ClientOptions
const& options,
202 std::string
const& serviceName,
203 std::string
const& packageName,
204 std::string packageVersion)
205 : m_serviceName{serviceName}, m_packageName{packageName}, m_packageVersion{packageVersion}
209 if (options.Telemetry.TracingProvider)
212 = Azure::Core::Tracing::_internal::TracerProviderImplGetter::TracerImplFromTracer(
213 options.Telemetry.TracingProvider)
214 ->CreateTracer(packageName, packageVersion);
230 [[deprecated]] TracingContextFactory(
231 Azure::Core::_internal::ClientOptions
const& options,
232 std::string
const& serviceName,
233 std::string packageVersion)
234 : TracingContextFactory(options, serviceName, serviceName, packageVersion)
238 TracingContextFactory() =
default;
239 TracingContextFactory(TracingContextFactory
const&) =
default;
244 struct TracingContext
269 TracingContext CreateTracingContext(
270 std::string
const& spanName,
283 TracingContext CreateTracingContext(
284 std::string
const& spanName,
285 Azure::Core::Tracing::_internal::CreateSpanOptions& spanOptions,
288 std::unique_ptr<Azure::Core::Tracing::_internal::AttributeSet> CreateAttributeSet()
const;
292 bool HasTracer()
const {
return static_cast<bool>(m_serviceTracer); }
294 static std::unique_ptr<TracingContextFactory> CreateFromContext(
305 class TracingAttributes
306 :
public Azure::Core::_internal::ExtendableEnumeration<TracingAttributes> {
308 explicit TracingAttributes(std::string
const& that) : ExtendableEnumeration(that) {}
318 AZ_CORE_DLLEXPORT
const static TracingAttributes AzNamespace;
325 AZ_CORE_DLLEXPORT
const static TracingAttributes RequestId;
332 AZ_CORE_DLLEXPORT
const static TracingAttributes ServiceRequestId;
338 AZ_CORE_DLLEXPORT
const static TracingAttributes HttpMethod;
344 AZ_CORE_DLLEXPORT
const static TracingAttributes HttpUrl;
357 AZ_CORE_DLLEXPORT
const static TracingAttributes HttpUserAgent;
363 AZ_CORE_DLLEXPORT
const static TracingAttributes NetPeerName;
369 AZ_CORE_DLLEXPORT
const static TracingAttributes NetPeerPort;
A key used to store and retrieve data in an Azure::Core::Context object.
Definition context.hpp:77
A context is a node within a unidirectional tree that represents deadlines and key/value pairs.
Definition context.hpp:72
A request message from a client to a server.
Definition http.hpp:182
Manages an optional contained value, i.e. a value that may or may not be present.
Definition nullable.hpp:30
Base type for all client option types, exposes various common client options like Retry and Transport...
Context for canceling long running operations.
Internal utility functions for extendable enumerations.
HttpStatusCode
Defines the possible HTTP status codes.
Definition http_status_code.hpp:18
Compute the hash value for the input binary data, using SHA256, SHA384 and SHA512.
Definition azure_assert.hpp:57
Internal classes which abstract the OpenTelemetry API surface.
Declaration of the UserAgentGenerator type.