@forge/runtime 5.3.0-next.1 → 5.3.0-next.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # @forge/runtime
2
2
 
3
+ ## 5.3.0-next.2
4
+
5
+ ### Patch Changes
6
+
7
+ - 579c6a2: send metrics with the same name but different tags separately
8
+
3
9
  ## 5.3.0-next.1
4
10
 
5
11
  ### Patch Changes
@@ -7,12 +7,15 @@ export declare class InMemoryMetrics implements Metrics {
7
7
  private readonly _children;
8
8
  private readonly _events;
9
9
  private readonly _tags;
10
- constructor(tags?: Tags);
10
+ private readonly _name;
11
+ constructor(tags?: Tags, name?: string);
12
+ getName(): string;
11
13
  getTimers(): TimedMetricsRecord[];
12
14
  getCounters(): Map<string, CounterMetricsRecord>;
13
15
  getEvents(): EventMetricsRecord[];
14
16
  getGauges(): Map<string, GaugeMetricsRecord>;
15
17
  getChildren(): Map<string, InMemoryMetrics>;
18
+ private getHashedMetricName;
16
19
  child(name: string, tags?: Tags): Metrics;
17
20
  counter(name: string, tags?: Tags): Counter;
18
21
  event(title: string, description?: string): void;
@@ -1 +1 @@
1
- {"version":3,"file":"in-memory-metrics.d.ts","sourceRoot":"","sources":["../../src/metrics/in-memory-metrics.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,gDAAgD,CAAC;AAKvG,OAAO,EAAE,oBAAoB,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,MAAM,WAAW,CAAC;AAM7G,qBAAa,eAAgB,YAAW,OAAO;IAC7C,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAuB;IAC/C,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAoC;IAC9D,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAkC;IAC1D,OAAO,CAAC,QAAQ,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IAC1D,OAAO,CAAC,QAAQ,CAAC,SAAS,CAA+B;IACzD,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAuB;IAC/C,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAO;IAC7B,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAS;gBAEnB,IAAI,GAAE,IAAS,EAAE,IAAI,SAAK;IAU/B,OAAO;IAIP,SAAS,IAAI,kBAAkB,EAAE;IAIjC,WAAW,IAAI,GAAG,CAAC,MAAM,EAAE,oBAAoB,CAAC;IAIhD,SAAS,IAAI,kBAAkB,EAAE;IAIjC,SAAS,IAAI,GAAG,CAAC,MAAM,EAAE,kBAAkB,CAAC;IAI5C,WAAW,IAAI,GAAG,CAAC,MAAM,EAAE,eAAe,CAAC;IAIlD,OAAO,CAAC,mBAAmB;IAK3B,KAAK,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,GAAE,IAAS,GAAG,OAAO;IAW7C,OAAO,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,GAAE,IAAS,GAAG,OAAO;IAS/C,KAAK,CAAC,KAAK,EAAE,MAAM,EAAE,WAAW,CAAC,EAAE,MAAM,GAAG,IAAI;IAIhD,KAAK,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,GAAE,IAAS,GAAG,KAAK;IAS3C,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,IAAI,GAAG,MAAM;CAK1C"}
@@ -6,13 +6,17 @@ const in_memory_event_metric_1 = require("./in-memory-event-metric");
6
6
  const in_memory_gauge_metric_1 = require("./in-memory-gauge-metric");
7
7
  const in_memory_timed_metric_1 = require("./in-memory-timed-metric");
8
8
  class InMemoryMetrics {
9
- constructor(tags = {}) {
9
+ constructor(tags = {}, name = '') {
10
10
  this._timers = [];
11
11
  this._counters = new Map();
12
12
  this._gauges = new Map();
13
13
  this._children = new Map();
14
14
  this._events = [];
15
15
  this._tags = tags;
16
+ this._name = name;
17
+ }
18
+ getName() {
19
+ return this._name;
16
20
  }
17
21
  getTimers() {
18
22
  return this._timers;
@@ -29,31 +33,38 @@ class InMemoryMetrics {
29
33
  getChildren() {
30
34
  return this._children;
31
35
  }
32
- child(name, tags) {
33
- if (!this._children.has(name)) {
34
- const child = new InMemoryMetrics();
36
+ getHashedMetricName(name, tags) {
37
+ const sortedTags = Object.entries(Object.assign(Object.assign({}, this._tags), tags)).sort();
38
+ return `${name}_${JSON.stringify(sortedTags)}`;
39
+ }
40
+ child(name, tags = {}) {
41
+ const hashedMetricName = this.getHashedMetricName(name, tags);
42
+ if (!this._children.has(hashedMetricName)) {
43
+ const child = new InMemoryMetrics({}, name);
35
44
  Object.assign(child._tags, this._tags);
36
45
  Object.assign(child._tags, tags);
37
- this._children.set(name, child);
46
+ this._children.set(hashedMetricName, child);
38
47
  }
39
- return this._children.get(name);
48
+ return this._children.get(hashedMetricName);
40
49
  }
41
- counter(name, tags) {
42
- if (!this._counters.has(name)) {
50
+ counter(name, tags = {}) {
51
+ const hashedMetricName = this.getHashedMetricName(name, tags);
52
+ if (!this._counters.has(hashedMetricName)) {
43
53
  const counter = new in_memory_counter_metric_1.InMemoryCounterMetric(name, Object.assign(Object.assign({}, this._tags), tags));
44
- this._counters.set(name, counter);
54
+ this._counters.set(hashedMetricName, counter);
45
55
  }
46
- return this._counters.get(name);
56
+ return this._counters.get(hashedMetricName);
47
57
  }
48
58
  event(title, description) {
49
59
  this._events.push(new in_memory_event_metric_1.InMemoryEventMetric(title, description));
50
60
  }
51
- gauge(name, tags) {
52
- if (!this._gauges.has(name)) {
61
+ gauge(name, tags = {}) {
62
+ const hashedMetricName = this.getHashedMetricName(name, tags);
63
+ if (!this._gauges.has(hashedMetricName)) {
53
64
  const gauge = new in_memory_gauge_metric_1.InMemoryGaugeMetric(name, Object.assign(Object.assign({}, this._tags), tags));
54
- this._gauges.set(name, gauge);
65
+ this._gauges.set(hashedMetricName, gauge);
55
66
  }
56
- return this._gauges.get(name);
67
+ return this._gauges.get(hashedMetricName);
57
68
  }
58
69
  timing(name, tags) {
59
70
  const timer = new in_memory_timed_metric_1.InMemoryTimedMetric(name, Object.assign(Object.assign({}, this._tags), tags));
@@ -29,8 +29,8 @@ class MetricsCollector {
29
29
  const addPrefix = (p, value) => {
30
30
  return p ? p + '.' + value : value;
31
31
  };
32
- const allMetrics = Array.from(metrics.getChildren().entries())
33
- .map(([k, v]) => [...MetricsCollector.collect(v, addPrefix(prefix, k))])
32
+ const allMetrics = Array.from(metrics.getChildren().values())
33
+ .map((v) => [...MetricsCollector.collect(v, addPrefix(prefix, v.getName()))])
34
34
  .reduce((accumulator, value) => accumulator.concat(value), []);
35
35
  const counters = Array.from(metrics.getCounters().values()).map((v) => ({
36
36
  name: addPrefix(prefix, v.getName()),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@forge/runtime",
3
- "version": "5.3.0-next.1",
3
+ "version": "5.3.0-next.2",
4
4
  "description": "A Node.js runtime for Atlassian app functions",
5
5
  "author": "Atlassian",
6
6
  "license": "UNLICENSED",