@web3api/tracing-js
Advanced tools
Comparing version 0.0.1-prealpha.49 to 0.0.1-prealpha.50
@@ -14,2 +14,3 @@ import * as api from "@opentelemetry/api"; | ||
static recordException(error: api.Exception): void; | ||
static traceMethod(span: string): (target: unknown, key: string | symbol, descriptor: PropertyDescriptor) => PropertyDescriptor; | ||
static traceFunc<TArgs extends Array<unknown>, TReturn>(span: string, func: (...args: TArgs) => TReturn): (...args: TArgs) => TReturn; | ||
@@ -16,0 +17,0 @@ static _initProvider(serviceName: string): void; |
@@ -105,2 +105,36 @@ "use strict"; | ||
}; | ||
Tracer.traceMethod = function (span) { | ||
return function (target, key, descriptor) { | ||
var original = descriptor.value; | ||
descriptor.value = function () { | ||
var args = []; | ||
for (var _i = 0; _i < arguments.length; _i++) { | ||
args[_i] = arguments[_i]; | ||
} | ||
try { | ||
Tracer.startSpan(span); | ||
Tracer.setAttribute("input", __assign({}, args)); | ||
var result = original.apply(this, args); | ||
if (isPromise(result)) { | ||
return result.then(function (result) { | ||
Tracer.setAttribute("output", result); | ||
Tracer.endSpan(); | ||
return result; | ||
}); | ||
} | ||
else { | ||
Tracer.setAttribute("output", result); | ||
Tracer.endSpan(); | ||
return result; | ||
} | ||
} | ||
catch (error) { | ||
Tracer.recordException(error); | ||
Tracer.endSpan(); | ||
throw error; | ||
} | ||
}; | ||
return descriptor; | ||
}; | ||
}; | ||
Tracer.traceFunc = function (span, func) { | ||
@@ -107,0 +141,0 @@ var _this = this; |
{ | ||
"name": "@web3api/tracing-js", | ||
"description": "Web3API Core Tracing", | ||
"version": "0.0.1-prealpha.49", | ||
"version": "0.0.1-prealpha.50", | ||
"license": "MIT", | ||
@@ -16,3 +16,3 @@ "repository": { | ||
"build": "rimraf ./build && tsc --project tsconfig.build.json", | ||
"lint": "eslint --color --ext .ts src/", | ||
"lint": "eslint --color -c ../../../.eslintrc.js src/", | ||
"test": "jest --passWithNoTests --runInBand --verbose", | ||
@@ -45,3 +45,3 @@ "test:ci": "jest --passWithNoTests --runInBand --verbose", | ||
}, | ||
"gitHead": "ee0cda1e460fe4232945e159038e1e4d9fb7680e", | ||
"gitHead": "2947f956485decb43363f42c99c2a6176a25bde8", | ||
"publishConfig": { | ||
@@ -48,0 +48,0 @@ "access": "public" |
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
16024
219