Skip to content

fix: stop otel warning logs - #1956

Open
RafeArnold wants to merge 2 commits into
open-feature:mainfrom
RafeArnold:fix-otel-warnings
Open

RafeArnold wants to merge 2 commits into
open-feature:mainfrom
RafeArnold:fix-otel-warnings

Conversation

@RafeArnold

@RafeArnold RafeArnold commented Oct 28, 2026 •

Copy link
Copy Markdown
  • fix: otel warn logs for null TracesHook attribs
  • fix: otel warn logs for null MetricsHook attribs

This PR

as of otel api 1.67.0, AttributesBuilder.putAll logs a warning if passed null. both TracesHook and MetricsHook call AttributesBuilder.putAll in their after and error methods, so if any of the Hooks' attribute options produced null, it would trigger this warning log. the PR prevents those logs by ensuring Attributes.putAll is never called with a null argument.

How to test

Relevant tests have been added to the existing junit suite.

@coderabbitai

coderabbitai Bot commented Oct 28, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

Important

Review skipped

Review was skipped as selected files did not have any reviewable changes.

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: a0f082c5-d652-48cc-9815-592813548eb3
Commits

Reviewing files that changed from the base of the PR and between af5c24c and 69712a6.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • Trigger review

No actionable comments were generated in the recent review.

Walkthrough

MetricsHook and TracesHook now handle null extra attributes and null results from attribute extractors. Parameterized tests capture warning-level and higher log messages for several option configurations.

Changes: OpenTelemetry attribute handling

Layer / File(s) Summary
Null-safe attribute handling
hooks/open-telemetry/src/main/java/dev/openfeature/contrib/hooks/otel/MetricsHook.java, hooks/open-telemetry/src/main/java/dev/openfeature/contrib/hooks/otel/TracesHook.java
Both hooks use empty attributes when extra attributes are null. Their after methods add extracted attributes only when the extractor returns a non-null value.
Parameterized warning-log tests
hooks/open-telemetry/src/test/java/dev/openfeature/contrib/hooks/otel/MetricsHookTest.java, hooks/open-telemetry/src/test/java/dev/openfeature/contrib/hooks/otel/TracesHookTest.java
The tests capture root-logger messages at warning level or higher while invoking the error and after stages with the specified option configurations.

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix

Suggested reviewers: kavindu-dodan

Merge Risk: Minimal · previous review f08c1

No merge-blocking risk was identified.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 25.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documenta… Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed

Check name Status Explanation
Title check Passed The title clearly summarizes the main change: preventing OpenTelemetry warning logs caused by null attributes.
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Description check Passed The description states the PR fixes OpenTelemetry warning logs caused by AttributesBuilder.putAll receiving null attributes in TracesHook and MetricsHook. It names the affected after and error methods…
Full details: Description check

Explanation

The description states the PR fixes OpenTelemetry warning logs caused by AttributesBuilder.putAll receiving null attributes in TracesHook and MetricsHook. It names the affected after and error methods, the cause (otel api 1.67.0), the fix (never call putAll with null), and the added tests. This matches the changeset, which guards null attributes in both hooks and adds tests that assert no warnings are logged.

Full details: Docstring Coverage

Explanation

Docstring coverage is 25.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 4 functions across 4 files.

Resolution

Write docstrings for the functions missing them to satisfy the coverage threshold.

  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 89e7f752-5521-45c2-91e0-5abef3ec4778
Commits

Reviewing files that changed from the base of the PR and between a91a790 and f08c16c.

Files selected for processing: 4

  • hooks/open-telemetry/src/main/java/dev/openfeature/contrib/hooks/otel/MetricsHook.java
  • hooks/open-telemetry/src/main/java/dev/openfeature/contrib/hooks/otel/TracesHook.java
  • hooks/open-telemetry/src/test/java/dev/openfeature/contrib/hooks/otel/MetricsHookTest.java
  • hooks/open-telemetry/src/test/java/dev/openfeature/contrib/hooks/otel/TracesHookTest.java

Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.

@aepfli aepfli left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thank you, looks like a good addition to me.

@RafeArnold

Copy link
Copy Markdown
Author

thanks for the review @aepfli! is there anything i can do to move this forward?

@aepfli

aepfli commented Nov 4, 2026

Copy link
Copy Markdown
Member

hey @RafeArnold, nothing I can do, we need a second approval from @open-feature/sdk-java-maintainers - hopefully this ping helps

as of otel api 1.67.0, AttributesBuilder.putAll logs a warning if passed
null. both TracesHook.after and TracesHook.error call AttributesBuilder
.putAll, so if TracesHookOptions.extraAttributes is left as its null
default, or set to null explicitly, or the provided dimensionExtractor
returns null it triggers this warning log. to avoid this, TracesHook
uses Attributes.empty if passed an options instance with a null
extraAttributes field, and checks if the extractor produced null before
adding the result.

Signed-off-by: rafearnold <rafe.arnold@gmail.com>
port the TracesHook fix from the previous commit to MetricsHook.

Signed-off-by: rafearnold <rafe.arnold@gmail.com>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants