Select your cookie preferences

We use essential cookies and similar tools that are necessary to provide our site and services. We use performance cookies to collect anonymous statistics, so we can understand how customers use our site and make improvements. Essential cookies cannot be deactivated, but you can choose “Customize” or “Decline” to decline performance cookies.

If you agree, AWS and approved third parties will also use cookies to provide useful site features, remember your preferences, and display relevant content, including relevant advertising. To accept or decline all non-essential cookies, choose “Accept” or “Decline.” To make more detailed choices, choose “Customize.”

Observability - AWS SDK for .NET (version 3)

Version 4 (V4) of the AWS SDK for .NET is in preview! To see information about this new version in preview, see the AWS SDK for .NET (version 4 preview) Developer Guide.

Please note that V4 of the SDK is in preview, therefore its content is subject to change.

Version 4 (V4) of the AWS SDK for .NET is in preview! To see information about this new version in preview, see the AWS SDK for .NET (version 4 preview) Developer Guide.

Please note that V4 of the SDK is in preview, therefore its content is subject to change.

Observability

Observability is the extent to which a system's current state can be inferred from the data it emits. The data emitted is commonly referred to as telemetry.

The AWS SDK for .NET can provide two common telemetry signals, metrics and traces, as well as logging. You can wire up a TelemetryProvider to send telemetry data to an observability backend (such as AWS X-Ray or Amazon CloudWatch) and then act on it.

By default, telemetry signals are disabled in the SDK. This topic explains how to enable and configure telemetry output.

Additional resources

For more information about enabling and using observability, see the following resources:

Configure a TelemetryProvider

You can configure a TelemetryProvider in your application globally for all service clients or for individual clients, as shown in the following examples. The Telemetry providers section contains information about telemetry implementations, including information about implementations that are provided with the SDK.

Configure the default global telemetry provider

By default, every service client attempts to use the globally available telemetry provider. This way, you can set the provider once, and all clients will use it. This should be done only once, before you create any service clients.

The following code snippet shows you how to set the global telemetry provider. It then creates an Amazon S3 service client and tries to perform an operation that fails. The code adds both tracing and metrics to the application. This code uses the following NuGet packages: OpenTelemetry.Exporter.Console and OpenTelemetry.Instrumentation.AWS.

Note

If you're using AWS IAM Identity Center for authentication, be sure to also add AWSSDK.SSO and AWSSDK.SSOOIDC.

using Amazon.S3; using OpenTelemetry; using OpenTelemetry.Metrics; using OpenTelemetry.Resources; using OpenTelemetry.Trace; Sdk.CreateTracerProviderBuilder() .ConfigureResource(e => e.AddService("DemoOtel")) .AddAWSInstrumentation() .AddConsoleExporter() .Build(); Sdk.CreateMeterProviderBuilder() .ConfigureResource(e => e.AddService("DemoOtel")) .AddAWSInstrumentation() .AddConsoleExporter() .Build(); var s3Client = new AmazonS3Client(); try { var listBucketsResponse = await s3Client.ListBucketsAsync(); // Attempt to delete a bucket that doesn't exist. var deleteBucketResponse = await s3Client.DeleteBucketAsync("amzn-s3-demo-bucket"); } catch (Exception ex) { Console.WriteLine(ex.Message); } Console.Read();

Configure a telemetry provider for a specific service client

You can configure an individual service client with a specific telemetry provider (other than the global one). To do so, use the TelemetryProvider class of the Config object of a service client constructor. For example, see AmazonS3Config and look for the TelemetryProvider property. See Telemetry providers for information about custom telemetry implementations.

PrivacySite termsCookie preferences
© 2025, Amazon Web Services, Inc. or its affiliates. All rights reserved.