Skip to content

Commit 2d435d9

Browse files
committed
support links
1 parent 2de1d0f commit 2d435d9

File tree

1 file changed

+16
-1
lines changed
  • ext/opentelemetry-ext-azure-monitor/src/opentelemetry/ext/azure_monitor

1 file changed

+16
-1
lines changed

ext/opentelemetry-ext-azure-monitor/src/opentelemetry/ext/azure_monitor/trace.py

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,22 @@ def span_to_envelope(self, span): # noqa pylint: disable=too-many-branches
152152
data.resultCode = str(span.attributes["http.status_code"])
153153
else: # SpanKind.INTERNAL
154154
data.type = "InProc"
155-
# TODO: links, tracestate, tags
156155
for key in span.attributes:
157156
data.properties[key] = span.attributes[key]
157+
if span.links:
158+
links = []
159+
for link in span.links:
160+
links.append(
161+
{
162+
"operation_Id": "{:032x}".format(
163+
link.context.trace_id
164+
),
165+
"id": "|{:032x}.{:016x}.".format(
166+
link.context.trace_id, link.context.span_id
167+
),
168+
}
169+
)
170+
data.properties["_MS.links"] = json.dumps(links)
171+
print(data.properties["_MS.links"])
172+
# TODO: tracestate, tags
158173
return envelope

0 commit comments

Comments
 (0)