-
Notifications
You must be signed in to change notification settings - Fork 534
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(mongo instrumentation): added response hook option #533
Conversation
|
b6ed8de
to
8a97ea9
Compare
plugins/node/opentelemetry-instrumentation-mongodb/src/instrumentation.ts
Outdated
Show resolved
Hide resolved
plugins/node/opentelemetry-instrumentation-mongodb/src/instrumentation.ts
Outdated
Show resolved
Hide resolved
Codecov Report
@@ Coverage Diff @@
## main #533 +/- ##
==========================================
+ Coverage 94.72% 94.98% +0.25%
==========================================
Files 169 162 -7
Lines 10638 10163 -475
Branches 1062 1004 -58
==========================================
- Hits 10077 9653 -424
+ Misses 561 510 -51 |
922f96e
to
fd65df7
Compare
plugins/node/opentelemetry-instrumentation-mongodb/src/instrumentation.ts
Outdated
Show resolved
Hide resolved
9517cfc
to
e230086
Compare
plugins/node/opentelemetry-instrumentation-mongodb/src/types.ts
Outdated
Show resolved
Hide resolved
plugins/node/opentelemetry-instrumentation-mongodb/src/instrumentation.ts
Outdated
Show resolved
Hide resolved
plugins/node/opentelemetry-instrumentation-mongodb/src/instrumentation.ts
Outdated
Show resolved
Hide resolved
plugins/node/opentelemetry-instrumentation-mongodb/src/types.ts
Outdated
Show resolved
Hide resolved
plugins/node/opentelemetry-instrumentation-mongodb/test/mongodb.test.ts
Outdated
Show resolved
Hide resolved
plugins/node/opentelemetry-instrumentation-mongodb/test/mongodb.test.ts
Outdated
Show resolved
Hide resolved
assert.ifError(err); | ||
const spans = memoryExporter.getFinishedSpans(); | ||
const findSpan = spans[0]; | ||
const spanResult = JSON.parse( |
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 name spanResult
is not clear IMO. it's the hookAttributeValue
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.
Sure, changed to hookAttributeValue
to make it more clear
const spans = memoryExporter.getFinishedSpans(); | ||
const findSpan = spans[0]; | ||
const spanResult = JSON.parse( | ||
findSpan.attributes[dataAttributeName]?.toString() || '{}' |
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.
Current implementation gives the impression that findSpan.attributes[dataAttributeName]
can be undefined (by using the ?
and setting a default value).
But that's something that the test should assert instead.
If the attribute is missing, we will just fail few lines below when trying to access spanResult.cursor
.
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.
Added null validations inside the assertion - now if the findSpan.attributes[dataAttributeName]
is undefined, the assertion will fail.
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.
cool, but still this code is written in a way that implies that findSpan.attributes[dataAttributeName]
can be legitimately falsy, where the purpose of the test is exactly to assert that it is not.
I find it a bit confusing, but that's just a matter of personal style I suppose. If you prefer to have it this way, I'm good with it :)
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.
Just as the test above... if its empty - the test will fail.
e230086
to
297fe17
Compare
plugins/node/opentelemetry-instrumentation-mongodb/src/instrumentation.ts
Outdated
Show resolved
Hide resolved
0254d13
to
d75cf00
Compare
plugins/node/opentelemetry-instrumentation-mongodb/src/types.ts
Outdated
Show resolved
Hide resolved
d75cf00
to
b235838
Compare
plugins/node/opentelemetry-instrumentation-mongodb/src/instrumentation.ts
Outdated
Show resolved
Hide resolved
LGTM (there are still some nonblocking minors that can be optionally addressed). |
9bb6010
to
9257eb5
Compare
Conversations which have been addressed and resolved should be marked as resolved please |
I don't have permissions to resolve conversations. Marked with emoji what has been addressed from the comments I wrote. |
e3669b0
to
89d4a35
Compare
All conversations are resolved now, thank you :) |
Everything has been addressed. LGTM |
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 but this is out of date with the base branch and I don't have permission to update it.
89d4a35
to
99a2879
Compare
Rebased over main |
99a2879
to
9b894a2
Compare
Which problem is this PR solving?
Short description of the changes
responseHook
configuration member which is called at the end of each mongo action