Skip to content
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

Merged

Conversation

mauriciovasquezbernal
Copy link
Member

@mauriciovasquezbernal mauriciovasquezbernal commented Sep 17, 2019

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

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:
Copy link
Member

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. 🤔

Copy link
Member Author

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":
?

Copy link
Member

@Oberon00 Oberon00 Sep 17, 2019

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.

opentelemetry-api/src/opentelemetry/trace/__init__.py Outdated Show resolved Hide resolved
"""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.
Copy link
Member

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():
Copy link
Member

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)?

Copy link
Member Author

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>
Copy link
Member

@c24t c24t left a 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.

@reyang reyang merged commit b6e97fc into open-telemetry:master Sep 18, 2019
@mauriciovasquezbernal mauriciovasquezbernal deleted the mauricio/add_span_is_recording_events branch April 14, 2020 21:50
srikanthccv pushed a commit to srikanthccv/opentelemetry-python that referenced this pull request Nov 1, 2020
* chore: add c8 settings

* fix: add .nycrc
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants