diff --git a/vsintegration/Vsix/VisualFSharpFull/Properties/launchSettings.json b/vsintegration/Vsix/VisualFSharpFull/Properties/launchSettings.json index 5731d86cdd6..99030e1cd63 100644 --- a/vsintegration/Vsix/VisualFSharpFull/Properties/launchSettings.json +++ b/vsintegration/Vsix/VisualFSharpFull/Properties/launchSettings.json @@ -1,6 +1,21 @@ { "profiles": { "VisualFSharpDebug": { + "commandName": "Executable", + "executablePath": "$(DevEnvDir)devenv.exe", + "commandLineArgs": "/rootsuffix $(VSSDKTargetPlatformRegRootSuffix) /log", + "environmentVariables": { + "FSharpCompilerPath": "$(FSharpCompilerPathForDebuggingLocally)", + "DisableAutoSetFscCompilerPath": "true", + "FSharpPreferNetFrameworkTools": "true", + "FSharp_Shim_Present": "true", + "FSharpPreferAnyCpuTools": "true", + "Fsc_NetFramework_ToolPath": "$(FSharpCompilerPathForDebuggingLocally)", + "Fsc_NetFramework_AnyCpu_ToolExe": "fscAnyCpu.exe", + "FSHARP_OTEL_EXPORT": "http://127.0.0.1:4317" + } + }, + "No OTEL": { "commandName": "Executable", "executablePath": "$(DevEnvDir)devenv.exe", "commandLineArgs": "/rootsuffix $(VSSDKTargetPlatformRegRootSuffix) /log", diff --git a/vsintegration/src/FSharp.Editor/Common/DebugHelpers.fs b/vsintegration/src/FSharp.Editor/Common/DebugHelpers.fs index fa8303b7e60..8781a3cd1b1 100644 --- a/vsintegration/src/FSharp.Editor/Common/DebugHelpers.fs +++ b/vsintegration/src/FSharp.Editor/Common/DebugHelpers.fs @@ -136,10 +136,19 @@ module FSharpServiceTelemetry = open OpenTelemetry.Trace open OpenTelemetry.Metrics - let otelExport () = - // On Windows forwarding localhost to wsl2 docker container sometimes does not work. Use IP address instead. - let otlpEndpoint = Uri("http://127.0.0.1:4317") - + // Nothing listening on the endpoint means an exporter retrying in the background and a 5s flush + // on shutdown, so exporting is opt-in: FSHARP_OTEL_EXPORT enables it and can carry the endpoint. + let private otelEndpoint = + match Environment.GetEnvironmentVariable "FSHARP_OTEL_EXPORT" with + | null + | "" -> ValueNone + | value -> + match Uri.TryCreate(value, UriKind.Absolute) with + | true, uri -> ValueSome uri + // On Windows forwarding localhost to wsl2 docker container sometimes does not work. Use IP address instead. + | _ -> ValueSome(Uri "http://127.0.0.1:4317") + + let private startOtelExport (otlpEndpoint: Uri) = let meterProvider = // Configure OpenTelemetry metrics. Metrics can be viewed in Prometheus or other compatible tools. OpenTelemetry.Sdk @@ -170,5 +179,10 @@ module FSharpServiceTelemetry = tracerProvider.Dispose() meterProvider.Dispose() + let otelExport () = + match otelEndpoint with + | ValueNone -> ignore + | ValueSome endpoint -> startOtelExport endpoint + let listenToAll () = listen "" #endif