Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@dynatrace/metric-utils

Package Overview
Dependencies
Maintainers
9
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@dynatrace/metric-utils - npm Package Compare versions

Comparing version 0.1.0 to 0.1.1

.nyc_output/925a0fe8-e1d2-4903-84ba-a4342b501170.json

4

build/example/index.js

@@ -29,4 +29,4 @@ "use strict";

console.log("Dynatrace API Constants:");
console.log("Limit lines per payload: " + (0, src_1.getPayloadLinesLimit)());
console.log("Default OneAgent endpoint: " + (0, src_1.getDefaultOneAgentEndpoint)());
console.log("Limit lines per payload: ".concat((0, src_1.getPayloadLinesLimit)()));
console.log("Default OneAgent endpoint: ".concat((0, src_1.getDefaultOneAgentEndpoint)()));
console.log("");

@@ -33,0 +33,0 @@ if (gauge == null) {

@@ -19,3 +19,7 @@ "use strict";

if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {

@@ -22,0 +26,0 @@ if (k2 === undefined) k2 = k;

@@ -29,10 +29,10 @@ "use strict";

if (this.dimensions.length > 0) {
line = line + "," + this.dimensions.map(function (_a) {
line = "".concat(line, ",").concat(this.dimensions.map(function (_a) {
var key = _a.key, value = _a.value;
return key + "=" + value;
}).join(",");
return "".concat(key, "=").concat(value);
}).join(","));
}
line = line + " " + this.serializeValue();
line = "".concat(line, " ").concat(this.serializeValue());
if (this.timestamp != null) {
line = line + " " + this.timestamp.valueOf();
line = "".concat(line, " ").concat(this.timestamp.valueOf());
}

@@ -39,0 +39,0 @@ return line;

@@ -41,3 +41,3 @@ "use strict";

Counter.prototype.serializeValue = function () {
return "count,delta=" + this.value;
return "count,delta=".concat(Number(this.value));
};

@@ -44,0 +44,0 @@ return Counter;

@@ -41,3 +41,3 @@ "use strict";

Gauge.prototype.serializeValue = function () {
return "gauge," + this.value;
return "gauge,".concat(Number(this.value));
};

@@ -44,0 +44,0 @@ return Gauge;

"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {

@@ -6,0 +10,0 @@ if (k2 === undefined) k2 = k;

@@ -105,3 +105,3 @@ "use strict";

if (this._prefix != null) {
return this._prefix + "." + name;
return "".concat(this._prefix, ".").concat(name);
}

@@ -108,0 +108,0 @@ return name;

@@ -41,3 +41,3 @@ "use strict";

Summary.prototype.serializeValue = function () {
return "gauge,min=" + this.value.min + ",max=" + this.value.max + ",sum=" + this.value.sum + ",count=" + this.value.count;
return "gauge,min=".concat(Number(this.value.min), ",max=").concat(Number(this.value.max), ",sum=").concat(Number(this.value.sum), ",count=").concat(Number(this.value.count));
};

@@ -44,0 +44,0 @@ return Summary;

@@ -58,3 +58,3 @@ "use strict";

var normalizedSections = key
.substr(0, DIMENSION_KEY_MAX_LENGTH)
.substring(0, DIMENSION_KEY_MAX_LENGTH)
.split(".")

@@ -93,3 +93,3 @@ .map(normalizeDimensionKeySection)

function escapeCharacters(s) {
return s.split("").map(function (c) { return CHARS_TO_ESCAPE.has(c) ? "\\" + c : c; }).join("");
return s.split("").map(function (c) { return CHARS_TO_ESCAPE.has(c) ? "\\".concat(c) : c; }).join("");
}

@@ -96,0 +96,0 @@ function ensureValidTrailingSlashes(s) {

@@ -42,5 +42,5 @@ "use strict";

var summary = factory.createSummary("name", [], { min: 1, max: 10, sum: 34, count: 42 }, now);
assert.strictEqual(counter === null || counter === void 0 ? void 0 : counter.serialize(), "name count,delta=25 " + now.valueOf());
assert.strictEqual(gauge === null || gauge === void 0 ? void 0 : gauge.serialize(), "name gauge,25 " + now.valueOf());
assert.strictEqual(summary === null || summary === void 0 ? void 0 : summary.serialize(), "name gauge,min=1,max=10,sum=34,count=42 " + now.valueOf());
assert.strictEqual(counter === null || counter === void 0 ? void 0 : counter.serialize(), "name count,delta=25 ".concat(now.valueOf()));
assert.strictEqual(gauge === null || gauge === void 0 ? void 0 : gauge.serialize(), "name gauge,25 ".concat(now.valueOf()));
assert.strictEqual(summary === null || summary === void 0 ? void 0 : summary.serialize(), "name gauge,min=1,max=10,sum=34,count=42 ".concat(now.valueOf()));
});

@@ -113,5 +113,5 @@ it("should serialize metrics without timestamps", function () {

var summary = factory.createSummary("name", dims, { min: 1, max: 10, sum: 34, count: 42 }, now);
assert.strictEqual(counter === null || counter === void 0 ? void 0 : counter.serialize(), "name,dim=value count,delta=25 " + now.valueOf());
assert.strictEqual(gauge === null || gauge === void 0 ? void 0 : gauge.serialize(), "name,dim=value gauge,25 " + now.valueOf());
assert.strictEqual(summary === null || summary === void 0 ? void 0 : summary.serialize(), "name,dim=value gauge,min=1,max=10,sum=34,count=42 " + now.valueOf());
assert.strictEqual(counter === null || counter === void 0 ? void 0 : counter.serialize(), "name,dim=value count,delta=25 ".concat(now.valueOf()));
assert.strictEqual(gauge === null || gauge === void 0 ? void 0 : gauge.serialize(), "name,dim=value gauge,25 ".concat(now.valueOf()));
assert.strictEqual(summary === null || summary === void 0 ? void 0 : summary.serialize(), "name,dim=value gauge,min=1,max=10,sum=34,count=42 ".concat(now.valueOf()));
});

@@ -127,5 +127,5 @@ it("should skip dimensions with empty keys", function () {

var summary = factory.createSummary("name", dims, { min: 1, max: 10, sum: 34, count: 42 }, now);
assert.strictEqual(counter === null || counter === void 0 ? void 0 : counter.serialize(), "name,dim=value,_=value3 count,delta=25 " + now.valueOf());
assert.strictEqual(gauge === null || gauge === void 0 ? void 0 : gauge.serialize(), "name,dim=value,_=value3 gauge,25 " + now.valueOf());
assert.strictEqual(summary === null || summary === void 0 ? void 0 : summary.serialize(), "name,dim=value,_=value3 gauge,min=1,max=10,sum=34,count=42 " + now.valueOf());
assert.strictEqual(counter === null || counter === void 0 ? void 0 : counter.serialize(), "name,dim=value,_=value3 count,delta=25 ".concat(now.valueOf()));
assert.strictEqual(gauge === null || gauge === void 0 ? void 0 : gauge.serialize(), "name,dim=value,_=value3 gauge,25 ".concat(now.valueOf()));
assert.strictEqual(summary === null || summary === void 0 ? void 0 : summary.serialize(), "name,dim=value,_=value3 gauge,min=1,max=10,sum=34,count=42 ".concat(now.valueOf()));
});

@@ -140,5 +140,5 @@ it("should normalize dimension keys", function () {

var summary = factory.createSummary("name", dims, { min: 1, max: 10, sum: 34, count: 42 }, now);
assert.strictEqual(counter === null || counter === void 0 ? void 0 : counter.serialize(), "name,dim=value,n_rmalize=value count,delta=25 " + now.valueOf());
assert.strictEqual(gauge === null || gauge === void 0 ? void 0 : gauge.serialize(), "name,dim=value,n_rmalize=value gauge,25 " + now.valueOf());
assert.strictEqual(summary === null || summary === void 0 ? void 0 : summary.serialize(), "name,dim=value,n_rmalize=value gauge,min=1,max=10,sum=34,count=42 " + now.valueOf());
assert.strictEqual(counter === null || counter === void 0 ? void 0 : counter.serialize(), "name,dim=value,n_rmalize=value count,delta=25 ".concat(now.valueOf()));
assert.strictEqual(gauge === null || gauge === void 0 ? void 0 : gauge.serialize(), "name,dim=value,n_rmalize=value gauge,25 ".concat(now.valueOf()));
assert.strictEqual(summary === null || summary === void 0 ? void 0 : summary.serialize(), "name,dim=value,n_rmalize=value gauge,min=1,max=10,sum=34,count=42 ".concat(now.valueOf()));
});

@@ -153,5 +153,5 @@ it("should not skip dimensions with invalid values", function () {

var summary = factory.createSummary("name", dims, { min: 1, max: 10, sum: 34, count: 42 }, now);
assert.strictEqual(counter === null || counter === void 0 ? void 0 : counter.serialize(), "name,dim=value,dim2= count,delta=25 " + now.valueOf());
assert.strictEqual(gauge === null || gauge === void 0 ? void 0 : gauge.serialize(), "name,dim=value,dim2= gauge,25 " + now.valueOf());
assert.strictEqual(summary === null || summary === void 0 ? void 0 : summary.serialize(), "name,dim=value,dim2= gauge,min=1,max=10,sum=34,count=42 " + now.valueOf());
assert.strictEqual(counter === null || counter === void 0 ? void 0 : counter.serialize(), "name,dim=value,dim2= count,delta=25 ".concat(now.valueOf()));
assert.strictEqual(gauge === null || gauge === void 0 ? void 0 : gauge.serialize(), "name,dim=value,dim2= gauge,25 ".concat(now.valueOf()));
assert.strictEqual(summary === null || summary === void 0 ? void 0 : summary.serialize(), "name,dim=value,dim2= gauge,min=1,max=10,sum=34,count=42 ".concat(now.valueOf()));
});

@@ -166,5 +166,5 @@ it("should normalize and escape dimension values", function () {

var summary = factory.createSummary("name", dims, { min: 1, max: 10, sum: 34, count: 42 }, now);
assert.strictEqual(counter === null || counter === void 0 ? void 0 : counter.serialize(), "name,dim=value,dim2=a_b\\\"quoted\\\" count,delta=25 " + now.valueOf());
assert.strictEqual(gauge === null || gauge === void 0 ? void 0 : gauge.serialize(), "name,dim=value,dim2=a_b\\\"quoted\\\" gauge,25 " + now.valueOf());
assert.strictEqual(summary === null || summary === void 0 ? void 0 : summary.serialize(), "name,dim=value,dim2=a_b\\\"quoted\\\" gauge,min=1,max=10,sum=34,count=42 " + now.valueOf());
assert.strictEqual(counter === null || counter === void 0 ? void 0 : counter.serialize(), "name,dim=value,dim2=a_b\\\"quoted\\\" count,delta=25 ".concat(now.valueOf()));
assert.strictEqual(gauge === null || gauge === void 0 ? void 0 : gauge.serialize(), "name,dim=value,dim2=a_b\\\"quoted\\\" gauge,25 ".concat(now.valueOf()));
assert.strictEqual(summary === null || summary === void 0 ? void 0 : summary.serialize(), "name,dim=value,dim2=a_b\\\"quoted\\\" gauge,min=1,max=10,sum=34,count=42 ".concat(now.valueOf()));
});

@@ -179,5 +179,5 @@ describe("with prefix", function () {

var summary = factory.createSummary("name", [], { min: 1, max: 10, sum: 34, count: 42 }, now);
assert.strictEqual(counter === null || counter === void 0 ? void 0 : counter.serialize(), "prefix.name count,delta=25 " + now.valueOf());
assert.strictEqual(gauge === null || gauge === void 0 ? void 0 : gauge.serialize(), "prefix.name gauge,25 " + now.valueOf());
assert.strictEqual(summary === null || summary === void 0 ? void 0 : summary.serialize(), "prefix.name gauge,min=1,max=10,sum=34,count=42 " + now.valueOf());
assert.strictEqual(counter === null || counter === void 0 ? void 0 : counter.serialize(), "prefix.name count,delta=25 ".concat(now.valueOf()));
assert.strictEqual(gauge === null || gauge === void 0 ? void 0 : gauge.serialize(), "prefix.name gauge,25 ".concat(now.valueOf()));
assert.strictEqual(summary === null || summary === void 0 ? void 0 : summary.serialize(), "prefix.name gauge,min=1,max=10,sum=34,count=42 ".concat(now.valueOf()));
});

@@ -193,5 +193,5 @@ });

