Home

Awesome

AWS X-Ray .NET Agent

The AWS X-Ray .NET Agent is a drop-in solution that enables the propagation of X-Ray traces within your web applications. This includes automatic tracing for AWS X-Ray SDK supported frameworks and libraries. The agent enables you to use the X-Ray SDK out of box, and requires no code changes to enable the basic propagation of traces. See the compatibility chart below for the current feature parity between the AWS X-Ray .NET SDK and the AWS X-Ray .NET Agent.

See the Sample App for a demonstration on how to use the agent.

Compatibility Chart

FeatureX-Ray SDK(.NET)X-Ray SDK(.NET Core)X-Ray Agent(.NET)X-Ray Agent(.NET Core)
AWS
Incoming Http
HttpClient
HttpWebRequest
System.Data.SqlClient
Microsoft.Data.SqlClient
EntityFramework✔ (EF Core)✔ (EF 6)✔ (EF Core)
Local Sampling
Dynamic Sampling
Multithreaded Execution
Plugins
Custom Subsegment

Prerequisites

If you're running an Asp.Net Core application, you need to install the latest version of Visual C++ Redistributable

Configuration

AWS X-Ray .Net Agent will register the configuration items as AWS X-Ray .NET SDK.

Besides, AWS X-Ray .Net Agent will register the following configuration items.

{
    "ServiceName" : "DefaultService",
    "DaemonAddress" : "127.0.0.1:2000",
    "TraceHttpRequests" : "true",
    "TraceAWSRequests" : "true",
    "TraceSqlRequests" : "true",
    "TraceEFRequests" : "true"
}

You can customize the service name of your application, the daemon address and specify which request to trace through appsettings.json file (Asp.Net Core) or web.config file (Asp.Net).

If you don't provide these configuration items, the default values shown above will be applied by AWS X-Ray .NET Agent.

Note:

Installation

Minimum Requirements

For building AWSXRayRecorder.AutoInstrumentation package, you need to install Visual Studio 2019.

For building profiler, you need to have workloads .NET desktop development and Desktop development with C++ installed within Visual Studio 2019.

Development

Note:

DotNet Coreclr Lib is required to build the profiler project in this repo. You can find it at this repo. Put coreclr folder under aws-xray-dotnet-agent\src\profiler, then you are good to go.

Automatic Instrumentation

Internet Information Services (IIS)

Asp.Net Core & Asp.Net
  1. Git clone this repo and import AWSXRayRecorder.AutoInstrumentation package into your project and rebuild.
  2. Download and run AWS X-Ray .NET Agent Installer (x64 and x86).
  3. Restart IIS and launch your application.
iisreset

Others (Not IIS)

Asp.Net Core
  1. Git clone this repo and import AWSXRayRecorder.AutoInstrumentation package into your project and rebuild.
  2. Download and run AWS X-Ray .NET Agent Installer (x64 and x86).
  3. Launch your application as follows.
SET CORECLR_PROFILER={AE47A175-390A-4F13-84CB-7169CEBF064A}
SET CORECLR_ENABLE_PROFILING=1

dotnet YourApplication.dll

Note:

Asp.Net
  1. Import AWSXRayRecorder.AutoInstrumentation package into your project and rebuild.
  2. Add the following snippet into the web.config file.
<system.webServer>
 <modules>
  <add name="AWSXRayTracingModule" type="Amazon.XRay.Recorder.AutoInstrumentation.AspNetAutoInstrumentationModule,AWSXRayRecorder.AutoInstrumentation,Version=2.10.0.0,Culture=neutral,PublicKeyToken=d427001f96b0d0b6" />
 </modules>
</system.webServer>
  1. Launch your application

Manual Instrumentation

Asp.Net Core

Instead of using profiler, you may choose to manually instrument AWS X-Ray SDK into your Asp.Net Core application.

  1. Import AWSXRayRecorder.AutoInstrumentation package into your project.

  2. Add the following method into any method in startup.cs or program.cs file

Amazon.XRay.Recorder.AutoInstrumentation.Initialize.AddXRay();

Getting Help

Please use these community resources for getting help.

Documentation

The developer guide provides guidance on using the AWS X-Ray DotNet Agent. Please refer to the Sample App for an example.

License

The AWS X-Ray SDK DotNet Agent is licensed under the Apache 2.0 License. See LICENSE for more information.