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
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions opentelemetry-api/src/opentelemetry/trace/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,16 @@ def add_link(self: 'Span',
`SpanContext` passed as argument.
"""

def update_name(self, name: str) -> None:
"""Updates the `Span` name.

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.

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


class TraceOptions(int):
"""A bitmask that represents options specific to the trace.
Expand Down
3 changes: 3 additions & 0 deletions opentelemetry-sdk/src/opentelemetry/sdk/trace/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,9 @@ def end(self):
if self.end_time is None:
self.end_time = util.time_ns()

def update_name(self, name: str) -> None:
self.name = name


def generate_span_id():
"""Get a new random span ID.
Expand Down
3 changes: 3 additions & 0 deletions opentelemetry-sdk/tests/trace/test_trace.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,9 @@ def test_span_members(self):
root.add_link(other_context1)
root.add_link(other_context2, {'name': 'neighbor'})

root.update_name('toor')
self.assertEqual(root.name, 'toor')

# The public API does not expose getters.
# Checks by accessing the span members directly

Expand Down