Using instrumentation libraries
当你开发应用时,可能会使用第三方库和框架来加快开发进度。如果你随后使用 OpenTelemetry 对应用进行插桩,你可能希望避免额外花时间为所用的第三方库和框架手动添加链路、日志和指标。
许多库和框架已经原生支持 OpenTelemetry,或者通过 OpenTelemetry 的插桩获得支持, 因此它们能够生成可导出到可观测性后端的遥测数据。
如果你正在为使用第三方库或框架的应用或服务进行插桩, 请按照以下说明学习如何为你的依赖项使用原生插桩库和插桩库。
使用原生插桩库
如果某个库默认就支持 OpenTelemetry,你只需在应用中添加并配置 OpenTelemetry SDK, 就可以获取该库发出的链路、指标和日志。
该库可能需要一些额外的插桩配置。请查阅该库的文档以了解更多信息。
截至目前,我们还不知道有任何 C++ 库已原生集成 OpenTelemetry。 如果你知道这样的库,请告诉我们。
Using instrumentation libraries
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. See the documentation for that library to learn more.
If a library doesn’t include OpenTelemetry support, you can use instrumentation libraries to generate telemetry data for a library or framework.
Setup
To set up an instrumentation library see otel-cpp-contrib
Available packages
A full list of instrumentation libraries available can be found in the OpenTelemetry registry
Next steps
After you’ve set up instrumentation libraries, you might want to add additional instrumentation to collect custom telemetry data.
You might also want to configure an appropriate exporter to export your telemetry data to one or more telemetry backends.
Feedback
Was this page helpful?
Thank you. Your feedback is appreciated!
Please let us know how we can improve this page. Your feedback is appreciated!