Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

More OpenTelemetry changes #18246

Merged
merged 16 commits into from
Feb 10, 2025
Prev Previous commit
Next Next commit
declutter StackGuard.Guard traces
majocha committed Jan 17, 2025
commit 06639288c8036b375b39f941ddae41c9a72d7e2b
22 changes: 11 additions & 11 deletions src/Compiler/Facilities/DiagnosticsLogger.fs
Original file line number Diff line number Diff line change
@@ -875,17 +875,17 @@ type StackGuard(maxDepth: int, name: string) =
[<CallerFilePath; Optional; DefaultParameterValue("")>] path: string,
[<CallerLineNumber; Optional; DefaultParameterValue(0)>] line: int
) =
use _ =
Activity.start
"DiagnosticsLogger.StackGuard.Guard"
[|
Activity.Tags.stackGuardName, name
Activity.Tags.stackGuardCurrentDepth, string depth
Activity.Tags.stackGuardMaxDepth, string maxDepth
Activity.Tags.callerMemberName, memberName
Activity.Tags.callerFilePath, path
Activity.Tags.callerLineNumber, string line
|]

Activity.logEvent
"DiagnosticsLogger.StackGuard.Guard"
[|
Activity.Tags.stackGuardName, name
Activity.Tags.stackGuardCurrentDepth, string depth
Activity.Tags.stackGuardMaxDepth, string maxDepth
Activity.Tags.callerMemberName, memberName
Activity.Tags.callerFilePath, path
Activity.Tags.callerLineNumber, string line
|]

depth <- depth + 1

10 changes: 8 additions & 2 deletions src/Compiler/Utilities/Activity.fs
Original file line number Diff line number Diff line change
@@ -7,6 +7,7 @@ open System.Diagnostics
open System.IO
open System.Text
open Internal.Utilities.Library
open System.Collections.Generic


module ActivityNames =
@@ -102,12 +103,17 @@ module internal Activity =

let startNoTags (name: string) : IDisposable = activitySource.StartActivity name

let addEvent name =
let logEvent name (tags: (string * obj) seq) =
match Activity.Current with
| null -> ()
| activity when activity.Source = activitySource -> activity.AddEvent(ActivityEvent name) |> ignore
| activity when activity.Source = activitySource ->
let collection = tags |> Seq.map KeyValuePair |> ActivityTagsCollection
let event = new ActivityEvent(name, tags = collection)
activity.AddEvent event |> ignore
| _ -> ()

let addEvent name = logEvent name Seq.empty

module Profiling =

module Tags =
2 changes: 2 additions & 0 deletions src/Compiler/Utilities/Activity.fsi
Original file line number Diff line number Diff line change
@@ -45,6 +45,8 @@ module internal Activity =

val addEvent: name: string -> unit

val logEvent: name: string -> tags: (string * obj) seq -> unit

module Profiling =
val startAndMeasureEnvironmentStats: name: string -> IDisposable
val addConsoleListener: unit -> IDisposable