Skip to content

Commit

Permalink
feat/enable_batch_metrics_for_all (#3027)
Browse files Browse the repository at this point in the history
Batch Metrics as a capability developed to support the frontend API to
handle more metrics from SDKs without overloading the DB to much. It has
been running in Unleash Cloud for months and has proven to work quite
nice.

This PR simply removes the flag to make the capability GA, also for
self-hosted users.
  • Loading branch information
ivarconr committed Feb 1, 2023
1 parent 896994d commit 627958d
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 20 deletions.
2 changes: 0 additions & 2 deletions src/lib/__snapshots__/create-config.test.ts.snap
Expand Up @@ -69,7 +69,6 @@ exports[`should create default config 1`] = `
"flags": {
"ENABLE_DARK_MODE_SUPPORT": false,
"anonymiseEventLog": false,
"batchMetrics": false,
"caseInsensitiveInOperators": false,
"crOnVariants": false,
"embedProxy": true,
Expand All @@ -91,7 +90,6 @@ exports[`should create default config 1`] = `
"experiments": {
"ENABLE_DARK_MODE_SUPPORT": false,
"anonymiseEventLog": false,
"batchMetrics": false,
"caseInsensitiveInOperators": false,
"crOnVariants": false,
"embedProxy": true,
Expand Down
17 changes: 5 additions & 12 deletions src/lib/services/client-metrics/metrics-service-v2.ts
Expand Up @@ -95,18 +95,11 @@ export default class ClientMetricsServiceV2 {
no: value.bucket.toggles[name].no,
}));

if (this.config.flagResolver.isEnabled('batchMetrics')) {
this.unsavedMetrics = collapseHourlyMetrics([
...this.unsavedMetrics,
...clientMetrics,
]);
this.lastSeenService.updateLastSeen(clientMetrics);
} else {
if (toggleNames.length > 0) {
await this.featureToggleStore.setLastSeen(toggleNames);
}
await this.clientMetricsStoreV2.batchInsertMetrics(clientMetrics);
}
this.unsavedMetrics = collapseHourlyMetrics([
...this.unsavedMetrics,
...clientMetrics,
]);
this.lastSeenService.updateLastSeen(clientMetrics);

this.config.eventBus.emit(CLIENT_METRICS, value);
}
Expand Down
4 changes: 0 additions & 4 deletions src/lib/types/experimental.ts
Expand Up @@ -22,10 +22,6 @@ const flags = {
process.env.UNLEASH_EXPERIMENTAL_EMBED_PROXY_FRONTEND,
true,
),
batchMetrics: parseEnvVarBoolean(
process.env.UNLEASH_EXPERIMENTAL_BATCH_METRICS,
false,
),
responseTimeWithAppName: parseEnvVarBoolean(
process.env.UNLEASH_EXPERIMENTAL_RESPONSE_TIME_WITH_APP_NAME,
false,
Expand Down
1 change: 0 additions & 1 deletion src/server-dev.ts
Expand Up @@ -36,7 +36,6 @@ process.nextTick(async () => {
flags: {
embedProxy: true,
embedProxyFrontend: true,
batchMetrics: true,
anonymiseEventLog: false,
responseTimeWithAppName: true,
variantsPerEnvironment: true,
Expand Down
1 change: 0 additions & 1 deletion src/test/config/test-config.ts
Expand Up @@ -26,7 +26,6 @@ export function createTestConfig(config?: IUnleashOptions): IUnleashConfig {
flags: {
embedProxy: true,
embedProxyFrontend: true,
batchMetrics: true,
variantsPerEnvironment: true,
},
},
Expand Down

0 comments on commit 627958d

Please sign in to comment.