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

Enable OnException for AspNetCore instrumentation #1408

Merged
merged 12 commits into from
Oct 28, 2020
Merged

Enable OnException for AspNetCore instrumentation #1408

merged 12 commits into from
Oct 28, 2020

Conversation

eddynaka
Copy link
Contributor

Fixes #1405.

Changes

Please provide a brief description of the changes here.

For significant contributions please make sure you have completed the following items:

  • CHANGELOG.md updated for non-trivial changes
  • Design discussion issue #
  • Changes in public API reviewed

@eddynaka eddynaka requested a review from a team October 27, 2020 20:41
@codecov
Copy link

codecov bot commented Oct 27, 2020

Codecov Report

Merging #1408 into master will decrease coverage by 0.06%.
The diff coverage is 66.66%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1408      +/-   ##
==========================================
- Coverage   81.33%   81.26%   -0.07%     
==========================================
  Files         227      227              
  Lines        6097     6112      +15     
==========================================
+ Hits         4959     4967       +8     
- Misses       1138     1145       +7     
Impacted Files Coverage Δ
...tation.AspNetCore/Implementation/HttpInListener.cs 84.29% <64.28%> (-2.62%) ⬇️
...ion.AspNetCore/AspNetCoreInstrumentationOptions.cs 100.00% <100.00%> (ø)
...us/Implementation/PrometheusExporterEventSource.cs 63.63% <0.00%> (-9.10%) ⬇️
...emetry.Api/Internal/OpenTelemetryApiEventSource.cs 79.41% <0.00%> (-2.95%) ⬇️

@reyang
Copy link
Member

reyang commented Oct 27, 2020

@pakrym FYI.

@pakrym
Copy link
Contributor

pakrym commented Oct 27, 2020

@pakrym FYI.

Does this mean that Azure SDKs should put the message into description as well?

@cijothomas
Copy link
Member

@pakrym FYI.

Does this mean that Azure SDKs should put the message into description as well?

Not sure I understood. Could your clarify?
This PR is responding to one more DS event from AspNetCore. This event gives Exception, which is stored as ActivityEvent following the semantic conventions. There shouldn't be anything specific to Azure SDK here..

@pakrym
Copy link
Contributor

pakrym commented Oct 27, 2020

Recently @reyang mentioned in the email "We SHOULD NOT add any exception object to the Span. How to report an exception is not in the scope this year. I think most likely we will be using logs" but it looks like this PR uses Status.Description to report the exception message. So I'm trying to understand what should we do when reporting exceptions from Azure SDKs.

@cijothomas
Copy link
Member

cijothomas commented Oct 27, 2020

Recently @reyang mentioned in the email "We SHOULD NOT add any exception object to the Span. How to report an exception is not in the scope this year. I think most likely we will be using logs" but it looks like this PR uses Status.Description to report the exception message. So I'm trying to understand what should we do when reporting exceptions from Azure SDKs.

How to report an exception is not in the scope this year

This is probably specific to Microsoft specific Exporters. We can discuss it offline.

This PR is just making this repo compliant to the OpenTelemetry specs:
https://github.com/open-telemetry/opentelemetry-specification/blob/master/specification/trace/semantic_conventions/exceptions.md

https://github.com/open-telemetry/opentelemetry-specification/blob/master/specification/trace/semantic_conventions/http.md#status

@CodeBlanch
Copy link
Member

@eddynaka Are you going to add a test for this?

@eddynaka
Copy link
Contributor Author

@eddynaka Are you going to add a test for this?

i was thinking how i would do that.

@CodeBlanch
Copy link
Member

@eddynaka For the test...

public override async Task<bool> ProcessAsync(HttpContext context)
{
context.Response.StatusCode = this.statusCode;
context.Response.HttpContext.Features.Get<IHttpResponseFeature>().ReasonPhrase = this.reasonPhrase;
await context.Response.WriteAsync("empty");
return false;
}

I think all you need is for that callback to throw an unhandled exception. You could have the test add something to request query string like "?throw=true" which you could detect off the context in the callback? Might work 😄

@eddynaka
Copy link
Contributor Author

@eddynaka For the test...

public override async Task<bool> ProcessAsync(HttpContext context)
{
context.Response.StatusCode = this.statusCode;
context.Response.HttpContext.Features.Get<IHttpResponseFeature>().ReasonPhrase = this.reasonPhrase;
await context.Response.WriteAsync("empty");
return false;
}

I think all you need is for that callback to throw an unhandled exception. You could have the test add something to request query string like "?throw=true" which you could detect off the context in the callback? Might work 😄

Thanks for the guidance! just pushed one change testing the exception.
Let me know what do you think!

@cijothomas cijothomas merged commit 688ffd6 into open-telemetry:master Oct 28, 2020
@eddynaka eddynaka deleted the feature/enable-onexception-aspnetcore branch October 28, 2020 19:28
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.

Exception recording in AspNetCore instrumentation
5 participants