Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Metrics refactor #221

Merged
merged 28 commits into from
Apr 10, 2025
Merged

Metrics refactor #221

merged 28 commits into from
Apr 10, 2025

Conversation

Rentacookie
Copy link
Contributor

@Rentacookie Rentacookie commented Mar 3, 2025

Refactored metrics to use a MetricsEngine which forms part of the service context.
Metrics and their creation are abstracted away behind interfaces decoupled from Opentelemetry.
Metrics can be created and accessed via the MetricsEngine.

Moved the metrics initialisation code out of the service and into service core. That way the initialisation code can be re-used by the powersync cloud edition.

…on of those interfaces for Opentelemetry

Added a MetricsEngine that handles creation and registration of metrics
…lication, storage and API metrics

Added the MetricsEngine to the service context
Added a MetricsHelper to aid with test setup for metrics
# Conflicts:
#	modules/module-mongodb/src/replication/ChangeStream.ts
#	modules/module-mongodb/test/src/change_stream_utils.ts
#	modules/module-postgres/test/src/slow_tests.test.ts
#	packages/service-core-tests/src/tests/register-sync-tests.ts
Copy link

changeset-bot bot commented Mar 3, 2025

🦋 Changeset detected

Latest commit: 7c358b8

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 11 packages
Name Type
@powersync/service-module-postgres-storage Minor
@powersync/service-module-mongodb-storage Minor
@powersync/service-core-tests Minor
@powersync/service-module-postgres Minor
@powersync/service-module-mongodb Minor
@powersync/service-core Minor
@powersync/service-module-mysql Minor
@powersync/service-types Minor
@powersync/service-image Minor
test-client Patch
@powersync/lib-service-postgres Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@Rentacookie Rentacookie marked this pull request as ready for review March 4, 2025 08:11
# Conflicts:
#	modules/module-mongodb/test/src/change_stream_utils.ts
#	modules/module-mysql/test/src/BinlogStreamUtils.ts
#	modules/module-postgres/test/src/wal_stream_utils.ts
#	packages/service-core-tests/src/tests/register-sync-tests.ts
#	packages/service-core/src/routes/endpoints/socket-route.ts
#	packages/service-core/src/routes/endpoints/sync-stream.ts
#	packages/service-core/src/system/ServiceContext.ts
# Conflicts:
#	modules/module-postgres/src/replication/WalStream.ts
# Conflicts:
#	packages/service-core-tests/src/tests/register-sync-tests.ts
Consolidated some extra logging info from powersync cloud runners into service runners
@Rentacookie
Copy link
Contributor Author

I tested this on the hosted powersync on staging, and did not pick up any issues. Metrics are still being correctly reported to Prometheus.

@rkistner rkistner requested a review from stevensJourney March 26, 2025 12:21
dylanvorster
dylanvorster previously approved these changes Apr 4, 2025
Copy link
Contributor

@dylanvorster dylanvorster left a comment

Choose a reason for hiding this comment

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

skimmed, but happy with the patterns and architecture used. Nice work!

stevensJourney
stevensJourney previously approved these changes Apr 8, 2025
Copy link
Collaborator

@stevensJourney stevensJourney left a comment

Choose a reason for hiding this comment

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

Left some minor comments. Overall this looks brilliant.

@Rentacookie Rentacookie dismissed stale reviews from stevensJourney and dylanvorster via 7c358b8 April 9, 2025 07:11
@Rentacookie Rentacookie merged commit d1b83ce into main Apr 10, 2025
22 checks passed
@Rentacookie Rentacookie deleted the metrics-refactor branch April 10, 2025 07:25
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.

3 participants