[SDK] Read span limits from environment variables#4258
Conversation
3184ec8 to
25b7940
Compare
|
@HrMathematiker thanks for the contribution. Please take a look on the missing CLA authorization. |
3c5e3ca to
2578631
Compare
|
Thanks for the contribution, this part is really needed in opentelemetry-cpp. Please clear the EasyCLA, merging can not happen without it. |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #4258 +/- ##
==========================================
+ Coverage 81.19% 81.20% +0.02%
==========================================
Files 444 445 +1
Lines 18880 18902 +22
==========================================
+ Hits 15328 15348 +20
- Misses 3552 3554 +2
🚀 New features to boost your workflow:
|
972fc04 to
d3c2d3a
Compare
Adds span_limits_env::GetSpanLimitsFromEnv(), which builds a SpanLimits from the environment variables defined in the specification (OTEL_SPAN_ATTRIBUTE_COUNT_LIMIT, OTEL_SPAN_ATTRIBUTE_VALUE_LENGTH_LIMIT, OTEL_SPAN_EVENT_COUNT_LIMIT, OTEL_SPAN_LINK_COUNT_LIMIT, OTEL_EVENT_ATTRIBUTE_COUNT_LIMIT, OTEL_LINK_ATTRIBUTE_COUNT_LIMIT, and the general OTEL_ATTRIBUTE_* fallbacks), and uses it as the default in the TracerProviderFactory::Create overloads that previously defaulted to SpanLimits::NoLimits(). A field whose variable is unset keeps its NoLimits() value, so behavior is unchanged when no variables are set; explicitly passed SpanLimits keep taking precedence.
d3c2d3a to
1f21f0b
Compare
|
@marcalff the CLI is authorized now :) |
dbarker
left a comment
There was a problem hiding this comment.
Looks good to me. Thanks for the contribution. Just optional feedback below.
| void UpdateFromEnv(const char *env_var_name, std::uint32_t &limit) | ||
| { | ||
| std::uint32_t value{}; | ||
| if (opentelemetry::sdk::common::GetUintEnvironmentVariable(env_var_name, value)) |
There was a problem hiding this comment.
Could we also update the Bazel deps for this new env parsing code? CMake includes the new source file, but Bazel will pick it up too and needs the matching env_variables dependency.
lalitb
left a comment
There was a problem hiding this comment.
LGTM with comment on bazel build. Thanks
Fixes #4257
Changes
Adds
span_limits_env::GetSpanLimitsFromEnv(), which builds aSpanLimitsfrom the environment variables defined in the specification, and uses it as the default in theTracerProviderFactory::Createoverloads that previously defaulted toSpanLimits::NoLimits(). The implementation mirrors the existingbatch_span_processor_options_envpattern (OTEL_BSP_*).Semantics, chosen to preserve the backward-compatible default established in #4232:
SpanLimits::NoLimits()value — with no variables set,GetSpanLimitsFromEnv() == SpanLimits::NoLimits()and SDK behavior is unchanged.OTEL_SPAN_ATTRIBUTE_VALUE_LENGTH_LIMIT,OTEL_SPAN_ATTRIBUTE_COUNT_LIMIT,OTEL_SPAN_EVENT_COUNT_LIMIT,OTEL_SPAN_LINK_COUNT_LIMIT,OTEL_EVENT_ATTRIBUTE_COUNT_LIMIT,OTEL_LINK_ATTRIBUTE_COUNT_LIMIT, plus the generalOTEL_ATTRIBUTE_VALUE_LENGTH_LIMIT/OTEL_ATTRIBUTE_COUNT_LIMIT, with the span-specific variables taking precedence per the spec.SpanLimits(programmatic, or declarative configuration through the sdk builder) continue to take precedence over the environment, matching the spec's configuration-precedence order.Follow-up once merged: flip the C++ cells of the span-limit env-variable rows in the spec compliance matrix (separate PR to the specification repo).
For significant contributions please make sure you have completed the following items:
CHANGELOG.mdupdated for non-trivial changes