Skip to content

Thread allocationKey into ResolutionDetails flagMetadata#3534

Merged
gh-worker-dd-mergequeue-cf854d[bot] merged 10 commits into
developfrom
typo/thread-allocation-key-to-resolution-details-metadata
Jun 12, 2026
Merged

Thread allocationKey into ResolutionDetails flagMetadata#3534
gh-worker-dd-mergequeue-cf854d[bot] merged 10 commits into
developfrom
typo/thread-allocation-key-to-resolution-details-metadata

Conversation

@typotter

Copy link
Copy Markdown
Contributor

What does this PR do?

The allocationKey field from the Precomputed Flags API response (PrecomputedFlag) was not included in ResolutionDetails.flagMetadata, making it unavailable to callers who use resolve() for rich evaluation details (e.g. OpenFeature providers).

This PR threads allocationKey into flagMetadata so it is accessible alongside other extraLogging fields.

Motivation

OpenFeature providers (e.g. dd-openfeature-provider-kotlin) expose evaluation metadata to consumers via the EvaluationMetadata map. allocationKey is a key field for attribution and debugging. Without it in flagMetadata, providers cannot surface it to OpenFeature clients.

Additional Notes

  • buildMetadata(PrecomputedFlag) replaces the old extractMetadata(JSONObject) helper (dead code removed).
  • allocationKey is only added when non-blank.
  • A new test covers the blank allocationKey edge case to verify it is excluded from metadata.

Review checklist (to be filled by reviewers)

  • Feature or bugfix MUST have appropriate tests (unit, integration, e2e)
  • Make sure you discussed the feature or bugfix with the maintaining team in an Issue
  • Make sure each commit and the PR mention the Issue number (cf the CONTRIBUTING doc)

@typotter
typotter requested review from a team as code owners June 11, 2026 16:01
@dd-octo-sts-4191dd

Copy link
Copy Markdown

🐑 PR Shepherd is maintaining this PR

I watch your PR and automatically fix CI failures, rebase your branch, handle flaky tests, and push it to the merge queue when it's ready.

More about what I do → Guide

To pause me on this PR, add the flow-skip label.

@datadog-official

This comment has been minimized.

@codecov-commenter

codecov-commenter commented Jun 11, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 85.00000% with 3 lines in your changes missing coverage. Please review.
✅ Project coverage is 72.26%. Comparing base (edd7172) to head (b0593c8).

Files with missing lines Patch % Lines
.../flags/openfeature/internal/adapters/Converters.kt 72.73% 0 Missing and 3 partials ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #3534      +/-   ##
===========================================
+ Coverage    72.22%   72.26%   +0.04%     
===========================================
  Files          966      966              
  Lines        35644    35654      +10     
  Branches      5947     5951       +4     
===========================================
+ Hits         25741    25763      +22     
+ Misses        8281     8274       -7     
+ Partials      1622     1617       -5     
Files with missing lines Coverage Δ
...tadog/android/flags/internal/DatadogFlagsClient.kt 91.76% <100.00%> (+0.59%) ⬆️
.../flags/openfeature/internal/adapters/Converters.kt 82.14% <72.73%> (-6.75%) ⬇️

... and 39 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

- Add toEvaluationMetadata() helper that builds EvaluationMetadata from
  flagMetadata via the public Builder API (EvaluationMetadata constructor
  is internal in kotlin-sdk 0.6.2)
- Wire metadata into toProviderEvaluation()
- Add test verifying allocationKey round-trips through flagMetadata
0xnm
0xnm previously approved these changes Jun 11, 2026
@typotter

Copy link
Copy Markdown
Contributor Author

FFL-2510

val result = resolution.toProviderEvaluation()

// Then
assertThat(result.metadata?.getString("allocationKey")).isEqualTo(fakeAllocationKey)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Fails CI due to metadata is non-null

e: warnings found and -Werror specified
w: file:///go/src/github.com/DataDog/dd-sdk-android/features/dd-sdk-android-flags-openfeature/src/test/kotlin/com/datadog/android/flags/openfeature/internal/adapters/ConvertersTest.kt:154:35 Unnecessary safe call on a non-null receiver of type EvaluationMetadata

Suggested change
assertThat(result.metadata?.getString("allocationKey")).isEqualTo(fakeAllocationKey)
assertThat(result.metadata.getString("allocationKey")).isEqualTo(fakeAllocationKey)

is String -> builder.putString(key, value)
is Boolean -> builder.putBoolean(key, value)
is Int -> builder.putInt(key, value)
is Double -> builder.putDouble(key, value)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

typotter added 2 commits June 11, 2026 16:30
The Builder API doesn't have putLong; Long values fall through to
putString as-is via the else branch.
@typotter

Copy link
Copy Markdown
Contributor Author

Verified via javap on the actual kotlin-sdk-release-api.jar for the 0.6.2 version used in this project — Builder exposes only putString, putInt, putDouble, putBoolean. There is no putLong. The link you shared is likely to a different SDK version or branch. The compile error (Unresolved reference: putLong) was correct, and the removal is the right fix. Added a test to document that Long values fall through to the else -> putString branch.

@typotter

Copy link
Copy Markdown
Contributor Author

/merge

@gh-worker-devflow-routing-ef8351

gh-worker-devflow-routing-ef8351 Bot commented Jun 12, 2026

Copy link
Copy Markdown

View all feedbacks in Devflow UI.

2026-06-12 04:56:56 UTC ℹ️ Start processing command /merge


2026-06-12 04:57:01 UTC ℹ️ MergeQueue: waiting for PR to be ready

This pull request is not mergeable according to GitHub. Common reasons include pending required checks, missing approvals, or merge conflicts — but it could also be blocked by other repository rules or settings.
It will be added to the queue as soon as checks pass and/or get approvals. View in MergeQueue UI.
Note: if you pushed new commits since the last approval, you may need additional approval.
You can remove it from the waiting list with /remove command.


2026-06-12 05:35:09 UTC ℹ️ MergeQueue: merge request added to the queue

The expected merge time in develop is approximately 57m (p90).


2026-06-12 06:38:08 UTC ℹ️ MergeQueue: This merge request was merged

@BoolForgery fakeValue: Boolean
) {
// Given — Builder has no putLong (only putInt/putDouble/putString/putBoolean);
// Long values fall through to the else branch and are stored as their toString() representation.

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.

long value can be converted to int though if it fits

@gh-worker-dd-mergequeue-cf854d
gh-worker-dd-mergequeue-cf854d Bot merged commit dd1726c into develop Jun 12, 2026
28 checks passed
@gh-worker-dd-mergequeue-cf854d
gh-worker-dd-mergequeue-cf854d Bot deleted the typo/thread-allocation-key-to-resolution-details-metadata branch June 12, 2026 06:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants