Skip to content

Update App.Metrics to v4#248

Open
dkropachev wants to merge 9 commits into
scylladb:masterfrom
dkropachev:fix/appmetrics-4-ci
Open

Update App.Metrics to v4#248
dkropachev wants to merge 9 commits into
scylladb:masterfrom
dkropachev:fix/appmetrics-4-ci

Conversation

@dkropachev

@dkropachev dkropachev commented Jun 26, 2026

Copy link
Copy Markdown
Collaborator

Supersedes #240.

This recreates and broadens Renovate's App.Metrics v4 bump on top of current master, which includes the shard-aware pool-balancing fix from #242.

The shipped AppMetrics extension and the integration-test consumer are now aligned on App.Metrics 4.3.0:

  • Cassandra.IntegrationTests uses App.Metrics 4.3.0
  • Cassandra.AppMetrics uses App.Metrics.Abstractions and App.Metrics.Concurrency 4.3.0

Using 4.3.0 avoids the vulnerable legacy NETStandard.Library dependency path exposed by App.Metrics.Concurrency 4.2.0. Cassandra.IntegrationTests also pins patched System.Text.Json / System.Text.RegularExpressions versions so the restored graph does not retain vulnerable legacy transitive versions.

AppMetricsGraphite remains on its existing App.Metrics 3.2.0 reporter package in this PR. It still builds against the updated extension project, and changing that example manifest causes Snyk to scan/fail the example dependency tree independently of the shipped extension update.

The replacement CI runs exposed unrelated/flaky integration-test assertions:

  • shard-aware pool connection counts were asserted after fixed sleeps even though pool growth can settle asynchronously
  • a shard-aware connection-count check could observe a pool before it had warmed to the configured target count
  • node-down metrics counters were assumed to stay zero on live hosts, but retries/errors can be observed nondeterministically while one node is down

This PR keeps the same expectations where they are deterministic, replaces fixed sleeps with retry assertions for connection-pool counts, warms the relevant pools before checking shard-aware target sizes, treats node-down counters as valid non-negative metric values, and uses a tolerance for the App.Metrics gauge comparison.

Local verification:

make .use-development-snk
dotnet build src/Extensions/Cassandra.AppMetrics/Cassandra.AppMetrics.csproj -c Release /p:BuildTarget=all -v:minimal -m:1
dotnet build examples/Metrics/AppMetricsGraphite/AppMetricsGraphite.csproj -c Release -v:minimal -m:1
dotnet list src/Extensions/Cassandra.AppMetrics/Cassandra.AppMetrics.csproj package --vulnerable --include-transitive
dotnet build src/Cassandra.IntegrationTests/Cassandra.IntegrationTests.csproj -c Release /p:BuildTarget=all /t:Rebuild -v:minimal -m:1
dotnet build src/Cassandra.IntegrationTests/Cassandra.IntegrationTests.csproj -c Release /p:BuildTarget=all -v:minimal -m:1
dotnet format --verify-no-changes --severity warn --verbosity diagnostic src/Cassandra.IntegrationTests/Cassandra.IntegrationTests.csproj

Result: all local builds completed successfully. The AppMetrics extension has no vulnerable packages according to NuGet vulnerability metadata. The integration-test project build completed with 64 existing/expected unsupported-TFM warnings and 0 errors.

@coderabbitai

coderabbitai Bot commented Jun 26, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: f4c080cf-29ba-49dc-9348-5b2a18166559

📥 Commits

Reviewing files that changed from the base of the PR and between 4af0d2d and 3fc3aa1.

📒 Files selected for processing (3)
  • src/Cassandra.IntegrationTests/Cassandra.IntegrationTests.csproj
  • src/Cassandra.IntegrationTests/Core/SessionTests.cs
  • src/Extensions/Cassandra.AppMetrics/Cassandra.AppMetrics.csproj
🚧 Files skipped from review as they are similar to previous changes (2)
  • src/Extensions/Cassandra.AppMetrics/Cassandra.AppMetrics.csproj
  • src/Cassandra.IntegrationTests/Core/SessionTests.cs

📝 Walkthrough

Walkthrough

The PR upgrades App.Metrics from version 3.2.0 to 4.3.0 in the integration tests project, adds a System.Text.RegularExpressions 4.3.1 package reference, and pins App.Metrics.Abstractions and App.Metrics.Concurrency to exact version 4.3.0 in the AppMetrics extension project. Integration tests are updated: session connection pool assertions replace fixed Thread.Sleep calls with TestHelper.RetryAssert retry loops and a WarmupAndAssertFirstTwoPoolsHaveOpenConnections helper. Metrics test assertions are relaxed to use numeric tolerance for gauge comparisons and uniform non-negative checks for node counters.

