-
Notifications
You must be signed in to change notification settings - Fork 624
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
span: add is_recording_events #141
span: add is_recording_events #141
Conversation
Add missing is_recording_events() function to span in API and SDK. The important point of this commit is to implement the check in functions like add_event, set_attribute and so son. Currently is_recording_events always returns true.
@@ -191,6 +191,13 @@ def update_name(self, name: str) -> None: | |||
on the implementation. | |||
""" | |||
|
|||
def is_recording_events(self) -> bool: |
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.
You should return a boolean value (most likely False
) here too. I wonder why mypy didn't catch this. 🤔
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.
mmm, so what about
def get_context(self) -> "SpanContext": |
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.
Seems also wrong.
EDIT: I created #142.
"""Returns the flag whether this span will be recorded. | ||
|
||
Returns true if this Span is active and recording information like | ||
events with the AddEvent operation and attributes using SetAttributes. |
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.
These names are not Python-adjusted.
@@ -302,6 +304,8 @@ def add_event( | |||
|
|||
def add_lazy_event(self, event: trace_api.Event) -> None: | |||
with self._lock: | |||
if not self.is_recording_events(): |
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.
As long as we always return True
in is_recording_events
I wonder if we need these checks at all yet. And if we want them, maybe they can be outside the lock (I think the sampling decision is made when creating the span already, so this should never change)?
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.
Well, I just wanted to put that logic in place regardless the value that is returned by is_recording_events
(the same that otel-java does right now).
I am not sure if we can move those checks outside the lock, so I preferred to stay in the safe side and leave them inside.
Co-Authored-By: Christian Neumüller <christian+github@neumueller.me>
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 implementation looks good and according to spec, but I'm not sure about the utility of is_recording_events
.
* chore: add c8 settings * fix: add .nycrc
Add missing is_recording_events() function to span in API and SDK.
The important point of this commit is to implement the check in functions like
add_event, set_attribute and so son. Currently is_recording_events always
returns true.
Solves: #100