|
1 | | -# OpenTelemetry as a single .dll |
2 | | - |
3 | | -This branch builds a single `.dll`, combining both api + sdk parts, instead of being separate .dlls. |
4 | | - |
5 | | -Why? |
6 | | - - The `vcpkg` version of the package can build only static libraries, and in the future, if dynamic works it'll create .dll for each component: zlib, protobuf, etc. |
7 | | - - The built-in `CMake` rules produce more than one .dll, and do not expose all of the `sdk` by default. |
8 | | - |
9 | | -There are some critical issues with OpenTelemetry C++ in the original branch: |
10 | | - - The static library version does not work across dlls using it - their own `singleton_test` fails. |
11 | | - - The static library brings dozen of dependencies (zlib, protobuf, grpc, etc.) |
12 | | - - This not only increases the distribution size (from 100mb to 2GB), it can also silently introduce `ODR` violations too. |
13 | | - - Integration with MSVC's STL is needed, instead of relying the `nostd` custom implementation (using `abseil` internally). |
14 | | - |
15 | | -Why not `CMake`: |
16 | | - - It's not friendly, neither from the command-line, nor from the IDE. |
17 | | - - It requires plenty of custom build steps, some from the `ci/` folder, others from `tools/` |
18 | | - |
19 | | - ``` |
20 | | - pwsh ci/setup_windows_ci_environment.ps1 |
21 | | - pwsh ci/do_ci.ps1 cmake.dll.test |
22 | | - pwsh ci/do_ci.ps1 cmake.exporter.otprotocol.dll.test |
23 | | - ``` |
24 | | - |
25 | | -To tackle the above issues, this branch creates a dynamic `otel_sdk_r.dll` library, exposing only the OpenTelemetry C++ api: |
26 | | - - All of the `api` classes are inline, and only few static function members need to be exported, in order to guarantee single stroage for their own static variables ("singletons") |
27 | | - - Hence `OPENTELEMETRY_API_SINGLETON` would be `__declspec(dllimport)` when using the library. |
28 | | - - For the `sdk` part (exporters, ext, etc.) the above is not used, but rather `OPENTELEMETRY_EXPORT` (also `dllimport`) for some classes. |
29 | | - |
30 | | -## Build settings |
31 | | - |
32 | | -- The `.bazelrc` file tries to import `../top.bazelrc`, where you can specify more settings (for example disk cache) |
33 | | -- MSVC Toolset version `14.29.30133` is used (the last from the `v142` series in VS2019). This toolset is also available, as an additional install, in VS2022 too. |
34 | | -- VS2019 was chosen due to: https://learn.microsoft.com/en-us/cpp/porting/binary-compat-2015-2017#restrictions |
35 | | - |
36 | | -## How to use |
37 | | - |
38 | | -In order to use the library, the users only need to define OPENTELEMETRY_DLL to 1, and include `<opentelemetry/version.h>` as the first file: |
39 | | - |
40 | | -```C++ |
41 | | -#define OPENTELEMETRY_DLL 1 |
42 | | -#include <opentelemetry/version.h> |
43 | | -#include <opentelemetry/... some other header file> |
44 | | -``` |
45 | | -
|
46 | | -- Some MSVC warnings might have to be disabled too, like: 4505 4251 4275 |
47 | | -
|
48 | | -## Some limitations |
49 | | -
|
50 | | -Some things are missing: |
51 | | - - The `protobuf` level of accessing metrics/logs/trace APIs is missing. |
52 | | - - Some useful plumbing with `grpc` is missing too. |
53 | | -
|
54 | | -## Building |
55 | | -
|
56 | | -This branch uses `bazel` to build, and relies on the `//:with_dll` bool flag to configure the build in `dll` mode: |
57 | | -
|
58 | | -``` |
59 | | -bazel test --//:with_dll=true ... -k |
60 | | -``` |
61 | | - |
62 | | -This produces `otel_sdk_rd.dll` (in the default `fastbuild` configuration, `rd` stands for `release/debug` borrowed from `CMake`'s jargon). |
63 | | - |
64 | | -## Packaging |
65 | | - |
66 | | -A single `otel_sdk.zip` is produced, mimicking how `vcpkg` exports packages: |
67 | | - - Single `include/` folder |
68 | | - - Three `lib` folders: `lib/`, `debug/lib` and `reldeb/lib` (vcpkg only generates the first two) |
69 | | - - Same for `bin`: `bin`, `debug/bin` and `reldeb/bin` |
70 | | - - In addition Sentry's `sentrycli` was used to gather (from the .pdb files) all sources used to compile and bundle them in additional .zip files. |
| 1 | +# OpenTelemetry as a single .dll |
| 2 | + |
| 3 | +This branch builds a single `.dll`, combining both api + sdk parts, instead of being separate .dlls. |
| 4 | + |
| 5 | +Why? |
| 6 | + - The `vcpkg` version of the package can build only static libraries, and in the future, if dynamic works it'll create .dll for each component: zlib, protobuf, etc. |
| 7 | + - The built-in `CMake` rules produce more than one .dll, and do not expose all of the `sdk` by default. |
| 8 | + |
| 9 | +There are some critical issues with OpenTelemetry C++ in the original branch: |
| 10 | + - The static library version does not work across dlls using it - their own `singleton_test` fails. |
| 11 | + - The static library brings dozen of dependencies (zlib, protobuf, grpc, etc.) |
| 12 | + - This not only increases the distribution size (from 100mb to 2GB), it can also silently introduce `ODR` violations too. |
| 13 | + - Integration with MSVC's STL is needed, instead of relying the `nostd` custom implementation (using `abseil` internally). |
| 14 | + |
| 15 | +Why not `CMake`: |
| 16 | + - It's not friendly, neither from the command-line, nor from the IDE. |
| 17 | + - It requires plenty of custom build steps, some from the `ci/` folder, others from `tools/` |
| 18 | + |
| 19 | + ``` |
| 20 | + pwsh ci/setup_windows_ci_environment.ps1 |
| 21 | + pwsh ci/do_ci.ps1 cmake.dll.test |
| 22 | + pwsh ci/do_ci.ps1 cmake.exporter.otprotocol.dll.test |
| 23 | + ``` |
| 24 | + |
| 25 | +To tackle the above issues, this branch creates a dynamic `otel_sdk_r.dll` library, exposing only the OpenTelemetry C++ api: |
| 26 | + - All of the `api` classes are inline, and only few static function members need to be exported, in order to guarantee single stroage for their own static variables ("singletons") |
| 27 | + - Hence `OPENTELEMETRY_API_SINGLETON` would be `__declspec(dllimport)` when using the library. |
| 28 | + - For the `sdk` part (exporters, ext, etc.) the above is not used, but rather `OPENTELEMETRY_EXPORT` (also `dllimport`) for some classes. |
| 29 | + |
| 30 | +## Build settings |
| 31 | + |
| 32 | +- The `.bazelrc` file tries to import `../top.bazelrc`, where you can specify more settings (for example disk cache) |
| 33 | +- MSVC Toolset version `14.29.30133` is used (the last from the `v142` series in VS2019). This toolset is also available, as an additional install, in VS2022 too. |
| 34 | +- VS2019 was chosen due to: https://learn.microsoft.com/en-us/cpp/porting/binary-compat-2015-2017#restrictions |
| 35 | + |
| 36 | +## How to use |
| 37 | + |
| 38 | +In order to use the library, the users only need to define OPENTELEMETRY_DLL to 1, and include `<opentelemetry/version.h>` as the first file: |
| 39 | + |
| 40 | +```C++ |
| 41 | +#define OPENTELEMETRY_DLL 1 |
| 42 | +#include <opentelemetry/version.h> |
| 43 | +#include <opentelemetry/... some other header file> |
| 44 | +``` |
| 45 | +
|
| 46 | +- Some MSVC warnings might have to be disabled too, like: 4505 4251 4275 |
| 47 | +
|
| 48 | +## Some limitations |
| 49 | +
|
| 50 | +Some things are missing: |
| 51 | + - The `protobuf` level of accessing metrics/logs/trace APIs is missing. |
| 52 | + - Some useful plumbing with `grpc` is missing too. |
| 53 | +
|
| 54 | +## Building |
| 55 | +
|
| 56 | +This branch uses `bazel` to build, and relies on the `//:with_dll` bool flag to configure the build in `dll` mode: |
| 57 | +
|
| 58 | +``` |
| 59 | +bazel test --//:with_dll=true ... -k |
| 60 | +``` |
| 61 | + |
| 62 | +This produces `otel_sdk_rd.dll` (in the default `fastbuild` configuration, `rd` stands for `release/debug` borrowed from `CMake`'s jargon). |
| 63 | + |
| 64 | +## Packaging |
| 65 | + |
| 66 | +A single `otel_sdk.zip` is produced, mimicking how `vcpkg` exports packages: |
| 67 | + - Single `include/` folder |
| 68 | + - Three `lib` folders: `lib/`, `debug/lib` and `reldeb/lib` (vcpkg only generates the first two) |
| 69 | + - Same for `bin`: `bin`, `debug/bin` and `reldeb/bin` |
| 70 | + - In addition Sentry's `sentrycli` was used to gather (from the .pdb files) all sources used to compile and bundle them in additional .zip files. |
0 commit comments