Small util library to work with app insights library
Adjust all telemetry with role name. Helps to search in metrics
To register it just add the following code when you are building your service provider
services.AddSingleton<ITelemetryInitializer>(new ServiceNameInitializer(<RoleName>));
Prevents metrics, which match the specified condition, to be sample on the client-side To register it just add the following code when you are building your service provider
services.AddSingleton<ITelemetryInitializer>(
new AvoidSamplingTelemetryInitializer(
t => t is RequestTelemetry telemetry && telemetry.Name == operationName))
Just a small convenient wrapper around AvoidSamplingTelemetryInitializer
services.AddSingleton<ITelemetryInitializer>(
new AvoidRequestSamplingTelemetryInitializer(operationName))
Executes operations as RequestTelemetry
Usage
await telemetryClient.ExecuteAsRequestAsync(new ExecuteAsRequestAsyncOptions(operationName, func));
Action<IOperationHolder<RequestTelemetry>>? Configure
- if more telemetry details need to be added. Is called right before operations itselfint? FlushWait
- time for telemetry to be pushed. Usefull for console apps. In secondss - default 15Action? PostExecute
- is called after an operation just before operation.Dispose(). That means logs will still be attached to the RequestTelemetry and method execution time will be included
Enrich telemetry with response content to dependency http requests.
services.AddSingleton<ITelemetryInitializer>(
new HttpResponseTelemetryInitializer(
c => c.StatusCode >= HttpStatusCode.BadRequest))