File tree 8 files changed +66
-15
lines changed
tests/FSharp.Test.Utilities
8 files changed +66
-15
lines changed Original file line number Diff line number Diff line change @@ -882,17 +882,17 @@ type StackGuard(maxDepth: int, name: string) =
882
882
[<CallerFilePath; Optional; DefaultParameterValue( " " ) >] path : string ,
883
883
[<CallerLineNumber; Optional; DefaultParameterValue( 0 ) >] line : int
884
884
) =
885
- use _ =
886
- Activity.start
887
- " DiagnosticsLogger.StackGuard.Guard"
888
- [|
889
- Activity.Tags.stackGuardName, name
890
- Activity.Tags.stackGuardCurrentDepth, string depth
891
- Activity.Tags.stackGuardMaxDepth, string maxDepth
892
- Activity.Tags.callerMemberName, memberName
893
- Activity.Tags.callerFilePath, path
894
- Activity.Tags.callerLineNumber, string line
895
- |]
885
+
886
+ Activity.addEventWithTags
887
+ " DiagnosticsLogger.StackGuard.Guard"
888
+ ( seq {
889
+ Activity.Tags.stackGuardName, box name
890
+ Activity.Tags.stackGuardCurrentDepth, depth
891
+ Activity.Tags.stackGuardMaxDepth, maxDepth
892
+ Activity.Tags.callerMemberName, memberName
893
+ Activity.Tags.callerFilePath, path
894
+ Activity.Tags.callerLineNumber, line
895
+ })
896
896
897
897
depth <- depth + 1
898
898
Original file line number Diff line number Diff line change @@ -7,6 +7,7 @@ open System.Diagnostics
7
7
open System.IO
8
8
open System.Text
9
9
open Internal.Utilities .Library
10
+ open System.Collections .Generic
10
11
11
12
12
13
module ActivityNames =
@@ -102,12 +103,17 @@ module internal Activity =
102
103
103
104
let startNoTags ( name : string ) : IDisposable MaybeNull = activitySource.StartActivity name
104
105
105
- let addEvent name =
106
+ let addEventWithTags name ( tags : ( string * objnull ) seq ) =
106
107
match Activity.Current with
107
108
| null -> ()
108
- | activity when activity.Source = activitySource -> activity.AddEvent( ActivityEvent name) |> ignore
109
+ | activity when activity.Source = activitySource ->
110
+ let collection = tags |> Seq.map KeyValuePair |> ActivityTagsCollection
111
+ let event = new ActivityEvent( name, tags = collection)
112
+ activity.AddEvent event |> ignore
109
113
| _ -> ()
110
114
115
+ let addEvent name = addEventWithTags name Seq.empty
116
+
111
117
module Profiling =
112
118
113
119
module Tags =
Original file line number Diff line number Diff line change @@ -46,6 +46,8 @@ module internal Activity =
46
46
47
47
val addEvent : name : string -> unit
48
48
49
+ val addEventWithTags : name : string -> tags : ( string * objnull ) seq -> unit
50
+
49
51
module Profiling =
50
52
val startAndMeasureEnvironmentStats : name : string -> IDisposable MaybeNull
51
53
val addConsoleListener : unit -> IDisposable
Original file line number Diff line number Diff line change @@ -168,7 +168,16 @@ type FSharpXunitFramework(sink: IMessageSink) =
168
168
cleanUpTemporaryDirectoryOfThisTestRun ()
169
169
traceProvider.ForceFlush() |> ignore
170
170
traceProvider.Dispose()
171
- base .Dispose()
171
+ base .Dispose()
172
+
173
+ // Group test run under single activity, to make traces more readable.
174
+ // Otherwise this overriden method is not necessary and can be removed.
175
+ override this.CreateExecutor ( assemblyName ) =
176
+ { new XunitTestFrameworkExecutor( assemblyName, this.SourceInformationProvider, this.DiagnosticMessageSink) with
177
+ override _.RunTestCases ( testCases , executionMessageSink , executionOptions ) =
178
+ use _ = Activity.start $" {assemblyName.Name} {Runtime.InteropServices.RuntimeInformation.FrameworkDescription}" []
179
+ base .RunTestCases( testCases, executionMessageSink, executionOptions)
180
+ }
172
181
173
182
override this.CreateDiscoverer ( assemblyInfo ) =
174
183
{ new XunitTestFrameworkDiscoverer( assemblyInfo, this.SourceInformationProvider, this.DiagnosticMessageSink) with
Original file line number Diff line number Diff line change 110
110
<Private >False</Private >
111
111
</ProjectReference >
112
112
113
- <ProjectReference Include =" $(FSharpSourcesRoot)\..\vsintegration\src\FSharp.Editor\FSharp.Editor.fsproj" >
113
+ <!-- Include OTel dlls in DEBUG to allow trace collection-->
114
+ <ProjectReference Include =" $(FSharpSourcesRoot)\..\vsintegration\src\FSharp.Editor\FSharp.Editor.fsproj" Condition =" '$(Configuration)'=='Debug'" >
115
+ <Project >{65e0e82a-eace-4787-8994-888674c2fe87}</Project >
116
+ <Name >FSharp.Editor</Name >
117
+ <IncludeOutputGroupsInVSIX >ReferenceCopyLocalPathsOutputGroup%3bBuiltProjectOutputGroup%3bGetCopyToOutputDirectoryItems%3bPkgDefProjectOutputGroup%3bSatelliteDllsProjectOutputGroup%3b</IncludeOutputGroupsInVSIX >
118
+ <IncludeOutputGroupsInVSIXLocalOnly >DebugSymbolsProjectOutputGroup%3b</IncludeOutputGroupsInVSIXLocalOnly >
119
+ <Ngen >true</Ngen >
120
+ <NgenArchitecture >All</NgenArchitecture >
121
+ <NgenPriority >2</NgenPriority >
122
+ <Private >True</Private >
123
+ </ProjectReference >
124
+
125
+ <ProjectReference Include =" $(FSharpSourcesRoot)\..\vsintegration\src\FSharp.Editor\FSharp.Editor.fsproj" Condition =" '$(Configuration)'=='Release'" >
114
126
<Project >{65e0e82a-eace-4787-8994-888674c2fe87}</Project >
115
127
<Name >FSharp.Editor</Name >
116
128
<IncludeOutputGroupsInVSIX >BuiltProjectOutputGroup%3bGetCopyToOutputDirectoryItems%3bPkgDefProjectOutputGroup%3bSatelliteDllsProjectOutputGroup%3b</IncludeOutputGroupsInVSIX >
Original file line number Diff line number Diff line change @@ -7,6 +7,8 @@ open Microsoft.VisualStudio.Shell
7
7
open Microsoft.VisualStudio .Shell .Interop
8
8
open Microsoft.VisualStudio .FSharp .Editor
9
9
10
+ open FSharp.Compiler .Diagnostics
11
+
10
12
[<RequireQualifiedAccess>]
11
13
type LogType =
12
14
| Info
@@ -116,7 +118,12 @@ module Logging =
116
118
let logExceptionWithContext ( ex : Exception , context ) =
117
119
logErrorf " Context: %s \n Exception Message: %s \n Stack Trace: %s " context ex.Message ex.StackTrace
118
120
121
+ #if DEBUG
119
122
module Activity =
123
+
124
+ open OpenTelemetry.Resources
125
+ open OpenTelemetry.Trace
126
+
120
127
let listen filter =
121
128
let indent ( activity : Activity ) =
122
129
let rec loop ( activity : Activity ) n =
@@ -145,4 +152,17 @@ module Activity =
145
152
146
153
ActivitySource.AddActivityListener( listener)
147
154
155
+ let export () =
156
+ OpenTelemetry.Sdk
157
+ .CreateTracerProviderBuilder()
158
+ .AddSource( ActivityNames.FscSourceName)
159
+ .SetResourceBuilder(
160
+ ResourceBuilder
161
+ .CreateDefault()
162
+ .AddService( serviceName = " F#" , serviceVersion = " 1.0.0" )
163
+ )
164
+ .AddOtlpExporter()
165
+ .Build()
166
+
148
167
let listenToAll () = listen " "
168
+ #endif
Original file line number Diff line number Diff line change 194
194
<PackageReference Include =" Microsoft.VisualStudio.Text.UI.Wpf" Version =" $(MicrosoftVisualStudioTextUIWpfVersion)" PrivateAssets =" all" ExcludeAssets =" runtime;contentFiles;build;analyzers;native" />
195
195
<PackageReference Include =" Microsoft.VisualStudio.Threading" Version =" $(MicrosoftVisualStudioThreadingVersion)" PrivateAssets =" all" ExcludeAssets =" runtime;contentFiles;build;analyzers;native" />
196
196
<PackageReference Include =" Microsoft.VisualStudio.Validation" Version =" $(MicrosoftVisualStudioValidationVersion)" PrivateAssets =" all" ExcludeAssets =" runtime;contentFiles;build;analyzers;native" />
197
+ <PackageReference Include =" OpenTelemetry.Exporter.OpenTelemetryProtocol" Version =" 1.9.0" Condition =" '$(Configuration)' == 'Debug'" />
197
198
<PackageReference Include =" Newtonsoft.Json" Version =" $(NewtonsoftJsonVersion)" PrivateAssets =" all" ExcludeAssets =" runtime;contentFiles;build;analyzers;native" />
198
199
<PackageReference Include =" StreamJsonRpc" Version =" $(StreamJsonRpcVersion)" />
199
200
<PackageReference Include =" Nerdbank.Streams" Version =" $(NerdbankStreamsVersion)" />
Original file line number Diff line number Diff line change @@ -341,6 +341,7 @@ type internal FSharpPackage() as this =
341
341
let mutable solutionEventsOpt = None
342
342
343
343
#if DEBUG
344
+ let _traceProvider = Logging.Activity.export ()
344
345
let _logger = Logging.Activity.listenToAll ()
345
346
// Logging.Activity.listen "IncrementalBuild"
346
347
#endif
You can’t perform that action at this time.
0 commit comments