Skip to content

fix: Accept any numeric tracking event value - #65

Draft
kinyoklion wants to merge 1 commit into
mainfrom
devin/1788361015-java-track-metric-value
Draft

fix: Accept any numeric tracking event value#65
kinyoklion wants to merge 1 commit into
mainfrom
devin/1788361015-java-track-metric-value

Conversation

@kinyoklion

Copy link
Copy Markdown
Member

track threw a ClassCastException for a tracking event value which was not a Double.

  • TrackingEventDetails.getValue() is an Optional<Number>, so new MutableTrackingEventDetails(99) (an Integer) reached the provider and failed the (Double) cast before any event was sent.
  • The value is now converted with Number.doubleValue(), which is what the LaunchDarkly trackMetric API takes.
  • Added a test tracking an integer value.
Implementation details

The OpenFeature Java SDK does not constrain the numeric type an application passes, and MutableTrackingEventDetails stores the Number as given, so any of Integer, Long, Float, or BigDecimal reached the cast. Only Double worked.

Testing: the change is covered by ProviderTest.itCanTrackAnIntegerTrackingEventValue. The test suite could not be run on this machine because Maven Central and the Gradle plugin portal answered dependency resolution with HTTP 429 from this network; CI runs the suite.

Link to Devin session: https://app.devin.ai/sessions/fe1eb757fe694ef79f3d09f6307d4b47
Open in Devin Desktop: https://app.devin.ai/desktop/session/fe1eb757fe694ef79f3d09f6307d4b47?variant=devin
Requested by: @kinyoklion

Signed-off-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Co-Authored-By: rlamb@launchdarkly.com <4955475+kinyoklion@users.noreply.github.com>
@devin-ai-integration

Copy link
Copy Markdown
Contributor

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment, CI, and merge conflict monitoring

@devin-ai-integration

Copy link
Copy Markdown
Contributor

@cursor review

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant