Skip to content

Record exception on context manager exit#1162

Merged
lzchen merged 1 commit intoopen-telemetry:masterfrom
owais:record-exceptions
Oct 7, 2020
Merged

Record exception on context manager exit#1162
lzchen merged 1 commit intoopen-telemetry:masterfrom
owais:record-exceptions

Conversation

@owais
Copy link
Copy Markdown
Contributor

@owais owais commented Sep 25, 2020

Description

This updates the tracer context manager to record exceptions automatically on
exit if an exception was raised within the context manager's context.

This should be helpful in some situations when manually instrumenting apps. For example,
it can help record any uncaught/unexpected exceptions which one would expect from a tracing
system. This can also be helpful in simplifying auto-instrumentations. I think this should be the
default behavior but happy to hear other thoughts. Otel spec does not say anything about this and leaves span creation/activation to each language implementation. Both OpenTracing and OpenCensus did it AFAICT:

Type of change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

How Has This Been Tested?

  • Unit Test

Checklist:

  • Followed the style guidelines of this project
  • Changelogs have been updated
  • Unit tests have been added
  • Documentation has been updated

@owais owais changed the title Record exception on context manager exit DO NOT REVIEW: Record exception on context manager exit Sep 25, 2020
@owais owais force-pushed the record-exceptions branch 2 times, most recently from c343f53 to 75e46c9 Compare September 25, 2020 02:20
@owais owais changed the title DO NOT REVIEW: Record exception on context manager exit Record exception on context manager exit Sep 25, 2020
@owais owais marked this pull request as ready for review September 25, 2020 02:31
@owais owais requested a review from a team September 25, 2020 02:31
@owais owais force-pushed the record-exceptions branch 9 times, most recently from ccac4bb to 5c04297 Compare September 25, 2020 03:45
@lzchen lzchen self-assigned this Oct 1, 2020
@owais owais force-pushed the record-exceptions branch from 694b26c to f5abcd5 Compare October 2, 2020 15:13
Copy link
Copy Markdown
Member

@toumorokoshi toumorokoshi left a comment

Choose a reason for hiding this comment

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

The goal looks great! +1 to add this convenience.

I think we should re-examine adding that field to the span though. See my comment above.

@owais owais force-pushed the record-exceptions branch 10 times, most recently from 29f7ef6 to 2222d26 Compare October 4, 2020 01:45
Copy link
Copy Markdown
Member

@toumorokoshi toumorokoshi left a comment

Choose a reason for hiding this comment

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

One minor question (incongruent default value from "record_exception") but looking really good!

@owais owais force-pushed the record-exceptions branch 3 times, most recently from 5a72598 to 7e30859 Compare October 5, 2020 20:15
@owais owais force-pushed the record-exceptions branch from 7e30859 to cf94b05 Compare October 7, 2020 02:15
This updates the tracer context manager to automatically record
exceptions as events on exit if an exception was raised within the
context manager's context.
@owais owais force-pushed the record-exceptions branch from cf94b05 to 57a01cd Compare October 7, 2020 02:18
Copy link
Copy Markdown
Member

@toumorokoshi toumorokoshi left a comment

Choose a reason for hiding this comment

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

Great, thanks!

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.

3 participants