var summary = factory.createSummary("name", [], { min: 1, max: 10, sum: 34, count: 42 }, now);
assert.strictEqual(counter === null || counter === void 0 ? void 0 : counter.serialize(), "prefix.name count,delta=25 " + now.valueOf());
assert.strictEqual(gauge === null || gauge === void 0 ? void 0 : gauge.serialize(), "prefix.name gauge,25 " + now.valueOf());
assert.strictEqual(summary === null || summary === void 0 ? void 0 : summary.serialize(), "prefix.name gauge,min=1,max=10,sum=34,count=42 " + now.valueOf());
assert.strictEqual(counter === null || counter === void 0 ? void 0 : counter.serialize(), "prefix.name count,delta=25 ".concat(now.valueOf()));
assert.strictEqual(gauge === null || gauge === void 0 ? void 0 : gauge.serialize(), "prefix.name gauge,25 ".concat(now.valueOf()));
assert.strictEqual(summary === null || summary === void 0 ? void 0 : summary.serialize(), "prefix.name gauge,min=1,max=10,sum=34,count=42 ".concat(now.valueOf()));
});

@@ -207,5 +207,5 @@ });

var summary = factory.createSummary("name", [], { min: 1, max: 10, sum: 34, count: 42 }, now);
assert.strictEqual(counter === null || counter === void 0 ? void 0 : counter.serialize(), "name,from=default count,delta=25 " + now.valueOf());
assert.strictEqual(gauge === null || gauge === void 0 ? void 0 : gauge.serialize(), "name,from=default gauge,25 " + now.valueOf());
assert.strictEqual(summary === null || summary === void 0 ? void 0 : summary.serialize(), "name,from=default gauge,min=1,max=10,sum=34,count=42 " + now.valueOf());
assert.strictEqual(counter === null || counter === void 0 ? void 0 : counter.serialize(), "name,from=default count,delta=25 ".concat(now.valueOf()));
assert.strictEqual(gauge === null || gauge === void 0 ? void 0 : gauge.serialize(), "name,from=default gauge,25 ".concat(now.valueOf()));
assert.strictEqual(summary === null || summary === void 0 ? void 0 : summary.serialize(), "name,from=default gauge,min=1,max=10,sum=34,count=42 ".concat(now.valueOf()));
});

