Recreate span on every run of a decorated function#1451
Recreate span on every run of a decorated function#1451codeboten merged 1 commit intoopen-telemetry:masterfrom
Conversation
|
Any comments? |
toumorokoshi
left a comment
There was a problem hiding this comment.
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. |
| 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.
Does this same decorator pattern work with start_span()? I would expect them to behave the same
There was a problem hiding this comment.
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_spancould 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: