Feature Request: Support for `pathlib.Path` objects in OTLP Exporter attributes
Maintainer antworten meist innerhalb von 2 Tagen
@danilopeixoto arbeitet bereits daran.
Seit 20.5.2026.
- #5239 von @grvmishra788 — ohne Merge geschlossen
Bewertung
- Schwierigkeit
- 3/5
- Geschätzter Aufwand
- 1-2 Tage
- Anfängerfreundlichkeit
- 66/100
- Issue-Typ
- Feature
- Klarheit
- Größtenteils klar
- Aktivitätsstatus
- Ruhig
- Tech-Stack
- python
- Bereich
- observability-sre
Rechercherichtung
Beginne in opentelemetry/exporter/otlp/proto/common/_internal/init.py bei _encode_value, wo pathlib.PosixPath derzeit eine Ausnahme auslöst. Verfolge, wie OTLP-Attribute für LogRecord und Span diesen Encoder erreichen, und überprüfe anschließend, dass Path-Werte als Zeichenfolgen behandelt werden, ohne die bestehende Kodierung primitiver Werte oder die relevanten Exporter-Tests zu beeinträchtigen.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Beschreibung
Is your feature request related to a problem?
Currently, passing a pathlib.Path object as an attribute value to a LogRecord (or Span) causes the OTLP Exporter to fail with an Exception: Invalid type <class 'pathlib.PosixPath'>. While I understand the OTLP spec is strict about primitive types, pathlib.Path is a Python standard library type frequently used in logging context (e.g., model paths, log file locations).
Describe the solution you'd like
It would be helpful if the OpenTelemetry Python SDK could automatically coerce pathlib.Path objects to strings during the OTLP encoding process, or provide a standard hook/configuration to handle common non-primitive types without crashing the exporter.
Describe alternatives you've considered
I am currently using a custom structlog processor to manually stringify all Path objects before they reach the OpenTelemetry logging bridge:
def stringify_non_standard_types(event_dict):
for key, value in event_dict.items():
if isinstance(value, Path):
event_dict[key] = str(value)
return event_dict
While this works, it requires manual configuration for every project and doesn't cover cases where third-party instrumentations might inject Path objects into the context.
Additional Context
Stack trace:
File ".../opentelemetry/exporter/otlp/proto/common/_internal/__init__.py", line 100, in _encode_value
raise Exception(f"Invalid type {type(value)} of value {value}")
Exception: Invalid type <class 'pathlib.PosixPath'> of value /Users/user/models/my-model
Would you like to implement a fix?
Yes
Tip
React with 👍 to help prioritize this issue. Please use comments to provide useful context, avoiding +1 or me too, to help us triage it. Learn more here.
- Vorherrschende Sprache
- Python
- Sterne
- 2.7k
- Forks
- 1.1k
- Ø Merge
- 3 T. 12 Std.
- Gemergte PRs (30 T.)
- 16
Entwicklungsumgebung
- Kein Dockerfile und keine Docker-Compose-Datei
- Hat eine Pull-Request-Vorlage
- Beitragsleitfaden lesen
Erste Schritte
- Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
- Forken Sie das Repository und arbeiten Sie in einem Branch.
- Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.
Mehr aus open-telemetry/opentelemetry-python
-
References to Archived open-telemetry/otepsEvtl. vergeben @RjyavardhanSingh hat das heute übernommen. Offen
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 72/100
open-telemetry/opentelemetry-python#5984 · 1 Kommentar ·
Maintainer antworten meist innerhalb von 2 Tagen
-
Autoconfiguration rejects OTEL_EXPORTER_OTLP_PROTOCOL=http/jsonEvtl. vergeben @WendeelMarinho hat das vor 2 Tagen übernommen. Offenbug
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 82/100
open-telemetry/opentelemetry-python#5981 ·
Maintainer antworten meist innerhalb von 2 Tagen
-
MeterProvider raises ValueError on empty or uppercase OTEL_METRICS_EXEMPLAR_FILTEREvtl. vergeben @bishalde hat das vor 8 Tagen übernommen. Offenbug
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 83/100
open-telemetry/opentelemetry-python#5948 · 3 Kommentare ·
Maintainer antworten meist innerhalb von 2 Tagen
-
W3CBaggagePropagator drops a list-member over 4096 bytes that W3C Baggage requires it to propagateEvtl. vergeben @codedbyadiiii hat das vor 20 Tagen übernommen. Offen
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 70/100
open-telemetry/opentelemetry-python#5913 ·
Maintainer antworten meist innerhalb von 2 Tagen
-
otel.sdk.processor.{span,log}.queue.capacity uses synchronous UpDownCounter recorded once in __init__Evtl. wieder frei Ein Pull Request dazu wurde ohne Merge geschlossen. Offen
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 78/100
open-telemetry/opentelemetry-python#5891 ·
Maintainer antworten meist innerhalb von 2 Tagen
Alle Issues in open-telemetry/opentelemetry-python
Ähnliche Issues
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 78/100
Maintainer antworten meist innerhalb von 1 Tag
-
bug improve content
Schwierigkeit 1/5 Unter einer Stunde Anfängerfreundlichkeit 92/100
opensafely/documentation#2102 ·
Maintainer antworten meist innerhalb von 1 Tag
-
difficulty:1 documentation
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 82/100
MakazhanAlpamys/Soup#3533 ·
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 74/100
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 76/100
onyx-dot-app/onyx#18730 ·
Maintainer antworten meist innerhalb von 1 Tag