Skip to content

Commit

Permalink
set tags early as possible
Browse files Browse the repository at this point in the history
  • Loading branch information
TheAngryByrd committed Feb 24, 2023
1 parent 2d8045c commit 1c67dcc
Showing 1 changed file with 15 additions and 14 deletions.
29 changes: 15 additions & 14 deletions src/FsAutoComplete.Core/Utils.fs
Original file line number Diff line number Diff line change
Expand Up @@ -837,6 +837,7 @@ module Tracing =
open System.Diagnostics
open FsOpenTelemetry
open StreamJsonRpc
open System.Collections.Generic

module SemanticConventions =
/// <remarks>
Expand Down Expand Up @@ -882,20 +883,20 @@ module Tracing =
type StreamJsonRpcTracingStrategy(activitySource: ActivitySource) =
interface IActivityTracingStrategy with
member this.ApplyInboundActivity(request: Protocol.JsonRpcRequest) : IDisposable =

let activity = activitySource.StartActivity(request.Method)

activity
.SetTagSafe("rpc.system", "jsonrpc")
.SetTagSafe("rpc.jsonrpc.argumentNames", String.Join(',', request.ArgumentNames))
.SetTagSafe("rpc.jsonrpc.is_notification", request.IsNotification)
.SetTagSafe("rpc.jsonrpc.is_response_expected", request.IsResponseExpected)
.SetTagSafe("rpc.jsonrpc.version", request.Version)
.SetTagSafe("rpc.jsonrpc.request_id", request.RequestId)
.SetTagSafe("rpc.method", request.Method)
|> ignore

activity.TraceStateString <- request.TraceState
let tags =
[
"rpc.system", box "jsonrpc"
"rpc.jsonrpc.is_notification", box request.IsNotification
"rpc.jsonrpc.is_response_expected", box request.IsResponseExpected
"rpc.jsonrpc.version", box request.Version
"rpc.jsonrpc.request_id", box request.RequestId
"rpc.method", box request.Method
]
|> Seq.map KeyValuePair

let activity = activitySource.StartActivity(ActivityKind.Server, name = request.Method, tags = tags)
if activity <> null then
activity.TraceStateString <- request.TraceState

if request.TraceParent <> null then
activity.SetParentId(request.TraceParent) |> ignore
Expand Down

0 comments on commit 1c67dcc

Please sign in to comment.