Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Documentation for ADOT .Net remote sampling #538

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 44 additions & 0 deletions src/docs/getting-started/dotnet-sdk/trace-manual-instr.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,50 @@ public void ConfigureServices(IServiceCollection services)
}
```

### Using X-Ray Remote Sampling

The `OpenTelemetry.Sampler.AWS` nuget package provides a `Sampler` implementation for use with [X-Ray remote sampling](https://docs.aws.amazon.com/xray/latest/devguide/xray-console-sampling.html).

```shell
dotnet add package OpenTelemetry.Sampler.AWS
```

When initializing the `TracerProvider`, register the `AWSXRayRemoteSampler`. Moreover, you can configure the following attributes for the sampler.

| **Attribute** | **Type** | **Description** | **Default** |
|-------------------|----------|----------------------------------------------------------------------|-------------------------|
| `pollingInterval` | TimeSpan | Duration between polling the GetSamplingRules API | 5 minutes |
| `endpoint` | string | Endpoint used to communicate with the `awsproxy` collector extension | `http://localhost:2000` |


```csharp linenumbers=true
using OpenTelemetry;
using OpenTelemetry.Contrib.Extensions.AWSXRay.Resources;
using OpenTelemetry.Contrib.Extensions.AWSXRay.Trace;
using OpenTelemetry.Sampler.AWS;
using OpenTelemetry.Trace;

var serviceName = "MyServiceName";

var resourceBuilder = ResourceBuilder
.CreateDefault()
.AddService(serviceName: serviceName)
.AddDetector(new AWSEC2ResourceDetector()); // optionally add any detector for your platform

using var tracerProvider = Sdk.CreateTracerProviderBuilder()
.AddSource(serviceName)
.SetResourceBuilder(resourceBuilder)
.AddConsoleExporter() // optionally add the exporter for the spans
.SetSampler(AWSXRayRemoteSampler.Builder(resourceBuilder.Build()) // you must provide a resource
.SetPollingInterval(TimeSpan.FromMinutes(10))
.SetEndpoint("http://localhost:2000")
.Build())
.Build();
```

Please note that you will also need to [configure the OpenTelemetry collector](/docs/getting-started/remote-sampling) to allow the application to fetch sampling configuration for AWS X-Ray service.
If the AWS X-Ray remote sampler is unable to fetch the sampling configurations due to network or configuration issue, the sampler will sample the requests at a default rate of 1 request per second and 5% of additional requests during that second.

<SectionSeparator />

## Custom Instrumentation
Expand Down
1 change: 1 addition & 0 deletions src/docs/getting-started/remote-sampling.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ Note that in order to use X-Ray remote sampling, your application's tracer must
* [ADOT Java agent](https://aws-otel.github.io/docs/getting-started/java-sdk/trace-auto-instr#using-x-ray-remote-sampling)
* [ADOT Java SDK](https://aws-otel.github.io/docs/getting-started/java-sdk/trace-manual-instr#using-x-ray-remote-sampling)
* [ADOT Go SDK](https://aws-otel.github.io/docs/getting-started/go-sdk/trace-manual-instr#using-x-ray-remote-sampling)
* [ADOT .Net SDK](https://aws-otel.github.io/docs/getting-started/dotnet-sdk/trace-manual-instr#using-x-ray-remote-sampling)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* [ADOT .Net SDK](https://aws-otel.github.io/docs/getting-started/dotnet-sdk/trace-manual-instr#using-x-ray-remote-sampling)
* [ADOT .NET SDK](https://aws-otel.github.io/docs/getting-started/dotnet-sdk/trace-manual-instr#using-x-ray-remote-sampling)


Enable the extension by adding this snippet to your collector configuration.

Expand Down