add optional parameter to record_exception method#1242
add optional parameter to record_exception method#1242codeboten merged 9 commits intoopen-telemetry:masterfrom
Conversation
|
|
codeboten
left a comment
There was a problem hiding this comment.
Thanks @shreyagupta30 for the PR, the same change will be needed in the SDK here:
Please add an entry to opentelemetry-api/changelog and opentelemetry-sdk/changelog to note the change.
|
@codeboten I have made required changes but somehow almost all the tests are failed. What do you suggest me to do now? |
|
Looks like a missing import: https://github.com/open-telemetry/opentelemetry-python/pull/1242/checks?check_run_id=1255343757#step:6:578 |
|
@codeboten kindly let me know if any further changes are required. |
codeboten
left a comment
There was a problem hiding this comment.
Thanks for addressing my previous comments, please add a test to ensure that attributes and timestamp parameters are used when record_exception is called with the additional parameters.
| exception: Exception, | ||
| attributes: types.Attributes = None, | ||
| timestamp: Optional[int] = None, | ||
| ) -> None: |
There was a problem hiding this comment.
the additional parameters here (attributes, timestamp) should be used in the method below. As per the spec:
If attributes with the same name would be generated by the method already, the additional attributes take precedence
There was a problem hiding this comment.
@codeboten Can you please guide me on how to do this. I am not able to figure out what exactly needs to be done here.
There was a problem hiding this comment.
@shreyagupta30 you'll want to pass in the timestamp argument into add_event, you can see what it looks like by looking at the method signature here:
You'll also want to pass the attributes parameter in the add_event call below, ensuring that any attributes passed into this method overrides any of the default attributes, the way i'd approach it is probably to create a dict with the default attributes seen below, then loop through the attributes arg and set any values in the dict that way.
Last but not least, adding a test like the one below to ensure the attributes are set as expected
opentelemetry-python/opentelemetry-sdk/tests/trace/test_trace.py
Lines 855 to 872 in 937863f
toumorokoshi
left a comment
There was a problem hiding this comment.
+1 to @codeboten's PR: the SDK is not honoring the intended behavior and adding the event.
|
@shreyagupta30 will you have time to look at this PR, the issue it's addressing is time sensitive. |
|
I am so sorry @codeboten, I got busy with other work. I will definitely get back to it. I was looking into unit tests as I am not very familiar with it. |
|
No worries @shreyagupta30, if you're ok with it, we can merge this PR as is and then get the other PR #1314 committed over top of it to address the unit tests and implementation details. |
|
Sure @codeboten Thanks a lot :D |
If that's the strategy you'd like to take @codeboten, i'll switch mine to an approval then. |
toumorokoshi
left a comment
There was a problem hiding this comment.
Approved based on the conversation, with merging in unit tests and behavior quickly after.
codeboten
left a comment
There was a problem hiding this comment.
Sounds good, let's merge this and get the other PR merged quickly after

This fixes #1102.
I have added two additional attributes to
record_exceptionmethod. Those areI have applied the tox lint checks.