Dynatrace.OneAgent.Sdk
1.0.0-alpha
Prefix Reserved
See the version list below for details.
dotnet add package Dynatrace.OneAgent.Sdk --version 1.0.0-alpha
NuGet\Install-Package Dynatrace.OneAgent.Sdk -Version 1.0.0-alpha
<PackageReference Include="Dynatrace.OneAgent.Sdk" Version="1.0.0-alpha" />
paket add Dynatrace.OneAgent.Sdk --version 1.0.0-alpha
#r "nuget: Dynatrace.OneAgent.Sdk, 1.0.0-alpha"
// Install Dynatrace.OneAgent.Sdk as a Cake Addin #addin nuget:?package=Dynatrace.OneAgent.Sdk&version=1.0.0-alpha&prerelease // Install Dynatrace.OneAgent.Sdk as a Cake Tool #tool nuget:?package=Dynatrace.OneAgent.Sdk&version=1.0.0-alpha&prerelease
Disclaimer: This SDK is currently in EAP and still work in progress.
Dynatrace OneAgent SDK for .NET
This SDK allows Dynatrace customers to instrument .NET applications. This is useful to enhance the visibility for proprietary frameworks or custom frameworks not directly supported by Dynatrace OneAgent out-of-the-box.
This is the official .NET implementation of the Dynatrace OneAgent SDK.
Package contents
samples
: sample applications, which demonstrates the usage of the SDK.src
: source code of the SDKLICENSE
: license under which the whole SDK and sample applications are published
Requirements
- Dynatrace OneAgent (required versions see below)
- Any .NET Full framework or .NET Core version that supports .NET Standard 1.0
OneAgent SDK for .NET | Required OneAgent version:
- 1.0.0-alpha | 1.153-1.155
Integration
Using this SDK should not cause any errors if no OneAgent is present (e.g. in testing).
Dependencies
If you want to integrate the OneAgent SDK into your application, just add the following NuGet dependency:
The Dynatrace OneAgent SDK for .NET has no further dependencies.
Troubleshooting
- Make sure OneAgent is installed and running on the host monitoring your application
- Make sure process monitoring is enabled
API Concepts
Common concepts of the Dynatrace OneAgent SDK are explained the Dynatrace OneAgent SDK repository.
OneAgentSDK object
Use OneAgentSDKFactory.CreateInstance() to obtain an OneAgentSDK instance. You should reuse this object over the whole application and if possible CLR lifetime:
OneAgentSdk oneAgentSdk = OneAgentSdkFactory.CreateInstance();
Tracers
To trace any kind of call you first need to create a Tracer. The Tracer object represents the logical and physical endpoint that you want to call. A Tracer serves two purposes. First to time the call (duraction, cpu and more) and report errors. That is why each Tracer has these three methods. The error method must be called only once, and it must be in between start and end.
void Start();
void Error(String message);
void End();
The Start method only supports synchronous methods (in other words C# methods without the async keyword). If you call Start() in an async method, then with high probability the SDK won’t capture the specific data.
To support asynchronous methods (which are C# methods that are marked with the async keyword) the SDK offers a StartAsync() method.
Sample usage:
public static async Task SampleMethodAsync()
{
var instance = OneAgentSdkFactory.CreateInstance();
var dbinfo = instance.CreateDatabaseInfo("MyDb", "MyVendor", Dynatrace.OneAgent.Sdk.Api.Enums.ChannelType.TCP_IP, "MyChannelEndpoint");
var dbTracer = instance.TraceSQLDatabaseRequest(dbinfo, "Select * From AA");
dbTracer.StartAsync(); //instead of Start() we call the StartAsync() method
try
{
await DatabaseApi.AsyncDatabaseCall();
}
catch
{
dbTracer.Error("DB call failed");
}
finally
{
dbTracer.End();
}
}
Additionally the .NET OneAgent SDK also offers a convenient Trace() method with multiple overloads. This method can be called in both asynchronous and synchronous methods. In case of an async method you can pass the given async method to the Trace method and await on the result of the Trace method.
Sample usage:
public static async Task SampleMethodAsync()
{
var instance = OneAgentSdkFactory.CreateInstance();
var dbinfo = instance.CreateDatabaseInfo("MyDb", "MyVendor", Dynatrace.OneAgent.Sdk.Api.Enums.ChannelType.TCP_IP, "MyChannelEndpoint");
var dbTracer = instance.TraceSQLDatabaseRequest(dbinfo, "Select * From AA");
var result = await dbTracer.Trace(() => DatabaseApi.AsyncDatabaseCall());
}
The Trace method internally calls the Start or StartAsync and the End method, and in case of an exception it also calls the Error method. Additionally, it also takes care of collecting timing information across threads in case of the C# async method is executed on multiple threads.
The Trace method with its overloads supports both synchronous and asynchronous methods. So, to summarize this, in case of
- synchronous methods you can either use the Start(), End(), and Error() methods, or the convenient Trace() method,
- asynchronous methods you can either use the StartAsync(), End(), and Error() methods, or the convenient Trace() method.
The second purpose of a Tracer is to allow tracing across process boundaries.
Features
The feature sets differ slightly with each language implementation. More functionality will be added over time, see Planned features for OneAgent SDK for details on upcoming features.
A more detailed specification of the features can be found in Dynatrace OneAgent SDK.
Feature | Required OneAgent SDK for .NET version:
- Trace SQL database requests | >=1.0.0
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. |
.NET Core | netcoreapp1.0 was computed. netcoreapp1.1 was computed. netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard1.0 is compatible. netstandard1.1 was computed. netstandard1.2 was computed. netstandard1.3 was computed. netstandard1.4 was computed. netstandard1.5 was computed. netstandard1.6 was computed. netstandard2.0 was computed. netstandard2.1 was computed. |
.NET Framework | net45 was computed. net451 was computed. net452 was computed. net46 was computed. net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen30 was computed. tizen40 was computed. tizen60 was computed. |
Universal Windows Platform | uap was computed. uap10.0 was computed. |
Windows Phone | wp8 was computed. wp81 was computed. wpa81 was computed. |
Windows Store | netcore was computed. netcore45 was computed. netcore451 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 1.0
- NETStandard.Library (>= 1.6.1)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on Dynatrace.OneAgent.Sdk:
Package | Downloads |
---|---|
TCERJ.Logging
This package provides configuration for logging. |
GitHub repositories (1)
Showing the top 1 popular GitHub repositories that depend on Dynatrace.OneAgent.Sdk:
Repository | Stars |
---|---|
Dynatrace/superdump
A service for automated crash-dump analysis
|
Version | Downloads | Last updated |
---|---|---|
1.8.0 | 322,979 | 12/13/2021 |
1.7.1 | 52,013 | 1/18/2021 |
1.7.0 | 93,500 | 10/18/2019 |
1.6.0 | 2,269 | 8/6/2019 |
1.5.0 | 625 | 6/26/2019 |
1.4.0 | 1,116 | 5/7/2019 |
1.3.0 | 3,572 | 4/2/2019 |
1.2.0 | 837 | 2/20/2019 |
1.1.0 | 859 | 12/18/2018 |
1.1.0-alpha1 | 593 | 11/27/2018 |
1.1.0-alpha | 950 | 11/23/2018 |
1.0.0-alpha | 740 | 8/29/2018 |