opentelemetry-configuration: OTLP HTTP exporter does not validate TLS files exist at startup

Ouverte Adaptée aux débutants
#5,928 0 commentaires 0 réactions 0 personnes assignées Voir sur GitHub

Les mainteneurs répondent en général sous 2 jours

@Dotify71 y travaille déjà.

Depuis le 12/11/2026.

  • #5929 par @Dotify71 — ouverte

Évaluation

Difficulté
2/5
Temps estimé
1-3 heures
Accessibilité débutants
78/100
Type d'issue
Bug
Clarté
Clairement spécifiée
Activité
Active
Stack technique
python

Piste de recherche

Lisez les chemins de création des exportateurs HTTP OTLP dans _tracer_provider.py, _meter_provider.py et _logger_provider.py, puis comparez leur gestion de TLS à celle de la fonction auxiliaire gRPC _read_tls_file(). Vérifiez comment les exportateurs HTTP reçoivent ca_file, key_file et cert_file, et recherchez les tests de configuration associés. La tâche est terminée lorsque les fichiers TLS configurés manquants ou illisibles déclenchent ConfigurationError au démarrage des exportateurs HTTP.

Rédigé par le modèle d'indexation à partir du texte de l'issue.

Description

Describe your environment
  • Component: opentelemetry-configuration
  • SDK Version: main (commit af91f2864c1ce6ee118bbb01e6d6fe7297e05275 / PR #5781)
  • Python Version: Python 3.10+
  • OS: All platforms
What happened?

In PR #5781, TLS and mTLS support was added to declarative configuration for both gRPC and HTTP exporters.

For otlp_grpc, certificate and key file paths are read and validated right away at startup using _read_tls_file(). If a path does not exist or cannot be read, it fails immediately with a clear ConfigurationError:

def _read_tls_file(path: str, field: str) -> bytes:
    try:
        with open(path, "rb") as file:
            return file.read()
    except OSError as exc:
        raise ConfigurationError(f"Failed to read tls.{field} '{path}': {exc}") from exc

However, for otlp_http exporters (_tracer_provider.py, _meter_provider.py, and _logger_provider.py), the file paths are passed straight to the exporter constructors (OTLPSpanExporter, OTLPMetricExporter, OTLPLogExporter) as raw strings without checking if the files actually exist or can be read.

Why this is a problem in production
  1. Delayed failures and silent data loss: If a user makes a typo in a certificate path or mounts a Kubernetes secret file with the wrong name or permissions, the service starts up normally without any warning or error. The failure only happens much later when the background worker thread tries to send batches of telemetry over HTTP, causing failed exports and lost data.
  2. Inconsistent behavior: otlp_grpc fails fast at startup with ConfigurationError, while otlp_http silently ignores missing files until runtime requests fail.
Steps to Reproduce
  1. Use an otel-config.yaml with a missing certificate path:
file_format: "1.0"
tracer_provider:
  processors:
    - simple:
        exporter:
          otlp_http:
            endpoint: https://collector.example.com:4318/v1/traces
            tls:
              ca_file: /path/to/missing_ca.pem
  1. Initialize OpenTelemetry:
from opentelemetry.configuration import load_config_file

load_config_file("otel-config.yaml")
  1. Startup finishes without any error or validation warning.
  2. If you change otlp_http to otlp_grpc, startup immediately fails fast with:
    ConfigurationError: Failed to read tls.ca_file '/path/to/missing_ca.pem'
Expected Result

_create_otlp_http_*_exporter should check that configured ca_file, key_file, and cert_file exist and are readable at startup (for example using _read_tls_file or a shared file validation helper), raising ConfigurationError to fail fast just like otlp_grpc.

Would you like to implement a fix?

Yes, happy to help open a pull request.

Langage dominant
Python
Étoiles
2.7k
Forks
1.1k
Merge moyen
4 j 13 min
PR mergées (30 j)
38

Préparer son environnement

Par où commencer

  1. Lisez l'issue en entier, puis le guide de contribution du projet.
  2. Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
  3. Forkez le dépôt et travaillez sur une branche.
  4. Ouvrez une pull request qui référence le numéro de l'issue.

Autres issues de open-telemetry/opentelemetry-python

Toutes les issues de open-telemetry/opentelemetry-python

Issues similaires

Plus d'issues Python

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.