iT邦幫忙

2022 iThome 鐵人賽

DAY 6
5
DevOps

淺談DevOps與Observability系列 第 6

淺談OpenTelemetry Client Library Architecture

  • 分享至 

  • xImage
  •  

OpenTelmetry Data Pipeline Architecture

Client通用設計模型

  • API 定義了data types 和 生成對應的logging, metrcis, tracing 資料, 也能在這裡增添自己的程式碼做成第三方套件, OpenTelemetry提供的Client套件也被視為API的一部分.
  • SDK 定義了上一點的API, 針對特定語言的實做. 也包含了設定配置, 資料的處理轉換以及怎把遙測資料做匯出的部份

上圖將CLient設計模型, 簡易抽象一下並分層

來看看.Net這裡關於API與SDK的介紹

OTel API

OTel-dotnet/OTelAPI
開頭就有講得很明確

Application developers and library authors use OpenTelemetry API to instrument their application/library. The API only surfaces necessary abstractions to instrument an application/library. It does not address concerns like how telemetry is exported to a specific telemetry backend, how to sample the telemetry, etc. The API consists of Tracing API, Logging API, Metrics API, Context and Propagation API, and a set of semantic conventions.

開發人員應該使用OTel API來檢測自己的應用程序.
OTel API只有暴露必要的抽向來檢測程序. 並不干涉怎麼把檢測拿到的遙測資料給送到特定的遙測後端, 還有對遙測資料進行採樣等問題.

這如同設計模型講的,這些職責在SDK身上.

OTel API Package內容

在OTel API內有個很特別的模組傳播Propagation, 它作為橫切關注點(Cross-cutting concern), 使用Propagation從資料中讀取和寫入context資料和Baggage資料.

  • /api/context : 描述程序內的context傳播用的API
  • /api/metric : 用來紀錄應用程式的metric用的Metrics API
  • /api/baggage : Baggage, 作用在context之間與metrics之間傳遞事件屬性(k-v pair)用的, 這組就是用來給描述Baggage API
  • api/trace : Trace API, 主要描述Tracer與Span
  • /api/logs : 就Log API, 只是OpenTelmetry對這塊目前還在Experimental階段.

OTel .NET API

OTel .NET API中,
有Tracing, Logging, Metrics, Context, Baggage API的部份
其中Logging沒特別用OTel logs api, 而是整合了.net原本的Microsoft.Extensions.Logging API
Context module內有Propagation的部份.
跟OTel client架構符合程度非常的高.

OTel Go API

here, 就各資料夾名稱就是

OTel SDK

OTel-dotnet/OTelSDK

OpenTelemetry SDK is a reference implementation of the OpenTelemetry API. It implements the Tracing API, the Metrics API, and the Context API. Once a valid SDK is installed and configured, all the OpenTelemetry API methods, which were no-ops without an SDK, will start emitting telemetry. This SDK also supports ILogger integration.
The SDK deals with concerns such as sampling, processing pipeline, exporting telemetry to a particular backend etc. In most cases, users indirectly install and enable the SDK, when they install a particular exporter.

跟OTel定義一樣, SDK是API這抽象的實做.
實做了Log API, Metric API, Trace API 甚至還有ContextAPI.
一些配置設定, 採樣, 導出都在這.
通常只有在指定特定的exporter時才會安裝跟啟用SDK.

  • /sdk/context : /api/context的實做
  • /sdk/metrics : /api/metrics的實做
  • /sdk/baggage : OTel規格寫TODO, 但應該就是/api/baggage的實做吧?
  • /sdk/logs : 也是TODO...
  • /sdk/trace : /api/trace和/api/span的實做外, 還有Sampler, Span Processor, Span Exporter等的實做.
  • /sdk/resource : 執行捕捉遙測資料的程序本體, 像在K8S的容器內的話, 其輸出的metric上會有cluster, namespace, pod, container各名稱.

OTel .NET SDK

OTel .NET SDK內也是有Logs, Metrics, Trace, Resources, 甚至有Proceesor, Exporter, Samplter一些實做.

Exporter部份更多在, here.

OTel Go SDK

here,
Go的Log部份目前進度是Frozen, 其他都還是在蓬勃開發中.

今日小心得

OpenTelemetry在Client模組與套件的設計上真的頗複雜, 思考了非常多.
為了讓每個模組能滿足SOLID中的像是OCP、ISP、SRP, 拆了很多東西出來.
對這些有些初步理解方便於我們去閱讀OpenTelemetry的specification.
有了這些設計規範後, 各語言的社群就能去開發OTel的contrib(3rd-party packages, 包含instrumentation, propagators, detectors...)
相較於Go的文件跟資料夾分類, 我覺得.net這邊的可讀性比較豐富就是了,
希望有天能幫忙Go這裡補充資訊.

參考資料

OpenTelemetry Specification


ps. 8月忙著裝潢&搬家, 9月忙鐵人賽跟找工作, 好多事情嘎在一起QQ
這次準備非常不充足, 請多見諒.


上一篇
淺談OpenTelemetry
下一篇
淺談OpenTelemetry Specification - Logs
系列文
淺談DevOps與Observability36
圖片
  直播研討會
圖片
{{ item.channelVendor }} {{ item.webinarstarted }} |
{{ formatDate(item.duration) }}
直播中

1 則留言

1
json_liang
iT邦研究生 5 級 ‧ 2022-09-06 09:45:25

大大辛苦了!找工作加油!鐵人賽加油!

我要留言

立即登入留言