Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit8b738bf

Browse files
committed
pass other association props in LaminarSpanContext
1 parent959a29c commit8b738bf

File tree

4 files changed

+311
-110
lines changed

4 files changed

+311
-110
lines changed

‎src/lmnr/opentelemetry_lib/tracing/span.py‎

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,14 @@
1616

1717
fromlmnr.opentelemetry_lib.tracing.attributesimport (
1818
ASSOCIATION_PROPERTIES,
19+
METADATA,
20+
SESSION_ID,
1921
SPAN_IDS_PATH,
2022
SPAN_INPUT,
2123
SPAN_OUTPUT,
2224
SPAN_PATH,
25+
TRACE_TYPE,
26+
USER_ID,
2327
)
2428
fromlmnr.opentelemetry_lib.tracing.contextimport (
2529
detach_context,
@@ -79,9 +83,28 @@ def get_laminar_span_context(self) -> LaminarSpanContext:
7983
ifhasattr(self.span,"attributes"):
8084
span_path=list(self.span.attributes.get(SPAN_PATH,tuple()))
8185
span_ids_path=list(self.span.attributes.get(SPAN_IDS_PATH,tuple()))
86+
user_id=self.span.attributes.get(
87+
f"{ASSOCIATION_PROPERTIES}.{USER_ID}",None
88+
)
89+
session_id=self.span.attributes.get(
90+
f"{ASSOCIATION_PROPERTIES}.{SESSION_ID}",None
91+
)
92+
trace_type=self.span.attributes.get(
93+
f"{ASSOCIATION_PROPERTIES}.{TRACE_TYPE}",None
94+
)
95+
metadata= {
96+
k.replace(f"{ASSOCIATION_PROPERTIES}.{METADATA}.",""):v
97+
fork,vinself.span.attributes.items()
98+
ifk.startswith(f"{ASSOCIATION_PROPERTIES}.{METADATA}.")
99+
}
100+
fork,vinmetadata.items():
101+
try:
102+
metadata[k]=orjson.loads(v)
103+
exceptException:
104+
metadata[k]=v
82105
else:
83106
self.logger.warning(
84-
"Attributes object is not available. Most likely the span is not a LaminarSpan ",
107+
"Attributes object is not available. Most likely the span is not a LaminarSpan "
85108
"and not an OpenTelemetry default SDK span. Span path and ids path will be empty.",
86109
)
87110
returnLaminarSpanContext(
@@ -90,6 +113,10 @@ def get_laminar_span_context(self) -> LaminarSpanContext:
90113
is_remote=self.span.get_span_context().is_remote,
91114
span_path=span_path,
92115
span_ids_path=span_ids_path,
116+
user_id=user_id,
117+
session_id=session_id,
118+
trace_type=trace_type,
119+
metadata=metadata,
93120
)
94121

95122
defspan_id(self,format:Literal["int","uuid"]="int")->int|uuid.UUID:
@@ -172,7 +199,7 @@ def tags(self) -> list[str]:
172199
self.logger.debug(
173200
"[LaminarSpan.tags] WARNING. Current span does not have attributes object. "
174201
"Perhaps, the span was created with a custom OTel SDK. Returning an empty list."
175-
"Help: OpenTelemetry API does not guarantee reading attributes from a span, but OTel SDK ",
202+
"Help: OpenTelemetry API does not guarantee reading attributes from a span, but OTel SDK "
176203
"allows it by default. Laminar SDK allows to read attributes too.",
177204
)
178205
return []

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp