Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

azure-monitor-opentelemetry-exporter: HTTP dependency target rendered as host:None when server.port is absent

Chiusa Adatta ai principianti
#49,343 1 commento 1 reazione 1 assegnatario Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

@rads-1996 ci sta già lavorando.

Dal 7/10/2026.

  • #49344 di @sonmaximum — aperta

Valutazione

Difficoltà
1/5
Tempo stimato
1-3 ore
Idoneità per principianti
92/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
azure, python

Direzione di ricerca

Inizia in azure/monitor/opentelemetry/exporter/export/trace/_utils.py, in _get_target_and_path_for_http_dependency, quindi esegui la riproduzione fornita usando solo SERVER_ADDRESS. Il lavoro è completato quando l'assenza di server.port produce ('example.com', '/'), mentre un 443 esplicito rimane invariato e 8443 resta incluso nel target.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

Client customer-reported Monitor - Exporter question
Package / version
  • azure-monitor-opentelemetry-exporter==1.0.0b57 (via azure-monitor-opentelemetry==1.8.10)
  • azure-core==1.41.0
  • Present on main as of time of this writing (2026-10-03)
Description

When an HTTP client span has server.address but no server.port attribute, _get_target_and_path_for_http_dependency renders the dependency target with a literal None port, e.g.:

target = "<host>.vault.azure.net:None"

azure-core's DistributedTracingPolicy produces exactly this attribute shape for any request to a default-port URL. It sets server.address from the hostname, but only sets server.port when the URL has an explicit port (azure/core/pipeline/policies/_distributed_tracing.py):

if parsed_url.hostname:
    attributes[self._SERVER_ADDRESS] = parsed_url.hostname
if parsed_url.port:
    attributes[self._SERVER_PORT] = parsed_url.port

So every Azure SDK call to a standard HTTPS endpoint is affected. Observed in production App Insights (dependencies table):

target name
<host>.vault.azure.net:None GET /secrets
login.microsoftonline.com:None POST /.../token
Root cause

azure/monitor/opentelemetry/exporter/export/trace/_utils.py,
_get_target_and_path_for_http_dependency (~line 201 on main):

server_port = attributes.get(server_attributes.SERVER_PORT)
# if not default port, include port in target
if server_port != default_port:
    target = "{}:{}".format(target, server_port)

attributes.get(...) returns None when the attribute is absent, and
None != default_port is True, so None gets formatted into the target.

The DB path in the same file already guards against this, in _get_target_for_db_dependency (~line 247):

server_port = attributes.get(server_attributes.SERVER_PORT)
if server_port and server_port != _get_default_port_db(str(db_system)):
    target = "{}:{}".format(target, server_port)

The HTTP path is missing the same guard.

Reproduction
from opentelemetry.semconv.attributes import server_attributes
from azure.monitor.opentelemetry.exporter.export.trace._utils import (
    _get_target_and_path_for_http_dependency,
)
 
_get_target_and_path_for_http_dependency(
    {server_attributes.SERVER_ADDRESS: "example.com"}
)
# -> ('example.com:None', '/')   expected ('example.com', '/')

For comparison, with an explicit port the function behaves correctly:

  • SERVER_PORT=443 -> ('example.com', '/')
  • SERVER_PORT=8443 -> ('example.com:8443', '/')
Suggested fix

Mirror the DB-path guard:

-            if server_port != default_port:
+            if server_port and server_port != default_port:
                 target = "{}:{}".format(target, server_port)
Impact
  • Default-port dependencies show host:None as their target in App Insights.
Lingua principale
Python
Stelle
5.6k
Fork
3.4k
Merge medio
2g 3h
PR unite (30g)
206

Preparare l'ambiente

Apri in Codespaces

Avvia il container di sviluppo del progetto nel browser, con il tuo account GitHub.

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di Azure/azure-sdk-for-python

Tutte le issue di Azure/azure-sdk-for-python

Issue simili

Altre issue su Python

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.