@@ -216,5 +216,5 @@ it("should prioritize metric dimensions over default", function () {

var summary = factory.createSummary("name", [{ key: "from", value: "metric" }], { min: 1, max: 10, sum: 34, count: 42 }, now);
assert.strictEqual(counter === null || counter === void 0 ? void 0 : counter.serialize(), "name,from=metric count,delta=25 " + now.valueOf());
assert.strictEqual(gauge === null || gauge === void 0 ? void 0 : gauge.serialize(), "name,from=metric gauge,25 " + now.valueOf());
assert.strictEqual(summary === null || summary === void 0 ? void 0 : summary.serialize(), "name,from=metric gauge,min=1,max=10,sum=34,count=42 " + now.valueOf());
assert.strictEqual(counter === null || counter === void 0 ? void 0 : counter.serialize(), "name,from=metric count,delta=25 ".concat(now.valueOf()));
assert.strictEqual(gauge === null || gauge === void 0 ? void 0 : gauge.serialize(), "name,from=metric gauge,25 ".concat(now.valueOf()));
assert.strictEqual(summary === null || summary === void 0 ? void 0 : summary.serialize(), "name,from=metric gauge,min=1,max=10,sum=34,count=42 ".concat(now.valueOf()));
});

@@ -230,5 +230,5 @@ });

var summary = factory.createSummary("name", [], { min: 1, max: 10, sum: 34, count: 42 }, now);
assert.strictEqual(counter === null || counter === void 0 ? void 0 : counter.serialize(), "name,from=static count,delta=25 " + now.valueOf());
assert.strictEqual(gauge === null || gauge === void 0 ? void 0 : gauge.serialize(), "name,from=static gauge,25 " + now.valueOf());
assert.strictEqual(summary === null || summary === void 0 ? void 0 : summary.serialize(), "name,from=static gauge,min=1,max=10,sum=34,count=42 " + now.valueOf());
assert.strictEqual(counter === null || counter === void 0 ? void 0 : counter.serialize(), "name,from=static count,delta=25 ".concat(now.valueOf()));
assert.strictEqual(gauge === null || gauge === void 0 ? void 0 : gauge.serialize(), "name,from=static gauge,25 ".concat(now.valueOf()));
assert.strictEqual(summary === null || summary === void 0 ? void 0 : summary.serialize(), "name,from=static gauge,min=1,max=10,sum=34,count=42 ".concat(now.valueOf()));
});

@@ -239,5 +239,5 @@ it("should prioritize static dimensions over metric", function () {

var summary = factory.createSummary("name", [{ key: "from", value: "metric" }], { min: 1, max: 10, sum: 34, count: 42 }, now);
assert.strictEqual(counter === null || counter === void 0 ? void 0 : counter.serialize(), "name,from=static count,delta=25 " + now.valueOf());
assert.strictEqual(gauge === null || gauge === void 0 ? void 0 : gauge.serialize(), "name,from=static gauge,25 " + now.valueOf());
assert.strictEqual(summary === null || summary === void 0 ? void 0 : summary.serialize(), "name,from=static gauge,min=1,max=10,sum=34,count=42 " + now.valueOf());
assert.strictEqual(counter === null || counter === void 0 ? void 0 : counter.serialize(), "name,from=static count,delta=25 ".concat(now.valueOf()));
assert.strictEqual(gauge === null || gauge === void 0 ? void 0 : gauge.serialize(), "name,from=static gauge,25 ".concat(now.valueOf()));
assert.strictEqual(summary === null || summary === void 0 ? void 0 : summary.serialize(), "name,from=static gauge,min=1,max=10,sum=34,count=42 ".concat(now.valueOf()));
});

@@ -244,0 +244,0 @@ });

@@ -24,19 +24,34 @@ "use strict";

it("should serialize a value", function () {
var ctr = new metric_1.Counter("key", [], 1, testDate);
assert.strictEqual(ctr.serialize(), "key count,delta=1 1624028522292");
var metric = new metric_1.Counter("key", [], 1, testDate);
assert.strictEqual(metric.serialize(), "key count,delta=1 1624028522292");
});
it("should make a best effort with non-numeric input", function () {
// @ts-expect-error non-numeric input
var metric = new metric_1.Counter("key", [], "3", testDate);
assert.strictEqual(metric.serialize(), "key count,delta=3 1624028522292");
});
});
describe("Gauge", function () {
it("should serialize a value", function () {
var ctr = new metric_1.Gauge("key", [], 1, testDate);
assert.strictEqual(ctr.serialize(), "key gauge,1 1624028522292");
var metric = new metric_1.Gauge("key", [], 1, testDate);
assert.strictEqual(metric.serialize(), "key gauge,1 1624028522292");
});
it("should make a best effort with non-numeric input", function () {
// @ts-expect-error non-numeric input
var metric = new metric_1.Gauge("key", [], "3", testDate);
assert.strictEqual(metric.serialize(), "key gauge,3 1624028522292");
});
});
describe("Summary", function () {
it("should serialize a value", function () {
var ctr = new metric_1.Summary("key", [], { min: 1, max: 10, sum: 34, count: 42 }, testDate);
assert.strictEqual(ctr.serialize(), "key gauge,min=1,max=10,sum=34,count=42 1624028522292");
var metric = new metric_1.Summary("key", [], { min: 1, max: 10, sum: 34, count: 42 }, testDate);
assert.strictEqual(metric.serialize(), "key gauge,min=1,max=10,sum=34,count=42 1624028522292");
});
it("should make a best effort with non-numeric input", function () {
// @ts-expect-error non-numeric input
var metric = new metric_1.Summary("key", [], { min: "1", max: "10", sum: "34", count: "42" }, testDate);
assert.strictEqual(metric.serialize(), "key gauge,min=1,max=10,sum=34,count=42 1624028522292");
});
});
});
//# sourceMappingURL=metric.test.js.map

