-
Notifications
You must be signed in to change notification settings - Fork 483
[Draft] Add bundle version of utf8_range to validate attribute values #3512
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
✅ Deploy Preview for opentelemetry-cpp-api-docs canceled.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR introduces a bundled UTF-8 validation library (utf8_range
) and integrates it into attribute validation throughout the SDK, ensuring that span, resource, and instrumentation-scope attributes containing invalid UTF-8 are filtered out with warnings.
- Add
attribute_validity
module wrapping the newutf8_range
library - Integrate attribute validation/filtering into
Span
,Resource
, andInstrumentationScope
- Add build rules for
utf8_range
and update CMake/Bazel files accordingly
Reviewed Changes
Copilot reviewed 16 out of 16 changed files in this pull request and generated 1 comment.
Show a summary per file
File | Description |
---|---|
sdk/src/common/internal/utf8_range/uft8_range.cc | Added bundled UTF-8 validation implementation |
sdk/src/common/internal/utf8_range/utf8_range.h | Declared public API for UTF-8 validation (IsValid , ValidPrefix ) |
sdk/src/common/attribute_validity.cc | Wrapped validation logic around SDK attribute values |
sdk/src/common/BUILD | Added utf8_range and attribute_validity libraries |
sdk/src/common/CMakeLists.txt | Updated to include new source in common build |
sdk/src/trace/span.cc | Applied attribute validation in Span::SetAttribute and AddLink |
sdk/src/resource/resource.cc | Applied attribute validation in Resource constructor |
sdk/include/opentelemetry/sdk/instrumentationscope/instrumentation_scope.h | Applied attribute validation in instrumentation scope factories and setters |
sdk/test/instrumentationscope/CMakeLists.txt | Updated linkage to include opentelemetry_common |
sdk/test/instrumentationscope/BUILD | Added dependency on attribute_validity for tests |
Comments suppressed due to low confidence (2)
sdk/src/common/internal/utf8_range/uft8_range.cc:1
- The source file is named
uft8_range.cc
, which looks like a typo. Renaming it toutf8_range.cc
would align with the header (utf8_range.h
) and improve consistency.
// Copyright 2023 Google LLC
sdk/src/common/BUILD:6
- The new
utf8_range
library adds core validation logic but there are no accompanying unit tests verifying valid and invalid UTF-8 sequences. Consider adding tests undersdk/test/common/
to cover edge cases.
cc_library(
@@ -22,7 +24,20 @@ namespace resource | |||
|
|||
Resource::Resource(const ResourceAttributes &attributes, const std::string &schema_url) noexcept | |||
: attributes_(attributes), schema_url_(schema_url) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Initializing attributes_
with the full map and then selectively re-adding valid entries in the constructor means invalid entries remain in attributes_
. Consider default-initializing attributes_
empty and only inserting valid key–value pairs.
: attributes_(attributes), schema_url_(schema_url) | |
: attributes_(), schema_url_(schema_url) |
Copilot uses AI. Check for mistakes.
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #3512 +/- ##
==========================================
- Coverage 89.96% 88.49% -1.47%
==========================================
Files 219 222 +3
Lines 7051 7235 +184
==========================================
+ Hits 6343 6402 +59
- Misses 708 833 +125
🚀 New features to boost your workflow:
|
Fixes #3491
Changes
For significant contributions please make sure you have completed the following items:
CHANGELOG.md
updated for non-trivial changes