[SDK] Create instrumentation scope library - #4351
Open
dbarker wants to merge 5 commits into
Open
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #4351 +/- ##
==========================================
+ Coverage 82.61% 82.63% +0.02%
==========================================
Files 511 512 +1
Lines 20132 20140 +8
==========================================
+ Hits 16631 16641 +10
+ Misses 3501 3499 -2
🚀 New features to boost your workflow:
|
dbarker
marked this pull request as ready for review
August 3, 2026 21:18
There was a problem hiding this comment.
Pull request overview
This PR introduces a standalone SDK “instrumentation scope” library target (CMake + Bazel) and moves InstrumentationScope method implementations out of the public header into a compiled .cc, enabling consumers to link only what they need and supporting the ongoing effort to shift SDK implementation into source files.
Changes:
- Added new
opentelemetry_instrumentation_scopeCMake target and corresponding Bazel//sdk/src/instrumentationscopelibrary. - Moved
InstrumentationScopeimplementation frominstrumentation_scope.hintoinstrumentation_scope.cc. - Made metrics/trace/logs targets depend transitively on the new instrumentation scope library and updated tests/build wiring accordingly.
Reviewed changes
Copilot reviewed 15 out of 15 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| sdk/test/instrumentationscope/CMakeLists.txt | Switches the test executable to link against the new instrumentation scope library target. |
| sdk/test/instrumentationscope/BUILD | Adds Bazel deps so the instrumentation scope tests link against the new library (and related common code). |
| sdk/src/trace/CMakeLists.txt | Adds opentelemetry_instrumentation_scope as a PUBLIC dependency of the trace SDK library. |
| sdk/src/trace/BUILD | Adds Bazel dependency on //sdk/src/instrumentationscope for the trace SDK library. |
| sdk/src/metrics/CMakeLists.txt | Adds opentelemetry_instrumentation_scope as a PUBLIC dependency of the metrics SDK library. |
| sdk/src/metrics/BUILD | Adds Bazel dependency on //sdk/src/instrumentationscope for the metrics SDK library. |
| sdk/src/logs/CMakeLists.txt | Adds opentelemetry_instrumentation_scope as a PUBLIC dependency of the logs SDK library. |
| sdk/src/logs/BUILD | Adds Bazel dependency on //sdk/src/instrumentationscope for the logs SDK library. |
| sdk/src/instrumentationscope/instrumentation_scope.cc | New compiled implementation of InstrumentationScope APIs previously inline in the header. |
| sdk/src/instrumentationscope/CMakeLists.txt | New CMake target definition for opentelemetry_instrumentation_scope (with install/pkg-config support). |
| sdk/src/instrumentationscope/BUILD | New Bazel cc_library for the instrumentation scope implementation. |
| sdk/src/CMakeLists.txt | Adds the new instrumentationscope subdirectory to the SDK build. |
| sdk/include/opentelemetry/sdk/instrumentationscope/instrumentation_scope.h | Converts previously-inline methods to declarations only (implementation moved to .cc). |
| sdk/CMakeLists.txt | Registers the new SDK component so it’s exported/installed with other SDK libraries. |
| CHANGELOG.md | Adds a changelog entry for the new SDK instrumentation scope library target. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Comment on lines
+4
to
+8
| #include "opentelemetry/sdk/instrumentationscope/instrumentation_scope.h" | ||
| #include <unordered_map> | ||
| #include <utility> | ||
| #include <vector> | ||
| #include "opentelemetry/nostd/variant.h" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Contributes to #1429
This PR creates CMake and Bazel targets for the instrumentation scope library. This is an important target to provide as it supports users in linking to just what they need use the
InstrumentationScopeobject in their projects (e.g. building custom configurators, etc.). Also supports moving SDK code out of headers and into .cc files (#1429).With this change users can link directly to the library with:
The library will also be a public transitive link provided by metrics, trace, and logs targets.
Changes
For significant contributions please make sure you have completed the following items:
CHANGELOG.mdupdated for non-trivial changes