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: implement update_name method #112

Merged
merged 1 commit into from
Aug 29, 2019

Conversation

mauriciovasquezbernal
Copy link
Member

Fixes: #99

@@ -261,6 +261,11 @@ def end(self):
if self.end_time is None:
self.end_time = util.time_ns()

def update_name(self: 'Span', name: str) -> None:
if not name:
raise ValueError("Name cannot be empty")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is an empty string for name actually illegal?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is nothing about it the specification. I think we could allow it, I got confused by a check in the Java implementation but this is actually checking if the string is not null, not if this is empty.

@mauriciovasquezbernal mauriciovasquezbernal force-pushed the mauricio/add_span_update_name branch from 0c59ba3 to c62b413 Compare August 27, 2019 22:41
Copy link
Member

@a-feld a-feld left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎉

@reyang
Copy link
Member

reyang commented Aug 27, 2019

Let's wait for a day to get comments before merge.

Upon this update, any sampling behavior based on Span name will depend
on the implementation.
"""

Copy link
Contributor

@Jamim Jamim Aug 28, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't it raise a NotImplementedError?

Suggested change
raise NotImplementedError

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know what is the preferred way to implement interfaces in python without using ABC. So far none of the methods in the opentelemetry.Span class raise exceptions. Should they?
This PR is just following the current style, maybe this discussion should be moved to #66.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

➡️ #66

Copy link
Member

@Oberon00 Oberon00 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I realize I should have said this long before, but wouldn't it be more pythonic to not have this update_name method and instead allow (documented) users to set span.name? If we need special logic in the future, we can still make it a @property.

This will override the name provided via :func:`Tracer.create_span`
or :func:`Tracer.start_span`.

Upon this update, any sampling behavior based on Span name will depend
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Upon this update, any sampling behavior based on Span name will depend
After this update, any sampling behavior based on Span name will depend

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@@ -261,6 +261,9 @@ def end(self):
if self.end_time is None:
self.end_time = util.time_ns()

def update_name(self: 'Span', name: str) -> None:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
def update_name(self: 'Span', name: str) -> None:
def update_name(self: Span, name: str) -> None:

Not sure if that also works in the API package, but here it should definitely work without quotes.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's go a step back first, should we really annotate the self member?, In the examples in https://www.python.org/dev/peps/pep-0484 it is not annotated.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 You are right AFAIK, self is implicitly annotated with the containing class.

@mauriciovasquezbernal
Copy link
Member Author

@Oberon00 I am new here I don't have a strong opinion whether we should "pythonize" the API or not. My only comment is that if we use a member we could put all the name related thing directly on the API without touching the SDK.

@mauriciovasquezbernal mauriciovasquezbernal force-pushed the mauricio/add_span_update_name branch from c62b413 to c789415 Compare August 28, 2019 15:02
@carlosalberto
Copy link
Contributor

On the pythonization: I'd rather stay with the explicit name (update_name() that is), as it makes it clear for the users what Specification operation this is.

If we decide to go with the pythonic route, then we need to expose the name getter/setter as functions/properties at the API level, so implementors can still put logic there, etc.

@reyang reyang merged commit abe00f7 into open-telemetry:master Aug 29, 2019
@mauriciovasquezbernal mauriciovasquezbernal deleted the mauricio/add_span_update_name branch April 14, 2020 21:50
srikanthccv pushed a commit to srikanthccv/opentelemetry-python that referenced this pull request Nov 1, 2020
Resolve open-telemetry#111

Signed-off-by: Olivier Albertini <olivier.albertini@montreal.ca>
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.

Add Span's UpdateName operation.
7 participants