Suggested Reviewers

  • nikagra
  • sylwiaszunejko
  • Lorak-mmk
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main change: upgrading App.Metrics to v4.
Description check ✅ Passed The description matches the dependency updates and test stabilization work in the pull request.
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.

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 3

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/Cassandra.IntegrationTests/Cassandra.IntegrationTests.csproj`:
- Line 36: App.Metrics has been bumped to 4.2.0, but the integration tests still
need a full 4.x migration audit across src/Cassandra.IntegrationTests. Review
all App.Metrics usage sites and update them to the 4.x API surface, including
any renamed packages like App.Metrics.AspNetCore, removed Health Checks, and
host model changes from IWebHost to IHost. If the existing metrics integration
cannot be adapted cleanly, replace the App.Metrics references with
OpenTelemetry-based equivalents and remove obsolete App.Metrics dependencies
from the test project.
- Line 36: The integration test project is referencing App.Metrics 4.2.0 while
Cassandra.AppMetrics and AppMetricsGraphite are still pinned to older 3.x
packages, so align the App.Metrics dependency versions across these projects.
Update Cassandra.AppMetrics to use App.Metrics.Abstractions 4.* (or 4.2.0) and
bring AppMetricsGraphite up to App.Metrics 4.2.0, then confirm the extension
code still matches the newer Abstractions and Concurrency APIs. Use the project
names Cassandra.IntegrationTests, Cassandra.AppMetrics, and AppMetricsGraphite
to locate the mismatched references.
- Line 36: The strict equality check in MetricsTests is comparing App.Metrics
gauge values that may now differ in type or precision under App.Metrics 4.x.
Update the assertion around GetNodeGauge and _metricsRoot.Snapshot.GetGaugeValue
to first confirm both sides are the same numeric type, and if they are
floating-point values, switch to a tolerance-based comparison instead of exact
equality.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: fa4f77b1-7344-4d7f-9499-7501ebcf523b

📥 Commits

Reviewing files that changed from the base of the PR and between be70f71 and e40113f.

📒 Files selected for processing (1)
  • src/Cassandra.IntegrationTests/Cassandra.IntegrationTests.csproj

Comment thread src/Cassandra.IntegrationTests/Cassandra.IntegrationTests.csproj Outdated
@dkropachev
dkropachev force-pushed the fix/appmetrics-4-ci branch from e40113f to 4aed567 Compare June 26, 2026 16:21

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/Cassandra.IntegrationTests/Metrics/MetricsTests.cs`:
- Line 300: The counter assertion in MetricsTests is too weak because checking
GetNodeCounter(...).GetValue() >= 0 will always pass even if the down-node path
stops updating metrics. Strengthen the invariant in the relevant test block
around MetricsTests and GetNodeCounter by asserting the expected counter
behavior under the node-down scenario, such as requiring a meaningful non-zero
change or a specific propagated value, so the test still verifies counter
activity rather than only non-negativity.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: ba79bf69-343d-4083-b40e-a7853c338840

📥 Commits

Reviewing files that changed from the base of the PR and between e40113f and 4af0d2d.

📒 Files selected for processing (5)
  • examples/Metrics/AppMetricsGraphite/AppMetricsGraphite.csproj
  • src/Cassandra.IntegrationTests/Cassandra.IntegrationTests.csproj
  • src/Cassandra.IntegrationTests/Core/SessionTests.cs
  • src/Cassandra.IntegrationTests/Metrics/MetricsTests.cs
  • src/Extensions/Cassandra.AppMetrics/Cassandra.AppMetrics.csproj
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/Cassandra.IntegrationTests/Cassandra.IntegrationTests.csproj

{
Assert.AreEqual(0, metrics.GetNodeCounter(h, c).GetValue());
}
Assert.GreaterOrEqual(metrics.GetNodeCounter(h, c).GetValue(), 0);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

This counter check is now effectively non-assertive.

>= 0 is a tautology for counters, so this block will still pass if the node-down path stops recording counter activity entirely. Please keep a stricter invariant here so the test still validates counter propagation under a down-node scenario.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/Cassandra.IntegrationTests/Metrics/MetricsTests.cs` at line 300, The
counter assertion in MetricsTests is too weak because checking
GetNodeCounter(...).GetValue() >= 0 will always pass even if the down-node path
stops updating metrics. Strengthen the invariant in the relevant test block
around MetricsTests and GetNodeCounter by asserting the expected counter
behavior under the node-down scenario, such as requiring a meaningful non-zero
change or a specific propagated value, so the test still verifies counter
activity rather than only non-negativity.

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.

1 participant