Feature Request: Support for `pathlib.Path` objects in OTLP Exporter attributes
メンテナーはふだん 2 日以内に返信
評価
- 難易度
- 3/5
- 見積もり時間
- 1〜2日
- 初心者へのやさしさ
- 66/100
- issue の種類
- 機能追加
- 明瞭さ
- おおむね明確
- 活発さ
- 静か
- 技術スタック
- python
調査の方向性
opentelemetry/exporter/otlp/proto/common/_internal/init.py の _encode_value から始めます。ここでは現在 pathlib.PosixPath が例外を発生させます。LogRecord と Span の OTLP 属性がこのエンコーダーに到達するまでを追跡し、そのうえで、既存のプリミティブ値のエンコーディングや関連する exporter のテストを壊すことなく、Path の値が文字列として処理されることを確認します。
索引モデルが issue の本文から書いたものです。
説明
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.
- 主要言語
- Python
- スター
- 2.7k
- フォーク
- 1.1k
- 平均マージ
- 3日 12時間
- マージ済み PR(30日)
- 16
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
open-telemetry/opentelemetry-python のほかの issue
-
References to Archived open-telemetry/oteps対応中かも @RjyavardhanSingh が今日担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
open-telemetry/opentelemetry-python#5984 · コメント 1 件 ·
メンテナーはふだん 2 日以内に返信
-
Autoconfiguration rejects OTEL_EXPORTER_OTLP_PROTOCOL=http/json対応中かも @WendeelMarinho が 2 日前に担当しました。 オープンbug
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
open-telemetry/opentelemetry-python#5981 ·
メンテナーはふだん 2 日以内に返信
-
MeterProvider raises ValueError on empty or uppercase OTEL_METRICS_EXEMPLAR_FILTER対応中かも @bishalde が 8 日前に担当しました。 オープンbug
難易度 2/5 1〜3時間 初心者へのやさしさ 83/100
open-telemetry/opentelemetry-python#5948 · コメント 3 件 ·
メンテナーはふだん 2 日以内に返信
-
W3CBaggagePropagator drops a list-member over 4096 bytes that W3C Baggage requires it to propagate対応中かも @codedbyadiiii が 20 日前に担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
open-telemetry/opentelemetry-python#5913 ·
メンテナーはふだん 2 日以内に返信
-
otel.sdk.processor.{span,log}.queue.capacity uses synchronous UpDownCounter recorded once in __init__再び着手できるかも このイシューのプルリクエストはマージされずにクローズされました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
open-telemetry/opentelemetry-python#5891 ·
メンテナーはふだん 2 日以内に返信
open-telemetry/opentelemetry-python の issue をすべて見る
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
メンテナーはふだん 1 日以内に返信
-
bug improve content
難易度 1/5 1時間未満 初心者へのやさしさ 92/100
opensafely/documentation#2102 ·
メンテナーはふだん 1 日以内に返信
-
difficulty:1 documentation
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
MakazhanAlpamys/Soup#3533 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 74/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
onyx-dot-app/onyx#18730 ·
メンテナーはふだん 1 日以内に返信