-
Notifications
You must be signed in to change notification settings - Fork 306
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
Khanayan123/implement span events #4386
Merged
+315
−12
Merged
Changes from 18 commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
87e21d5
commit
khanayan123 091cb04
implement span events
khanayan123 df3b0a7
try
khanayan123 5ef993a
try
khanayan123 3439c72
try
khanayan123 f82e7b0
try
khanayan123 55df6b6
try again
khanayan123 7e72f2b
try
khanayan123 d033293
try
khanayan123 3f8608b
try
khanayan123 b2d6bb6
try
khanayan123 bee251a
try
khanayan123 27b1dc7
clean
khanayan123 a0c57c6
update comment
khanayan123 fd29975
fix ci
khanayan123 052a5c1
update error bit setting
khanayan123 bf0feb2
revert
khanayan123 81c43a3
update unit test
khanayan123 dffe200
address feedback
khanayan123 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -348,12 +348,24 @@ describe('OTel Span', () => { | |
} | ||
|
||
const error = new TestError() | ||
span.recordException(error) | ||
const datenow = Date.now() | ||
span.recordException(error, datenow) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This should be tested to also work without the second parameter. |
||
|
||
const { _tags } = span._ddSpan.context() | ||
expect(_tags).to.have.property(ERROR_TYPE, error.name) | ||
expect(_tags).to.have.property(ERROR_MESSAGE, error.message) | ||
expect(_tags).to.have.property(ERROR_STACK, error.stack) | ||
|
||
const events = span._ddSpan._events | ||
expect(events).to.have.lengthOf(1) | ||
expect(events).to.deep.equal([{ | ||
name: error.name, | ||
attributes: { | ||
'exception.message': error.message, | ||
'exception.stacktrace': error.stack | ||
}, | ||
startTime: datenow | ||
}]) | ||
}) | ||
|
||
it('should not set status on already ended spans', () => { | ||
|
@@ -402,4 +414,25 @@ describe('OTel Span', () => { | |
expect(processor.onStart).to.have.been.calledWith(span, span._context) | ||
expect(processor.onEnd).to.have.been.calledWith(span) | ||
}) | ||
it('should add span events', () => { | ||
const span1 = makeSpan('span1') | ||
const span2 = makeSpan('span2') | ||
const datenow = Date.now() | ||
span1.addEvent('Web page unresponsive', | ||
{ 'error.code': '403', 'unknown values': [1, ['h', 'a', [false]]] }, datenow) | ||
span2.addEvent('Web page loaded') | ||
span2.addEvent('Button changed color', { colors: [112, 215, 70], 'response.time': 134.3, success: true }) | ||
const events1 = span1._ddSpan._events | ||
const events2 = span2._ddSpan._events | ||
expect(events1).to.have.lengthOf(1) | ||
expect(events1).to.deep.equal([{ | ||
name: 'Web page unresponsive', | ||
startTime: datenow, | ||
attributes: { | ||
'error.code': '403', | ||
'unknown values': [1] | ||
} | ||
}]) | ||
expect(events2).to.have.lengthOf(2) | ||
}) | ||
}) |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Creating an object with no keys and then immediately mutating it like this is not recommended. Each modification creates a new hidden class with a new object shape whereas if you include all the keys, even if they are undefined initially, will produce a single shape and so will be faster. I would build the object in a single statement instead.