Skip to content

Add Warning for Endpoint Mismatch in OTLP GRPC Exporter #3619

Closed

Description

@gshiva

While trying to initialize a HTTP exporter, I mistakenly passed a GRPC one which led to the silent truncation of the endpoint value. This caused confusion and resulted in hours of debugging. The source of the confusion was this import line:

Instead of

from opentelemetry.exporter.otlp.proto.http.trace_exporter import OTLPSpanExporter

I copy pasted from the commonly available examples, which use:

from opentelemetry.exporter.otlp.proto.grpc.trace_exporter import OTLPSpanExporter

This issue might be a common occurrence for newcomers, as almost all the examples use the GRPC exporter. To prevent this from happening in the future, I propose adding a warning message in the OTLP GRPC Exporter when there is a mismatch between the configured endpoint and the provided endpoint. This would provide clear, actionable feedback to the user and improve the overall user experience.

Here’s the proposed change:

if parsed_url.netloc:
    self._endpoint = parsed_url.netloc
    if parsed_url.path:
        logger.warning(f"Endpoint set to {self._endpoint}, which differs from the provided endpoint {endpoint}. If you're trying to configure a HTTP endpoint, please ensure you're using the correct exporter.")

This change replaces the existing code:

if parsed_url.netloc:
    self._endpoint = parsed_url.netloc

Activity

  1. chrikrah commented on Sep 10, 2026

    @chrikrah

    Reproduces on main (5aa2f8f). exporter.py:299-300 keeps parsed_url.netloc, so the path is
    dropped with no warning. The port survives, because it is part of netloc.

    endpoint given self._endpoint parsed_url.path
    https://otlp.example.com/v1/traces otlp.example.com /v1/traces
    https://otlp.example.com:4317/v1/traces otlp.example.com:4317 /v1/traces
    https://otlp.example.com/ otlp.example.com /
    otlp.example.com:4317 otlp.example.com:4317 4317

    Identical on the OTEL_EXPORTER_OTLP_ENDPOINT route, since both converge at :288. A gRPC target has
    no path component, so a warning is the only available fix.

    Row 4 breaks the guard #3620 proposed. A scheme-less host:port parses as
    scheme='otlp.example.com', path='4317', so if parsed_url.path and parsed_url.path.strip("/")
    both warn on an endpoint that works. The warning has to sit inside if parsed_url.netloc. G004 now
    also forbids the f-string #3620 used.

    One more thing that costs a reviewer time: logger carries DuplicateFilter, which drops a repeat of
    the same format string within a 20 second bucket, so an assertLogs test passes against a mutated
    guard. Patching logger.warning catches it.

    6 production lines and 2 tests. 69 passed in exporter/opentelemetry-exporter-otlp-proto-grpc/tests/,
    and each test fails against a reverted fix. Open a PR?

  2. added 2 commits that reference this issue on Sep 12, 2026
    d2a650d
    4ceca15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions