* Support BaseName overrides in CI mode for New-TestResources.ps1 (#3559)
Co-authored-by: Ben Broderick Phillips <bebroder@microsoft.com>
* Do not pass Generated to -BaseName (#3562)
Co-authored-by: Heath Stewart <heaths@microsoft.com>
* Sort by service name first (#3570)
Co-authored-by: sima-zhu <sizhu@microsoft.com>
* Initialize the suppression file. (#3569)
* Sync eng/common directory with azure-sdk-tools for PR 3169 (#3572)
* Use the batch version of ValidateDocsMsPackagesFn
* Use proper pipelining for GetPackageInfoJson function
Co-authored-by: Patrick Hallisey <pahallis@microsoft.com>
* [Tech Docs] Libcurl transport adapter (#3484)
* libcurl transport adapter
* updates
* Update LibcurlTransportAdapter.md
* Update LibcurlTransportAdapter.md
* Update doc/LibcurlTransportAdapter.md
Co-authored-by: Jeffrey Richter <jeffrichter@live.com>
Co-authored-by: Jeffrey Richter <jeffrichter@live.com>
* Skip azcopy download if it already exists (#3576)
Co-authored-by: Patrick Hallisey <pahallis@microsoft.com>
* Pin openssl to 1.1.1n (#3575)
* Pin openssl to 1.1.1n
* Updated vcpkg commit to one containing OpenSSL 1.1.1n
* Fixed version number in vcpkg.json
* Fix typo (#3583)
* update curl transport options to support ignore proxy from system (#3564)
* update curl transport options to support ignore proxy from system
* update changelog
* bug fix for cl
* update log level from Retry policy (#3586)
* update log level
* Update sdk/core/azure-core/CHANGELOG.md
Co-authored-by: Ahson Khan <ahkha@microsoft.com>
Co-authored-by: Ahson Khan <ahkha@microsoft.com>
* Add batch protocol layer (#3580)
* Add batch protocol layer
* some small fixes on Storage cmakefiles (#3588)
* Migrate to matrix generator (#3553)
* Represent existing matrix in json
* Use new matrix
* Move to stage
* Cloud configuration
* MaxParallel
* DependsOn
* Quote CtestRegex
* Use template for cmake generate tests
* Template name mappings
* Formatting, parameters
* Remove duplicate bypass-local-dns.yml
* Enable Location override
* Add Location
* Add spelling words
* Use Ubuntu 20 where the name specifies Ubuntu 20
* Apply suggestions from code review
Co-authored-by: Ben Broderick Phillips <ben@benbp.net>
* PR feedback
* fix storage sample
* Matrix documentation
Co-authored-by: Ben Broderick Phillips <ben@benbp.net>
Co-authored-by: Victor Vazquez <vhvb1989@gmail.com>
* Sync eng/common directory with azure-sdk-tools for PR 3212 (#3587)
* bump consumed version of test proxy. update scripting to target the fully cross-platform image tag name.
* update target version of the test-proxy to one that enforces http/1.1
Co-authored-by: scbedd <45376673+scbedd@users.noreply.github.com>
* Sync eng/common directory with azure-sdk-tools for PR 3238 (#3590)
* pin proxy version to one that properly sets listenoptions
* update targeted test-proxy docker repo. "testproxy" -> "test-proxy"
Co-authored-by: scbedd <45376673+scbedd@users.noreply.github.com>
* Sync eng/common directory with azure-sdk-tools for PR 3221 (#3591)
* Make docs.ms link relative link
* Update Update-DocsMsMetadata.ps1
* Update eng/common/scripts/Update-DocsMsMetadata.ps1
Co-authored-by: Daniel Jurek <djurek@microsoft.com>
Co-authored-by: sima-zhu <sizhu@microsoft.com>
Co-authored-by: Sima Zhu <48036328+sima-zhu@users.noreply.github.com>
Co-authored-by: Daniel Jurek <djurek@microsoft.com>
* Remove the daily branch before date (#3593)
Co-authored-by: sima-zhu <sizhu@microsoft.com>
* Add ClientCertificateCredential (#3578)
* Add ClientCertificateCredential
* Update unit test
* cspell
* Update Readme
* Cosmetic fixes
* Changelog to mention env cred update
* Fix warning
* cspell
* Tell CI to install openssl
* openssl for all Windows
* update dependency manifest
* Re-phrase changelog
* Clang warnings
* Clang warning
* Clang warning - 2
* Ubuntu18 warning
* Update sdk/identity/azure-identity/CHANGELOG.md
Co-authored-by: Victor Vazquez <victor.vazquez@microsoft.com>
* PR feedback
Co-authored-by: Anton Kolesnyk <antkmsft@users.noreply.github.com>
Co-authored-by: Victor Vazquez <victor.vazquez@microsoft.com>
* Sync eng/common directory with azure-sdk-tools for PR 3250 (#3595)
* Change the direction of the commit date
* Log on right place
* remove auth
* fix typo
* Add auth token back
* add delete back
* Update eng/common/scripts/Delete-RemoteBranches.ps1
Co-authored-by: Wes Haggard <weshaggard@users.noreply.github.com>
* Update Delete-RemoteBranches.ps1
* Update Delete-RemoteBranches.ps1
* Update Delete-RemoteBranches.ps1
* Update Delete-RemoteBranches.ps1
* Update Delete-RemoteBranches.ps1
Co-authored-by: sima-zhu <sizhu@microsoft.com>
Co-authored-by: Sima Zhu <48036328+sima-zhu@users.noreply.github.com>
Co-authored-by: Wes Haggard <weshaggard@users.noreply.github.com>
* Create a session handle once in the transport ctor and reuse it for all requests rather than creating a new one each time. (#3585)
* Reuse the same session handle for all requests rather than creating a new one each time.
* Move the session handle creation to the transport adapter ctor.
* Update changelog entry.
* Address PR feedback.
* Change CreateSessionHandle to return a local session handle
* Fix-up the changelog entry link for the curtransportoption bug fix (#3598)
* Remove extra period at ends of exception messages in winhttp transport (#3601)
* fix cmake in storage (#3604)
* Reword the curl proxy fix changelog entry. (#3606)
* Add Emma Zhu as code owner (#3605)
* Short circuit out of msdocs publish if no package locations are specified (#3607)
Co-authored-by: Patrick Hallisey <pahallis@microsoft.com>
* sdk/core: Reimplement Md5OpenSSL using EVP API (#3609)
The MD5_Init/Update/Final functions are deprecated in OpenSSL 3.0 and result in
a compile-time warning. Due to the default usage of -Werror during compilation,
these warnings are treated as errors and prevent the SDK from being built on
Ubuntu 22.04, which ships with OpenSSL by default. The deprecated APIs should
be replaced by the EVP APIs, which are already in use for the SHA family of
functions, and supported on all versions of OpenSSL.
* API Review Feedback for Attestation SDK (#3543)
* API Review Feedback for Attestation SDK
* Updated changelog to reflect API Review updates
* Remove version pin for OpenSSL (#3610)
* Remove version pin for OpenSSL
* Gratuitous change to trigger CI pipelines
* Update the version tool to the latest (#3616)
Co-authored-by: sima-zhu <sizhu@microsoft.com>
* Get rid of warnings in nullable.hpp (#3617)
* cl (#3613)
* Update pipeline-generator version (#3623)
Co-authored-by: Patrick Hallisey <pahallis@microsoft.com>
* Prepare Attestation SDK for May Release. (#3625)
* Prepare attestation for May release
* Removed some noise from changelog
* Increment package version after release of azure-core (#3624)
* Update CODEOWNERS (#3628)
* Fix identity samples running in CI (#3632)
* azure identity may 2022 release (#3615)
* Increment package version after release of azure-identity (#3637)
* Removed uwp-x86 from platform matrix. (#3629)
* Increment package version after release of azure-security-attestation (#3636)
* Update readme for -pre and -post TestResource scripts (#3645)
Co-authored-by: Christopher Scott <chriss@microsoft.com>
* Fixed a bug where text of XML element cannot be empty. (#3643)
* String parsing improvements to service directory resource names (#3644)
Co-authored-by: Ben Broderick Phillips <bebroder@microsoft.com>
* Adding Acknowledgments (#3611)
* cl
* Update sdk/core/azure-core/CHANGELOG.md
Co-authored-by: Ahson Khan <ahkha@microsoft.com>
* cspell
Co-authored-by: Ahson Khan <ahkha@microsoft.com>
* Add skip variable for remove test resources to support debugging (#3648)
Co-authored-by: Ben Broderick Phillips <bebroder@microsoft.com>
* Storage Blob Stg78 Features (#3650)
* Clean up target_include_directories() (#3641)
Co-authored-by: Anton Kolesnyk <antkmsft@users.noreply.github.com>
* Update all-inclusive headers, and CMakeFiles for including all headers (#3640)
* Remove (#3657)
oexcept specifier from Context::IsCancelled()
Co-authored-by: Anton Kolesnyk <antkmsft@users.noreply.github.com>
* Add Language product slug (#3665)
Co-authored-by: Deyaaeldeen Almahallawi <dealmaha@microsoft.com>
* Sync eng/common directory with azure-sdk-tools for PR 3342 (#3664)
* Delete PR and branch which central PR is closed
* more logging changes
* resume the delete operations.
* Change the pr link directly
* fix the regex
* Refactor on regex name
* change the function to inline logic
* change typo
* delete on branch
* make changes on comments
* add commnets
* Update eng/common/scripts/Delete-RemoteBranches.ps1
Co-authored-by: Wes Haggard <weshaggard@users.noreply.github.com>
* Update eng/common/scripts/Delete-RemoteBranches.ps1
Co-authored-by: Wes Haggard <weshaggard@users.noreply.github.com>
* Update eng/common/scripts/Delete-RemoteBranches.ps1
Co-authored-by: Wes Haggard <weshaggard@users.noreply.github.com>
* Update eng/common/scripts/Delete-RemoteBranches.ps1
Co-authored-by: Wes Haggard <weshaggard@users.noreply.github.com>
Co-authored-by: sima-zhu <sizhu@microsoft.com>
Co-authored-by: Sima Zhu <48036328+sima-zhu@users.noreply.github.com>
Co-authored-by: Wes Haggard <weshaggard@users.noreply.github.com>
* Split out attestation client factory into separate class (#3654)
* Split out attestation client factory into separate class
* Updated readme; clang-format
* Final set of API review changes
* Replaced () constructors with {} constructors
* Initial implementation of OpenTelemetry APIs. (#3561)
* Start of tracing prototype
* Created initial implementation of azure-core-opentelemetry package
* New version of enabling MSVCRT Lib for static configs
* Attempt to add OpenTelemetry tests to build
* Take a dependency on OpenTelemetry version 1.3
* Added service API level tracing support
* API Review feedback
* storage unittest fix and improvement (#3667)
* Sync eng/common directory with azure-sdk-tools for PR 3362 (#3676)
* spell-check skippable by commit
* suceededOrFailed -> succeededOrFailed
Co-authored-by: scbedd <45376673+scbedd@users.noreply.github.com>
* Sync eng/common directory with azure-sdk-tools for PR 3378 (#3679)
* Create json package property parent directory
* Fix the issue in script
Co-authored-by: praveenkuttappan <prmarott@microsoft.com>
* Vcpkg sample (#3670)
* one commit to rule them all
* main merge
* error
* all smoke
* typo
* 120 minutes
* timeout param missing on job
* actual url
* Update samples/integration/vcpkg-all-smoke/src/main.cpp
Co-authored-by: Larry Osterman <LarryOsterman@users.noreply.github.com>
* actual creds
Co-authored-by: Larry Osterman <LarryOsterman@users.noreply.github.com>
* Complete the initial implementation of OpenTelemetry (#3677)
* Added telemetry support for HTTP pipeline elements
* Finish OpenTelemetry implementation
* clang-format and added doxygen comments
* Creadscan skips (#3671)
* one commit to rule them all
* main merge
* error
* add recordings for cred scan skipping
* certificates added
* remove dupe
* cspell
* Moved attestation factory back to static method on attestation class … (#3682)
* Moved attestation factory back to static method on attestation class and return a concrete type not a pointer
* Fixed factory in readme file
* OpenTelemetry API Review Feedback (#3687)
* OpenTelemetry API Review Feedback
* Attestation 1.0.0 GA Release (#3693)
* Prepare attestation for release
* removed references to RetrieveResponseValidationCollateral from docs
* Added C++ SDK team as owners of attestation SDK
* Added Ahmad from attestation team to attestation owners
* Removed dead API; switched attestation back to beta-3
* Disable detached head warnings on sparse checkout to commit (#3680)
Co-authored-by: Ben Broderick Phillips <bebroder@microsoft.com>
* Remove samples with docker.io (#3621)
* remove samples using docker.io
* removing docker files
* remove project
* Fix issue where matrix replace was not using imported display names (#3694)
Co-authored-by: Ben Broderick Phillips <bebroder@microsoft.com>
* Additional OpenTelemetry Feedback... (#3691)
* OpenTelemetry API Review Feedback
* Returns std::unique_ptr<DiagnosticTracingFactory instead of raw pointer
* Late breaking pull request feedback
* Renamed clientContext parameter to CreateSpan
* Renamed ContextAndSpanFactory to TracingContextFactory and CreateSpan to CreateTracingContext.
* Added ability to create instance with pointer (#3698)
* Added ability to create instance with pointer
* Pull request feedback
* Core 1.7.0-beta.1 Release (#3684)
Co-authored-by: Anton Kolesnyk <antkmsft@users.noreply.github.com>
* Increment package version after release of azure-core (#3699)
* Format vcpkg.json (#3701)
Co-authored-by: Anton Kolesnyk <antkmsft@users.noreply.github.com>
* Update README to list all the vcpkgs (#3704)
Co-authored-by: Anton Kolesnyk <antkmsft@users.noreply.github.com>
* Removed version>= fields for openssl in vcpkg.json files (#3705)
* Tab vcpkg publishing condition in to apply to the task (#3709)
* Storage June Release (#3686)
* Override live test location default to westus (#3696)
* Changelog updates for secrets and certificates (#3714)
* Changelog updates for secrets and certificates
* Update package versions
* Removed empty sections in changelog (#3718)
* Identity 1.3.0 Release (#3685)
Co-authored-by: Anton Kolesnyk <antkmsft@users.noreply.github.com>
* OpenTelemetry vcpkg fixes (#3716)
* OpenTelemetry vcpkg fixes
* Update ci.yml
* Drop version >= from project-level vcpkg
* find_package only supports numeric versions
* include(AzureBuildTargetForCI)
* Do not build as Windows/UWP DLL
* Docs and package dependencies
* Update condition
* Move condition down
* Move more under condition
* Rephrase condition
* Try hack for CI that won't affect vcpkg
Co-authored-by: Anton Kolesnyk <antkmsft@users.noreply.github.com>
* Increment package version after release of azure-identity (#3721)
* Increment version for storage releases (#3713)
* Increment package version after release of azure-storage-common
* Increment package version after release of azure-storage-blobs
* [EngSys] Get Vcpkg automatically (#3614)
* get vcpkg automatically
* Updated changelog (#3726)
* Increment package version after release of azure-core-tracing-opentelemetry (#3727)
* Increment package version after release of azure-security-attestation (#3717)
* Increment package version after release of azure-security-attestation (#3720)
* Enable Distributed Tracing for Attestation SDK client. (#3706)
* Implement tracing for Attestation and Template services
* Pipeline no longer requires service name if opting into distributed tracing; enable tracing in attestation service
* Generate user-agent header from request activity policy
* Added test to catch the redacted header regression
* Updated documentation to reflect API surface changes
* Make sample service an object library (#3728)
Co-authored-by: Anton Kolesnyk <antkmsft@users.noreply.github.com>
* Include pi-version to default list of unredacted query params for logging (#3730)
Co-authored-by: Anton Kolesnyk <antkmsft@users.noreply.github.com>
* Sync eng/common directory with azure-sdk-tools for PR 3433 (#3731)
* add condition
* divide line
Co-authored-by: Mariana Rios Flores <mariari@microsoft.com>
* Sync eng/common directory with azure-sdk-tools for PR 3267 (#3655)
* Use seperate scripts
* address comments.
* do compare and update
* save on the service level readme
* have the helper for reuse function
* remove mgmt table
* changes
* fix
* no return on error
* return if no contents
* Address comments
* change the table
* address wes comments.
* address wes comments.
* address more comments.
Co-authored-by: sima-zhu <sizhu@microsoft.com>
* Sync eng/common directory with azure-sdk-tools for PR 3386 (#3733)
* Update the order of remarks and examples to align with docs.ms
* change all occurance
* Update class.tmpl.partial
Co-authored-by: sizhu <sizhu@microsoft.com>
Co-authored-by: Sima Zhu <48036328+sima-zhu@users.noreply.github.com>
* ensure conditions all work properly in the case of a previous error (#3732)
Co-authored-by: Scott Beddall <scbedd@microsoft.com>
* InputSanitizer: rename to HttpSanitizer, remove static member (#3736)
* InputSanitizer => HttpSanitizer, remove static
* Update cpp
* Clang format
Co-authored-by: Anton Kolesnyk <antkmsft@users.noreply.github.com>
* Increment version for keyvault releases (#3719)
* Increment package version after release of azure-security-keyvault-certificates
* Increment package version after release of azure-security-keyvault-secrets
* Update DistributedTracing.md (#3715)
Fix typo
* ApiView command line generation script (#3711)
* ApiView command line generation script
* Strongly typed parameters
Co-authored-by: Ben Broderick Phillips <ben@benbp.net>
Co-authored-by: Anton Kolesnyk <antkmsft@users.noreply.github.com>
Co-authored-by: Ben Broderick Phillips <ben@benbp.net>
* Add missing license header to http_sanitizer source file (#3739)
* Add ResourceType parameter - Selects live test or perf test resources (#3740)
Co-authored-by: Mike Harder <mharder@microsoft.com>
* Update identity codeowners (#3744)
* ManagedIdentityCredential: Add support for AppServiceV2019 (#3734)
* ManagedIdentityCredential: Add support for AppServiceV2019
* Attempt to create 2019 before 2017
* Changelog update
Co-authored-by: Anton Kolesnyk <antkmsft@users.noreply.github.com>
* Fix Bug in Resource Ref Verifier (#3758)
Co-authored-by: Chidozie Ononiwu <chononiw@microsoft.com>
* Use westus as default region in test resource deployments (#3759)
Co-authored-by: Ben Broderick Phillips <bebroder@microsoft.com>
* Perf test for certs (#3729)
* one commit to rule them all
* main merge
* error
* main merge
* error
* main merge
* error
* main merge
* error
* example of perf test
* remove file
* create certs and keys in post setup, use to run the test
* PR comments
* Revert "Override live test location default to westus (#3696)" (#3761)
This reverts commit d4192609d5.
* Sync eng/common directory with azure-sdk-tools for PR 3481 (#3764)
* Support local addons path override in stress test deployment
* Support username based deployId in local stress deployment
* Support WhatIf in stress infrastructure provision script
* Simplify stress user detection
Co-authored-by: Wes Haggard <weshaggard@users.noreply.github.com>
* Run helm plugin add with helper
* Add WhatIf support to ps module install helper function
Co-authored-by: Ben Broderick Phillips <bebroder@microsoft.com>
Co-authored-by: Wes Haggard <weshaggard@users.noreply.github.com>
* Fixed typo in LibcurlTransportAdapter.md (#3768)
Co-authored-by: Azure SDK Bot <53356347+azure-sdk@users.noreply.github.com>
Co-authored-by: Ben Broderick Phillips <bebroder@microsoft.com>
Co-authored-by: Heath Stewart <heaths@microsoft.com>
Co-authored-by: sima-zhu <sizhu@microsoft.com>
Co-authored-by: Sima Zhu <48036328+sima-zhu@users.noreply.github.com>
Co-authored-by: Patrick Hallisey <pahallis@microsoft.com>
Co-authored-by: Victor Vazquez <victor.vazquez@microsoft.com>
Co-authored-by: Jeffrey Richter <jeffrichter@live.com>
Co-authored-by: Rick Winter <rick.winter@microsoft.com>
Co-authored-by: Ahson Khan <ahkha@microsoft.com>
Co-authored-by: JinmingHu <jinmhu@microsoft.com>
Co-authored-by: Daniel Jurek <djurek@microsoft.com>
Co-authored-by: Ben Broderick Phillips <ben@benbp.net>
Co-authored-by: Victor Vazquez <vhvb1989@gmail.com>
Co-authored-by: scbedd <45376673+scbedd@users.noreply.github.com>
Co-authored-by: Anton Kolesnyk <41349689+antkmsft@users.noreply.github.com>
Co-authored-by: Anton Kolesnyk <antkmsft@users.noreply.github.com>
Co-authored-by: Wes Haggard <weshaggard@users.noreply.github.com>
Co-authored-by: Ahson Khan <ahson_ahmedk@yahoo.com>
Co-authored-by: Jeremi Piotrowski <jeremi.piotrowski@gmail.com>
Co-authored-by: Christopher Scott <chriss@microsoft.com>
Co-authored-by: Deyaaeldeen Almahallawi <dealmaha@microsoft.com>
Co-authored-by: praveenkuttappan <prmarott@microsoft.com>
Co-authored-by: George Arama <50641385+gearama@users.noreply.github.com>
Co-authored-by: Mariana Rios Flores <mariari@microsoft.com>
Co-authored-by: Scott Beddall <scbedd@microsoft.com>
Co-authored-by: Mike Harder <mharder@microsoft.com>
Co-authored-by: Chidozie Ononiwu <chononiw@microsoft.com>
249 lines
12 KiB
Markdown
249 lines
12 KiB
Markdown
---
|
|
# cspell:words openetelemetry
|
|
---
|
|
# Distributed Tracing in the C++ SDK
|
|
|
|
Azure has adopted [W3C Distributed Tracing](https://www.w3.org/TR/trace-context/) as a paradigm for correlating
|
|
requests from clients across multiple services.
|
|
|
|
This document explains how the Azure C++ SDK implements distributed tracing, how clients integrate with distributed tracing, how
|
|
services should integrate with distributed tracing and finally how the network pipeline and other functionality should
|
|
integrate with distributed tracing.
|
|
|
|
## Tracing Overview
|
|
|
|
The Azure SDK for C++ Tracing APIs are modeled after the opentelemetry-cpp API surface defined in the [OpenTelemetry Tracing Specification](https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/trace/api.md).
|
|
Additional architectural information about OpenTelemetry can be found in [OpenTelemetry Concepts](https://opentelemetry.io/docs/concepts/).
|
|
|
|
There are three major components which the Azure SDK components interact with:
|
|
|
|
- `TracerProvider` - this is a factory which creates `Tracer` objects.
|
|
- `Tracer` - this is a factory which creates `Span` objects.
|
|
- `Span` - Span objects are the APIs which allow tracing an operation.
|
|
Each `span` has a name, a type and a "status". `Spans` also contain "attributes" and "events" which describe an operation.
|
|
|
|
There is typically a single `TracerProvider` for each application, and for the Azure SDK, each
|
|
service will have a `Tracer` implementation which creates `Span` objects for each service client.
|
|
|
|
A `Span` can be considered a "unit of work" for a service. Each service method (method which calls into the service) will have a single `Span` reflecting the client method which
|
|
was called.
|
|
|
|
`Span`'s are hierarchical and each span can have multiple children (each `Span` can only have a single parent). The typical way that this manifests itself during a
|
|
service method call is:
|
|
|
|
- Service Method "MyServiceMethod" creates a span named "MyServiceMethod" and starts an HTTP request to communicate with the service.
|
|
- The HTTP pipeline (specifically the `RequestActivityPolicy`) will create a child `span` under the service method `span` named `"HTTP <verb> #0"`. This span
|
|
|
|
reflects the HTTP call into the service.
|
|
- If the HTTP call needs to be retried, the existing `span` will be closed an a new span named `HTTP <verb> #1` will be created for the retry.
|
|
|
|
## Distributed Tracing Client Integration
|
|
|
|
Applications which wish to integrate Distributed Tracing are strongly encouraged
|
|
to use the [opentelemetry-cpp](https://github.com/open-telemetry/opentelemetry-cpp) vcpkg package.
|
|
|
|
There are numerous examples on the OpenTelemetry web site which demonstrate how to integrate
|
|
opentelemetry into a customer application and integrate the generated traces
|
|
with Azure monitoring infrastructure such as Geneva Monitoring.
|
|
|
|
Following the examples from opentelemetry-cpp, the following can be used
|
|
to establish an OpenTelemetry exporter which logs to the console or to an
|
|
in-memory logger.
|
|
|
|
```c++
|
|
opentelemetry::nostd::shared_ptr<opentelemetry::trace::TracerProvider>
|
|
CreateOpenTelemetryProvider()
|
|
{
|
|
#if USE_MEMORY_EXPORTER
|
|
auto exporter = std::make_unique<opentelemetry::exporter::memory::InMemorySpanExporter>();
|
|
#else
|
|
auto exporter = std::make_unique<opentelemetry::exporter::trace::OStreamSpanExporter>();
|
|
#endif
|
|
|
|
// simple processor
|
|
auto simple_processor = std::unique_ptr<opentelemetry::sdk::trace::SpanProcessor>(
|
|
new opentelemetry::sdk::trace::SimpleSpanProcessor(std::move(exporter)));
|
|
|
|
auto always_on_sampler = std::unique_ptr<opentelemetry::sdk::trace::AlwaysOnSampler>(
|
|
new opentelemetry::sdk::trace::AlwaysOnSampler);
|
|
|
|
auto resource_attributes = opentelemetry::sdk::resource::ResourceAttributes{
|
|
{"service.name", "telemetryTest"}, {"service.instance.id", "instance-1"}};
|
|
auto resource = opentelemetry::sdk::resource::Resource::Create(resource_attributes);
|
|
// Create using SDK configurations as parameter
|
|
return opentelemetry::nostd::shared_ptr<opentelemetry::trace::TracerProvider>(
|
|
new opentelemetry::sdk::trace::TracerProvider(
|
|
std::move(simple_processor), resource, std::move(always_on_sampler)));
|
|
}
|
|
```
|
|
|
|
Other exporters exist to export to [Jaeger](https://github.com/open-telemetry/opentelemetry-cpp/tree/main/exporters/jaeger),
|
|
[Windows ETW](https://github.com/open-telemetry/opentelemetry-cpp/tree/main/exporters/etw) and others.
|
|
|
|
Once the `opentelemetry::trace::TracerProvider` has been created, The client needs to create a new `Azure::Core::Tracing::OpenTelemetry::OpenTelemetryProvider` which
|
|
functions as an abstract class integration between OpenTelemetry and Azure Core:
|
|
|
|
```c++
|
|
std::shared_ptr<Azure::Core::Tracing::TracerProvider> traceProvider
|
|
= std::make_shared<Azure::Core::Tracing::OpenTelemetry::OpenTelemetryProvider>(CreateOpenTelemetryProvider());
|
|
```
|
|
|
|
To finish the integration with Azure clients, there are two mechanisms to integrate OpenTelemetry into a client application:
|
|
|
|
1) `Azure::Core::Context` integration.
|
|
1) Service Client Options integration.
|
|
|
|
### Integrate an OpenTelemetryProvider via the ApplicationContext
|
|
|
|
To integrate OpenTelemetry for all Azure Clients in the application, the customer can call `Azure::Core::Context::ApplicationContext.SetTracerProvider` to establish the
|
|
tracer provider for the application.
|
|
|
|
```c++
|
|
Azure::Core::Context::ApplicationContext.SetTracerProvider(provider);
|
|
```
|
|
|
|
### Integrate an OpenTelemetryProvider via Service ClientOptions
|
|
|
|
While using the ApplicationContext is the simplest mechanism for integration OpenTelemetry with a customer application, there may be times the customer needs more flexibility when creating service clients.
|
|
To enable customers to further customize how tracing works, the application can set the `Telemetry.TracingProvider` field in the service client options, which will establish the tracer provider used by
|
|
the service client.
|
|
|
|
```c++
|
|
auto tracerProvider(CreateOpenTelemetryProvider());
|
|
auto provider(std::make_shared<Azure::Core::Tracing::OpenTelemetry::OpenTelemetryProvider>(tracerProvider));
|
|
|
|
ServiceClientOptions clientOptions;
|
|
clientOptions.Telemetry.TracingProvider = provider;
|
|
clientOptions.Telemetry.ApplicationId = "MyApplication";
|
|
ServiceClient myServiceClient(clientOptions);
|
|
```
|
|
|
|
## Distributed Tracing Service Integration
|
|
|
|
There are two steps needed to integrate Distributed Tracing with a Service Client.
|
|
|
|
1. Add a `DiagnosticTracingFactory` object to the ServiceClient object
|
|
1. Update each service method as follows:
|
|
1. Add a call to the `CreateSpan` method on the diagnostic tracing factory. This will create a new span for the client operation.
|
|
1. Call `SetStatus` on the created span when the service method successfully completes.
|
|
1. Wrap the client method code with a try/catch handler which catches exceptions and call AddEvent with the value of the exception.
|
|
|
|
### Add a `DiagnosticTracingFactory` to the serviceClient class
|
|
|
|
To add a new `DiagnosticTracingFactory` to the client, simply add the class as a member:
|
|
|
|
```c++
|
|
Azure::Core::Tracing::_internal::TracingContextFactory m_tracingFactory;
|
|
|
|
```
|
|
|
|
And construct the new tracing factory in the service constructor:
|
|
|
|
```c++
|
|
explicit ServiceClient(ServiceClientOptions const& clientOptions = ServiceClientOptions{})
|
|
: m_tracingFactory(clientOptions, "Azure.Core.OpenTelemetry.Test.Service", PackageVersion::ToString())
|
|
```
|
|
|
|
### Update Each Service Method
|
|
|
|
There are three methods of interest when updating the service method:
|
|
|
|
1. `DiagnosticTracingFactory::CreateSpan` - this creates and returns a `Span` and `Context` object for the service method. The returned Context object must be used for subsequent service operations.
|
|
1. `Span::AddEvent(std::exception&)` - This registers the exception with the distributed tracing infrastructure.
|
|
1. `Span::SetStatus` - This sets the status of the operation in the trace.
|
|
|
|
```c++
|
|
Azure::Response<std::string> ServiceMethod(
|
|
std::string const&,
|
|
Azure::Core::Context const& context = Azure::Core::Context{})
|
|
{
|
|
// Create a new context and span for this request.
|
|
auto contextAndSpan = m_tracingFactory.CreateSpan("ServiceMethod", context);
|
|
|
|
// contextAndSpan.Context is the new context for the operation.
|
|
// contextAndSpan.Span is the new span for the operation.
|
|
|
|
try
|
|
{
|
|
// <Call Into Service via an HTTP pipeline>
|
|
Azure::Core::Http::Request requestToSend(
|
|
HttpMethod::Get, Azure::Core::Url("<Service URL>"));
|
|
|
|
std::unique_ptr<Azure::Core::Http::RawResponse> response
|
|
= m_pipeline->Send(requestToSend, contextAndSpan.Context);
|
|
contextAndSpan.Span.SetStatus(Azure::Core::Tracing::_internal::SpanStatus::Ok);
|
|
return Azure::Response<std::string>("", std::move(response));
|
|
}
|
|
catch (std::exception const& ex)
|
|
{
|
|
// Register that the exception has happened and that the span is now in error.
|
|
contextAndSpan.Span.AddEvent(ex);
|
|
throw;
|
|
}
|
|
|
|
// When contextAndSpan.second goes out of scope, it ends the span, which will record it.
|
|
}
|
|
};
|
|
```
|
|
|
|
## Implementation Details
|
|
|
|
### Distributed Tracing components
|
|
|
|
In order to maintain flexibility, the opentelemetry-cpp APIs are implemented in a separate package - azure-core-tracing-opentelemetry.
|
|
This is consistent with how opentelemetry is distributed for
|
|
the other Azure SDKs.
|
|
|
|
The Azure Core API surface interacts with a set of pure virtual base classes (aka "interfaces") in
|
|
the `Azure::Core::Tracing` and `Azure::Core::Tracing::_internal` namespace. These allow a level of separation
|
|
between the Azure Core API surface and the OpenTelemetry API surface - an alternative tracing mechanism needs
|
|
to provide APIs consistent with the `Azure::Core::Tracing` APIs.
|
|
|
|
The azure-core-tracing-openetelemetry-cpp package implements a set of APIs in the `Azure::Core::Tracing::OpenTelemetry`
|
|
and `Azure::Core::Tracing::OpenTelemetry::_detail` namespace. These provide an Azure Core compatable API surface for distributed tracing.
|
|
|
|
The core service client interface is the `DiagnosticTracingFactory` class which implements two APIs: `CreateSpan` and
|
|
`CreateSpanFromContext`. `CreateSpan` is intended to be used by service methods which have direct access to a
|
|
`DiagnosticTracingFactory` object, `CreateSpanFromContext` in intended to be used from code which does NOT have
|
|
direct access to the `DiagnosticTracingFactory`.
|
|
|
|
The final significant piece of the distributed tracing infrastructure is the `RequestActivityPolicy` - this policy MUST be
|
|
inserted into the HTTP pipeline AFTER the `RetryPolicy`. It is responsible for creating the span associated with the HTTP request, it will
|
|
also propagate the W3C distributed tracing headers from the span into the HTTP request.
|
|
|
|
### Generated traces
|
|
|
|
The Azure standards for distributed tracing are define in [Azure Distributed Tracing Conventions](https://github.com/Azure/azure-sdk/blob/main/docs/tracing/distributed-tracing-conventions.md).
|
|
The actual tracing elements generated by Azure services are defined in [Azure Tracing Conventions YAML](https://github.com/Azure/azure-sdk/blob/main/docs/tracing/distributed-tracing-conventions.yml).
|
|
|
|
In summary, these are the traces and attributes which should be generated
|
|
for azure services:
|
|
|
|
#### Spans
|
|
|
|
The distributed tracing standards define the following traces:
|
|
|
|
##### Public APIs
|
|
|
|
All public APIs MUST create a span which will describes the API.
|
|
The name of the span MUST be the API name.
|
|
|
|
##### HTTP Calls
|
|
|
|
Each HTTP request sent to the service MUST create a span describing the request to the service.
|
|
The name of the span MUST be of the form `HTTP <HTTP VERB> #<HTTP RETRY>`.
|
|
|
|
#### Attributes
|
|
|
|
Generated traces have the following attributes:
|
|
|
|
| Attribute Name | Semantics | Where Used
|
|
|-----------|--------|-------
|
|
| `az.namespace` |Namespace of the azure service request| All spans.
|
|
| `http.method`| HTTP Method ("GET", "PUT", etc)| HTTP Spans.
|
|
| `http.url`| URL being retrieved (sanitized)| HTTP Spans.
|
|
| `http.status_code` | HTTP status code returned by the service | HTTP Spans.
|
|
| `http.user_agent` | The value of the `User-Agent` HTTP header sent to the service | HTTP Spans.
|
|
| `requestId` | The value of the `x-ms-client-request-id` header sent by the client | HTTP Spans.
|
|
| `serviceRequestId` | The value of the `x-ms-request-id` sent by the server | HTTP Spans.
|