Skip to content

Commit 3bd6f94

Browse files
authored
Merge branch 'main' into fix/clearing-bucket-parameters
2 parents 08e6e92 + 914b324 commit 3bd6f94

File tree

83 files changed

+1130
-823
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

83 files changed

+1130
-823
lines changed

libs/lib-postgres/CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
# @powersync/lib-service-postgres
22

3+
## 0.4.1
4+
5+
### Patch Changes
6+
7+
- Updated dependencies [d1b83ce]
8+
- @powersync/service-types@0.10.0
9+
310
## 0.4.0
411

512
### Minor Changes

libs/lib-postgres/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "@powersync/lib-service-postgres",
33
"repository": "https://github.com/powersync-ja/powersync-service",
44
"types": "dist/index.d.ts",
5-
"version": "0.4.0",
5+
"version": "0.4.1",
66
"main": "dist/index.js",
77
"license": "FSL-1.1-Apache-2.0",
88
"type": "module",

modules/module-mongodb-storage/CHANGELOG.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,17 @@
11
# @powersync/service-module-mongodb-storage
22

3+
## 0.9.0
4+
5+
### Minor Changes
6+
7+
- d1b83ce: Refactored Metrics to use a MetricsEngine which is telemetry framework agnostic.
8+
9+
### Patch Changes
10+
11+
- Updated dependencies [d1b83ce]
12+
- @powersync/service-core@1.11.0
13+
- @powersync/service-types@0.10.0
14+
315
## 0.8.2
416

517
### Patch Changes

modules/module-mongodb-storage/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "@powersync/service-module-mongodb-storage",
33
"repository": "https://github.com/powersync-ja/powersync-service",
44
"types": "dist/index.d.ts",
5-
"version": "0.8.2",
5+
"version": "0.9.0",
66
"main": "dist/index.js",
77
"license": "FSL-1.1-Apache-2.0",
88
"type": "module",
Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
import { container } from '@powersync/lib-services-framework';
2-
import { test_utils } from '@powersync/service-core-tests';
32
import { beforeAll, beforeEach } from 'vitest';
3+
import { METRICS_HELPER } from '@powersync/service-core-tests';
44

55
beforeAll(async () => {
66
// Executes for every test file
77
container.registerDefaults();
8-
await test_utils.initMetrics();
98
});
109

1110
beforeEach(async () => {
12-
await test_utils.resetMetrics();
11+
METRICS_HELPER.resetMetrics();
1312
});

modules/module-mongodb/CHANGELOG.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,17 @@
11
# @powersync/service-module-mongodb
22

3+
## 0.8.0
4+
5+
### Minor Changes
6+
7+
- d1b83ce: Refactored Metrics to use a MetricsEngine which is telemetry framework agnostic.
8+
9+
### Patch Changes
10+
11+
- Updated dependencies [d1b83ce]
12+
- @powersync/service-core@1.11.0
13+
- @powersync/service-types@0.10.0
14+
315
## 0.7.5
416

517
### Patch Changes

modules/module-mongodb/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "@powersync/service-module-mongodb",
33
"repository": "https://github.com/powersync-ja/powersync-service",
44
"types": "dist/index.d.ts",
5-
"version": "0.7.5",
5+
"version": "0.8.0",
66
"main": "dist/index.js",
77
"license": "FSL-1.1-Apache-2.0",
88
"type": "module",

modules/module-mongodb/src/module/MongoModule.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,14 @@ export class MongoModule extends replication.ReplicationModule<types.MongoConnec
3737
id: this.getDefaultId(normalisedConfig.database ?? ''),
3838
syncRuleProvider: syncRuleProvider,
3939
storageEngine: context.storageEngine,
40+
metricsEngine: context.metricsEngine,
4041
connectionFactory: connectionFactory,
4142
rateLimiter: new MongoErrorRateLimiter()
4243
});
4344
}
4445

46+
async onInitialized(context: system.ServiceContextContainer): Promise<void> {}
47+
4548
/**
4649
* Combines base config with normalized connection settings
4750
*/

modules/module-mongodb/src/replication/ChangeStream.ts

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,25 +8,20 @@ import {
88
ReplicationAssertionError,
99
ServiceError
1010
} from '@powersync/lib-services-framework';
11-
import {
12-
BSON_DESERIALIZE_DATA_OPTIONS,
13-
Metrics,
14-
SaveOperationTag,
15-
SourceEntityDescriptor,
16-
SourceTable,
17-
storage
18-
} from '@powersync/service-core';
11+
import { MetricsEngine, SaveOperationTag, SourceEntityDescriptor, SourceTable, storage } from '@powersync/service-core';
1912
import { DatabaseInputRow, SqliteRow, SqlSyncRules, TablePattern } from '@powersync/service-sync-rules';
2013
import { MongoLSN } from '../common/MongoLSN.js';
2114
import { PostImagesOption } from '../types/types.js';
2215
import { escapeRegExp } from '../utils.js';
2316
import { MongoManager } from './MongoManager.js';
2417
import { constructAfterRecord, createCheckpoint, getCacheIdentifier, getMongoRelation } from './MongoRelation.js';
2518
import { CHECKPOINTS_COLLECTION } from './replication-utils.js';
19+
import { ReplicationMetric } from '@powersync/service-types';
2620

2721
export interface ChangeStreamOptions {
2822
connections: MongoManager;
2923
storage: storage.SyncRulesBucketStorage;
24+
metrics: MetricsEngine;
3025
abort_signal: AbortSignal;
3126
}
3227

@@ -59,13 +54,15 @@ export class ChangeStream {
5954
private connections: MongoManager;
6055
private readonly client: mongo.MongoClient;
6156
private readonly defaultDb: mongo.Db;
57+
private readonly metrics: MetricsEngine;
6258

6359
private abort_signal: AbortSignal;
6460

6561
private relation_cache = new Map<string | number, storage.SourceTable>();
6662

6763
constructor(options: ChangeStreamOptions) {
6864
this.storage = options.storage;
65+
this.metrics = options.metrics;
6966
this.group_id = options.storage.group_id;
7067
this.connections = options.connections;
7168
this.client = this.connections.client;
@@ -318,7 +315,7 @@ export class ChangeStream {
318315
}
319316

320317
at += docBatch.length;
321-
Metrics.getInstance().rows_replicated_total.add(docBatch.length);
318+
this.metrics.getCounter(ReplicationMetric.ROWS_REPLICATED).add(docBatch.length);
322319
const duration = performance.now() - lastBatch;
323320
lastBatch = performance.now();
324321
logger.info(
@@ -446,7 +443,7 @@ export class ChangeStream {
446443
return null;
447444
}
448445

449-
Metrics.getInstance().rows_replicated_total.add(1);
446+
this.metrics.getCounter(ReplicationMetric.ROWS_REPLICATED).add(1);
450447
if (change.operationType == 'insert') {
451448
const baseRecord = constructAfterRecord(change.fullDocument);
452449
return await batch.save({

modules/module-mongodb/src/replication/ChangeStreamReplicationJob.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ export class ChangeStreamReplicationJob extends replication.AbstractReplicationJ
7171
const stream = new ChangeStream({
7272
abort_signal: this.abortController.signal,
7373
storage: this.options.storage,
74+
metrics: this.options.metrics,
7475
connections: connectionManager
7576
});
7677
await stream.replicate();

0 commit comments

Comments
 (0)