-
Notifications
You must be signed in to change notification settings - Fork 819
[OTLP] Synchronous requests for HTTP calls #6235
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
…lls in .NET Framework and .NET (Core) < 5
Thank you for the contribution! We appreciate the effort to improve the OTLP Exporter. However, we’d like to avoid introducing additional complexity or options into the core Send logic of the exporter. The current design intentionally relies on asynchronous operations for performance and scalability. If there's a need to perform a synchronous export or customize the behavior (e.g., for testing or integration scenarios), the exporter already exposes an HttpClientFactory option, which can be leveraged to plug in custom HTTP handlers or logic as needed: We recommend using that extensibility point to handle such custom scenarios without modifying the core exporter logic. |
Hi @rajkumar-rangaraj thanks for the update. I must say however that, from performance benchmarks, an application on .NET Framework 4.8 is currently exhibiting markedly slower throughput (~75% less throughput) when enabling OTEL tracing. It is also exhibiting random crashes, consistent with treadpool starvation that is hallmark behaviour of sync-over-async. Would it perhaps help if I provide a .NET 4.8 MVP that replicates the scenario for further analysis and clarification? Thanks |
Hi @carlcamilleri, Thanks again for the detailed follow-up. We’d like to avoid adding synchronous logic or new configuration options to the core OTLP exporter. Maintaining a single, async-first pathway helps us ensure long-term reliability and consistency across platforms. That being said, we want to make sure your scenario is unblocked. If you could share a minimal reproducible example (MVP) that highlights the issue, we’d be happy to take a closer look and work with you on potential alternatives, such as using the HttpClientFactory extensibility point or other workarounds for .NET Framework-specific needs. Thanks again for engaging with us on this — looking forward to your MVP. |
Great thanks! I’ll provide that asap |
Hello @rajkumar-rangaraj please find an MVP here: https://github.com/carlcamilleri/opentelemetry-dotnet-mvp/ In this case the application is barebones and therefore does not generate as much data as the production application (no database calls, for example), but toggling ON/OFF OTEL still results in ~11% drop in throughput: |
This PR was marked stale due to lack of activity and will be closed in 7 days. Commenting or pushing will instruct the bot to automatically remove the label. This bot runs once per day. |
Proposed changes to perform truly synchronous calls for the HTTP protocol in .NET Framework and .NET (Core) versions less than .NET 5
Fixes #
Targets to remove the "synch-over-async" anti-pattern within
OtlExportClient
, mandated by the use ofHttpClient
. TheHttpClient
version only supports truly synchronous calls from .NET 5 upwards .This is only done for Otlp exporters over HTTP, since GRPC requests need HTTP/2, which is not supported except through the use of
HttpClient
.Changes
The main changes are:
SendHttpRequestSynchronous
inOtlpExportClient
abstract class, that performs truly synchronous requests. This method avoids the use ofHttpClient
and instead uses the (obsolete)WebRequest
.HttpResponseMessage
via the new methodCreateResponseFromWebResponse
to retain compatibility with the return type of the existingSendHttpRequest
method.CreateSynchronousRequestParams
to build the arguments forSendHttpRequestSynchronous
, equivalent to what is done inCreateHttpRequest
.OtlpHttpExportClient
such thatCreateSynchronousRequestParams
andSendHttpRequestSynchronous
are used unless running under .NET 5.0 or upwards.Merge requirement checklist
CHANGELOG.md
files updated for non-trivial changes