計装ライブラリの使用
When you develop an app, you might use third-party libraries and frameworks to accelerate your work. If you then instrument your app using OpenTelemetry, you might want to avoid spending additional time to manually add traces, logs, and metrics to the third-party libraries and frameworks you use.
Many libraries and frameworks already support OpenTelemetry or are supported through OpenTelemetry instrumentation, so that they can generate telemetry you can export to an observability backend.
If you are instrumenting an app or service that use third-party libraries or frameworks, follow these instructions to learn how to use natively instrumented libraries and instrumentation libraries for your dependencies.
Use natively instrumented libraries
If a library comes with OpenTelemetry support by default, you can get traces, metrics, and logs emitted from that library by adding and setting up the OpenTelemetry SDK with your app.
The library might require some additional configuration for the instrumentation. Go to the documentation for that library to learn more.
As of today, we don’t know about any Go library that has OpenTelemetry natively integrated. If you know about such a library, let us know.
計装ライブラリの使用
ライブラリにOpenTelemetryが最初から付属していない場合は、計装ライブラリを使用して、ライブラリまたはフレームワークのテレメトリーデータを生成できます。
たとえば、net/http
の計装ライブラリは、HTTPリクエストに基づいてスパンとメトリクスを自動的に作成します。
セットアップ
各計装ライブラリはパッケージです。一般的に、これは適切なパッケージをgo get
する必要があることを意味します。
たとえば、Contribリポジトリで維持されている計装ライブラリを取得するには、以下を実行します。
go get go.opentelemetry.io/contrib/instrumentation/{import-path}/otel{package-name}
次に、ライブラリが有効化するために必要なものに基づいて、コード内で設定します。
はじめにでは、net/http
サーバーの計装を設定する方法を示す例を提供しています。
利用可能なパッケージ
利用可能な計装ライブラリの完全なリストは、OpenTelemetryレジストリで見つけることができます。
次のステップ
計装ライブラリは、インバウンドおよびアウトバウンドHTTPリクエストのテレメトリーデータを生成するなどのことができますが、実際のアプリケーションを計装化することはありません。
カスタムインストルメンテーションをコードに統合して、テレメトリーデータを充実させてください。 これは標準ライブラリのテレメトリーを補完し、実行中のアプリケーションへのより深い洞察を提供できます。
フィードバック
このページは役に立ちましたか?
Thank you. Your feedback is appreciated!
Please let us know how we can improve this page. Your feedback is appreciated!