Skip to content

Conversation

@leonnicolas
Copy link

When using a replica with the mysql datastore, we register the
same metrics again and again.

This commit ignores AlreadyRegisteredError when registering our
custom metrics and adds a db_name label similar to the postgres
instrumentation.

Additionally, it updates the tests for multi instance creation in a way that we
don't create 2 connections with the same index. Otherwise we would
get another registration error when registering the sql collector sqlstats.

fixes: #2518

Signed-off-by: leonnicolas [email protected]

@leonnicolas leonnicolas requested a review from a team as a code owner September 9, 2025 20:11
@github-actions github-actions bot added area/datastore Affects the storage system area/tooling Affects the dev or user toolchain (e.g. tests, ci, build tools) labels Sep 9, 2025
@github-actions
Copy link

github-actions bot commented Sep 9, 2025

CLA Assistant Lite bot All contributors have signed the CLA ✍️ ✅

@leonnicolas
Copy link
Author

I have read the CLA Document and I hereby sign the CLA

authzedbot added a commit to authzed/cla that referenced this pull request Sep 9, 2025
@codecov
Copy link

codecov bot commented Sep 9, 2025

Codecov Report

❌ Patch coverage is 91.66667% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 77.77%. Comparing base (4ff0d47) to head (8b2afbf).
⚠️ Report is 8 commits behind head on main.

Files with missing lines Patch % Lines
internal/datastore/mysql/connection.go 87.50% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2554      +/-   ##
==========================================
- Coverage   77.77%   77.77%   -0.00%     
==========================================
  Files         440      440              
  Lines       53689    53690       +1     
==========================================
- Hits        41751    41750       -1     
- Misses       9344     9346       +2     
  Partials     2594     2594              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@leonnicolas leonnicolas force-pushed the fix-metrics-collector-for-mysql-datastore branch from fdc53e5 to 7a35b83 Compare September 14, 2025 15:12
When using a replica with the mysql datastore, we register the
same metrics again and again.

This commit ignores AlreadyRegisteredError when registering our
custom metrics and adds a `db_name` label similar to the postgres
instrumentation.

Additionally, it updates the tests for multi instance creation in a way that we
don't create 2 connections with the same index. Otherwise we would
get another registration error when registering the sql collector `sqlstats`.

fixes: authzed#2518

Signed-off-by: leonnicolas <[email protected]>

Override the default Prometheus registry in tests again

Some tests were failing when previous test cases registered their
metrics with the default Prometheus registry.

Signed-off-by: leonnicolas <[email protected]>
In order to increase the coverage of the patch, I added the following
tests:

- connection metrics can't be registered
- duplicate db names are used to create the datastore

Signed-off-by: leonnicolas <[email protected]>
@leonnicolas leonnicolas force-pushed the fix-metrics-collector-for-mysql-datastore branch from 7a35b83 to 8b2afbf Compare September 14, 2025 15:12
@leonnicolas
Copy link
Author

I hope I could increase the patch coverage with my last changes and fix the commit message format

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

Labels

area/datastore Affects the storage system area/tooling Affects the dev or user toolchain (e.g. tests, ci, build tools)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Using SPICEDB_DATASTORE_READ_REPLICA_CONN_URI and SPICEDB_DATASTORE_CONN_URI environment variables causes duplicate metrics error

1 participant