Skip to content

[BUG]: grpc target parsing fails for Dapr‐style "dns:127.0.0.1:50001" #15094

@MarcoP9

Description

@MarcoP9

Tracer Version(s)

latest 3.17

Python Version(s)

3.12

Pip Version(s)

25.1.1

Bug Report

When using ddtrace with Dapr (or any gRPC client that uses a dns:-prefixed target such as dns:127.0.0.1:50001), Datadog’s internal gRPC instrumentation logs a warning:
Non-integer port in target 'dns:127.0.0.1:50001'

This is caused by _parse_target_from_args prepending "//" before calling urllib.parse.urlsplit(), which makes urlsplit unable to parse the hostname and port correctly.

Reproduction Code

  1. Use a Dapr client configuration that uses dns:127.0.0.1:50001 as the gRPC endpoint.
  2. Run a traced application with ddtrace-run and send a publish event via the Dapr client.
from urllib import parse
from ddtrace.contrib.internal.grpc import utils

target = "dns:127.0.0.1:50001"
# Simulate ddtrace behavior
parsed = parse.urlsplit("//" + target if not target.startswith("//") else target)
print(parsed.hostname, parsed.port)

Error Logs

WARNING ddtrace.contrib.internal.grpc.utils _parse_target_from_args Non-integer port in target 'dns:127.0.0.1:50001'

Libraries in Use

dapr-ext-fastapi = "1.15.0"
fastapi = "0.115.12"
uvicorn = "0.30.4"
ddtrace = "^3.15.0"

Operating System

Windows

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions