Skip to content
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

HttpClient: Invoke Enrich when SocketException = HostNotFound #3407

Merged

Conversation

alanwest
Copy link
Member

Fixes #3406.

@alanwest alanwest requested a review from a team June 24, 2022 19:27
@codecov
Copy link

codecov bot commented Jun 24, 2022

Codecov Report

Merging #3407 (d989284) into main (b7a3a83) will decrease coverage by 0.18%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #3407      +/-   ##
==========================================
- Coverage   86.39%   86.21%   -0.19%     
==========================================
  Files         258      258              
  Lines        9259     9254       -5     
==========================================
- Hits         7999     7978      -21     
- Misses       1260     1276      +16     
Impacted Files Coverage Δ
...tp/Implementation/HttpHandlerDiagnosticListener.cs 73.17% <100.00%> (+4.20%) ⬆️
...entation/ExportClient/OtlpGrpcTraceExportClient.cs 50.00% <0.00%> (-28.58%) ⬇️
...xporter.OpenTelemetryProtocol/OtlpTraceExporter.cs 59.09% <0.00%> (-18.19%) ⬇️
...tation/OpenTelemetryProtocolExporterEventSource.cs 85.00% <0.00%> (-15.00%) ⬇️
...porter.OpenTelemetryProtocol/OtlpMetricExporter.cs 72.72% <0.00%> (-13.64%) ⬇️
...metryProtocol/Implementation/ActivityExtensions.cs 91.20% <0.00%> (-3.30%) ⬇️
...Telemetry/Internal/SelfDiagnosticsEventListener.cs 96.87% <0.00%> (-0.79%) ⬇️

Copy link
Member

@cijothomas cijothomas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM with a changelog entry as this is user facing change

}
}

if (exc.InnerException != null)
else if (exc.InnerException != null)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The flow seems a bit weird. Consider moving the exc.InnerException is SocketException exception check inside exc.InnerException != null?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yup.
Also there is no need of a Switch case... as there is a single check..

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So I moved the check, because I agree the else if was wonky. Though, yes as the code currently stands, there's zero need to explicitly check for the SocketException. It seems there was once some thought that we'd set the status description differently based on the type of exception, but clearly that was not actually happening in practice. So I guess I don't know what the original intent was here 😆.

I'll see if the history can shed any light on this...

Copy link
Member Author

@alanwest alanwest Jun 24, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah ha ok, all of this dates back to the time that Span.Status was more than just OK, ERROR, or UNSET

if (exc is HttpRequestException)
{
if (exc.InnerException is SocketException exception)
{
switch (exception.SocketErrorCode)
{
case SocketError.HostNotFound:
activity.SetStatus(Status.InvalidArgument.WithDescription(exc.Message));
return;
}
}
if (exc.InnerException != null)
{
activity.SetStatus(Status.Unknown.WithDescription(exc.Message));
}
}

I simplified it here 0cb81ea.

But still raises some questions... should we not be setting the status to ERROR when the exception is not an HttpRequestException?

{
activity.SetStatus(Status.Error.WithDescription(exc.Message));
}
activity.SetStatus(Status.Error.WithDescription(exc.Message));
Copy link
Member Author

@alanwest alanwest Jun 24, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess this kind of broadens the scope where we record an error status + description to also include HttpRequestException where InnerException is null... seems kinda odd we'd limit it in this way.

@cijothomas cijothomas merged commit 98b4fde into open-telemetry:main Jun 24, 2022
@alanwest alanwest deleted the alanwest/http-client-onexception branch June 24, 2022 21:04
alanwest added a commit that referenced this pull request Jun 27, 2022
* Added Jaeger Propagator to Opentelemetry.Extensions.Propagators (#3309)

* Remove unnecessary bullet in CHANGELOG.md (#3352)

Co-authored-by: Cijo Thomas <cithomas@microsoft.com>

* Fix OTLP test (#3357)

* Show that test is not doing what you might think it does

* More asserts the merrier

* Show this little test that it has potential

* improve test coverage: InMemoryExporter & IDeferredMeterProviderBuilder (#3345)

* [SDK] Circular buffer tweaks + cpu pressure test (#3349)

* CircularBuffer tweaks and cpu pressure test.

* Switch to Volatile.Read.

* Perf tweaks.

* Remove race check in debug after doing more testing.

Co-authored-by: Cijo Thomas <cithomas@microsoft.com>

* Fix event name logic + support null categoryname. (#3359)

* In-memory Exporter: Buffer log scopes (#3360)

* Buffer log scopes when using in-memory exporter.

* CHANGELOG update.

* Code review.

* Tests.

* CHANGELOG tweak.

* SDK: Forward SetParentProvider to children of CompositeProcessor (#3368)

* Examples: Fix ParentProvider not being set on MyFilteringProcessor (#3370)

* Fix ParentProvider not being set on MyFilteringProcessor example.

* Added XML comments.

* Tweak.

* Typo.

* Logs: Add helper ctors & forceflush on OpenTelemetryLoggerProvider (#3364)

* Add helper ctors & forceflush on OpenTelemetryLoggerProvider.

* CHANGELOG update.

* Unit tests.

* Code review.

* Code review.

* Tweak.

* SDK: Nullable annotations for base classes & batch + shims to enable compiler features (#3374)

* Nullable annotations and shims for SDK base classes & batch.

* Target updates.

* Remove System.Collections.Immutable ref.

* ApiCompat attribute exclusions.

* ASPNETCore instrumentation to populate httpflavor tag (#3372)

* improve test coverage: InMemoryExporter SnapshotMetric (#3344)

* Fix AspNetCore metrics to use correct value for http.flavor (#3379)

* Fix AspNetCore metrics to use correct value for http.flavor

* word better

* Logs: Add LogRecordData (#3378)

* Add LogRecordData and hook up to LogRecord.

* CHANGELOG update.

* Code review.

* Remove SetHttpFlavor from Http instrumentations (#3381)

* Asp.Net Core trace instrumentation to populate http schema tag (#3392)

* Try asp.net core tests with inproc server (#3394)

* Dedupe IsPackable (#3398)

* Remove AspNet and AspNet.TelemetryHttpModule instrumentation projects (#3397)

* Handle possible exception when initializing the default service name (#3405)

* HttpClient: Invoke Enrich when SocketException = HostNotFound (#3407)

* Add & use ConfigureResource API. (#3307)

Co-authored-by: tyler jago <ty_bone11@hotmail.com>
Co-authored-by: Robert Pająk <rpajak@splunk.com>
Co-authored-by: Cijo Thomas <cithomas@microsoft.com>
Co-authored-by: Timothy Mothra <tilee@microsoft.com>
Co-authored-by: Mikel Blanchard <mblanchard@macrosssoftware.com>
Co-authored-by: Reiley Yang <reyang@microsoft.com>
Co-authored-by: Utkarsh Umesan Pillai <utpilla@microsoft.com>
Co-authored-by: Christian Neumüller <christian.neumueller@dynatrace.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Enrich not invoked in HttpClient instrumentation when HostNotFound
3 participants