Skip to content

The official AWS X-Ray Auto Instrumentation Agent for .Net.

License

Notifications You must be signed in to change notification settings

sdolier/aws-xray-dotnet-agent

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

Feature X-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:

  • .Net Agent doesn't provide configuration item to disable tracing incoming Http request. If you want to disable tracing incoming request, you may set DisableXRayTracing as true.

  • AWS request will trigger Http outgoing handler, so if you want to disable tracing AWS request, you have to disable both AWS handler and Http outgoing handler.

  • Similiar situation happens to Entity Framework request, which triggers both Entity Framework handler and Sql handler, therefore, if you want to disable tracing Entity Framework request, remember to disable Sql handler as well.

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

Currently, the AWSXRayRecorder.AutoInstrumentation Nuget hasn’t been released yet (please stay tuned!), so in case that you need to add it to you application, you can git clone this repo, reference AWSXRayRecorder.AutoInstrumentation package to your application and rebuild.

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. 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. Import AWSXRayRecorder.AutoInstrumentation package into your project and rebuild.
  2. Follow development instructions and build profiler. The output file of profiler should be ClrProfiler.dll.
  3. Launch your application as follows.
SET CORECLR_PROFILER={AE47A175-390A-4F13-84CB-7169CEBF064A}
SET CORECLR_ENABLE_PROFILING=1
SET CORECLR_PROFILER_PATH=\Path\to\ClrProfiler.dll\ // The path to ClrProfiler.dll that you built

dotnet YourApplication.dll

Note:

  • Do not set environment variables globally into the system variables as profiler will try to instrument all .NET processes running on the instance with AWS X-Ray tracing SDK.
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.9.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.

About

The official AWS X-Ray Auto Instrumentation Agent for .Net.

Resources

License

Code of conduct

Stars

Watchers

Forks

Packages

No packages published

Languages

  • C# 77.7%
  • C++ 22.2%
  • C 0.1%