open-telemetry / open-telemetry/opentelemetry-python

Add Warning for Endpoint Mismatch in OTLP GRPC Exporter

Open Beginner friendly
#3,619 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
2.6k
Forks
1k
Avg merge
4d 15h
Merged PRs (30d)
19

Description

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

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in opentelemetry.exporter.otlp.proto.grpc.trace_exporter, where the OTLPSpanExporter parses the endpoint and currently keeps only parsed_url.netloc. Add actionable warning coverage for endpoints whose path indicates a possible HTTP/GRPC mismatch, and verify that ordinary GRPC endpoints remain unchanged.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
observability
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
68/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.