Skip to content

Add Warning for Endpoint Mismatch in OTLP GRPC Exporter #3619

@gshiva

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions