Skip to content

Commit d7db92a

Browse files
authored
Tag profiles with span_name label (#23)
1 parent ebe2d80 commit d7db92a

1 file changed

Lines changed: 3 additions & 0 deletions

File tree

src/pyroscope/otel/__init__.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212

1313
PROFILE_ID_SPAN_ATTRIBUTE_KEY = 'pyroscope.profile.id'
1414
PROFILE_ID_PYROSCOPE_TAG_KEY = 'span_id'
15+
SPAN_NAME_PYROSCOPE_TAG_KEY = 'span_name'
1516

1617
def _is_root_span(span: Span):
1718
return span.parent is None or span.parent.is_remote
@@ -28,10 +29,12 @@ def on_start(
2829
if _is_root_span(span):
2930
span.set_attribute(PROFILE_ID_SPAN_ATTRIBUTE_KEY, format(span.context.span_id, "016x"))
3031
pyroscope.add_thread_tag(threading.get_ident(), PROFILE_ID_PYROSCOPE_TAG_KEY, _get_span_id(span))
32+
pyroscope.add_thread_tag(threading.get_ident(), SPAN_NAME_PYROSCOPE_TAG_KEY, span.name)
3133

3234
def on_end(self, span: ReadableSpan) -> None:
3335
if _is_root_span(span):
3436
pyroscope.remove_thread_tag(threading.get_ident(), PROFILE_ID_PYROSCOPE_TAG_KEY, _get_span_id(span))
37+
pyroscope.remove_thread_tag(threading.get_ident(), SPAN_NAME_PYROSCOPE_TAG_KEY, span.name)
3538

3639
def shutdown(self) -> None:
3740
pass

0 commit comments

Comments
 (0)