@@ -6,113 +6,15 @@ open System
66open System.Diagnostics
77open System.Diagnostics .Tracing
88
9- module Activity =
10-
11- type ActivityFacade ( activity : Activity option ) =
12- member this.AddTag key ( value : #obj ) = match activity with | Some activity -> activity.AddTag( key, value) |> ignore | None -> ()
13- member this.Perform action = match activity with | Some activity -> action activity | None -> ()
14- member this.Dispose () = match activity with | Some activity -> activity.Dispose() | None -> ()
15- interface IDisposable with
16- member this.Dispose () = this.Dispose()
17-
18- let start ( source : ActivitySource ) ( activityName : string ) ( tags : ( string * #obj ) seq ) =
19- let activity = source.StartActivity( activityName) |> Option.ofObj
20- let facade = new ActivityFacade( activity)
21- for key, value in tags do
22- facade.AddTag key value
23- facade
24-
25- let startNoTags ( source : ActivitySource ) ( activityName : string ) = start source activityName []
26-
27- type ActivitySourceFacade ( source : ActivitySource ) =
28- member this.Start ( name : string ) ( tags : ( string * #obj ) seq ) = start source name tags
29- member this.StartNoTags name = startNoTags source name
30- member this.Name = source.Name
31- member this.Dispose () = source.Dispose()
32- interface IDisposable with
33- member this.Dispose () = this.Dispose()
34-
35- let private activitySourceName = " fsc"
36- let private activitySource = new ActivitySource( activitySourceName)
37- let instance = new ActivitySourceFacade( activitySource)
38-
39- type LogCompilerFunctionId =
40- | Service_ ParseAndCheckFileInProject = 1
41- | Service_ CheckOneFile = 2
42- | Service_ IncrementalBuildersCache_ BuildingNewCache = 3
43- | Service_ IncrementalBuildersCache_ GettingCache = 4
44- | CompileOps_ TypeCheckOneInputAndFinishEventually = 5
45- | IncrementalBuild_ CreateItemKeyStoreAndSemanticClassification = 6
46- | IncrementalBuild_ TypeCheck = 7
47-
48- /// This is for ETW tracing across FSharp.Compiler.
49- [<Sealed; EventSource( Name = " FSharpCompiler" ) >]
50- type FSharpCompilerEventSource () =
51- inherit EventSource()
52-
53- static let instance = new FSharpCompilerEventSource()
54- static member Instance = instance
55-
56- [<Event( 1 ) >]
57- member this.Log ( functionId : LogCompilerFunctionId ) =
58- if this.IsEnabled() then this.WriteEvent( 1 , int functionId)
59-
60- [<Event( 2 ) >]
61- member this.LogMessage ( message : string , functionId : LogCompilerFunctionId ) =
62- if this.IsEnabled() then
63- this.WriteEvent( 2 , message, int functionId)
64-
65- [<Event( 3 ) >]
66- member this.BlockStart ( functionId : LogCompilerFunctionId ) =
67- if this.IsEnabled() then this.WriteEvent( 3 , int functionId)
68-
69- [<Event( 4 ) >]
70- member this.BlockStop ( functionId : LogCompilerFunctionId ) =
71- if this.IsEnabled() then this.WriteEvent( 4 , int functionId)
72-
73- [<Event( 5 ) >]
74- member this.BlockMessageStart ( message : string , functionId : LogCompilerFunctionId ) =
75- if this.IsEnabled() then
76- this.WriteEvent( 5 , message, int functionId)
77-
78- [<Event( 6 ) >]
79- member this.BlockMessageStop ( message : string , functionId : LogCompilerFunctionId ) =
80- if this.IsEnabled() then
81- this.WriteEvent( 6 , message, int functionId)
82-
839[<RequireQualifiedAccess>]
84- module Logger =
85-
86- let Log functionId =
87- FSharpCompilerEventSource.Instance.Log( functionId)
88-
89- let LogMessage message functionId =
90- FSharpCompilerEventSource.Instance.LogMessage( message, functionId)
91-
92- let LogBlockStart functionId =
93- FSharpCompilerEventSource.Instance.BlockStart( functionId)
94-
95- let LogBlockStop functionId =
96- FSharpCompilerEventSource.Instance.BlockStop( functionId)
97-
98- let LogBlockMessageStart message functionId =
99- FSharpCompilerEventSource.Instance.BlockMessageStart( message, functionId)
100-
101- let LogBlockMessageStop message functionId =
102- FSharpCompilerEventSource.Instance.BlockMessageStop( message, functionId)
103-
104- let LogBlock functionId =
105- FSharpCompilerEventSource.Instance.BlockStart( functionId)
10+ module Activity =
10611
107- { new IDisposable with
108- member _.Dispose () =
109- FSharpCompilerEventSource.Instance.BlockStop( functionId)
110- }
12+ let private activitySource = new ActivitySource( " fsc" )
11113
112- let LogBlockMessage message functionId =
113- FSharpCompilerEventSource.Instance.BlockMessageStart( message, functionId)
14+ let Start name ( tags :( string * #obj ) seq ) : IDisposable =
15+ let act = activitySource.StartActivity( name)
16+ for key, value in tags do
17+ act.AddTag( key, value) |> ignore
18+ act
11419
115- { new IDisposable with
116- member _.Dispose () =
117- FSharpCompilerEventSource.Instance.BlockMessageStop( message, functionId)
118- }
20+ let StartNoTags name : IDisposable = activitySource.StartActivity( name)
0 commit comments