@@ -79,3 +79,3 @@ "use strict";

it(name, function () {
assert.strictEqual((0, normalize_1.normalizeMetricKey)(input), expected, "Failed to normalize metric key " + input);
assert.strictEqual((0, normalize_1.normalizeMetricKey)(input), expected, "Failed to normalize metric key ".concat(input));
});

@@ -148,3 +148,3 @@ };

it(name, function () {
assert.strictEqual((0, normalize_1.normalizeDimensionKey)(input), expected, "Failed to normalize dimension key " + input);
assert.strictEqual((0, normalize_1.normalizeDimensionKey)(input), expected, "Failed to normalize dimension key ".concat(input));
});

@@ -194,3 +194,3 @@ };

it(name, function () {
assert.strictEqual((0, normalize_1.normalizeDimensionValue)(input), expected, "Failed to normalize dimension value " + input);
assert.strictEqual((0, normalize_1.normalizeDimensionValue)(input), expected, "Failed to normalize dimension value ".concat(input));
});

@@ -197,0 +197,0 @@ };

{
"name": "@dynatrace/metric-utils",
"version": "0.1.0",
"version": "0.1.1",
"description": "Utility library for interacting with the Dynatrace metrics API v2",

@@ -45,4 +45,3 @@ "main": "build/src/index.js",

"typescript": "^4.3.4"
},
"dependencies": {}
}
}

@@ -20,4 +20,4 @@ /*

protected serializeValue(): string {
return `count,delta=${this.value}`;
return `count,delta=${Number(this.value)}`;
}
}

@@ -21,4 +21,4 @@ /*

protected serializeValue(): string {
return `gauge,${this.value}`;
return `gauge,${Number(this.value)}`;
}
}

@@ -21,3 +21,3 @@ /*

protected serializeValue(): string {
return `gauge,min=${this.value.min},max=${this.value.max},sum=${this.value.sum},count=${this.value.count}`;
return `gauge,min=${Number(this.value.min)},max=${Number(this.value.max)},sum=${Number(this.value.sum)},count=${Number(this.value.count)}`;
}

@@ -24,0 +24,0 @@ }

@@ -57,3 +57,3 @@ /*

const normalizedSections = key
.substr(0, DIMENSION_KEY_MAX_LENGTH)
.substring(0, DIMENSION_KEY_MAX_LENGTH)
.split(".")

@@ -60,0 +60,0 @@ .map(normalizeDimensionKeySection)

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc