Thundra APM
Search…
Deployment Integrations
Integration Options for .NET SDK

Upgrading from v1.x to 2.x

In v2.x, we've made some changes to our agent as we've started to support .NET Core 2.1 applications as well. If you are using the Thundra agent v1.x already, make sure to check what needs to be changed here.
Serverless Framework
Serverless Plugin
AWS SAM
AWS CDK
Programmatic

Serverless Framework

Step 1: Add Thundra NuGet package
The .NET Thundra agent can be easily downloaded with the command shown below:
1
dotnet add package Thundra.Agent --version $LATEST_VERSION
Copied!
Latest Version
Similarly, you can add the agent via the NuGet Package Manager of your IDE (if available). For example, Visual Studio allows you to add packages through the IDE itself; a simple search for Thundra .NET will allow you to procure and add the correct agent to your project.
Step 2: Change serverless.yml
You should replace all of your handlers to “Thundra.Agent::Thundra.Agent.Lambda.Core.ThundraProxy::Handle” and set the real handler path as a separate environment variable.
serverless.yml
1
...
2
3
functions:
4
FirstFunction:
5
handler: Thundra.Agent::Thundra.Agent.Lambda.Core.ThundraProxy::Handle
6
environment:
7
thundra_agent_lambda_handler: <your_handler>
8
thundra_apiKey: <your_api_key>
9
10
SecondFunction:
11
handler: Thundra.Agent::Thundra.Agent.Lambda.Core.ThundraProxy::Handle
12
environment:
13
thundra_agent_lambda_handler: <your_second_handler>
14
thundra_apiKey: <your_api_key>
15
16
...
Copied!
Using this method, you can connect Thundra to your functions by modifying the configuration files without needing to change your code. The ThundraProxy class will call the actual handler as soon as it receives the request.

Serverless Plugin

Step 1: Install Thundra’s Serverless Plugin
1
npm install serverless-plugin-thundra
Copied!
Step 2: Add Thundra's Serverless Plugin in the serverless.yml File After installing Thundra’s serverless plugin, you need to add it under the plugins section of your serverless.yml file in order to specify it as a plugin for your serverless environment.
serverless.yml
1
plugins:
2
- serverless-plugin-thundra
Copied!
Step 3: Add thundra Component to Custom
Add the thundra component under custom with the apiKey beneath that, as shown below:
serverless.yml
1
custom:
2
thundra:
3
apiKey: <YOUR THUNDRA API KEY>
Copied!
Step 4: Deploy and Test the App
1
serverless deploy
2
serverless invoke --function functionName
Copied!
Step 5: Monitor Your Function with Thundra
After generating your first invocation, the “Next” button will appear in the Invocation Monitor bar. Simply click the button to see monitoring data from your invocation.
For more information, visit the Thundra Serverless Plugin page.

AWS SAM

Step 1: Add the Thundra NuGet Package
The .NET Thundra agent can be easily downloaded with the command shown below:
1
dotnet add package Thundra.Agent --version $LATEST_VERSION
Copied!
Latest Version
Similarly, you can add the agent via the NuGet Package Manager of your IDE (if available). For example, Visual Studio allows you to add packages through the IDE itself; a simple search for Thundra .NET will allow you to procure and add the correct agent to your project.
Step 2: Change template.yaml
You should replace all of your handlers to “Thundra.Agent::Thundra.Agent.Lambda.Core.ThundraProxy::Handle” and set the real handler path as a separate environment variable.
template.yaml
1
....
2
3
FirstFunction:
4
Type: AWS::Serverless::Function
5
Properties:
6
Handler: Thundra.Agent::Thundra.Agent.Lambda.Core.ThundraProxy::Handle
7
Environment:
8
Variables:
9
thundra_agent_lambda_handler: <your_handler>
10
thundra_apiKey: <your_api_key>
11
12
SecondFunction:
13
Type: AWS::Serverless::Function
14
Properties:
15
Handler: Thundra.Agent::Thundra.Agent.Lambda.Core.ThundraProxy::Handle
16
Environment:
17
Variables:
18
thundra_agent_lambda_handler: <your_second_handler>
19
thundra_apiKey: <your_api_key>
20
21
...
Copied!
Using this method, you can connect Thundra to your functions by modifying the configuration files without needing to change your code. The ThundraProxy class will call the actual handler as soon as it receives the request.

AWS CDK

Step 1: Add the Thundra NuGet Package to Your Lambda
The .NET Thundra agent can be easily downloaded with the command shown below:
1
dotnet add package Thundra.Agent --version $LATEST_VERSION
Copied!
Latest Version
Similarly, you can add the agent via the NuGet Package Manager of your IDE (if available). For example, Visual Studio allows you to add packages through the IDE itself; a simple search for Thundra .NET will allow you to procure and add the correct agent to your project.

Step 2: Apply Configuration Changes to Your Function Properties

  • Add the thundra_apiKey environment variable with your Thundra API key.
1
using Amazon.CDK;
2
using Amazon.CDK.AWS.Lambda;
3
using System.Collections.Generic;
4
5
namespace YourNameSpace
6
{
7
public class YourConstructClass : Construct
8
{
9
public YourConstructClass(Construct scope, string id) : base(scope, id)
10
{
11
var thundraApiKey = <your_api_key>;
12
13
var handler = new Function(this, "YourHandler", new FunctionProps
14
{
15
..., // other function properties
16
Environment = new Dictionary<string, string>
17
{
18
..., // other environment variables
19
["thundra_apiKey"] = thundraApiKey
20
}
21
});
22
}
23
}
24
}
Copied!
  • Change the Handler of the function to
    1
    Thundra.Agent::Thundra.Agent.Lambda.Core.ThundraProxy::Handle
    Copied!
    and add the thundra_agent_lambda_handler environment variable to the actual handler of your function.
1
using Amazon.CDK;
2
using Amazon.CDK.AWS.Lambda;
3
using System.Collections.Generic;
4
5
namespace YourNameSpace
6
{
7
public class YourConstructClass : Construct
8
{
9
public YourConstructClass(Construct scope, string id) : base(scope, id)
10
{
11
var thundraApiKey = <your_api_key>;
12
13
var handler = new Function(this, "YourHandler", new FunctionProps
14
{
15
..., // other function properties
16
Handler = "Thundra.Agent::Thundra.Agent.Lambda.Core.ThundraProxy::Handle",
17
Environment = new Dictionary<string, string>
18
{
19
..., // other environment variables
20
["thundra_apiKey"] = thundraApiKey,
21
["thundra_agent_lambda_handler"] = "Your.Assembly::Your.Type::YourMethod"
22
}
23
});
24
}
25
}
26
}
Copied!
An example configuration:
1
using Amazon.CDK;
2
using Amazon.CDK.AWS.Lambda;
3
using System.Collections.Generic;
4
5
namespace YourNameSpace
6
{
7
public class YourConstructClass : Construct
8
{
9
public YourConstructClass(Construct scope, string id) : base(scope, id)
10
{
11
var thundraApiKey = <your_api_key>;
12
13
var handler = new Function(this, "WidgetHandler", new FunctionProps
14
{
15
Runtime = Runtime.DOTNET_CORE_3_1,
16
Code = Code.FromAsset("path/to/function/package"),
17
Handler = "Thundra.Agent::Thundra.Agent.Lambda.Core.ThundraProxy::Handle",
18
Environment = new Dictionary<string, string>
19
{
20
["thundra_apiKey"] = thundraApiKey,
21
["thundra_agent_lambda_handler"] = "Your.Assembly::Your.Type::YourMethod"
22
}
23
});
24
}
25
}
26
}
Copied!

Step 2: Build and Deploy

1
dotnet build src && cdk deploy
Copied!

Step 3: Invoke Your Function

Now you can invoke your Lambda function and see the details of your invocation in the Thundra console!
Step 1: Add the Thundra NuGet Package
The .NET Thundra agent can be easily downloaded with the command shown below:
1
dotnet add package Thundra.Agent --version $LATEST_VERSION
Copied!
Latest Version
Similarly, you can add the agent via the NuGet Package Manager of your IDE (if available). For example, Visual Studio allows you to add packages through the IDE itself; a simple search for Thundra .NET will allow you to procure and add the correct agent to your project.
Step 2: Change the Handler's Code
Extend Thundra's LambdaRequestHandler within your handler class and then override the DoHandleRequest method, which encapsulates your handler code. LambdaRequestHandler takes two generic classes as parameters: the type of request object and the type of response object.
Function.cs
1
using Amazon.Lambda.Core;
2
using Thundra.Agent.Lambda.Core;
3
4
namespace ThundraSample
5
{
6
public class Function : LambdaRequestHandler<string, string>
7
{
8
9
/// <summary>
10
/// Handler class needs to extend `LambdaRequestHandler< Request, Response >`
11
/// Please write all code within the DoHandleRequest method
12
/// </summary>
13
/// <param name="request"></param>
14
/// <param name="context"></param>
15
/// <returns>/Greeting Message/</returns>
16
public override string DoHandleRequest(string request, ILambdaContext context)
17
{
18
return "Hello Thundra";
19
}
20
}
21
}
Copied!
Step 3: Change Your Handler to Thundra's HandleRequest
Next, you should change your handler to <MyAssembly>::<MyNamespace>.<MyClass>::HandleRequest.
It is a common mistake to utilize the hook method DoHandleRequest as the handler. In order to initialize Thundra, you must change your handler to HandleRequest, which resides in the base class (LambdaRequestHandler).
Last modified 8mo ago
Copy link