-
Notifications
You must be signed in to change notification settings - Fork 159
Fix OTLP HTTP/protobuf export failures and improve OTLP integration test reliability #8449
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
Changes from all commits
883d2b6
193934c
8fcf313
0a35130
9129db4
e102afe
cffedfa
6b4a632
32d2ea4
e80e6ec
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -250,10 +250,17 @@ not null when string.Equals(x, "http/protobuf", StringComparison.OrdinalIgnoreCa | |
| }, | ||
| validator: null); | ||
|
|
||
| var otlpGeneralProtocolName = OtlpGeneralProtocol switch | ||
| { | ||
| OtlpProtocol.Grpc => "grpc", | ||
| OtlpProtocol.HttpProtobuf => "http/protobuf", | ||
| _ => "grpc", | ||
| }; | ||
|
Comment on lines
+253
to
+258
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Unsure if these changes are needed TBH will double check again
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah yeah so the issue here was that in tests we only set and that we weren't setting the metric/logs specific protocol so that when we ran the tests instead of running with http/protobuf they actually ran grpc Also the OpenTelemetry spec says (right at the top):
https://opentelemetry.io/docs/specs/otel/protocol/exporter/#configuration-options
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can confirm, this new logic is correct 👍🏼 |
||
|
|
||
| OtlpMetricsProtocol = config | ||
| .WithKeys(ConfigurationKeys.OpenTelemetry.ExporterOtlpMetricsProtocol) | ||
| .GetAs( | ||
| defaultValue: new(OtlpProtocol.Grpc, "grpc"), | ||
| defaultValue: new(OtlpGeneralProtocol, otlpGeneralProtocolName), | ||
| converter: x => x switch | ||
| { | ||
| not null when string.Equals(x, "grpc", StringComparison.OrdinalIgnoreCase) => OtlpProtocol.Grpc, | ||
|
|
@@ -312,7 +319,7 @@ not null when string.Equals(x, "lowmemory", StringComparison.OrdinalIgnoreCase) | |
| OtlpLogsProtocol = config | ||
| .WithKeys(ConfigurationKeys.OpenTelemetry.ExporterOtlpLogsProtocol) | ||
| .GetAs( | ||
| defaultValue: new(OtlpProtocol.Grpc, "grpc"), | ||
| defaultValue: new(OtlpGeneralProtocol, otlpGeneralProtocolName), | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
For users who set only Useful? React with 👍 / 👎. |
||
| converter: x => x switch | ||
| { | ||
| not null when string.Equals(x, "grpc", StringComparison.OrdinalIgnoreCase) => OtlpProtocol.Grpc, | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -126,11 +126,13 @@ public override async Task<ExportResult> ExportAsync(IReadOnlyList<MetricPoint> | |
| } | ||
|
|
||
| /// <summary> | ||
| /// Shuts down the exporter and ensures all pending exports complete. | ||
| /// Releases the exporter's HTTP resources. The final export already ran | ||
| /// synchronously in MetricReader.StopAsync and is bounded by the HTTP | ||
| /// request timeout (OTEL_EXPORTER_OTLP_METRICS_TIMEOUT), so there is | ||
| /// nothing further to wait on here. | ||
| /// </summary> | ||
| /// <param name="timeoutMilliseconds">Maximum time to wait for shutdown</param> | ||
| /// <returns>True if shutdown completed successfully, false otherwise</returns> | ||
| public override bool Shutdown(int timeoutMilliseconds) | ||
| public override bool Shutdown() | ||
| { | ||
| try | ||
| { | ||
|
|
@@ -146,7 +148,7 @@ public override bool Shutdown(int timeoutMilliseconds) | |
|
|
||
| /// <summary> | ||
| /// Creates an HttpClient with Unix Domain Socket support if the endpoint uses unix:// scheme. | ||
| /// For TCP/IP endpoints (http:// or https://), creates a standard HttpClient with HTTP/2. | ||
| /// For TCP/IP endpoints (http:// or https://), creates a standard HttpClient. | ||
| /// </summary> | ||
| private static HttpClient CreateHttpClient(Uri endpoint) | ||
| { | ||
|
|
@@ -168,11 +170,7 @@ private static HttpClient CreateHttpClient(Uri endpoint) | |
| } | ||
| }; | ||
|
|
||
| return new HttpClient(handler) | ||
| { | ||
| DefaultRequestVersion = HttpVersion.Version20, | ||
| DefaultVersionPolicy = HttpVersionPolicy.RequestVersionOrHigher | ||
| }; | ||
| return new HttpClient(handler); | ||
|
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I couldn't find any documentation / reason why it had to be HTTP/2 so I think this is fine, but feel free to request it to be reverted.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this could be because gRPC requires HTTP/2 🤔 But standard HTTP certainly shouldn't. So maybe we need to condition the client on that? (assuming this client is actually used in the grpc code path)
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah gRPC pins to 2 here I've assumed that takes affect as there aren't test failures there so I think that is good enough |
||
| } | ||
|
|
||
| // Standard TCP/IP endpoint | ||
|
|
@@ -181,11 +179,7 @@ private static HttpClient CreateHttpClient(Uri endpoint) | |
| AutomaticDecompression = DecompressionMethods.GZip | DecompressionMethods.Deflate | ||
| }; | ||
|
|
||
| return new HttpClient(tcpHandler) | ||
| { | ||
| DefaultRequestVersion = HttpVersion.Version20, | ||
| DefaultVersionPolicy = HttpVersionPolicy.RequestVersionOrHigher | ||
| }; | ||
| return new HttpClient(tcpHandler); | ||
| } | ||
|
|
||
| private async Task<bool> SendOtlpRequest(IReadOnlyList<MetricPoint> metrics) | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The removal of
System.Net.HttpVersionappears to be due to the removal ofDefaultRequestVersion = HttpVersion.Version20andDefaultVersionPolicy = HttpVersionPolicy.RequestVersionOrHigher