-
Notifications
You must be signed in to change notification settings - Fork 651
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
Recreate span on every run of a decorated function #1451
Recreate span on every run of a decorated function #1451
Conversation
Any comments? |
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.
This is a really interesting use case! I see the value of being able to cheaply wrap functions like this.
My one concern is the function isn't intuitively named to indicate it's a decorator. It may be good to add examples to the docs/faq page.
I thought it was implied to use it as a decorator, that's rather expected to me. Saves one indentation level.
How decorators should be named? Is there any special convention on it? I don't know any. |
There are no naming conventions for decorators. Mentioning in the documentation that this function can be used also as a decorator would be valuable, since every example so far does not use this pattern. |
@@ -760,7 +761,8 @@ def start_as_current_span( | |||
record_exception=record_exception, | |||
set_status_on_exception=set_status_on_exception, | |||
) | |||
return self.use_span(span, end_on_exit=True) | |||
with self.use_span(span, end_on_exit=True) as span_context: | |||
yield span_context | |||
|
|||
def start_span( # pylint: disable=too-many-locals |
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.
Does this same decorator pattern work with start_span()
? I would expect them to behave the same
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.
It doesn't use @contextmanager
, so no. And it should not
Agree with this. A better name would be nice. Ignoring all other Otel conventions, something like |
5cbde98
to
cf53669
Compare
Some pipelines are broken after branch update. I don't know why but pretty sure not because of this PR. Naming question — is it part of this PR? Could you please merge that bugfix first? |
27894be
to
8933f9c
Compare
Lets merge it before CI will disapprove it again? |
@anton-ryzhov looks like we missed it again if you can update the branch |
8933f9c
to
c855c14
Compare
@codeboten updated |
Any chance that this will be merged? With current setup CHANGELOG file will always have conflicts, so only chance to merge PR is to update it right before merging. But the PR is missed again and again. |
@anton-ryzhov if you can resolve the conflict, @lzchen and I can hold off on merging any other changes until this one passes CI and gets merged |
c855c14
to
f8af75b
Compare
Updated |
Thanks @anton-ryzhov! Merged |
Thank you |
Description
start_as_current_span
could be used as decorator. But it works incorrectly in this case — a span is created only once on decoration time and it is reused for every run of function.With that change it creates new span on every run.
Fixes # (issue)
Type of change
Please delete options that are not relevant.
How Has This Been Tested?
Unit test provided
Does This PR Require a Contrib Repo Change?
Checklist: