GraftCode.Netcore.Telemetry.AppInsightsConnector
1.0.3
See the version list below for details.
dotnet add package GraftCode.Netcore.Telemetry.AppInsightsConnector --version 1.0.3
NuGet\Install-Package GraftCode.Netcore.Telemetry.AppInsightsConnector -Version 1.0.3
<PackageReference Include="GraftCode.Netcore.Telemetry.AppInsightsConnector" Version="1.0.3" />
<PackageVersion Include="GraftCode.Netcore.Telemetry.AppInsightsConnector" Version="1.0.3" />
<PackageReference Include="GraftCode.Netcore.Telemetry.AppInsightsConnector" />
paket add GraftCode.Netcore.Telemetry.AppInsightsConnector --version 1.0.3
#r "nuget: GraftCode.Netcore.Telemetry.AppInsightsConnector, 1.0.3"
#:package GraftCode.Netcore.Telemetry.AppInsightsConnector@1.0.3
#addin nuget:?package=GraftCode.Netcore.Telemetry.AppInsightsConnector&version=1.0.3
#tool nuget:?package=GraftCode.Netcore.Telemetry.AppInsightsConnector&version=1.0.3
GraftCode App Insights Connector
Configure Application Insights for an application and Graft bridge spans with one call:
using GraftCode.Netcore.Telemetry.AppInsightsConnector;
using var telemetry = GraftCodeAppInsightsConnector.Start("MyService");
using var activity = telemetry.StartActivity("MyOperation");
telemetry.Logger.LogInformation("My operation started");
The connector reads APPLICATIONINSIGHTS_CONNECTION_STRING, exports logs and traces,
and automatically subscribes to the application's source and the Graftcode
source. An explicit connection string and additional activity sources can be configured:
using var telemetry = GraftCodeAppInsightsConnector.Start(options =>
{
options.ServiceName = "MyService";
options.ConnectionString = configuration["ApplicationInsights:ConnectionString"];
options.ActivitySourceNames.Add("MyCompany.Shared");
});
For dependency-injection applications:
services.AddGraftCodeAppInsightsConnector(options =>
{
options.ServiceName = "MyService";
});
Resolve GraftCodeAppInsightsConnectorPipeline to access its ActivitySource, Logger, and
ForceFlush() method.
For ASP.NET Core applications, register request telemetry after routing:
app.UseRouting();
app.UseGraftCodeAppInsightsConnectorRequestTelemetry();
app.MapControllers();
Each HTTP request gets a server Activity named {ServiceName}.{controller} when route
values are available, for example TestGgWebApi.Fetch. Logs and downstream bridge spans
inside the request then share the same trace automatically.
Sampling
Every trace is kept by default. Azure Monitor's own default is a rate limit of five traces per second, which drops whole traces once the budget is spent - and because unsampled traces also lose their log records, a short-lived caller that makes a single bridge call can end up reporting nothing at all while the long-running side it called reports normally.
Set TracesPerSecond to opt into rate limiting for high-volume services:
options.TracesPerSecond = 5;
Flushing
ForceFlush() covers both traces and logs, so a short-lived process should call it before
exiting. The pipeline also flushes on Dispose(), process exit, Ctrl+C, and unhandled
exceptions; telemetry is still lost when a process is killed outright, for example by
stopping a debugging session.
Diagnosing missing telemetry
IsExportingToAppInsightsConnector is false when no connection string was resolved, in which case
the connector logs a warning and telemetry stays local. This is worth asserting on startup
for services that must report, since a connection string set at machine level only reaches
processes started afterwards, and does not reach containers at all.
| 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 is compatible. 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 is compatible. 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. net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
| .NET Core | netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
| .NET Standard | netstandard2.1 is compatible. |
| MonoAndroid | monoandroid was computed. |
| MonoMac | monomac was computed. |
| MonoTouch | monotouch was computed. |
| Tizen | tizen60 was computed. |
| Xamarin.iOS | xamarinios was computed. |
| Xamarin.Mac | xamarinmac was computed. |
| Xamarin.TVOS | xamarintvos was computed. |
| Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.1
- Azure.Monitor.OpenTelemetry.Exporter (>= 1.8.3)
- Graftcode.Instrumentation (>= 1.0.3)
- Microsoft.Extensions.DependencyInjection (>= 10.0.9)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 10.0.9)
- Microsoft.Extensions.Logging (>= 10.0.9)
- Microsoft.Extensions.Logging.Console (>= 10.0.0)
- OpenTelemetry (>= 1.17.0)
-
net10.0
- Azure.Monitor.OpenTelemetry.Exporter (>= 1.8.3)
- Graftcode.Instrumentation (>= 1.0.3)
- OpenTelemetry (>= 1.17.0)
-
net8.0
- Azure.Monitor.OpenTelemetry.Exporter (>= 1.8.3)
- Graftcode.Instrumentation (>= 1.0.3)
- Microsoft.Extensions.DependencyInjection (>= 10.0.9)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 10.0.9)
- Microsoft.Extensions.Logging (>= 10.0.9)
- Microsoft.Extensions.Logging.Console (>= 10.0.0)
- OpenTelemetry (>= 1.17.0)
-
net9.0
- Azure.Monitor.OpenTelemetry.Exporter (>= 1.8.3)
- Graftcode.Instrumentation (>= 1.0.3)
- Microsoft.Extensions.DependencyInjection (>= 10.0.9)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 10.0.9)
- Microsoft.Extensions.Logging (>= 10.0.9)
- Microsoft.Extensions.Logging.Console (>= 10.0.0)
- OpenTelemetry (>= 1.17.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.