18namespace Azure {
namespace Core {
namespace Tracing {
namespace _internal {
30 class ServiceSpan final :
public Span {
32 std::shared_ptr<Span> m_span;
34 friend class TracingContextFactory;
35 ServiceSpan() =
default;
36 explicit ServiceSpan(std::shared_ptr<Span> span) : m_span(std::move(span)) {}
38 ServiceSpan(
const ServiceSpan&) =
delete;
39 ServiceSpan& operator=(ServiceSpan
const&) =
delete;
41 ServiceSpan& operator=(ServiceSpan&&) noexcept = default;
44 ServiceSpan(ServiceSpan&& that) = default;
46 ~ServiceSpan()
override
54 void End() { End({}); }
63 void SetStatus(Azure::Core::Tracing::_internal::SpanStatus
const& status)
65 SetStatus(status, {});
68 Azure::Core::Tracing::_internal::SpanStatus
const& status,
69 std::string
const& description)
override
73 m_span->SetStatus(status, description);
82 void AddAttributes(AttributeSet
const& attributeToAdd)
override
86 m_span->AddAttributes(attributeToAdd);
96 void AddAttribute(std::string
const& attributeName, std::string
const& attributeValue)
override
100 m_span->AddAttribute(attributeName, attributeValue);
113 void AddEvent(std::string
const& eventName, AttributeSet
const& eventAttributes)
override
117 m_span->AddEvent(eventName, eventAttributes);
128 void AddEvent(std::string
const& eventName)
override
132 m_span->AddEvent(eventName);
142 void AddEvent(std::exception
const& exception)
override
146 m_span->AddEvent(exception);
147 m_span->SetStatus(SpanStatus::Error, {});
161 m_span->PropagateToHttpHeaders(request);
172 class TracingContextFactory final {
174 std::string m_serviceName;
175 std::string m_packageName;
176 std::string m_packageVersion;
177 std::shared_ptr<Azure::Core::Tracing::_internal::Tracer> m_serviceTracer;
201 TracingContextFactory(
202 Azure::Core::_internal::ClientOptions
const& options,
203 std::string
const& serviceName,
204 std::string
const& packageName,
205 std::string packageVersion)
206 : m_serviceName{serviceName}, m_packageName{packageName}, m_packageVersion{packageVersion}
210 if (options.Telemetry.TracingProvider)
213 = Azure::Core::Tracing::_internal::TracerProviderImplGetter::TracerImplFromTracer(
214 options.Telemetry.TracingProvider)
215 ->CreateTracer(packageName, packageVersion);
231 [[deprecated]] TracingContextFactory(
232 Azure::Core::_internal::ClientOptions
const& options,
233 std::string
const& serviceName,
234 std::string packageVersion)
235 : TracingContextFactory(options, serviceName, serviceName, packageVersion)
239 TracingContextFactory() =
default;
240 TracingContextFactory(TracingContextFactory
const&) =
default;
245 struct TracingContext
270 TracingContext CreateTracingContext(
271 std::string
const& spanName,
284 TracingContext CreateTracingContext(
285 std::string
const& spanName,
286 Azure::Core::Tracing::_internal::CreateSpanOptions& spanOptions,
289 std::unique_ptr<Azure::Core::Tracing::_internal::AttributeSet> CreateAttributeSet()
const;
293 bool HasTracer()
const {
return static_cast<bool>(m_serviceTracer); }
295 static std::unique_ptr<TracingContextFactory> CreateFromContext(
306 class TracingAttributes
307 :
public Azure::Core::_internal::ExtendableEnumeration<TracingAttributes> {
309 explicit TracingAttributes(std::string
const& that) : ExtendableEnumeration(that) {}
319 AZ_CORE_DLLEXPORT
const static TracingAttributes AzNamespace;
326 AZ_CORE_DLLEXPORT
const static TracingAttributes RequestId;
333 AZ_CORE_DLLEXPORT
const static TracingAttributes ServiceRequestId;
339 AZ_CORE_DLLEXPORT
const static TracingAttributes HttpMethod;
345 AZ_CORE_DLLEXPORT
const static TracingAttributes HttpUrl;
358 AZ_CORE_DLLEXPORT
const static TracingAttributes HttpUserAgent;
364 AZ_CORE_DLLEXPORT
const static TracingAttributes NetPeerName;
370 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:183
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.