Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit abe00f7

Browse files
mauriciovasquezbernalreyang
authored andcommitted
span: implement update_name method (open-telemetry#112)
1 parent 96e5bc1 commit abe00f7

File tree

3 files changed

+16
-0
lines changed

3 files changed

+16
-0
lines changed

opentelemetry-api/src/opentelemetry/trace/__init__.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,16 @@ def add_link(self: 'Span',
132132
`SpanContext` passed as argument.
133133
"""
134134

135+
def update_name(self, name: str) -> None:
136+
"""Updates the `Span` name.
137+
138+
This will override the name provided via :func:`Tracer.create_span`
139+
or :func:`Tracer.start_span`.
140+
141+
Upon this update, any sampling behavior based on Span name will depend
142+
on the implementation.
143+
"""
144+
135145

136146
class TraceOptions(int):
137147
"""A bitmask that represents options specific to the trace.

opentelemetry-sdk/src/opentelemetry/sdk/trace/__init__.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -261,6 +261,9 @@ def end(self):
261261
if self.end_time is None:
262262
self.end_time = util.time_ns()
263263

264+
def update_name(self, name: str) -> None:
265+
self.name = name
266+
264267

265268
def generate_span_id():
266269
"""Get a new random span ID.

opentelemetry-sdk/tests/trace/test_trace.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,9 @@ def test_span_members(self):
145145
root.add_link(other_context1)
146146
root.add_link(other_context2, {'name': 'neighbor'})
147147

148+
root.update_name('toor')
149+
self.assertEqual(root.name, 'toor')
150+
148151
# The public API does not expose getters.
149152
# Checks by accessing the span members directly
150153

0 commit comments

Comments
 (0)