Make Debug OTLP export opt-in via FSHARP_OTEL_EXPORT - #20468
Conversation
❗ Release notes requiredYou can open this PR in browser to add release notes: open in github.dev
|
948a839 to
2581871
Compare
|
/azp run
|
|
Command 'run
`WindowsCompressedMetadata' is not supported by Azure Pipelines.
See additional documentation. |
|
/azp run |
|
Commenter does not have sufficient privileges for PR 20468 in repo dotnet/fsharp |
| "FSharpPreferAnyCpuTools": "true", | ||
| "Fsc_NetFramework_ToolPath": "$(FSharpCompilerPathForDebuggingLocally)", | ||
| "Fsc_NetFramework_AnyCpu_ToolExe": "fscAnyCpu.exe", | ||
| "FSHARP_OTEL_EXPORT": "http://127.0.0.1:4317" |
There was a problem hiding this comment.
🤖🕵️⏱️🔥
{"FSHARP_OTEL_EXPORT": ""}Default F5 must opt out. Use an explicit export profile and clear inherited values in No OTEL.
There was a problem hiding this comment.
Agreed. Flipped it: VisualFSharpDebug is now the default and explicitly clears FSHARP_OTEL_EXPORT (""), so an ambient value in the shell devenv.exe inherits from can't leak through either. Export moved to a new, explicitly-named OTEL Export profile.
| | null | ||
| | "" -> ValueNone | ||
| | value -> | ||
| match Uri.TryCreate(value, UriKind.Absolute) with |
There was a problem hiding this comment.
🤖🕵️
$env:FSHARP_OTEL_EXPORT = 'localhost:4317'UriKind.Absolute accepts this. Require http/https and a non-empty host.
There was a problem hiding this comment.
Good catch — confirmed Uri.TryCreate("localhost:4317", UriKind.Absolute) returns true with Scheme = "localhost" and an empty Host. Added a guard requiring http/https and a non-empty host; anything else (including this case) now falls back to the default endpoint instead of being handed to the exporter.
2581871 to
d99ae87
Compare
FSharpPackage unconditionally started an OTLP trace/metric exporter against http://127.0.0.1:4317 in Debug builds. Without a collector listening there, the metric exporter retries in the background for the whole session and Dispose blocks on a 5s ForceFlush, so closing the experimental VS instance stalls every time. otelExport now only starts the exporter when FSHARP_OTEL_EXPORT is set to an absolute http/https URI with a host - a value like "localhost:4317" parses as an absolute URI too but has no host, so it is treated the same as an empty or unparseable value and falls back to the default endpoint. The default VisualFSharpDebug launch profile clears the variable so a first F5 never surprises anyone with OTEL noise, even if it leaked in from an ambient shell environment; the new "OTEL Export" profile sets it to opt back in. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
d99ae87 to
0be8228
Compare
Problem
FSharpPackage's Debug-only constructor unconditionally starts an OTLP trace/metric exporter against a hardcodedhttp://127.0.0.1:4317. When nothing is listening there — the common case when just debugging the extension, without Jaeger/Prometheus running in a container — this is silent noise and a stall:DisposecallstracerProvider.ForceFlush(5000), so closing the experimental VS instance blocks for up to 5 seconds every time.There was no way to turn this off short of editing the source and rebuilding.
Fix
FSharpServiceTelemetry.otelExportnow only starts the OTLP exporter whenFSHARP_OTEL_EXPORTis set to an absolutehttp/httpsURI with a non-empty host. A value likelocalhost:4317parses as an absolute URI too (schemelocalhost, no host), so it's treated the same as an empty or unparseable value and falls back to the historical default endpoint rather than being handed to the exporter as-is.The default
VisualFSharpDebuglaunch profile explicitly clearsFSHARP_OTEL_EXPORT(rather than just omitting it), so a first F5 never surprises anyone with OTEL noise or the shutdown stall — including if the variable happened to be set in the ambient shell environment devenv.exe inherits from. A newOTEL Exportprofile in the samelaunchSettings.jsonsets it to opt back in — pick it from the run-button dropdown, no rebuild needed.DEVGUIDE.mddocuments the switch next to the existing F5 instructions, and the VS release notes get an entry.Testing
dotnet fantomas --checkon the changed.fsfile.1/localhost:4317→ default endpoint; a realhttp/httpsURI → used as-is) was exercised standalone viadotnet fsiagainst a stand-in copy of the logic.🤖 Generated with Claude Code