-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathKeyBuilderSS.ts
More file actions
74 lines (58 loc) · 1.88 KB
/
KeyBuilderSS.ts
File metadata and controls
74 lines (58 loc) · 1.88 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
import { KeyBuilder } from './KeyBuilder';
import { IMetadata } from '../dtos/types';
import { Method } from '../sync/submitters/types';
export const METHOD_NAMES: Record<Method, string> = {
t: 'treatment',
ts: 'treatments',
tc: 'treatmentWithConfig',
tcs: 'treatmentsWithConfig',
tf: 'treatmentsByFlagSet',
tfs: 'treatmentsByFlagSets',
tcf: 'treatmentsWithConfigByFlagSet',
tcfs: 'treatmentsWithConfigByFlagSets',
tr: 'track'
};
export class KeyBuilderSS extends KeyBuilder {
readonly latencyPrefix: string;
readonly exceptionPrefix: string;
readonly initPrefix: string;
private readonly versionablePrefix: string;
constructor(prefix: string, metadata: IMetadata) {
super(prefix);
this.latencyPrefix = `${this.prefix}.telemetry.latencies`;
this.exceptionPrefix = `${this.prefix}.telemetry.exceptions`;
this.initPrefix = `${this.prefix}.telemetry.init`;
this.versionablePrefix = `${metadata.s}/${metadata.n}/${metadata.i}`;
}
buildRegisteredSegmentsKey() {
return `${this.prefix}.segments.registered`;
}
buildImpressionsKey() {
return `${this.prefix}.impressions`;
}
buildImpressionsCountKey() {
return `${this.prefix}.impressions.count`;
}
buildUniqueKeysKey() {
return `${this.prefix}.uniquekeys`;
}
buildEventsKey() {
return `${this.prefix}.events`;
}
searchPatternForSplitKeys() {
return `${this.buildSplitKeyPrefix()}*`;
}
searchPatternForRBSegmentKeys() {
return `${this.buildRBSegmentKeyPrefix()}*`;
}
/* Telemetry keys */
buildLatencyKey(method: Method, bucket: number) {
return `${this.latencyPrefix}::${this.versionablePrefix}/${METHOD_NAMES[method]}/${bucket}`;
}
buildExceptionKey(method: Method) {
return `${this.exceptionPrefix}::${this.versionablePrefix}/${METHOD_NAMES[method]}`;
}
buildInitKey() {
return `${this.initPrefix}::${this.versionablePrefix}`;
}
}