Skip to content

span: add is_recording_events#141

Merged
reyang merged 3 commits intoopen-telemetry:masterfrom
kinvolk:mauricio/add_span_is_recording_events
Sep 18, 2019
Merged

span: add is_recording_events#141
reyang merged 3 commits intoopen-telemetry:masterfrom
kinvolk:mauricio/add_span_is_recording_events

Conversation

@mauriciovasquezbernal
Copy link
Copy Markdown
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.
on the implementation.
"""

def is_recording_events(self) -> bool:
Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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.

"""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
Copy Markdown
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.


def add_lazy_event(self, event: trace_api.Event) -> None:
with self._lock:
if not self.is_recording_events():
Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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