16namespace Azure {
namespace Core {
namespace Tracing {
namespace _internal {
28 class ServiceSpan final :
public Span {
30 std::shared_ptr<Span> m_span;
32 friend class TracingContextFactory;
33 ServiceSpan() =
default;
34 explicit ServiceSpan(std::shared_ptr<Span> span) : m_span(span) {}
36 ServiceSpan(
const ServiceSpan&) =
delete;
37 ServiceSpan& operator=(ServiceSpan
const&) =
delete;
39 ServiceSpan& operator=(ServiceSpan&&) noexcept = default;
42 ServiceSpan(ServiceSpan&& that) = default;
52 void End() { End({}); }
61 void SetStatus(Azure::Core::Tracing::_internal::SpanStatus
const& status)
63 SetStatus(status, {});
66 Azure::Core::Tracing::_internal::SpanStatus
const& status,
67 std::string
const& description)
override
71 m_span->SetStatus(status, description);
80 void AddAttributes(AttributeSet
const& attributeToAdd)
override
84 m_span->AddAttributes(attributeToAdd);
94 void AddAttribute(std::string
const& attributeName, std::string
const& attributeValue)
override
98 m_span->AddAttribute(attributeName, attributeValue);
111 void AddEvent(std::string
const& eventName, AttributeSet
const& eventAttributes)
override
115 m_span->AddEvent(eventName, eventAttributes);
126 void AddEvent(std::string
const& eventName)
override
130 m_span->AddEvent(eventName);
140 void AddEvent(std::exception
const& exception)
override
144 m_span->AddEvent(exception);
145 m_span->SetStatus(SpanStatus::Error, {});
159 m_span->PropagateToHttpHeaders(request);
170 class TracingContextFactory final {
172 std::string m_serviceName;
173 std::string m_packageName;
174 std::string m_packageVersion;
175 std::shared_ptr<Azure::Core::Tracing::_internal::Tracer> m_serviceTracer;
199 TracingContextFactory(
200 Azure::Core::_internal::ClientOptions
const& options,
201 std::string
const& serviceName,
202 std::string
const& packageName,
203 std::string packageVersion)
204 : m_serviceName{serviceName}, m_packageName{packageName}, m_packageVersion{packageVersion}
208 if (options.Telemetry.TracingProvider)
211 = Azure::Core::Tracing::_internal::TracerProviderImplGetter::TracerImplFromTracer(
212 options.Telemetry.TracingProvider)
213 ->CreateTracer(packageName, packageVersion);
229 [[deprecated]] TracingContextFactory(
230 Azure::Core::_internal::ClientOptions
const& options,
231 std::string
const& serviceName,
232 std::string packageVersion)
233 : TracingContextFactory(options, serviceName, serviceName, packageVersion)
237 TracingContextFactory() =
default;
238 TracingContextFactory(TracingContextFactory
const&) =
default;
243 struct TracingContext
268 TracingContext CreateTracingContext(
269 std::string
const& spanName,
282 TracingContext CreateTracingContext(
283 std::string
const& spanName,
284 Azure::Core::Tracing::_internal::CreateSpanOptions& spanOptions,
287 std::unique_ptr<Azure::Core::Tracing::_internal::AttributeSet> CreateAttributeSet()
const;
291 bool HasTracer()
const {
return static_cast<bool>(m_serviceTracer); }
293 static std::unique_ptr<TracingContextFactory> CreateFromContext(
304 class TracingAttributes
305 :
public Azure::Core::_internal::ExtendableEnumeration<TracingAttributes> {
307 explicit TracingAttributes(std::string
const& that) : ExtendableEnumeration(that) {}
317 AZ_CORE_DLLEXPORT
const static TracingAttributes AzNamespace;
324 AZ_CORE_DLLEXPORT
const static TracingAttributes RequestId;
331 AZ_CORE_DLLEXPORT
const static TracingAttributes ServiceRequestId;
337 AZ_CORE_DLLEXPORT
const static TracingAttributes HttpMethod;
343 AZ_CORE_DLLEXPORT
const static TracingAttributes HttpUrl;
356 AZ_CORE_DLLEXPORT
const static TracingAttributes HttpUserAgent;
362 AZ_CORE_DLLEXPORT
const static TracingAttributes NetPeerName;
368 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.