azure-core
Loading...
Searching...
No Matches
tracing_impl.hpp
Go to the documentation of this file.
1// Copyright (c) Microsoft Corporation.
2// Licensed under the MIT License.
3
9#pragma once
10
14
15#include <map>
16#include <memory>
17#include <string>
18
19// Forward declare Azure::Core::Http::Request to resolve an include file ordering problem.
20namespace Azure { namespace Core { namespace Http {
21 class Request;
22}}} // namespace Azure::Core::Http
23
24namespace Azure { namespace Core { namespace Tracing { namespace _internal {
25
56 class AttributeSet {
57 public:
64 virtual void AddAttribute(std::string const& attributeName, bool value) = 0;
71 virtual void AddAttribute(std::string const& attributeName, int32_t value) = 0;
78 virtual void AddAttribute(std::string const& attributeName, int64_t value) = 0;
85 virtual void AddAttribute(std::string const& attributeName, uint64_t value) = 0;
92 virtual void AddAttribute(std::string const& attributeName, double value) = 0;
99 virtual void AddAttribute(std::string const& attributeName, const char* value) = 0;
106 virtual void AddAttribute(std::string const& attributeName, std::string const& value) = 0;
107
112 virtual ~AttributeSet() = default;
113 };
114
117 enum class SpanKind : int
118 {
123 Internal,
128 Client,
133 Server,
138 Producer,
143 Consumer,
144 };
145
149 enum class SpanStatus : int
150 {
151
155 Unset,
159 Ok,
163 Error,
164
165 };
166
170 class Span {
171 public:
175 virtual void End(Azure::Nullable<Azure::DateTime> endTime) = 0;
176
182 virtual void AddAttributes(AttributeSet const& attributeToAdd) = 0;
183
190 virtual void AddAttribute(std::string const& attributeName, std::string const& attributeValue)
191 = 0;
192
202 virtual void AddEvent(std::string const& eventName, AttributeSet const& eventAttributes) = 0;
203
211 virtual void AddEvent(std::string const& eventName) = 0;
217 virtual void AddEvent(std::exception const& exception) = 0;
218
225 virtual void SetStatus(SpanStatus const& status, std::string const& description) = 0;
226
233 virtual void PropagateToHttpHeaders(Azure::Core::Http::Request& request) = 0;
234
235 virtual ~Span() = default;
236 };
237
242 struct CreateSpanOptions final
243 {
248 SpanKind Kind{SpanKind::Internal};
253 std::unique_ptr<AttributeSet> Attributes;
254
258 std::shared_ptr<Span> ParentSpan;
259 };
260
265 class Tracer {
266 public:
278 virtual std::shared_ptr<Span> CreateSpan(
279 std::string const& spanName,
280 CreateSpanOptions const& options) const = 0;
281
282 virtual std::unique_ptr<AttributeSet> CreateAttributeSet() const = 0;
283 virtual ~Tracer() = default;
284 };
285}}}} // namespace Azure::Core::Tracing::_internal
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
Support for date and time standardized string formats.
Compute the hash value for the input binary data, using SHA256, SHA384 and SHA512.
Definition azure_assert.hpp:57
Manages an optional contained value, i.e. a value that may or may not be present.
Public TracerProvider type used to represent a tracer provider.