metrics-sender
Advanced tools
Comparing version 0.0.5 to 0.0.6
export interface IMetrics { | ||
/** | ||
* Send metrics message and returns sent message content in promise value | ||
* Send metrics message and returns sent message content in promise resolve value | ||
* or returns the error message in rejection value if sending failed. | ||
*/ | ||
@@ -8,2 +9,15 @@ send(fieldSet: { | ||
}): Promise<string>; | ||
/** | ||
* Add new tag to list of tags | ||
* | ||
* @param {string} key | ||
* @param {string} value | ||
*/ | ||
addTag(key: string, value: string): void; | ||
/** | ||
* Removes tag from list of tags | ||
* | ||
* @param {string} key | ||
*/ | ||
removeTag(key: string): void; | ||
} |
@@ -28,2 +28,8 @@ import { IMetrics } from "./IMetrics"; | ||
/** | ||
* Removes tag | ||
* | ||
* @param {string} key | ||
*/ | ||
removeTag(key: string): void; | ||
/** | ||
* Sends UDP packet | ||
@@ -43,3 +49,3 @@ * | ||
*/ | ||
createLine(fieldSet: {}): string; | ||
private createLine(fieldSet); | ||
} |
@@ -36,2 +36,10 @@ "use strict"; | ||
/** | ||
* Removes tag | ||
* | ||
* @param {string} key | ||
*/ | ||
removeTag(key) { | ||
delete this.tags[key]; | ||
} | ||
/** | ||
* Sends UDP packet | ||
@@ -38,0 +46,0 @@ * |
@@ -33,3 +33,3 @@ "use strict"; | ||
} | ||
return resolve(`Metrics sent to ${this.serverIP}:${this.port}. Msg: ${message}`); | ||
return resolve(message); | ||
}); | ||
@@ -36,0 +36,0 @@ }); |
"use strict"; | ||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
return new (P || (P = Promise))(function (resolve, reject) { | ||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } | ||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } | ||
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); } | ||
step((generator = generator.apply(thisArg, _arguments || [])).next()); | ||
}); | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
@@ -8,10 +16,21 @@ const dgram = require("dgram"); | ||
describe("Metrics", () => { | ||
it("should create line in defined format", () => { | ||
it("should create line in defined format", () => __awaiter(this, void 0, void 0, function* () { | ||
const tags = { name: "appname", host: "10.28.30.45" }; | ||
const m = new Metrics_1.Metrics("measurementName", tags); | ||
const line = m.createLine({ value1: 10000, value2: "some value" }); | ||
const line = yield m.send({ value1: 10000, value2: "some value" }); | ||
const withoutTime = "measurementName,name=appname,host=10.28.30.45 value1=10000,value2=some\\ value"; | ||
chai_1.assert.lengthOf(line, withoutTime.length + 20); | ||
chai_1.assert.lengthOf(line.substr(0, withoutTime.length), withoutTime.length); | ||
}); | ||
})); | ||
it("should create line in defined format with lately added and removed tag", () => __awaiter(this, void 0, void 0, function* () { | ||
const tags = { name: "appname", host: "10.28.30.45" }; | ||
const m = new Metrics_1.Metrics("measurementName", tags); | ||
m.addTag("added", "foo"); | ||
m.removeTag("invalid"); | ||
m.removeTag("host"); | ||
const line = yield m.send({ value1: 10000, value2: "some value" }); | ||
const withoutTime = "measurementName,name=appname,added=foo value1=10000,value2=some\\ value"; | ||
chai_1.assert.lengthOf(line, withoutTime.length + 20); | ||
chai_1.assert.lengthOf(line.substr(0, withoutTime.length), withoutTime.length); | ||
})); | ||
it("should send and receive udp packet", (done) => { | ||
@@ -18,0 +37,0 @@ const server = dgram.createSocket("udp4"); |
{ | ||
"name": "metrics-sender", | ||
"version": "0.0.5", | ||
"version": "0.0.6", | ||
"description": "Library for sending application metrics", | ||
@@ -9,3 +9,3 @@ "main": "./dist/src/Metrics.js", | ||
"lint": "./node_modules/.bin/tslint ./src/lib/**/*.ts ./src/test/**/*.ts", | ||
"build": "rm -rf dist && tsc" | ||
"build": "rm -rf dist && tsc -d" | ||
}, | ||
@@ -12,0 +12,0 @@ "repository": { |
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
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
57152
303