@appsignal/nodejs
Advanced tools
Comparing version 1.0.4 to 1.0.5
# Changelog | ||
## 1.0.5 | ||
- Allow spans to be created with a startTime (#340) | ||
- Dependency bumps | ||
## 1.0.4 | ||
@@ -4,0 +8,0 @@ - Bumped agent to c55fb2c |
@@ -16,3 +16,3 @@ import { NodeClient, Metrics, Plugin, Tracer } from "@appsignal/types"; | ||
#private; | ||
readonly VERSION = "1.0.4"; | ||
readonly VERSION = "1.0.5"; | ||
config: Configuration; | ||
@@ -19,0 +19,0 @@ agent: Agent; |
@@ -72,4 +72,4 @@ import { NodeSpan, NodeSpanOptions, SpanContext, HashMap, HashMapValue } from "@appsignal/types"; | ||
export declare class ChildSpan extends BaseSpan { | ||
constructor(span: NodeSpan); | ||
constructor(context: SpanContext); | ||
constructor(span: NodeSpan, options?: Partial<NodeSpanOptions>); | ||
constructor(context: SpanContext, options?: Partial<NodeSpanOptions>); | ||
} | ||
@@ -81,3 +81,3 @@ /** | ||
export declare class RootSpan extends BaseSpan { | ||
constructor(options?: Partial<NodeSpanOptions>); | ||
constructor({ namespace, startTime }?: Partial<NodeSpanOptions>); | ||
} |
@@ -6,2 +6,3 @@ "use strict"; | ||
const data_1 = require("./internal/data"); | ||
const utils_1 = require("./utils"); | ||
/** | ||
@@ -123,4 +124,3 @@ * The `Span` object represents a length of time in the flow of execution | ||
if (endTime && typeof endTime === "number") { | ||
const sec = Math.round(endTime / 1000); // seconds | ||
const nsec = Math.round(endTime * 1e6); // nanoseconds | ||
const { sec, nsec } = utils_1.getAgentTimestamps(endTime); | ||
extension_1.span.closeSpanWithTimestamp(this._ref, sec, nsec); | ||
@@ -138,3 +138,10 @@ return this; | ||
toJSON() { | ||
return extension_1.span.spanToJSON(this._ref); | ||
const json = extension_1.span.spanToJSON(this._ref); | ||
// if this is true, then the span has been garbage collected | ||
// @TODO: i feel that this could have better ergonomics on the agent | ||
// side. come up with something better here later. | ||
if (json.trim() === "") { | ||
return JSON.stringify({ closed: true }); | ||
} | ||
return json; | ||
} | ||
@@ -148,5 +155,11 @@ } | ||
class ChildSpan extends BaseSpan { | ||
constructor({ traceId, spanId }) { | ||
constructor({ traceId, spanId }, { startTime } = {}) { | ||
super(); | ||
this._ref = extension_1.span.createChildSpan(traceId, spanId); | ||
if (startTime) { | ||
const { sec, nsec } = utils_1.getAgentTimestamps(startTime); | ||
this._ref = extension_1.span.createChildSpanWithTimestamp(traceId, spanId, sec, nsec); | ||
} | ||
else { | ||
this._ref = extension_1.span.createChildSpan(traceId, spanId); | ||
} | ||
} | ||
@@ -160,8 +173,13 @@ } | ||
class RootSpan extends BaseSpan { | ||
constructor(options = {}) { | ||
constructor({ namespace = "web", startTime } = {}) { | ||
super(); | ||
const { namespace = "web" } = options; | ||
this._ref = extension_1.span.createRootSpan(namespace); | ||
if (startTime) { | ||
const { sec, nsec } = utils_1.getAgentTimestamps(startTime); | ||
this._ref = extension_1.span.createRootSpanWithTimestamp(namespace, sec, nsec); | ||
} | ||
else { | ||
this._ref = extension_1.span.createRootSpan(namespace); | ||
} | ||
} | ||
} | ||
exports.RootSpan = RootSpan; |
@@ -27,3 +27,3 @@ "use strict"; | ||
else { | ||
return new span_1.ChildSpan(spanOrContext); | ||
return new span_1.ChildSpan(spanOrContext, options); | ||
} | ||
@@ -30,0 +30,0 @@ } |
@@ -8,1 +8,11 @@ /** | ||
export declare function getPackageVerson(basedir: string): string; | ||
/** | ||
* Given a valid POSIX `timestamp`, return an object containing a | ||
* representation if that timestamps in seconds and nanoseconds. | ||
* | ||
* @function | ||
*/ | ||
export declare function getAgentTimestamps(timestamp: number): { | ||
sec: number; | ||
nsec: number; | ||
}; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.getPackageVerson = void 0; | ||
exports.getAgentTimestamps = exports.getPackageVerson = void 0; | ||
const tslib_1 = require("tslib"); | ||
@@ -22,1 +22,14 @@ const path_1 = tslib_1.__importDefault(require("path")); | ||
exports.getPackageVerson = getPackageVerson; | ||
/** | ||
* Given a valid POSIX `timestamp`, return an object containing a | ||
* representation if that timestamps in seconds and nanoseconds. | ||
* | ||
* @function | ||
*/ | ||
function getAgentTimestamps(timestamp) { | ||
return { | ||
sec: Math.round(timestamp / 1000), | ||
nsec: Math.round(timestamp * 1e6) // nanoseconds | ||
}; | ||
} | ||
exports.getAgentTimestamps = getAgentTimestamps; |
@@ -1,2 +0,2 @@ | ||
export declare const VERSION = "1.0.4"; | ||
export declare const VERSION = "1.0.5"; | ||
export declare const AGENT_VERSION = "c55fb2c"; |
@@ -5,3 +5,3 @@ "use strict"; | ||
// Do not touch this file, auto-generated by scripts/create-versionfile | ||
exports.VERSION = "1.0.4"; | ||
exports.VERSION = "1.0.5"; | ||
exports.AGENT_VERSION = "c55fb2c"; |
{ | ||
"name": "@appsignal/nodejs", | ||
"version": "1.0.4", | ||
"version": "1.0.5", | ||
"main": "dist/index", | ||
@@ -19,3 +19,3 @@ "types": "dist/index", | ||
"optionalDependencies": { | ||
"@appsignal/nodejs-ext": "^1.0.4" | ||
"@appsignal/nodejs-ext": "^1.0.5" | ||
}, | ||
@@ -39,3 +39,3 @@ "scripts": { | ||
}, | ||
"gitHead": "17f6c1257088e614e676b6704192fa6f4ff3f510" | ||
"gitHead": "9dbc7e6c8d7dc98f006a9056f8486c6749e01209" | ||
} |
324001
2653