Skip to content
This repository was archived by the owner on Nov 16, 2023. It is now read-only.
Merged
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
14 changes: 12 additions & 2 deletions azure_monitor/src/azure_monitor/trace.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,11 +131,21 @@ def span_to_envelope(self, span): # noqa pylint: disable=too-many-branches
baseData=data, baseType="RemoteDependencyData"
)
if span.kind in (SpanKind.CLIENT, SpanKind.PRODUCER):
data.type = "HTTP" # TODO
if "component" in span.attributes and \
span.attributes["component"] == "http":
data.type = "HTTP"
if "http.url" in span.attributes:
url = span.attributes["http.url"]
# data is the url
data.data = url
parse_url = urlparse(url)
# TODO: error handling, probably put scheme as well
data.name = urlparse(url).netloc
# target matches authority (host:port)
data.target = parse_url.netloc
if "http.method" in span.attributes:
# name is METHOD/path
data.name = span.attributes["http.method"] \
+ "/" + parse_url.path
if "http.status_code" in span.attributes:
data.resultCode = str(span.attributes["http.status_code"])
else: # SpanKind.INTERNAL
Expand Down