azure-sdk-for-cpp/doc/DistributedTracing.md
Larry Osterman b8330a1f5c
Merge main into feature/websockets. (#3994)
* Stress test (#3820)

* mem leak fix

* PR comments fix

* PR comments

* seems to work?

* clang

* curl again

* add first stress test

* also update gitignore

* missing line

* only linux

* clang typo format

* typo 2

* PR comments

* cspell

* remove terminator

* Fixed the metadata for better handling (#3824)

Co-authored-by: sima-zhu <sizhu@microsoft.com>

* Update attestation core vcpkg dependency to latest GA version that is required. (#3830)

* Update attestation core vcpkg dependency to latest GA version that is required.

* Update vcpkg config.cmake to match the dependency version needed.

* Remove winhttp (#3832)

* remove refs to winhttp

* this tsst only curl

* Move perf.yml to eng/common (#3833)

Co-authored-by: Mike Harder <mharder@microsoft.com>

* Sync eng/common directory with azure-sdk-tools for PR 3656 (#3834)

* someone wants to reference the test-proxy startup scripts externally. to make this easy on them we're parameterizing the root of the eng/common for easy use in that scenario
* two leading $ signs on the definition of the certificate path was causing some issues!

Co-authored-by: scbedd <45376673+scbedd@users.noreply.github.com>

* Update casing for 'verison' (#3821)

Co-authored-by: Daniel Jurek <djurek@microsoft.com>

* Print additional result summary formats to pipelines UI (#3842)

Co-authored-by: Mike Harder <mharder@microsoft.com>

* Sync eng/common directory with azure-sdk-tools for PR 3702 (#3843)

* Add language-service to list of valid sample slugs

* Update link to taxonomies

Co-authored-by: Heath Stewart <heaths@microsoft.com>

* Fix incorrect failure notification in vcpkg publishing (#3838)

* Set up for testing of template pipeline

* Override branches, set up for template GA release

* More TODOs to prevent merging an unintended change

* More removal of TestPipeline

* Increment template version number

* Use script to set package version

* Check out the correct branch

* branch parameter in the command

* Use $(PublishToVcpkg) to determine if we should check for changes

* dictionary syntax

* Set GA package version to validate GA publish scenario

* Update changelog

* create-pull-request.yml optionally pushes changes

* Output GH PR URI

* Macro syntax with a variable set earlier

* Move up to 1.2.0-beta.2

* beta.1

* Revert changelog

* Revert testing-related changes

* Revert vcpkg-clone.yml

* Revert eng/common changes, ensure global $(HasChanges) is set properly

* Changes to enable testing

* 1.1.0-beta.1

* vcpkg clone should clone at configured branch

* Clone "main" branch of vcpkg betas

* Undo test-specific changes

* More PR cleanup

* PR cleanup

* Helm charts (#3841)

* helm chart

* first pipe setup

* poi

* magiks

* ewewe

* stress

* cleanup

* pr

* QFE and readme

* clang

* stupid clang , waste of time

* ewqwewewrqrewewrqewrqwrqr

* stupid clang

* cspell

* PR

* try try again

* clang again

* Sync eng/common directory with azure-sdk-tools for PR 3661 (#3846)

* Add full clone fallback to sparse checkout

* Improve clone handling and overrides for sparse checkout

* Use SkipSparseCheckout variable name

Co-authored-by: Ben Broderick Phillips <bebroder@microsoft.com>

* Sync eng/common directory with azure-sdk-tools for PR 3735 (#3845)

* Detect API changes using new snadboxinx approach

* Added strictmode

* Remove unset variable

* Changes as per strict mode 3

* Rervert strict mode to allow language level fixes to merge first

Co-authored-by: praveenkuttappan <prmarott@microsoft.com>

* Increment version for keyvault releases (#3809)

* Increment package version after release of azure-security-keyvault-keys

* Increment package version after release of azure-security-keyvault-secrets

* Increment package version after release of azure-security-keyvault-certificates

* Removed hard dependency on opentelemetry version (#3844)

* Revert "Add full clone fallback to sparse checkout (#3661)" (#3851)

This reverts commit 7605ead00308dd20f20f2afe5acc4ec9900a2c47.

Co-authored-by: Ben Broderick Phillips <ben@benbp.net>

* Sync eng/common directory with azure-sdk-tools for PR 3753 (#3857)

* Bump MacOs version to macos-11

* Update eng/common/scripts/job-matrix/tests/job-matrix-functions.tests.ps1

Co-authored-by: Wes Haggard <weshaggard@users.noreply.github.com>

* Update eng/common/scripts/job-matrix/tests/job-matrix-functions.tests.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>

* Bump macOs version to macos-11 (#3853)

* Update CHANGELOG.md

* Fix misleading step name in az module install (#3859)

Co-authored-by: Ben Broderick Phillips <bebroder@microsoft.com>

* Retry poll calls on EINTR (#3858)

When signals are delievered to the process, calls here to poll may be
interrupted and return with a spurious failure.  The call instead should be
restarted.

* Fix bad path to sample matrix json (#3860)

Co-authored-by: Ben Broderick Phillips <bebroder@microsoft.com>

* Sync eng/common directory with azure-sdk-tools for PR 3826 (#3863)

* Add link checking for stress CI

* Remove region segment from stress testing links

Co-authored-by: Ben Broderick Phillips <bebroder@microsoft.com>

* Core August releases (#3862)

* Core August releases

* cspell

Co-authored-by: Anton Kolesnyk <antkmsft@users.noreply.github.com>

* Increment version for core releases (#3865)

* Increment package version after release of azure-core

* Increment package version after release of azure-core-tracing-opentelemetry

* Storage Aug GA release (#3864)

* CG only runs on internal (#3866)

* Condition added and indentation changes

* STG 79 80 81 Features (#3850)

* Sync eng/common directory with azure-sdk-tools for PR 3860 (#3871)

* updating pfx and cert
* update the targeted version of the proxy as well

Co-authored-by: scbedd <45376673+scbedd@users.noreply.github.com>

* Storage August Preview Release (#3868)

* Storage August Preview Release

* update versions

* Increment version for storage releases (#3875)

* Increment package version after release of azure-storage-common

* Increment package version after release of azure-storage-blobs

* Fix an issue that reason phrase is missing as expected from HTTP/2 server (#3879)

* Fix an issue that reason phrase is missing as expected from HTTP/2 server

* reverse the condition

* compact comments

* fix clang format

* Update CODEOWNERS (#3881)

* updated targeted proxy version to one that properly allows consumption of TLS certificates (#3888)

Co-authored-by: scbedd <45376673+scbedd@users.noreply.github.com>

* Fix `azure-storage-blobs-cpp` beta install (#3889)

Co-authored-by: Anton Kolesnyk <antkmsft@users.noreply.github.com>

* Fixed #3899 - Handle new OSX version correctly; reformatted platform-matrix JSON files (#3900)

* Simpler get-binarysizes check for OSX (#3901)

* Simpler get-binarysizes check for OSX

* Missed wildcard

* Sync eng/common directory with azure-sdk-tools for PR 3874 (#3907)

* Add sparse checkout to perf template

* Rename base template, add parameters

* Add comment

* Add TODO

* Fix copy/pase bug, add language to artifacts path

* Fix language ref

* Fix python language

* perf.yml extends perf-base.yml

* Remove unnecessary base yml

* Fetch pull request refs

* Fix refs path

* Fetch commitish if matches PR syntax

* Print command before running

* Add PR commitish to remote.origin.fetch

* Add pool and vmimage parameters

* Map ref under "refs/remotes/origin"

* Add ref to refs/remotes/origin

Co-authored-by: Mike Harder <mharder@microsoft.com>

* File Share Features until STG82 (#3908)

* Empty file or existing file won't be created/overwritten if the blob to be downloaded doesn't exist. (#3910)

* Remove unnecessary checkout: none that causes conflicts with sparse checkout declarations (#3915)

Co-authored-by: Ben Broderick Phillips <bebroder@microsoft.com>

* Core September Release (#3913)

Co-authored-by: Anton Kolesnyk <antkmsft@users.noreply.github.com>

* Increment package version after release of azure-core (#3919)

* Migrate SkipDefaultCheckout to SkipCheckoutNone (#3916)

Co-authored-by: Ben Broderick Phillips <bebroder@microsoft.com>

* Storage Sept Release (#3914)

* Increment version for storage releases (#3924)

* Increment package version after release of azure-storage-common

* Increment package version after release of azure-storage-blobs

* Increment package version after release of azure-storage-files-shares

* Add github actions based check enforcer (#3922)

* Add `$schema` to `cgmanifest.json` (#3918)

Co-authored-by: Jamie Magee <jamie.magee@microsoft.com>

* Remove SkipDefaultCheckout parameter (#3930)

Co-authored-by: Ben Broderick Phillips <bebroder@microsoft.com>

* Compatibility improvement for striped blob (#3932)

* add a parameter 'condition' to the test-proxy ci invocations. (#3931)

Co-authored-by: scbedd <45376673+scbedd@users.noreply.github.com>

* storage ad-hoc release (#3934)

* Increment package version after release of azure-storage-blobs (#3935)

* Update `AttestationClient::AttestTpm` API to match existing `AttestOpenEnclave` and `AttestSgxmEnclave`  (#3928)

* Fix broken link and typo in contributing.md

* Use vector<uint8_t> for attest instead of strings

* remove options

* fix comments

* update release version

* remove versionig

* revert changelog

* add the change

* update comment

* Update sdk/attestation/azure-security-attestation/CHANGELOG.md

Co-authored-by: Larry Osterman <LarryOsterman@users.noreply.github.com>

* fix formatting

* address pr comment

* fix formating

* update a comment

* remove the attest tpm comment

Co-authored-by: Peng Li <pengfeli@microsoft.com>
Co-authored-by: Larry Osterman <LarryOsterman@users.noreply.github.com>

* Update check enforcer yaml permissions and name (#3944)

* Set VCPKG_ROOT (#3938)

* Set VCPKG_ROOT

* Update eng/pipelines/templates/steps/vcpkg-clone.yml

Co-authored-by: Ben Broderick Phillips <bebroder@microsoft.com>

Co-authored-by: Ben Broderick Phillips <bebroder@microsoft.com>

* Sync the devops helper scripts between azure-sdk repo and tools repo (#3949)

This should fix https://github.com/Azure/azure-sdk-tools/issues/3538
as it will now upgrade the devops extension to the latest version
which has the auth fix needed.

Co-authored-by: Wes Haggard <Wes.Haggard@microsoft.com>

* Add Win32FileTimeConverter (#3941)

* Sync eng/common directory with azure-sdk-tools for PR 4169 (#3950)

* pin newest version of proxy

Co-authored-by: scbedd <45376673+scbedd@users.noreply.github.com>

* Enable Query() test in blob SDK (#3960)

* Sync eng/common directory with azure-sdk-tools for PR 4212 (#3962)

* version including lock fixes
* target the correct proxy version

Co-authored-by: scbedd <45376673+scbedd@users.noreply.github.com>

* Pipeline core (#3953)

* test1

* glob

* quick cleanup

* ddasda

* ddsa

* envs

* dsds

* Revert "ddsa"

This reverts commit 6d9e385284ba37736fb5bc41e56065943abd7937.

* wq

* comment out issues

* valid test

* maybe

* qwewqewq

* lang steps

* Vcpkg pre-steps in the place Daniel should've recommend they go

* RepoOwner

* Correct repo owner name

* Remove vcpkg.yml (we don't need to write)

* PR trigger

* small change

* Update eng/pipelines/templates/jobs/perf.yml

Co-authored-by: Mike Harder <mharder@microsoft.com>

* Update eng/pipelines/templates/jobs/perf.yml

Co-authored-by: Mike Harder <mharder@microsoft.com>

* Update sdk/core/perf.yml

Co-authored-by: Mike Harder <mharder@microsoft.com>

Co-authored-by: Daniel Jurek <djurek@microsoft.com>
Co-authored-by: Mike Harder <mharder@microsoft.com>

* Win32FileTimeConverter (#3967)

* Sync eng/common directory with azure-sdk-tools for PR 4240 (#3965)

* use version of docker with CLI present

* target repaired executable

Co-authored-by: scbedd <45376673+scbedd@users.noreply.github.com>

* Revert "Add Win32FileTimeConverter (#3941)" (#3966)

This reverts commit 14e4f52b91.

* add test case for batch options on snapshots and versions (#3970)

* add test case for batch options on snapshots and versions

* recording

* Merge feature/datalakestg82 (#3973)

* Build subscription configuration from cloud config values (#3976)

* fix LROs in keyvault (#3952)

* fix LROs in keyvault

* qfe

* some cleanup

* fdd

* clangs

* correct fix

* oops

* Pull all Websockets changes to main except for WebSockets itself. (#3954)

* Pulled WebSocket fixes into main except for WebSockets functionality


Co-authored-by: Rick Winter <rick.winter@microsoft.com>
Co-authored-by: Daniel Jurek <djurek@microsoft.com>
Co-authored-by: George Arama <50641385+gearama@users.noreply.github.com>
Co-authored-by: Ahson Khan <ahson_ahmedk@yahoo.com>
Co-authored-by: Ben Broderick Phillips <bebroder@microsoft.com>
Co-authored-by: Anton Kolesnyk <antkmsft@users.noreply.github.com>

* Upadte Attestation changelog.md (#3992)

* Remove cspell directive from being visible (#3993)

* Post-merge changes to websockets code

* Update Attestation readme.md (#3991)

* Added back WebSocket_server.py

* Added Start-WebSocketServer.ps1 to list of files to copy

* clang-format

* Fixed memory leak in curl (#3995)

* Fixed memory leak in curl

* fixed documentation in unique_handle.hpp

Co-authored-by: George Arama <50641385+gearama@users.noreply.github.com>
Co-authored-by: Azure SDK Bot <53356347+azure-sdk@users.noreply.github.com>
Co-authored-by: sima-zhu <sizhu@microsoft.com>
Co-authored-by: Ahson Khan <ahson_ahmedk@yahoo.com>
Co-authored-by: Mike Harder <mharder@microsoft.com>
Co-authored-by: scbedd <45376673+scbedd@users.noreply.github.com>
Co-authored-by: Daniel Jurek <djurek@microsoft.com>
Co-authored-by: Heath Stewart <heaths@microsoft.com>
Co-authored-by: Ben Broderick Phillips <bebroder@microsoft.com>
Co-authored-by: praveenkuttappan <prmarott@microsoft.com>
Co-authored-by: Ben Broderick Phillips <ben@benbp.net>
Co-authored-by: Sima Zhu <48036328+sima-zhu@users.noreply.github.com>
Co-authored-by: Wes Haggard <weshaggard@users.noreply.github.com>
Co-authored-by: Rick Winter <rick.winter@microsoft.com>
Co-authored-by: John Heffner <john@topofcenter.net>
Co-authored-by: Anton Kolesnyk <41349689+antkmsft@users.noreply.github.com>
Co-authored-by: Anton Kolesnyk <antkmsft@users.noreply.github.com>
Co-authored-by: JinmingHu <jinmhu@microsoft.com>
Co-authored-by: Jonathan Cárdenas <JonathanCrd@users.noreply.github.com>
Co-authored-by: keshen-msft <53491277+keshen-msft@users.noreply.github.com>
Co-authored-by: microzchang <110015819+microzchang@users.noreply.github.com>
Co-authored-by: Jamie Magee <jamie.magee@gmail.com>
Co-authored-by: Jamie Magee <jamie.magee@microsoft.com>
Co-authored-by: Peng Li <86324823+penglimsft@users.noreply.github.com>
Co-authored-by: Peng Li <pengfeli@microsoft.com>
Co-authored-by: Wes Haggard <Wes.Haggard@microsoft.com>
2022-10-05 14:24:54 -07:00

12 KiB

Distributed Tracing in the C++ SDK

Azure has adopted W3C Distributed Tracing 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. Additional architectural information about OpenTelemetry can be found in OpenTelemetry 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 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.

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, Windows 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:

std::shared_ptr<Azure::Core::Tracing::TracerProvider> traceProvider
      = Azure::Core::Tracing::OpenTelemetry::OpenTelemetryProvider::Create(CreateOpenTelemetryProvider());

To finish the integration with Azure clients, there are two mechanisms to integrate OpenTelemetry into a client application:

  1. Azure::Core::Context integration.
  2. 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.

    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.

auto tracerProvider(CreateOpenTelemetryProvider());
auto provider(Azure::Core::Tracing::OpenTelemetry::OpenTelemetryProvider::Create(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
  2. 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.
    2. Call SetStatus on the created span when the service method successfully completes.
    3. 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:

  Azure::Core::Tracing::_internal::TracingContextFactory m_tracingFactory;

And construct the new tracing factory in the service constructor:

  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.
  2. Span::AddEvent(std::exception&) - This registers the exception with the distributed tracing infrastructure.
  3. Span::SetStatus - This sets the status of the operation in the trace.
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. The actual tracing elements generated by Azure services are defined in Azure Tracing Conventions YAML.

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.