Skip to content

Commit

Permalink
Enable Distributed Tracing for Attestation SDK client. (#3706)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
LarryOsterman authored Jun 8, 2022
1 parent 9792345 commit 99f45a5
Show file tree
Hide file tree
Showing 24 changed files with 1,105 additions and 609 deletions.
4 changes: 1 addition & 3 deletions doc/DistributedTracing.md
Original file line number Diff line number Diff line change
Expand Up @@ -158,8 +158,7 @@ And construct the new tracing factory in the service constructor:
Azure::Core::Context const& context = Azure::Core::Context{})
{
// Create a new context and span for this request.
auto contextAndSpan = m_tracingFactory.CreateSpan(
"ServiceMethod", Azure::Core::Tracing::_internal::SpanKind::Internal, context);
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.
Expand All @@ -179,7 +178,6 @@ And construct the new tracing factory in the service constructor:
{
// Register that the exception has happened and that the span is now in error.
contextAndSpan.Span.AddEvent(ex);
contextAndSpan.Span.SetStatus(Azure::Core::Tracing::_internal::SpanStatus::Error);
throw;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#include "azure/attestation/attestation_client_models.hpp"
#include "azure/attestation/attestation_client_options.hpp"
#include <azure/core/context.hpp>
#include <azure/core/internal/tracing/service_tracing.hpp>
#include <azure/core/url.hpp>
#include <string>

Expand Down Expand Up @@ -68,10 +69,7 @@ namespace Azure { namespace Security { namespace Attestation {
* @param attestationClient An existing attestation client.
*/
AttestationAdministrationClient(AttestationAdministrationClient const& attestationClient)
: m_endpoint(attestationClient.m_endpoint), m_apiVersion(attestationClient.m_apiVersion),
m_pipeline(attestationClient.m_pipeline),
m_tokenValidationOptions(attestationClient.m_tokenValidationOptions),
m_attestationSigners(attestationClient.m_attestationSigners){};
= default;

/**
* @brief Destructor.
Expand Down Expand Up @@ -258,6 +256,7 @@ namespace Azure { namespace Security { namespace Attestation {
std::shared_ptr<Azure::Core::Credentials::TokenCredential const> m_credentials;
std::shared_ptr<Azure::Core::Http::_internal::HttpPipeline> m_pipeline;
AttestationTokenValidationOptions m_tokenValidationOptions;
Azure::Core::Tracing::_internal::TracingContextFactory m_tracingFactory;

std::vector<Models::AttestationSigner> m_attestationSigners;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#include "azure/attestation/attestation_client_models.hpp"
#include "azure/attestation/attestation_client_options.hpp"
#include <azure/core/context.hpp>
#include <azure/core/internal/tracing/service_tracing.hpp>
#include <azure/core/url.hpp>
#include <string>

Expand Down Expand Up @@ -162,11 +163,7 @@ namespace Azure { namespace Security { namespace Attestation {
*
* @param attestationClient An existing attestation client.
*/
AttestationClient(AttestationClient const& attestationClient)
: m_endpoint(attestationClient.m_endpoint), m_apiVersion(attestationClient.m_apiVersion),
m_pipeline(attestationClient.m_pipeline),
m_tokenValidationOptions(attestationClient.m_tokenValidationOptions),
m_attestationSigners(attestationClient.m_attestationSigners){};
AttestationClient(AttestationClient const& attestationClient) = default;

std::string const Endpoint() const { return m_endpoint.GetAbsoluteUrl(); }

Expand Down Expand Up @@ -255,6 +252,7 @@ namespace Azure { namespace Security { namespace Attestation {
std::shared_ptr<Azure::Core::Http::_internal::HttpPipeline> m_pipeline;
AttestationTokenValidationOptions m_tokenValidationOptions;
std::vector<Models::AttestationSigner> m_attestationSigners;
Azure::Core::Tracing::_internal::TracingContextFactory m_tracingFactory;

/** @brief Construct a new Attestation Client object
*
Expand Down
Loading

0 comments on commit 99f45a5

Please sign in to comment.