From 0dd52587f202e829bc67cf080a96a168d37f62c2 Mon Sep 17 00:00:00 2001 From: Chet Husk Date: Sun, 17 Jul 2022 10:16:26 -0500 Subject: [PATCH] first activity plumbing --- eng/Versions.props | 1 + src/Compiler/Driver/fsc.fs | 2 +- src/fsc/fsc.targets | 3 +++ src/fsc/fscmain.fs | 20 ++++++++++++++++++++ 4 files changed, 25 insertions(+), 1 deletion(-) diff --git a/eng/Versions.props b/eng/Versions.props index 6571c5fb21a..fc37e7ec09c 100644 --- a/eng/Versions.props +++ b/eng/Versions.props @@ -87,6 +87,7 @@ 4.3.0 4.3.0 4.0.0 + 5.0.1 4.3.0 4.3.0 1.6.0 diff --git a/src/Compiler/Driver/fsc.fs b/src/Compiler/Driver/fsc.fs index de5fbf9ebd8..fe7147c6c9e 100644 --- a/src/Compiler/Driver/fsc.fs +++ b/src/Compiler/Driver/fsc.fs @@ -1380,7 +1380,7 @@ let CompileFromCommandLineArguments with _ -> () } - + use mainActivity = new Activity("fcs:main") main1 ( ctok, argv, diff --git a/src/fsc/fsc.targets b/src/fsc/fsc.targets index 9e4e4e48067..7aaa9c76239 100644 --- a/src/fsc/fsc.targets +++ b/src/fsc/fsc.targets @@ -37,12 +37,15 @@ + + + diff --git a/src/fsc/fscmain.fs b/src/fsc/fscmain.fs index ebdf21af60d..3bca741c979 100644 --- a/src/fsc/fscmain.fs +++ b/src/fsc/fscmain.fs @@ -17,6 +17,10 @@ open FSharp.Compiler.Driver open FSharp.Compiler.DiagnosticsLogger open FSharp.Compiler.CodeAnalysis open FSharp.Compiler.Text +open System.Diagnostics +open OpenTelemetry +open OpenTelemetry.Resources +open OpenTelemetry.Trace [] do () @@ -24,6 +28,20 @@ do () [] let main (argv) = + use tracerProvider = + Sdk.CreateTracerProviderBuilder() + .AddSource("fsc") + .SetResourceBuilder(ResourceBuilder.CreateDefault().AddService(serviceName ="fsc", serviceVersion = "42.42.42.42")) + .AddConsoleExporter() + .Build(); + use activitySource = new ActivitySource("fsc") + use mainActivity = activitySource.StartActivity("main") + + let forceCleanup() = + mainActivity.Dispose() + activitySource.Dispose() + tracerProvider.Dispose() + let compilerName = // the 64 bit desktop version of the compiler is name fscAnyCpu.exe, all others are fsc.exe if @@ -67,6 +85,7 @@ let main (argv) = let stats = ILBinaryReader.GetStatistics() AppDomain.CurrentDomain.ProcessExit.Add(fun _ -> + forceCleanup() printfn "STATS: #ByteArrayFile = %d, #MemoryMappedFileOpen = %d, #MemoryMappedFileClosed = %d, #RawMemoryFile = %d, #WeakByteArrayFile = %d" stats.byteFileCount @@ -81,6 +100,7 @@ let main (argv) = let quitProcessExiter = { new Exiter with member _.Exit(n) = + forceCleanup() try exit n with _ ->