<aside> 🏎️ Download one of our sample applications to get started quickly: RailtownSamples/AppInsights at master · RailtownAI/RailtownSamples (github.com)
</aside>
First, add the ApplicationInsights.Railtown nuget package to your project. https://www.nuget.org/packages/ApplicationInsights.Railtown/
There are a number of ways of setting up Application Insights and choosing the right approach depends upon which version of .NET you are using, and how you are currently using Application Insights in your project.
Before you begin, you'll need a Railtown Key. Go to the Railtown.ai configuration page. For each of your environments, there’s a configuration section which provides the code you need to integrate railtown.ai on that environment.
<aside> đź’ˇ Treat your Railtown Key like a password - it shouldn't be checked into source control. For simplicity, many of the examples below show the Key being assigned to a local variable, but best practice would be to retrieve the key from configuration.
</aside>
You’ll see two options for Application Insights, we’re going to start with the .net framework version.
This approach assumes you are already using ApplicationInsights.config
to store your InstrumentationKey and other Application Insights configurations. If you are using a different approach, skip to the next section to see how to register the telemetry processor using an initialization class.
Inside that file, you should find an existing node called <TelemetryProcessors>
, copy the <Add>
node from the railtown.ai configuration page (as shown above) and paste it inside the existing <TelemetryProcessors>
node.
If you are not using ApplicationInsights.config
, you can follow these steps instead.
Inside a file, such as Global.asax or Program.cs, add the following to the application’s entry point (eg. Application_Start or Main):
var builder = TelemetryConfiguration.Active.DefaultTelemetrySink.TelemetryProcessorChainBuilder;
builder.Use((next) => new RailtownTelemetryProcessor(next)
{
// put the Railtown Key here (or retrieve it from configuration like web.config)
RailtownKey = ""; };
);
builder.Build();
The correct value for RailtownKey is the contents of the <RailtownKey>
node from the configuration shown at the start of the page.