Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
3209a6e
qp
lzchen Oct 11, 2024
691ea15
update config
lzchen Oct 14, 2024
59cb90d
telemetry type
lzchen Oct 14, 2024
57be629
init dervied metrics
lzchen Oct 14, 2024
bf0a70d
Merge branch 'main' of https://github.com/Azure/azure-sdk-for-python …
lzchen Oct 15, 2024
3868560
target
lzchen Oct 15, 2024
569ca90
filtering + start of projections
lzchen Oct 17, 2024
0d1e46a
Merge branch 'main' of https://github.com/Azure/azure-sdk-for-python …
lzchen Oct 17, 2024
055b8be
collection + exporting
lzchen Oct 19, 2024
09b1b8f
tests
lzchen Oct 19, 2024
2afed98
exporter tests
lzchen Oct 19, 2024
2845946
test live metrics
lzchen Oct 21, 2024
1eefc4a
trace utils
lzchen Oct 21, 2024
0da3860
derive
lzchen Oct 24, 2024
cba3518
filters
lzchen Oct 24, 2024
bea3637
projections
lzchen Oct 24, 2024
be7859c
live
lzchen Oct 25, 2024
3a1523c
Merge branch 'main' of https://github.com/Azure/azure-sdk-for-python …
lzchen Oct 29, 2024
e87cb8b
Update _exporter.py
lzchen Oct 29, 2024
4ecc2d0
lint
lzchen Oct 29, 2024
fb5dbc8
black
lzchen Oct 29, 2024
ca864d8
lint
lzchen Oct 29, 2024
236f6f3
Merge branch 'main' of https://github.com/Azure/azure-sdk-for-python …
lzchen Oct 29, 2024
f0ccd8b
lint
lzchen Oct 29, 2024
10df783
blac
lzchen Oct 29, 2024
d12aec6
comment
lzchen Oct 30, 2024
179c24d
Update test_utils.py
lzchen Oct 30, 2024
dc0d0a0
Update test_live_metrics.py
lzchen Oct 30, 2024
8de5913
comment
lzchen Oct 30, 2024
b8fb7cb
test
lzchen Oct 30, 2024
6c6da94
tests
lzchen Oct 30, 2024
979096a
lint
lzchen Oct 31, 2024
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
Prev Previous commit
Next Next commit
target
  • Loading branch information
lzchen committed Oct 15, 2024
commit 386856088a95df38f64e8b4fc2f4c2aa7d3ce82b
Original file line number Diff line number Diff line change
Expand Up @@ -334,23 +334,7 @@ def _convert_span_to_envelope(span: ReadableSpan) -> TelemetryItem:
envelope.data = MonitorBase(
base_data=data, base_type="RemoteDependencyData"
)
target = None
if SpanAttributes.PEER_SERVICE in span.attributes:
target = span.attributes[SpanAttributes.PEER_SERVICE]
else:
if SpanAttributes.NET_PEER_NAME in span.attributes:
target = span.attributes[SpanAttributes.NET_PEER_NAME]
elif SpanAttributes.NET_PEER_IP in span.attributes:
target = span.attributes[SpanAttributes.NET_PEER_IP]
if SpanAttributes.NET_PEER_PORT in span.attributes:
port = span.attributes[SpanAttributes.NET_PEER_PORT]
# TODO: check default port for rpc
# This logic assumes default ports never conflict across dependency types
# type: ignore
if port != trace_utils._get_default_port_http(
str(span.attributes.get(SpanAttributes.HTTP_SCHEME))) and \
port != trace_utils._get_default_port_db(str(span.attributes.get(SpanAttributes.DB_SYSTEM))):
target = "{}:{}".format(target, port)
target = trace_utils._get_target_for_dependency_from_peer(span.attributes)
if span.kind is SpanKind.CLIENT:
if _AZURE_SDK_NAMESPACE_NAME in span.attributes: # Azure specific resources
# Currently only eventhub and servicebus are supported
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,28 @@ def _get_url_for_http_dependency(scheme: Optional[str], attributes: Attributes)
return str(url)


def _get_target_for_dependency_from_peer(attributes: Attributes) -> Optional[str]:
target = ""
if attributes:
if SpanAttributes.PEER_SERVICE in attributes:
target = attributes[SpanAttributes.PEER_SERVICE]
else:
if SpanAttributes.NET_PEER_NAME in attributes:
target = attributes[SpanAttributes.NET_PEER_NAME]
elif SpanAttributes.NET_PEER_IP in attributes:
target = attributes[SpanAttributes.NET_PEER_IP]
if SpanAttributes.NET_PEER_PORT in attributes:
port = attributes[SpanAttributes.NET_PEER_PORT]
# TODO: check default port for rpc
# This logic assumes default ports never conflict across dependency types
# type: ignore
if port != _get_default_port_http(
str(attributes.get(SpanAttributes.HTTP_SCHEME))) and \
port != _get_default_port_db(str(attributes.get(SpanAttributes.DB_SYSTEM))):
target = "{}:{}".format(target, port)
return str(target)


def _get_target_and_path_for_http_dependency(
target: Optional[str],
url: Optional[str],
Expand Down Expand Up @@ -143,7 +165,7 @@ def _get_target_and_path_for_http_dependency(
target = str(host)
except Exception: # pylint: disable=broad-except
pass
elif target_from_url:
elif target_from_url and not target:
target = target_from_url
return (target, path)

Expand All @@ -156,28 +178,29 @@ def _get_target_for_db_dependency(
if attributes:
db_name = attributes.get(SpanAttributes.DB_NAME)
if db_name:
if target is None:
if not target:
target = str(db_name)
else:
target = "{}|{}".format(target, db_name)
elif target is None:
elif not target:
target = db_system
return target


def _get_target_for_messaging_dependency(target: Optional[str], attributes: Attributes) -> Optional[str]:
if attributes:
if target is None:
if not target:
if SpanAttributes.MESSAGING_DESTINATION in attributes:
target = str(attributes[SpanAttributes.MESSAGING_DESTINATION])
elif SpanAttributes.MESSAGING_SYSTEM in attributes:
target = str(attributes[SpanAttributes.MESSAGING_SYSTEM])

return target


def _get_target_for_rpc_dependency(target: Optional[str], attributes: Attributes) -> Optional[str]:
if attributes:
if target is None:
if not target:
if SpanAttributes.RPC_SYSTEM in attributes:
target = str(attributes[SpanAttributes.RPC_SYSTEM])
return target