Skip to content

Conversation

@sjaanus
Copy link
Contributor

@sjaanus sjaanus commented Dec 18, 2025

Start sending impact metrics in metrics payload.

Comment on lines +72 to +76
List<CollectedMetric> impactMetricsOrNull =
impactMetrics.isEmpty() ? null : impactMetrics;

ClientMetrics metrics =
new ClientMetrics(unleashConfig, bucket, impactMetricsOrNull);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

There is design from node SDK, that if we do not have any metrics, we do not add the empty array to payload.

}

@Test
public void should_serialize_histogram_with_positive_infinity_as_plus_inf_string() {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Moving this to http level, so we can catch also if serializer was not mounted.

}

@Test
public void should_send_impact_metrics_with_histogram_and_plus_inf_bucket()
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Following the java test style, we verify that +Inf is being sent.

}

@Test
public void should_include_impact_metrics_in_clientmetrics_payload() throws YggdrasilError {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

These tests are same as in node SDK.

300,
unleashConfig.getUnleashURLs().getClientMetricsURL());
this.engine = engine;
ImpactMetricsDataSource configuredRegistry = unleashConfig.getImpactMetricsRegistry();
Copy link
Contributor

Choose a reason for hiding this comment

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

why the registry lives in the config and is not passed as other dependencies via constructor?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ImpactMetricsDataSource is configurable, so it belongs in UnleashConfig, and UnleashMetricServiceImpl reads it from there (with a default fallback), just like it does for other configurable dependencies.

unleashConfig.getUnleashURLs().getClientMetricsURL());
this.engine = engine;
ImpactMetricsDataSource configuredRegistry = unleashConfig.getImpactMetricsRegistry();
this.impactMetricsRegistry =
Copy link
Contributor

Choose a reason for hiding this comment

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

this is a code smell (https://lab.abilian.com/Tech/Architecture%20%26%20Software%20Design/Dependency%20Inversion/DI%20anti-patterns/#bastard-injection-poor-mans-injection). as a user I don't know when I should pass the registry and when it will be created automatically.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good catch, fixed it by following what we do with UnleashScheduledExecutorImpl

@kwasniew kwasniew self-requested a review December 18, 2025 13:55
@github-project-automation github-project-automation bot moved this from New to Approved PRs in Issues and PRs Dec 18, 2025
@sjaanus sjaanus merged commit 8c0f334 into main Dec 18, 2025
24 of 30 checks passed
@sjaanus sjaanus deleted the metric-send branch December 18, 2025 14:12
@github-project-automation github-project-automation bot moved this from Approved PRs to Done in Issues and PRs Dec 18, 2025
@coveralls
Copy link
Collaborator

coveralls commented Dec 18, 2025

Pull Request Test Coverage Report for Build 20338631979

Warning: This coverage report may be inaccurate.

This pull request's base commit is no longer the HEAD commit of its target branch. This means it includes changes from outside the original pull request, including, potentially, unrelated coverage changes.

Details

  • 12 of 12 (100.0%) changed or added relevant lines in 2 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+0.7%) to 79.638%

Totals Coverage Status
Change from base Build 20330496567: 0.7%
Covered Lines: 3075
Relevant Lines: 3730

💛 - Coveralls

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

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

3 participants