C#
How to setup recording & monitoring for C# applications

Requirements

  • C# project configuration
  • Any .NET application
  • Configured & installed RevDebug Server
To setup RevDeBug you will need to:
  1. 1.
    Add RevDeBug dependency
  2. 2.
    Configure the connection to RevDeBug Monitor

Adding RevDeBug dependency

Add RevDeBug NuGet repository to your solution. You can do that globally in Visual Studio settings:
Or by adding nuget.config file on solution level:
nuget.config
1
<?xml version="1.0" encoding="utf-8"?>
2
<configuration>
3
<packageSources>
4
<!--To inherit the global NuGet package sources remove the <clear/> line below -->
5
<clear />
6
<add key="nuget" value="https://api.nuget.org/v3/index.json" />
7
<add key="rdb" value="https://nexus.revdebug.com/repository/nuget/" />
8
</packageSources>
9
</configuration>
10
Copied!
Next use the NuGet package manager to add RevDeBug dependencies by adding the following NuGet packages:
After searching for a RevDeBug package, select both:
  • For .NET Core application:
    • RevDeBug.Net.Compilers.Toolset
    • RevDeBugAPM.Agent.AspNetCore
  • For .NET Framework application:
    • RevDeBug.Net.Compilers.Toolset
    • RevDeBugAPM.Agent.AspNet

Configure the connection to RevDeBug Monitor

Add Directory.Build.props file on solution level
Directory.Build.props
1
<Project>
2
<PropertyGroup Condition="'$(RevDeBugDisableNuget)' != 'true'">
3
<RevDeBugActive>true</RevDeBugActive>
4
<UseRevDeBugOnThisProject>true</UseRevDeBugOnThisProject>
5
<RevDeBugStateStorageType>CrashRecorder</RevDeBugStateStorageType>
6
<SendToServer>true</SendToServer>
7
<RecorderAddress>127.0.0.1</RecorderAddress>
8
<RecorderTCPPort>42734</RecorderTCPPort>
9
<RevDeBugForceTLS>false</RevDeBugForceTLS>
10
<ImportGitInfo>true</ImportGitInfo>
11
</PropertyGroup>
12
<PropertyGroup Condition="'$(TargetFrameworkIdentifier)' != '.NETFramework'">
13
<isNetCore>true</isNetCore>
14
</PropertyGroup>
15
</Project>
Copied!
There are several configurable fields:
  • RecorderTCPPort - Default port to connect to RevDeBug DevOps Monitor.
  • RecorderAddress - Here you have to enter the IP address or hostname of the recording servers (if you are using Docker, use Ifconfig command to get an IP address).
  • RevDeBugForceTLS - Forces TLS connection with the server. Set this to true if your RevDeBug DevOps Monitor instance has been configured to work with a SSL certificate.
  • RevDeBugUseWarningOnFailedSend - Replaces error messages with warnings for metadata transfer process. Useful for non-mandatory builds.
Both these fields are used to connect to the data repository. In most cases, it is a RevDeBug server - a place to store recordings.
  • RevDeBugActive - Fast way to disable revdebug on your solution.
  • RevDeBugStateStorageType - this field is crucial for application performance. There are three values that you can use here:
    • Continuous - means that your application will be permanently connected to the RevDeBug server. Even if you select standby or emergency recording mode, the application will be connected. It will not stream data, but there will be a slight decrease in performance.
    • OnEvent - works on the contrary. The application connects to the RevDeBug server only for a specific event. And this event must come from the application. For example, a failure or a particular method or object you want to record.
    • Noop - this field is handy when you want to connect to the RevDeBug server only in case of an emergency, or you care about performance. For example, you can build your application with RevDeBug, prepare all events that should be recorded, but until you change this setting, nothing will be recorded.

RevDeBug Compiler Tools behaviour modifiers

You can use these settings to modify how RevDebug Compiler Tools (RCT) will transform your application code. By default all modifiers are active. To turn off a behaviour, you have to set a corresponding MSBuild property to false. If you want to change the behaviour for all projects, add the property modification to your Directory.Build.props file. If you want to change the behaviour for one project only or for a selected group of projects, add the property modification directly to your project MSBuild file/files or to *.user* file of that/those projects.
Available modifiers:
  • RevDeBugHttpClientHandlerInject - used with ASP .NET (legacy) projects only. If this modifier is active, RCT will inject HttpClient wrappers into your project, which will allow our APM agent to track HttpClient calls from your code. Default value: false.
  • RevDeBugStoreInject - if this modifier is active, RCT will inject internal tracking points and will create RevDeBug metadata. If you turn this modifier off, you won’t be able to create recordings or track exceptions with RevDebug Monitor. Default value: true.

Configure tracing

Add skyapm.json to startup project and make sure its copied to output directory
skyapm.json
1
{
2
"SkyWalking": {
3
"ServiceName": "ServiceName",
4
"Namespace": "",
5
"HeaderVersions": [
6
"sw8"
7
],
8
"Sampling": {
9
"SamplePer3Secs": -1,
10
"Percentage": -1.0
11
},
12
"Logging": {
13
"Level": "Information",
14
"FilePath": "logs\\skyapm-{Date}.log"
15
},
16
"Transport": {
17
"Interval": 3000,
18
"ProtocolVersion": "v8",
19
"QueueSize": 30000,
20
"BatchSize": 3000,
21
"gRPC": {
22
"Servers": "[address]:11800",
23
"Timeout": 10000,
24
"ConnectTimeout": 10000,
25
"ReportTimeout": 600000,
26
"ForceTLS": false
27
}
28
}
29
}
30
}
31
Copied!
and set [address] to point to your record server instance. If your RevDeBug DevOps Monitor instance has been configured to work with a SSL certificate, set ForceTLS to true.
IMPORTANT NOTE: When you run ASP.NET Core application set environment variable ASPNETCORE_HOSTINGSTARTUPASSEMBLIES to RevDeBugAPM.Agent.AspNetCore

RevDeBug agent configuration using WebConfig

It is possible to configure selected revdebug agent options using the WebConfig file. At this moment we can change the following settings:
  • AgentActive - The option responsible for activating and deactivating the RevDeBug agent
  • ServiceInstanceName - Name of the application instance displayed in RevDeBug
1
<configuration>
2
<configSections>
3
<section name="revDeBugConfigs" type="SkyApm.Agent.AspNet.Configuration.AgentConfigsSection" />
4
</configSections>
5
<revDeBugConfigs agentActive="true" serviceInstanceName="servicename" />
6
</configuration>
Copied!