Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
22 changes: 18 additions & 4 deletions vsintegration/src/FSharp.Editor/Common/DebugHelpers.fs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Loading