This document describes the considerations and recommendations for using the OpenTelemetry-cpp library.
The OpenTelemetry-cpp libraries (API and SDK) and any library that depends on them are expected to be distributed as either "source" or "binary" artifacts. This document defines these distribution models as:
This document will focus on the specific challenges of the "binary" distribution model.
The library and its dependants can be distributed and bound (loaded) in multiple ways which are defined as follows:
.a
extension on Unix-like systems) which is linked and bound at compile-time..so on Unix-like systems), and its binding is defined at
compile-time. It is loaded by the dynamic linker when the application/library
depending on it is started/loaded..so on Unix-like systems), only its interface is known at
compile-time. It is loaded dynamically (using dlopen on POSIX).NOTE: A library may itself link in other libraries based on any of the above.
The following components will be considered for analysing the impact of different binding models and the recommendations.
TracerProvider.exporters may be provided externally (e.g.
distributed by a vendor).main(), this also
includes interpreters such as Python which will be considered. This binary may
itself instrument using OpenTelemetry or register a specific implementation.For more information on language-agnostic library, please see: OpenTelemetry Specification Library Guidelines.
Some guarantees regarding binary compatibility will be necessary given the binary distribution model supported by this project. The policies and approach regarding this will be documented in ABI Policy.
If you're a vendor and you wish to distribute an OpenTelemetry plugin (either a full implementation of the API or an exporter), you need to take precautions when linking your plugin to ensure it's portable. Here are some steps you should follow:
Binary executable can be distributed with static linkage ,for all libraries known at compile time. In this case the OpenTelemetry API Library can be linked in statically, guaranteeing that only a single symbol is exported for singletons.
An application can link to the OpenTelemetry API but dynamically load an implementation at runtime. Under this mode, an application can work with any vendor's implementation by using it as a plugin.
For example, a C++ database server might add support for the OpenTelemetry API and exposes configuration options that let a user point to a vendor's plugin and load it with a JSON config. (With OpenTracing, Ceph explored a deployment scenario similar to this. See this link)
An application itself may not be OpenTelemetry-aware, but it can support OpenTelemetry via extensions.
Examples:
Additionally, when multiple OpenTelemetry-aware extensions co-exist in the same application, the extensions should be able to coordinate and share context through the OpenTelemetry API's singletons.