-
Notifications
You must be signed in to change notification settings - Fork 851
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
feat: record exceptions in http instrumentation #3008
feat: record exceptions in http instrumentation #3008
Conversation
|
a1a8945
to
63c0929
Compare
Codecov Report
@@ Coverage Diff @@
## main #3008 +/- ##
==========================================
- Coverage 92.63% 91.24% -1.40%
==========================================
Files 187 68 -119
Lines 6166 1850 -4316
Branches 1301 392 -909
==========================================
- Hits 5712 1688 -4024
+ Misses 454 162 -292
|
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.
LGTM
Thanks for the contribution
Interesting OTEP regarding the future of SpanEvents: https://github.com/open-telemetry/oteps/pull/202/files
experimental/packages/opentelemetry-instrumentation-http/test/functionals/http-enable.test.ts
Show resolved
Hide resolved
63c0929
to
1248bb6
Compare
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.
LGTM % testing nit
experimental/packages/opentelemetry-instrumentation-http/test/utils/assertSpan.ts
Show resolved
Hide resolved
1248bb6
to
b6d57fc
Compare
b6d57fc
to
03cabe4
Compare
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.
LGTM % nits.
assert.strictEqual(span.events[0].name, 'exception'); | ||
|
||
const eventAttributes = span.events[0].attributes as Object; | ||
assert.deepEqual( |
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.
Strict version of assert.deepEqual
is preferred:
assert.deepEqual( | |
assert.deepStrictEqual( |
assert.strictEqual(span.events.length, 1); | ||
assert.strictEqual(span.events[0].name, 'exception'); | ||
|
||
const eventAttributes = span.events[0].attributes as Object; |
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.
I'd suggest asserting the eventAttributes
to be non-nullish rather than casting it as an object -- the casting has no runtime-effect, we'll get a TypeError below if it is actually an undefined
.
const eventAttributes = span.events[0].attributes as Object; | |
const eventAttributes = span.events[0].attributes; | |
assert.ok(eventAttributes != null); |
074c0a3
to
5f6880e
Compare
5f6880e
to
279dec9
Compare
Thank you for your contribution! |
Which problem is this PR solving?
When an error is captured, it is now recorded as an event using recordException().
Short description of the changes
Added the
recordException
call right after the status setup insetSpanWithError()
.Type of change
Please delete options that are not relevant.
How Has This Been Tested?
Updated the helper that compares spans so it supports errors being passed and checks if they've been recorded.
Checklist: