Last active
April 1, 2021 15:05
-
-
Save orient-man/c75b7b4e7d76705c6a51931d9b08e232 to your computer and use it in GitHub Desktop.
Set ApplicationInsights RequestTelemetry operation name suitable for grouping (just like https://github.com/Microsoft/ApplicationInsights-aspnetcore/blob/ead65975f0fa27650b40983265bad05fdea16a95/src/Microsoft.ApplicationInsights.AspNetCore/DiagnosticListeners/Implementation/MvcDiagnosticsListener.cs#L38)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Giraffe.ApplicationInsights | |
open Giraffe | |
open Microsoft.ApplicationInsights.DataContracts | |
let private setRoutingMetadata action : HttpHandler = | |
fun next ctx -> | |
let action' = ctx.Request.Method + " " + action | |
ctx.Request.RouteValues.["controller"] <- "Giraffe" | |
ctx.Request.RouteValues.["action"] <- action' | |
let telemetry = ctx.Features.Get<RequestTelemetry>() | |
if not <| isNull telemetry then telemetry.Name <- action' | |
next ctx | |
let routef (path: PrintfFormat<_,_,_,_, 'T>) (routeHandler: 'T -> HttpHandler) : HttpHandler = | |
setRoutingMetadata path.Value >=> (routef path routeHandler) | |
let route (path: string) : HttpHandler = | |
setRoutingMetadata path >=> (route path) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment