Thursday, December 18, 2025

OpenTelemetry

總之為了方便找問題,過往會自己寫的一些東西,想試試看用像是 GrafanaJaeger 這些現成比較完整的解決方案來實現。要把程式中的狀態傳出來,目前主流會是 OpenTelemetry 這套,名詞很多一直忘記,因此做一些紀錄。


下面是 What is OpenTelemetry 的摘要:

OpenTelemetry 是一套專注在產生、收集、管理、匯出應用程式與系統遙測資料 (主要是: Trace, Metric, Log) 的框架與工具集,讓 instrument 應用程式與系統的過程儘量的簡單,在儘可能多的程式語言、運算基礎建設、執行環境等都可以運作。遙測資料的儲存與視覺化沒有包含在 OpenTelemetry 中,而是留給其他工具來實現。

構成 OpenTelemetry 的是以下元件:

  1. A specification for all components.

    描述有哪些元件的規格,規格中說明包含名詞定義、各語言函式庫該有什麼功能、各遙測資訊的資料鍵值、有哪些通訊協定等資訊。

  2. A standard protocol that defines the shape of telemetry data

    遙測資料的標準資料格式協定

  3. Semantic conventions that define a standard naming scheme for common telemetry data types.

    定義了常見遙測資料型別的標準命名規則的 Semantic conventions (semconv)

  4. APIs that define how to generate telemetry data.

    定義了怎麼產生遙測資料的 API。

  5. Language SDKs that implement the specification, APIs, and export of telemetry data.

    實作了規格、API、匯出遙測資料等功能的各主流程式語言 SDK

  6. A library ecosystem that implements instrumentation for common libraries and frameworks.

    實作了對常見函式庫或框架進行 instrument 的函式庫生態系

  7. Automatic instrumentation components that generate telemetry data without requiring code changes.

    可以不用改程式碼就產生出遙測資料的自動化 instrument 元件。

  8. The OpenTelemetry Collector, a proxy that receives, processes, and exports telemetry data.

    作為一個中間轉運站,對遙測資料進行接收、處理、匯出作業的 OpenTelemetry Collector

  9. Various other tools, such as the OpenTelemetry Operator for Kubernetes, OpenTelemetry Helm Charts, and community assets for FaaS.

    各種其他的工具。

OpenTelemetry 是設計為可以擴充的,以下是一些例子:

  1. Adding a receiver to the OpenTelemetry Collector to support telemetry data from a custom source.

    增加 receiver 到 OpenTelemetry Collector 以便從客製化的遙測資料源收取資料。

  2. Loading custom instrumentation libraries into an SDK.

    可以將客製化的 instrumentation 函式庫載入 SDK 使用。

  3. Creating a distribution of an SDK or the Collector tailored to a specific use case.

    可以針對特定使用情境建立 SDK 或 Collector 的發布版本 (distribution),不用 fork 整個或特定 OpenTelemetry 元件。

  4. Creating a new exporter for a custom backend that doesn’t yet support the OpenTelemetry protocol (OTLP).

    如果有遙測資料處理系統還不支援 OTLP 的話,可以做一個 exporter 來將資料匯過去。

  5. Creating a custom propagator for a nonstandard context propagation format.

    當碰到非標準的 context propagation 機制或格式時,可以製作客製的 propagator 來應對。

No comments: