.NET installation instructions
Use the installation instructions below if you're installing Helios in a standard .NET service.
Configuring a trace provider
The first step when instrumenting your .NET service is configuring a trace provider to send traces to the Helios backend.
Start by installing the OpenTelemetry dependencies.
From your project's root directory run:
dotnet add package OpenTelemetry.Exporter.OpenTelemetryProtocol
dotnet add package OpenTelemetry.Extensions.Hosting --prerelease
dotnet add package OpenTelemetry.Instrumentation.AspNetCore --prerelease
Note that the --prerelease
flag is required for all instrumentation packages because they are all pre-release.
This will also install the OpenTelemetry
package.
Now you can define the trace provider by using:
public void ConfigureServices(IServiceCollection services)
{
// ...
services.AddOpenTelemetryTracing(
(builder) => builder
.SetResourceBuilder(ResourceBuilder.CreateDefault()
.AddService("<YOUR-SERVICE-NAME-GOES-HERE>")
.AddAttributes(new Dictionary<string, object>
{
["deployment.environment"] = "<ENVIRONMENT-NAME>"
}))
.AddOtlpExporter(o =>
{
o.Endpoint = new Uri("https://collector.heliosphere.io/traces");
o.Headers = "Authorization=<YOUR HELIOS TOKEN GOES HERE>";
o.Protocol = OtlpExportProtocol.HttpProtobuf;
})
.AddAspNetCoreInstrumentation() // adding instrumentation of incoming web requests
);
}
For more information about automatic and manual instrumentation with .NET see the Opentelemetry documentation.
Using instrumentation libraries
In order to generate telemetry data for a particular instrumented library you can use instrumentation libraries. For example, the instrumentation library for ASP.NET Core will automatically create spans based on the inbound HTTP requests.
Each instrumentation library is a NuGet package, and installing them is typically done like so:
dotnet add package OpenTelemetry.Instrumentation.{library-name-or-type}
You can then register it when creating the TraceProvider:
public void ConfigureServices(IServiceCollection services)
{
// ...
services.AddOpenTelemetryTracing(
(builder) => builder
.SetResourceBuilder(...)
.AddAspNetCoreInstrumentation()
.AddHttpClientInstrumentation() // Http client instrumentation for outgoing HTTP calls
.AddOtlpExporter(o => { ... })
);
}
All set
After setup is complete and once the service is up and running, it will show up in the Helios application.
Updated about 1 month ago