@appsignal/nodejs
Advanced tools
Comparing version 0.2.0 to 0.3.0
@@ -1,2 +0,2 @@ | ||
import { Extension } from "./extension"; | ||
import { Agent } from "./agent"; | ||
import { Configuration } from "./config"; | ||
@@ -20,3 +20,3 @@ import { Tracer } from "./tracer"; | ||
config: Configuration; | ||
extension: Extension; | ||
agent: Agent; | ||
instrumentation: Instrumentation; | ||
@@ -30,3 +30,3 @@ private _tracer; | ||
/** | ||
* Returns `true` if the extension is loaded and configuration is valid | ||
* Returns `true` if the agent is loaded and configuration is valid | ||
*/ | ||
@@ -33,0 +33,0 @@ get isActive(): boolean; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const extension_1 = require("./extension"); | ||
const tslib_1 = require("tslib"); | ||
const agent_1 = require("./agent"); | ||
const config_1 = require("./config"); | ||
@@ -10,2 +11,3 @@ const tracer_1 = require("./tracer"); | ||
const instrument_1 = require("./instrument"); | ||
const http = tslib_1.__importStar(require("./instrumentation/http")); | ||
/** | ||
@@ -30,11 +32,11 @@ * AppSignal for Node.js's main class. | ||
this.config = new config_1.Configuration(options); | ||
this.extension = new extension_1.Extension({ active }); | ||
this.agent = new agent_1.Agent({ active }); | ||
this.instrumentation = new instrument_1.Instrumentation(this._tracer); | ||
// this.instrumentation.load(http.PLUGIN_NAME, http.instrument) | ||
this.instrumentation.load(http.PLUGIN_NAME, http.instrument); | ||
} | ||
/** | ||
* Returns `true` if the extension is loaded and configuration is valid | ||
* Returns `true` if the agent is loaded and configuration is valid | ||
*/ | ||
get isActive() { | ||
return this.extension.isLoaded && this.config.isValid; | ||
return this.agent.isLoaded && this.config.isValid; | ||
} | ||
@@ -52,3 +54,3 @@ set isActive(arg) { | ||
if (this.config.isValid) { | ||
this.extension.start(); | ||
this.agent.start(); | ||
} | ||
@@ -72,3 +74,3 @@ else { | ||
} | ||
this.extension.stop(); | ||
this.agent.stop(); | ||
} | ||
@@ -102,3 +104,3 @@ /** | ||
if (!this.isActive) { | ||
console.warn("Cannot access the metrics object when the extension is inactive"); | ||
console.warn("Cannot access the metrics object when the agent is inactive"); | ||
return; | ||
@@ -105,0 +107,0 @@ } |
@@ -81,3 +81,3 @@ "use strict"; | ||
const priv = { | ||
_APPSIGNAL_AGENT_PATH: path_1.default.join(__dirname, "/../ext"), | ||
_APPSIGNAL_AGENT_PATH: path_1.default.join(__dirname, "/../node_modules/@appsignal/nodejs-ext/ext"), | ||
_APPSIGNAL_ENVIRONMENT: process.env.NODE_ENV || "development", | ||
@@ -84,0 +84,0 @@ _APPSIGNAL_PROCESS_NAME: process.title, |
@@ -1,19 +0,3 @@ | ||
/** | ||
* The public interface for the extension. | ||
* | ||
* @class | ||
*/ | ||
export declare class Extension { | ||
isLoaded: boolean; | ||
constructor(options?: { | ||
active: boolean; | ||
}); | ||
/** | ||
* Starts the extension. | ||
*/ | ||
start(): boolean; | ||
/** | ||
* Stops the extension. | ||
*/ | ||
stop(): boolean; | ||
} | ||
import { Extension } from "./interfaces/extension"; | ||
declare let mod: Extension; | ||
export = mod; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
// the C++ extension is loaded here (via commonjs for compatibility). | ||
// we keep this as a locally scoped variable; the C++ bindings | ||
// should not be visible publicly. | ||
const { extension } = require("../build/Release/extension.node"); | ||
/** | ||
* The public interface for the extension. | ||
* | ||
* @class | ||
*/ | ||
class Extension { | ||
constructor(options) { | ||
this.isLoaded = false; | ||
if (options === null || options === void 0 ? void 0 : options.active) | ||
this.start(); | ||
} | ||
/** | ||
* Starts the extension. | ||
*/ | ||
start() { | ||
try { | ||
extension.start(); | ||
this.isLoaded = true; | ||
let mod; | ||
try { | ||
mod = require("@appsignal/nodejs-ext"); | ||
} | ||
catch (e) { | ||
mod = { | ||
extension: { | ||
start() { | ||
throw new Error("Extension module not loaded"); | ||
}, | ||
stop() { | ||
return; | ||
} | ||
} | ||
catch (e) { | ||
console.error(`Failed to load extension ${e}, please run \`appsignal diagnose\` | ||
and email us at support@appsignal.com`); | ||
this.isLoaded = false; | ||
} | ||
return this.isLoaded; | ||
} | ||
/** | ||
* Stops the extension. | ||
*/ | ||
stop() { | ||
if (this.isLoaded) { | ||
extension.stop(); | ||
this.isLoaded = false; | ||
} | ||
return this.isLoaded; | ||
} | ||
}; | ||
} | ||
exports.Extension = Extension; | ||
module.exports = mod; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
// the C++ extension is loaded here (via commonjs for compatibility). | ||
// we keep this as a locally scoped variable; the C++ bindings | ||
// should not be visible publicly. | ||
const { dataarray } = require("../../build/Release/extension.node"); | ||
const extension_1 = require("../extension"); | ||
class DataArray { | ||
constructor(data) { | ||
this._data = data || []; | ||
this._ref = dataarray.create(); | ||
this._ref = extension_1.dataarray.create(); | ||
// if we init this object with data, it should be written to | ||
@@ -25,21 +22,21 @@ // the extension here | ||
if (!value) { | ||
dataarray.appendNull(this._ref); | ||
extension_1.dataarray.appendNull(this._ref); | ||
} | ||
switch (typeof value) { | ||
case "string": | ||
dataarray.appendString(value, this._ref); | ||
extension_1.dataarray.appendString(value, this._ref); | ||
break; | ||
case "number": | ||
if (Number.isInteger(value)) { | ||
dataarray.appendInteger(value, this._ref); | ||
extension_1.dataarray.appendInteger(value, this._ref); | ||
} | ||
else { | ||
dataarray.appendFloat(value, this._ref); | ||
extension_1.dataarray.appendFloat(value, this._ref); | ||
} | ||
break; | ||
case "boolean": | ||
dataarray.appendBoolean(value, this._ref); | ||
extension_1.dataarray.appendBoolean(value, this._ref); | ||
break; | ||
case "object": | ||
dataarray.appendData(value, this._ref); | ||
extension_1.dataarray.appendData(value, this._ref); | ||
break; | ||
@@ -46,0 +43,0 @@ default: |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
// the C++ extension is loaded here (via commonjs for compatibility). | ||
// we keep this as a locally scoped variable; the C++ bindings | ||
// should not be visible publicly. | ||
const { datamap } = require("../../build/Release/extension.node"); | ||
const extension_1 = require("../extension"); | ||
class DataMap { | ||
constructor(data) { | ||
this._data = data || {}; | ||
this._ref = datamap.create(); | ||
this._ref = extension_1.datamap.create(); | ||
// if we init this object with data, it should be written to | ||
@@ -25,21 +22,21 @@ // the extension here | ||
if (!value) { | ||
datamap.setNull(this._ref); | ||
extension_1.datamap.setNull(this._ref); | ||
} | ||
switch (typeof value) { | ||
case "string": | ||
datamap.setString(key, value, this._ref); | ||
extension_1.datamap.setString(key, value, this._ref); | ||
break; | ||
case "number": | ||
if (Number.isInteger(value)) { | ||
datamap.setInteger(key, value, this._ref); | ||
extension_1.datamap.setInteger(key, value, this._ref); | ||
} | ||
else { | ||
datamap.setFloat(key, value, this._ref); | ||
extension_1.datamap.setFloat(key, value, this._ref); | ||
} | ||
break; | ||
case "boolean": | ||
datamap.setBoolean(key, value, this._ref); | ||
extension_1.datamap.setBoolean(key, value, this._ref); | ||
break; | ||
case "object": | ||
datamap.setData(key, value, this._ref); | ||
extension_1.datamap.setData(key, value, this._ref); | ||
break; | ||
@@ -46,0 +43,0 @@ default: |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
// the C++ extension is loaded here (via commonjs for compatibility). | ||
// we keep this as a locally scoped variable; the C++ bindings | ||
// should not be visible publicly. | ||
const { metrics } = require("../build/Release/extension.node"); | ||
const extension_1 = require("./extension"); | ||
const internal_1 = require("./internal"); | ||
@@ -28,3 +25,3 @@ /** | ||
return this; | ||
metrics.setGauge(key, value, tags && Array.isArray(tags) | ||
extension_1.metrics.setGauge(key, value, tags && Array.isArray(tags) | ||
? (_a = new internal_1.DataArray(tags)) === null || _a === void 0 ? void 0 : _a.ref : (_b = new internal_1.DataMap(tags)) === null || _b === void 0 ? void 0 : _b.ref); | ||
@@ -50,3 +47,3 @@ return this; | ||
return this; | ||
metrics.addDistributionValue(key, value, tags && Array.isArray(tags) | ||
extension_1.metrics.addDistributionValue(key, value, tags && Array.isArray(tags) | ||
? (_a = new internal_1.DataArray(tags)) === null || _a === void 0 ? void 0 : _a.ref : (_b = new internal_1.DataMap(tags)) === null || _b === void 0 ? void 0 : _b.ref); | ||
@@ -73,3 +70,3 @@ return this; | ||
return this; | ||
metrics.incrementCounter(key, value, tags && Array.isArray(tags) | ||
extension_1.metrics.incrementCounter(key, value, tags && Array.isArray(tags) | ||
? (_a = new internal_1.DataArray(tags)) === null || _a === void 0 ? void 0 : _a.ref : (_b = new internal_1.DataMap(tags)) === null || _b === void 0 ? void 0 : _b.ref); | ||
@@ -76,0 +73,0 @@ return this; |
@@ -9,6 +9,6 @@ "use strict"; | ||
currentSpan() { | ||
return; | ||
return new span_1.NoopSpan(); | ||
} | ||
withSpan(span, fn) { | ||
return {}; | ||
return fn(span); | ||
} | ||
@@ -15,0 +15,0 @@ wrap(fn) { |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
// the C++ extension is loaded here (via commonjs for compatibility). | ||
// we keep this as a locally scoped variable; the C++ bindings | ||
// should not be visible publicly. | ||
const { span } = require("../build/Release/extension.node"); | ||
const extension_1 = require("./extension"); | ||
const internal_1 = require("./internal"); | ||
@@ -22,3 +19,3 @@ /** | ||
get traceId() { | ||
return span.getTraceId(this._ref); | ||
return extension_1.span.getTraceId(this._ref); | ||
} | ||
@@ -29,3 +26,3 @@ /** | ||
get spanId() { | ||
return span.getSpanId(this._ref); | ||
return extension_1.span.getSpanId(this._ref); | ||
} | ||
@@ -43,14 +40,14 @@ /** | ||
if (typeof value === "string") { | ||
span.setSpanAttributeString(this._ref, key, value); | ||
extension_1.span.setSpanAttributeString(this._ref, key, value); | ||
} | ||
if (typeof value === "number") { | ||
if (Number.isInteger(value)) { | ||
span.setSpanAttributeInt(this._ref, key, value); | ||
extension_1.span.setSpanAttributeInt(this._ref, key, value); | ||
} | ||
else { | ||
span.setSpanAttributeDouble(this._ref, key, value); | ||
extension_1.span.setSpanAttributeDouble(this._ref, key, value); | ||
} | ||
} | ||
if (typeof value === "boolean") { | ||
span.setSpanAttributeBool(this._ref, key, value); | ||
extension_1.span.setSpanAttributeBool(this._ref, key, value); | ||
} | ||
@@ -66,3 +63,3 @@ return this; | ||
const stackdata = new internal_1.DataArray(error.stack ? error.stack.split("\n") : ["No stacktrace available."]); | ||
span.addSpanError(this._ref, error.name, error.message, stackdata.ref); | ||
extension_1.span.addSpanError(this._ref, error.name, error.message, stackdata.ref); | ||
return this; | ||
@@ -77,3 +74,3 @@ } | ||
return this; | ||
span.setSpanName(this._ref, name); | ||
extension_1.span.setSpanName(this._ref, name); | ||
return this; | ||
@@ -88,3 +85,3 @@ } | ||
try { | ||
span.setSpanSampleData(this._ref, key, Array.isArray(data) ? new internal_1.DataArray(data).ref : new internal_1.DataMap(data).ref); | ||
extension_1.span.setSpanSampleData(this._ref, key, Array.isArray(data) ? new internal_1.DataArray(data).ref : new internal_1.DataMap(data).ref); | ||
} | ||
@@ -105,3 +102,3 @@ catch (e) { | ||
} | ||
span.closeSpan(this._ref); | ||
extension_1.span.closeSpan(this._ref); | ||
return this; | ||
@@ -113,3 +110,3 @@ } | ||
toJSON() { | ||
return span.spanToJSON(this._ref); | ||
return extension_1.span.spanToJSON(this._ref); | ||
} | ||
@@ -125,3 +122,3 @@ } | ||
super(); | ||
this._ref = span.createChildSpan(traceId, parentSpanId); | ||
this._ref = extension_1.span.createChildSpan(traceId, parentSpanId); | ||
} | ||
@@ -137,5 +134,5 @@ } | ||
super(); | ||
this._ref = span.createRootSpan(namespace); | ||
this._ref = extension_1.span.createRootSpan(namespace); | ||
} | ||
} | ||
exports.RootSpan = RootSpan; |
@@ -1,1 +0,1 @@ | ||
export declare const VERSION = "0.2.0"; | ||
export declare const VERSION = "0.3.0"; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
// Do not touch this file, auto-generated by scripts/create-versionfile | ||
exports.VERSION = "0.2.0"; | ||
exports.VERSION = "0.3.0"; |
{ | ||
"name": "@appsignal/nodejs", | ||
"version": "0.2.0", | ||
"version": "0.3.0", | ||
"main": "dist/index.js", | ||
"license": "MIT", | ||
"dependencies": { | ||
"node-addon-api": "^2.0.0", | ||
"node-gyp": "^6.1.0", | ||
"require-in-the-middle": "^5.0.3", | ||
"semver": "^7.1.3", | ||
"semver": "^7.2.1", | ||
"shimmer": "^1.2.1", | ||
"tslib": "^1.11.1" | ||
}, | ||
"optionalDependencies": { | ||
"@appsignal/nodejs-ext": "^0.3.0" | ||
}, | ||
"scripts": { | ||
"build": "tsc -p tsconfig.json", | ||
"build:ext": "node-gyp rebuild", | ||
"build:watch": "yarn versionfile && tsc -p tsconfig.json -w --preserveWatchOutput", | ||
@@ -23,4 +23,3 @@ "clean": "rimraf dist coverage", | ||
"versionfile": "node scripts/create-versionfile.js", | ||
"version": "yarn versionfile", | ||
"install": "node scripts/extension.js && node-gyp rebuild" | ||
"version": "yarn versionfile" | ||
}, | ||
@@ -33,3 +32,3 @@ "engines": { | ||
}, | ||
"gitHead": "e4793f0957cd7e6eb3385f033b8a498cb8032791" | ||
"gitHead": "af47d79ab4ce68aa1e08b91f5d575598e2a1eca4" | ||
} |
Native code
Supply chain riskContains native code (e.g., compiled binaries or shared libraries). Including native code can obscure malicious behavior.
Found 1 instance in 1 package
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
Shell access
Supply chain riskThis module accesses the system shell. Accessing the system shell increases the risk of executing arbitrary code.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 1 instance in 1 package
5
9
1
61827
62
1749
+ Added@appsignal/nodejs-ext@0.3.3(transitive)
+ Addednode-addon-api@3.2.1(transitive)
- Removednode-addon-api@^2.0.0
- Removednode-gyp@^6.1.0
- Removednode-addon-api@2.0.2(transitive)
Updatedsemver@^7.2.1