@hypertrace/nodejsagent
Advanced tools
Comparing version 1.6.1 to 1.7.0
@@ -36,3 +36,3 @@ "use strict"; | ||
Logging_1.logger.debug("Loading configuration"); | ||
let configObj = Config.mergeConfig({}, (0, defaults_1.getDefaultConfigValues)()); | ||
let configObj = Config.mergeConfig({}, defaults_1.getDefaultConfigValues()); | ||
let fileObj = Config.loadFromFile(); | ||
@@ -42,3 +42,3 @@ if (fileObj) { | ||
} | ||
let envObj = (0, envConfigReader_1.loadFromEnv)(); | ||
let envObj = envConfigReader_1.loadFromEnv(); | ||
configObj = Config.mergeConfig(configObj, envObj); | ||
@@ -49,7 +49,7 @@ Logging_1.logger.debug(`Configuration loaded with finalized values: ${JSON.stringify(configObj)}`); | ||
static loadFromFile() { | ||
let envPath = (0, envSettings_1.getEnvValue)('CONFIG_FILE'); | ||
let envPath = envSettings_1.getEnvValue('CONFIG_FILE'); | ||
if (envPath) { | ||
try { | ||
Logging_1.logger.debug(`Attempting to load log from configured path: ${envPath}`); | ||
const fileContents = (0, fs_1.readFileSync)(envPath, 'utf-8'); | ||
const fileContents = fs_1.readFileSync(envPath, 'utf-8'); | ||
Logging_1.logger.debug(`Successfully loaded config from file`); | ||
@@ -56,0 +56,0 @@ return yaml_1.default.parse(fileContents); |
@@ -8,11 +8,11 @@ "use strict"; | ||
let envConfig = {}; | ||
let enabled = (0, envSettings_1.getEnvValue)('ENABLED'); | ||
let enabled = envSettings_1.getEnvValue('ENABLED'); | ||
if (enabled) { | ||
envConfig['enabled'] = isTrue(enabled); | ||
} | ||
let serviceName = (0, envSettings_1.getEnvValue)('SERVICE_NAME'); | ||
let serviceName = envSettings_1.getEnvValue('SERVICE_NAME'); | ||
if (serviceName) { | ||
envConfig['service_name'] = serviceName; | ||
} | ||
let reportingEndpoint = (0, envSettings_1.getEnvValue)('REPORTING_ENDPOINT'); | ||
let reportingEndpoint = envSettings_1.getEnvValue('REPORTING_ENDPOINT'); | ||
let reporting = {}; | ||
@@ -22,15 +22,15 @@ if (reportingEndpoint) { | ||
} | ||
let traceReporterType = (0, envSettings_1.getEnvValue)('REPORTING_TRACE_REPORTER_TYPE'); | ||
let traceReporterType = envSettings_1.getEnvValue('REPORTING_TRACE_REPORTER_TYPE'); | ||
if (traceReporterType) { | ||
reporting['trace_reporter_type'] = traceReporterType; | ||
} | ||
let reportingSecure = (0, envSettings_1.getEnvValue)('REPORTING_SECURE'); | ||
let reportingSecure = envSettings_1.getEnvValue('REPORTING_SECURE'); | ||
if (reportingSecure) { | ||
reporting['secure'] = isTrue(reportingSecure); | ||
} | ||
let reportingCertFile = (0, envSettings_1.getEnvValue)("REPORTING_CERT_FILE"); | ||
let reportingCertFile = envSettings_1.getEnvValue("REPORTING_CERT_FILE"); | ||
if (reportingCertFile) { | ||
reporting["cert_file"] = reportingCertFile; | ||
} | ||
let reportingToken = (0, envSettings_1.getEnvValue)('REPORTING_TOKEN'); | ||
let reportingToken = envSettings_1.getEnvValue('REPORTING_TOKEN'); | ||
if (reportingToken) { | ||
@@ -43,3 +43,3 @@ reporting['token'] = reportingToken; | ||
let dataCapture = {}; | ||
let httpHeadersRequest = (0, envSettings_1.getEnvValue)('DATA_CAPTURE_HTTP_HEADERS_REQUEST'); | ||
let httpHeadersRequest = envSettings_1.getEnvValue('DATA_CAPTURE_HTTP_HEADERS_REQUEST'); | ||
if (httpHeadersRequest) { | ||
@@ -49,3 +49,3 @@ dataCapture['http_headers'] = {}; | ||
} | ||
let httpHeadersResponse = (0, envSettings_1.getEnvValue)('DATA_CAPTURE_HTTP_HEADERS_RESPONSE'); | ||
let httpHeadersResponse = envSettings_1.getEnvValue('DATA_CAPTURE_HTTP_HEADERS_RESPONSE'); | ||
if (httpHeadersResponse) { | ||
@@ -55,3 +55,3 @@ dataCapture['http_headers'] || (dataCapture['http_headers'] = {}); | ||
} | ||
let httpBodyRequest = (0, envSettings_1.getEnvValue)('DATA_CAPTURE_HTTP_BODY_REQUEST'); | ||
let httpBodyRequest = envSettings_1.getEnvValue('DATA_CAPTURE_HTTP_BODY_REQUEST'); | ||
if (httpBodyRequest) { | ||
@@ -61,3 +61,3 @@ dataCapture['http_body'] = {}; | ||
} | ||
let httpBodyResponse = (0, envSettings_1.getEnvValue)('DATA_CAPTURE_HTTP_BODY_RESPONSE'); | ||
let httpBodyResponse = envSettings_1.getEnvValue('DATA_CAPTURE_HTTP_BODY_RESPONSE'); | ||
if (httpBodyResponse) { | ||
@@ -67,3 +67,3 @@ dataCapture['http_body'] || (dataCapture['http_body'] = {}); | ||
} | ||
let rpcMetadataRequest = (0, envSettings_1.getEnvValue)('DATA_CAPTURE_RPC_METADATA_REQUEST'); | ||
let rpcMetadataRequest = envSettings_1.getEnvValue('DATA_CAPTURE_RPC_METADATA_REQUEST'); | ||
if (rpcMetadataRequest) { | ||
@@ -73,3 +73,3 @@ dataCapture['rpc_metadata'] = {}; | ||
} | ||
let rpcMetadataResponse = (0, envSettings_1.getEnvValue)('DATA_CAPTURE_RPC_METADATA_RESPONSE'); | ||
let rpcMetadataResponse = envSettings_1.getEnvValue('DATA_CAPTURE_RPC_METADATA_RESPONSE'); | ||
if (rpcMetadataResponse) { | ||
@@ -79,3 +79,3 @@ dataCapture['rpc_metadata'] || (dataCapture['rpc_metadata'] = {}); | ||
} | ||
let rpcBodyRequest = (0, envSettings_1.getEnvValue)('DATA_CAPTURE_RPC_BODY_REQUEST'); | ||
let rpcBodyRequest = envSettings_1.getEnvValue('DATA_CAPTURE_RPC_BODY_REQUEST'); | ||
if (rpcBodyRequest) { | ||
@@ -85,3 +85,3 @@ dataCapture['rpc_body'] = {}; | ||
} | ||
let rpcBodyResponse = (0, envSettings_1.getEnvValue)('DATA_CAPTURE_RPC_BODY_RESPONSE'); | ||
let rpcBodyResponse = envSettings_1.getEnvValue('DATA_CAPTURE_RPC_BODY_RESPONSE'); | ||
if (rpcBodyRequest) { | ||
@@ -91,7 +91,7 @@ dataCapture['rpc_body'] || (dataCapture['rpc_body'] = {}); | ||
} | ||
let bodyMaxSizeBytes = (0, envSettings_1.getEnvValue)('DATA_CAPTURE_BODY_MAX_SIZE_BYTES'); | ||
let bodyMaxSizeBytes = envSettings_1.getEnvValue('DATA_CAPTURE_BODY_MAX_SIZE_BYTES'); | ||
if (bodyMaxSizeBytes) { | ||
dataCapture['body_max_size_bytes'] = parseInt(bodyMaxSizeBytes); | ||
} | ||
let bodyMaxProcessingSizeBytes = (0, envSettings_1.getEnvValue)('DATA_CAPTURE_BODY_MAX_PROCESSING_SIZE_BYTES'); | ||
let bodyMaxProcessingSizeBytes = envSettings_1.getEnvValue('DATA_CAPTURE_BODY_MAX_PROCESSING_SIZE_BYTES'); | ||
if (bodyMaxProcessingSizeBytes) { | ||
@@ -103,3 +103,3 @@ dataCapture['body_max_processing_size_bytes'] = parseInt(bodyMaxProcessingSizeBytes); | ||
} | ||
let propagationFormats = (0, envSettings_1.getEnvValue)('PROPAGATION_FORMATS'); | ||
let propagationFormats = envSettings_1.getEnvValue('PROPAGATION_FORMATS'); | ||
if (propagationFormats) { | ||
@@ -106,0 +106,0 @@ envConfig['propagation_formats'] = propagationFormats.split(','); |
@@ -72,5 +72,5 @@ "use strict"; | ||
let httpWrapper = new HttpInstrumentationWrapper_1.HttpInstrumentationWrapper(this.config.config); | ||
(0, OutgoingRequestWrapper_1.patchClientRequest)(); | ||
(0, ExpressWrapper_1.patchExpress)(); | ||
(0, SailsWrapper_1.patchSails)(); | ||
OutgoingRequestWrapper_1.patchClientRequest(); | ||
ExpressWrapper_1.patchExpress(); | ||
SailsWrapper_1.patchSails(); | ||
if (Framework_1.Framework.getInstance().available('@grpc/grpc-js')) { | ||
@@ -109,6 +109,6 @@ // we need to check for grpc a level up before trying to patch since we cant "require" in the | ||
]; | ||
if ((0, InstrumentationCompat_1.isCompatible)("12.0.0")) { | ||
if (InstrumentationCompat_1.isCompatible("12.0.0")) { | ||
// Imports are only allowed at top level | ||
// so instead we need to require it if the node version is modern enough | ||
(0, HapiWrapper_1.patchHapi)(); | ||
HapiWrapper_1.patchHapi(); | ||
const hapiHypertraceInstrumentation = require("./instrumentation/HapiHypertraceInstrumentation"); | ||
@@ -115,0 +115,0 @@ instrumentations.push(new hapiHypertraceInstrumentation.HapiHypertraceInstrumentation({})); |
import * as filter from "./filter/Filter"; | ||
export type IFilter = filter.IFilter; | ||
export declare type IFilter = filter.IFilter; |
@@ -26,3 +26,3 @@ "use strict"; | ||
let receivedData = ''; | ||
let chunkSize = (0, object_sizeof_1.default)(chunk); | ||
let chunkSize = object_sizeof_1.default(chunk); | ||
if (!Buffer.isBuffer(chunk)) { | ||
@@ -29,0 +29,0 @@ if (chunk instanceof Object) { |
@@ -32,3 +32,3 @@ "use strict"; | ||
Object.entries(methods).forEach(([name, { originalName }]) => { | ||
if (!(0, utils_1._methodIsIgnored)(name, this.getConfig().ignoreGrpcMethods)) { | ||
if (!utils_1._methodIsIgnored(name, this.getConfig().ignoreGrpcMethods)) { | ||
methodList.push(name); // adds camel case method name: "unaryMethod" | ||
@@ -61,3 +61,3 @@ if (originalName && | ||
if (err.code) { | ||
span.setStatus((0, utils_1._grpcStatusCodeToSpanStatus)(err.code)); | ||
span.setStatus(utils_1._grpcStatusCodeToSpanStatus(err.code)); | ||
span.setAttribute(semantic_conventions_1.SemanticAttributes.RPC_GRPC_STATUS_CODE, err.code.toString()); | ||
@@ -113,3 +113,3 @@ } | ||
span.setStatus({ | ||
code: (0, utils_1._grpcStatusCodeToOpenTelemetryStatusCode)(err.code), | ||
code: utils_1._grpcStatusCodeToOpenTelemetryStatusCode(err.code), | ||
message: err.message, | ||
@@ -128,3 +128,3 @@ }); | ||
call[serverUtils_1.CALL_SPAN_ENDED] = true; | ||
span.setStatus((0, utils_1._grpcStatusCodeToSpanStatus)(status.code)); | ||
span.setStatus(utils_1._grpcStatusCodeToSpanStatus(status.code)); | ||
endSpan(); | ||
@@ -131,0 +131,0 @@ }); |
@@ -36,6 +36,6 @@ "use strict"; | ||
const wrappedFn = (err, res) => { | ||
(0, GrpcJsHypertraceInstrumentation_1.createAndAddBodyCapture)(span, res, 'response'); | ||
GrpcJsHypertraceInstrumentation_1.createAndAddBodyCapture(span, res, 'response'); | ||
if (err) { | ||
if (err.code) { | ||
span.setStatus((0, utils_1._grpcStatusCodeToSpanStatus)(err.code)); | ||
span.setStatus(utils_1._grpcStatusCodeToSpanStatus(err.code)); | ||
span.setAttribute(semantic_conventions_1.SemanticAttributes.RPC_GRPC_STATUS_CODE, err.code.toString()); | ||
@@ -80,3 +80,3 @@ } | ||
call.on('metadata', (metadata) => { | ||
(0, GrpcJsHypertraceInstrumentation_1.addMetadataToSpan)(span, metadata, 'response'); | ||
GrpcJsHypertraceInstrumentation_1.addMetadataToSpan(span, metadata, 'response'); | ||
}); | ||
@@ -101,3 +101,3 @@ // if server stream or bidi | ||
span.setStatus({ | ||
code: (0, utils_1._grpcStatusCodeToOpenTelemetryStatusCode)(err.code), | ||
code: utils_1._grpcStatusCodeToOpenTelemetryStatusCode(err.code), | ||
message: err.message, | ||
@@ -116,3 +116,3 @@ }); | ||
call[serverUtils_1.CALL_SPAN_ENDED] = true; | ||
span.setStatus((0, utils_1._grpcStatusCodeToSpanStatus)(status.code)); | ||
span.setStatus(utils_1._grpcStatusCodeToSpanStatus(status.code)); | ||
endSpan(); | ||
@@ -119,0 +119,0 @@ }); |
@@ -41,3 +41,3 @@ "use strict"; | ||
this._diag.debug(`Applying patch for @grpc/grpc-js@${version}`); | ||
if ((0, instrumentation_1.isWrapped)(moduleExports.Server.prototype.register)) { | ||
if (instrumentation_1.isWrapped(moduleExports.Server.prototype.register)) { | ||
this._unwrap(moduleExports.Server.prototype, 'register'); | ||
@@ -48,11 +48,11 @@ } | ||
// Patch Client methods | ||
if ((0, instrumentation_1.isWrapped)(moduleExports.makeGenericClientConstructor)) { | ||
if (instrumentation_1.isWrapped(moduleExports.makeGenericClientConstructor)) { | ||
this._unwrap(moduleExports, 'makeGenericClientConstructor'); | ||
} | ||
this._wrap(moduleExports, 'makeGenericClientConstructor', this._patchClient(moduleExports)); | ||
if ((0, instrumentation_1.isWrapped)(moduleExports.makeClientConstructor)) { | ||
if (instrumentation_1.isWrapped(moduleExports.makeClientConstructor)) { | ||
this._unwrap(moduleExports, 'makeClientConstructor'); | ||
} | ||
this._wrap(moduleExports, 'makeClientConstructor', this._patchClient(moduleExports)); | ||
if ((0, instrumentation_1.isWrapped)(moduleExports.loadPackageDefinition)) { | ||
if (instrumentation_1.isWrapped(moduleExports.loadPackageDefinition)) { | ||
this._unwrap(moduleExports, 'loadPackageDefinition'); | ||
@@ -92,4 +92,4 @@ } | ||
const self = this; | ||
if ((0, GrpcJsHypertraceServerUtils_1.shouldNotTraceServerCall)(call.metadata, name, config.ignoreGrpcMethods)) { | ||
return (0, GrpcJsHypertraceServerUtils_1.handleUntracedServerFunction)(type, originalFunc, call, callback); | ||
if (GrpcJsHypertraceServerUtils_1.shouldNotTraceServerCall(call.metadata, name, config.ignoreGrpcMethods)) { | ||
return GrpcJsHypertraceServerUtils_1.handleUntracedServerFunction(type, originalFunc, call, callback); | ||
} | ||
@@ -183,3 +183,3 @@ const spanName = `grpc.${name.replace('/', '')}`; | ||
createAndAddBodyCapture(span, args[0], 'request'); | ||
return api_1.context.with(api_1.trace.setSpan(api_1.context.active(), span), () => (0, GrpcJsHypertraceClientUtils_1.makeGrpcClientRemoteCall)(original, args, metadata, this)(span)); | ||
return api_1.context.with(api_1.trace.setSpan(api_1.context.active(), span), () => GrpcJsHypertraceClientUtils_1.makeGrpcClientRemoteCall(original, args, metadata, this)(span)); | ||
} | ||
@@ -186,0 +186,0 @@ Object.assign(clientMethodTrace, original); |
@@ -63,3 +63,3 @@ "use strict"; | ||
span.setStatus({ | ||
code: (0, utils_1._grpcStatusCodeToOpenTelemetryStatusCode)(err.code), | ||
code: utils_1._grpcStatusCodeToOpenTelemetryStatusCode(err.code), | ||
message: err.message, | ||
@@ -84,3 +84,3 @@ }); | ||
span.setStatus({ | ||
code: (0, utils_1._grpcStatusCodeToOpenTelemetryStatusCode)(err.code), | ||
code: utils_1._grpcStatusCodeToOpenTelemetryStatusCode(err.code), | ||
message: err.message, | ||
@@ -107,3 +107,3 @@ }); | ||
span.setAttribute("grpc.content_type", "application/grpc"); | ||
(0, GrpcJsHypertraceInstrumentation_1.createAndAddBodyCapture)(span, value, 'response'); | ||
GrpcJsHypertraceInstrumentation_1.createAndAddBodyCapture(span, value, 'response'); | ||
span.end(); | ||
@@ -158,4 +158,4 @@ return callback(err, value); | ||
const parsedName = methodName.split('/'); | ||
return (0, utils_1._methodIsIgnored)(parsedName[parsedName.length - 1] || methodName, ignoreGrpcMethods); | ||
return utils_1._methodIsIgnored(parsedName[parsedName.length - 1] || methodName, ignoreGrpcMethods); | ||
} | ||
exports.shouldNotTraceServerCall = shouldNotTraceServerCall; |
@@ -33,3 +33,3 @@ "use strict"; | ||
this._diag.debug(`Applying patch for @grpc/grpc-js@${version}`); | ||
if ((0, instrumentation_1.isWrapped)(moduleExports.Server.prototype.register)) { | ||
if (instrumentation_1.isWrapped(moduleExports.Server.prototype.register)) { | ||
this._unwrap(moduleExports.Server.prototype, 'register'); | ||
@@ -40,11 +40,11 @@ } | ||
// Patch Client methods | ||
if ((0, instrumentation_1.isWrapped)(moduleExports.makeGenericClientConstructor)) { | ||
if (instrumentation_1.isWrapped(moduleExports.makeGenericClientConstructor)) { | ||
this._unwrap(moduleExports, 'makeGenericClientConstructor'); | ||
} | ||
this._wrap(moduleExports, 'makeGenericClientConstructor', this._patchClient(moduleExports)); | ||
if ((0, instrumentation_1.isWrapped)(moduleExports.makeClientConstructor)) { | ||
if (instrumentation_1.isWrapped(moduleExports.makeClientConstructor)) { | ||
this._unwrap(moduleExports, 'makeClientConstructor'); | ||
} | ||
this._wrap(moduleExports, 'makeClientConstructor', this._patchClient(moduleExports)); | ||
if ((0, instrumentation_1.isWrapped)(moduleExports.loadPackageDefinition)) { | ||
if (instrumentation_1.isWrapped(moduleExports.loadPackageDefinition)) { | ||
this._unwrap(moduleExports, 'loadPackageDefinition'); | ||
@@ -83,4 +83,4 @@ } | ||
const self = this; | ||
if ((0, serverUtils_1.shouldNotTraceServerCall)(call.metadata, name, config.ignoreGrpcMethods)) { | ||
return (0, serverUtils_1.handleUntracedServerFunction)(type, originalFunc, call, callback); | ||
if (serverUtils_1.shouldNotTraceServerCall(call.metadata, name, config.ignoreGrpcMethods)) { | ||
return serverUtils_1.handleUntracedServerFunction(type, originalFunc, call, callback); | ||
} | ||
@@ -155,3 +155,3 @@ const spanName = `grpc.${name.replace('/', '')}`; | ||
}); | ||
return api_1.context.with(api_1.trace.setSpan(api_1.context.active(), span), () => (0, clientUtils_1.makeGrpcClientRemoteCall)(original, args, metadata, this)(span)); | ||
return api_1.context.with(api_1.trace.setSpan(api_1.context.active(), span), () => clientUtils_1.makeGrpcClientRemoteCall(original, args, metadata, this)(span)); | ||
} | ||
@@ -158,0 +158,0 @@ Object.assign(clientMethodTrace, original); |
@@ -62,3 +62,3 @@ "use strict"; | ||
span.setStatus({ | ||
code: (0, utils_1._grpcStatusCodeToOpenTelemetryStatusCode)(err.code), | ||
code: utils_1._grpcStatusCodeToOpenTelemetryStatusCode(err.code), | ||
message: err.message, | ||
@@ -83,3 +83,3 @@ }); | ||
span.setStatus({ | ||
code: (0, utils_1._grpcStatusCodeToOpenTelemetryStatusCode)(err.code), | ||
code: utils_1._grpcStatusCodeToOpenTelemetryStatusCode(err.code), | ||
message: err.message, | ||
@@ -147,4 +147,4 @@ }); | ||
const parsedName = methodName.split('/'); | ||
return (0, utils_1._methodIsIgnored)(parsedName[parsedName.length - 1] || methodName, ignoreGrpcMethods); | ||
return utils_1._methodIsIgnored(parsedName[parsedName.length - 1] || methodName, ignoreGrpcMethods); | ||
} | ||
exports.shouldNotTraceServerCall = shouldNotTraceServerCall; |
"use strict"; | ||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = 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); | ||
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } }); | ||
}) : (function(o, m, k, k2) { | ||
@@ -65,3 +61,3 @@ if (k2 === undefined) k2 = k; | ||
return new instrumentation_1.InstrumentationNodeModuleDefinition(types_1.HapiComponentName, ['>=17.0.0'], moduleExports => { | ||
if (!(0, instrumentation_1.isWrapped)(moduleExports.server)) { | ||
if (!instrumentation_1.isWrapped(moduleExports.server)) { | ||
api.diag.debug('Patching Hapi.server'); | ||
@@ -75,3 +71,3 @@ this._wrap(moduleExports, 'server', this._getServerPatch.bind(this)); | ||
// Function is defined at: https://github.com/hapijs/hapi/blob/main/lib/index.js#L9 | ||
if (!(0, instrumentation_1.isWrapped)(moduleExports.Server)) { | ||
if (!instrumentation_1.isWrapped(moduleExports.Server)) { | ||
api.diag.debug('Patching Hapi.Server'); | ||
@@ -160,3 +156,3 @@ this._wrap( | ||
const eventObj = eventsList[i]; | ||
if ((0, utils_1.isLifecycleExtType)(eventObj.type)) { | ||
if (utils_1.isLifecycleExtType(eventObj.type)) { | ||
const lifecycleEventObj = eventObj; | ||
@@ -170,3 +166,3 @@ const handler = instrumentation._wrapExtMethods(lifecycleEventObj.method, eventObj.type, pluginName); | ||
} | ||
else if ((0, utils_1.isDirectExtInput)(args)) { | ||
else if (utils_1.isDirectExtInput(args)) { | ||
const extInput = args; | ||
@@ -177,3 +173,3 @@ const method = extInput[1]; | ||
} | ||
else if ((0, utils_1.isLifecycleExtEventObj)(args[0])) { | ||
else if (utils_1.isLifecycleExtEventObj(args[0])) { | ||
const lifecycleEventObj = args[0]; | ||
@@ -220,3 +216,3 @@ const handler = instrumentation._wrapExtMethods(lifecycleEventObj.method, lifecycleEventObj.type, pluginName); | ||
const instrumentation = this; | ||
const pluginName = (0, utils_1.getPluginName)(plugin); | ||
const pluginName = utils_1.getPluginName(plugin); | ||
const oldHandler = plugin.register; | ||
@@ -260,3 +256,3 @@ const self = this; | ||
} | ||
else if ((0, utils_1.isPatchableExtMethod)(method)) { | ||
else if (utils_1.isPatchableExtMethod(method)) { | ||
if (method[types_1.handlerPatched] === true) | ||
@@ -270,3 +266,3 @@ return method; | ||
} | ||
const metadata = (0, utils_1.getExtMetadata)(extPoint, pluginName); | ||
const metadata = utils_1.getExtMetadata(extPoint, pluginName); | ||
const span = instrumentation.tracer.startSpan(metadata.name, { | ||
@@ -316,3 +312,3 @@ attributes: metadata.attributes, | ||
const hapiSpan = api.trace.getSpan(api.context.active()); | ||
if ((0, HapiBodyCapture_1.captureWithFilter)(hapiSpan, request)) { | ||
if (HapiBodyCapture_1.captureWithFilter(hapiSpan, request)) { | ||
const forbiddenResponse = h.response(); | ||
@@ -330,9 +326,9 @@ const message = "FORBIDDEN"; | ||
} | ||
const rpcMetadata = (0, core_1.getRPCMetadata)(api.context.active()); | ||
const rpcMetadata = core_1.getRPCMetadata(api.context.active()); | ||
if ((rpcMetadata === null || rpcMetadata === void 0 ? void 0 : rpcMetadata.type) === core_1.RPCType.HTTP) { | ||
const rootSpanMetadata = (0, utils_1.getRootSpanMetadata)(route); | ||
const rootSpanMetadata = utils_1.getRootSpanMetadata(route); | ||
rpcMetadata.span.updateName(rootSpanMetadata.name); | ||
rpcMetadata.span.setAttributes(rootSpanMetadata.attributes); | ||
} | ||
const metadata = (0, utils_1.getRouteMetadata)(route, pluginName); | ||
const metadata = utils_1.getRouteMetadata(route, pluginName); | ||
const span = instrumentation.tracer.startSpan(metadata.name, { | ||
@@ -339,0 +335,0 @@ attributes: metadata.attributes, |
/// <reference types="node" /> | ||
/// <reference types="node" /> | ||
import type * as http from 'http'; | ||
@@ -4,0 +3,0 @@ import * as url from 'url'; |
"use strict"; | ||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = 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); | ||
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } }); | ||
}) : (function(o, m, k, k2) { | ||
@@ -75,11 +71,11 @@ if (k2 === undefined) k2 = k; | ||
this._diag.debug(`Applying patch for http@${this._version}`); | ||
if ((0, instrumentation_1.isWrapped)(moduleExports.request)) { | ||
if (instrumentation_1.isWrapped(moduleExports.request)) { | ||
this._unwrap(moduleExports, 'request'); | ||
} | ||
this._wrap(moduleExports, 'request', this._getPatchOutgoingRequestFunction('http')); | ||
if ((0, instrumentation_1.isWrapped)(moduleExports.get)) { | ||
if (instrumentation_1.isWrapped(moduleExports.get)) { | ||
this._unwrap(moduleExports, 'get'); | ||
} | ||
this._wrap(moduleExports, 'get', this._getPatchOutgoingGetFunction(moduleExports.request)); | ||
if ((0, instrumentation_1.isWrapped)(moduleExports.Server.prototype.emit)) { | ||
if (instrumentation_1.isWrapped(moduleExports.Server.prototype.emit)) { | ||
this._unwrap(moduleExports.Server.prototype, 'emit'); | ||
@@ -101,11 +97,11 @@ } | ||
this._diag.debug(`Applying patch for https@${this._version}`); | ||
if ((0, instrumentation_1.isWrapped)(moduleExports.request)) { | ||
if (instrumentation_1.isWrapped(moduleExports.request)) { | ||
this._unwrap(moduleExports, 'request'); | ||
} | ||
this._wrap(moduleExports, 'request', this._getPatchHttpsOutgoingRequestFunction('https')); | ||
if ((0, instrumentation_1.isWrapped)(moduleExports.get)) { | ||
if (instrumentation_1.isWrapped(moduleExports.get)) { | ||
this._unwrap(moduleExports, 'get'); | ||
} | ||
this._wrap(moduleExports, 'get', this._getPatchHttpsOutgoingGetFunction(moduleExports.request)); | ||
if ((0, instrumentation_1.isWrapped)(moduleExports.Server.prototype.emit)) { | ||
if (instrumentation_1.isWrapped(moduleExports.Server.prototype.emit)) { | ||
this._unwrap(moduleExports.Server.prototype, 'emit'); | ||
@@ -229,3 +225,3 @@ } | ||
if (this._getConfig().applyCustomAttributesOnSpan) { | ||
(0, instrumentation_1.safeExecuteInTheMiddle)(() => this._getConfig().applyCustomAttributesOnSpan(span, request, response), () => { }, true); | ||
instrumentation_1.safeExecuteInTheMiddle(() => this._getConfig().applyCustomAttributesOnSpan(span, request, response), () => { }, true); | ||
} | ||
@@ -269,3 +265,3 @@ this._closeHttpSpan(span); | ||
if (utils.isIgnored(pathname, instrumentation._getConfig().ignoreIncomingPaths, (e) => instrumentation._diag.error('caught ignoreIncomingPaths error: ', e))) { | ||
return api_1.context.with((0, core_1.suppressTracing)(api_1.context.active()), () => { | ||
return api_1.context.with(core_1.suppressTracing(api_1.context.active()), () => { | ||
api_1.context.bind(api_1.context.active(), request); | ||
@@ -291,3 +287,3 @@ api_1.context.bind(api_1.context.active(), response); | ||
}; | ||
return api_1.context.with((0, core_2.setRPCMetadata)(api_1.trace.setSpan(ctx, span), rpcMetadata), () => { | ||
return api_1.context.with(core_2.setRPCMetadata(api_1.trace.setSpan(ctx, span), rpcMetadata), () => { | ||
api_1.context.bind(api_1.context.active(), request); | ||
@@ -332,5 +328,5 @@ api_1.context.bind(api_1.context.active(), response); | ||
response.end = originalEnd; | ||
(0, ExpressWrapper_1.ResponseEnded)(span, this, _args); | ||
ExpressWrapper_1.ResponseEnded(span, this, _args); | ||
// Cannot pass args of type ResponseEndArgs, | ||
const returned = (0, instrumentation_1.safeExecuteInTheMiddle)(() => response.end.apply(this, arguments), error => { | ||
const returned = instrumentation_1.safeExecuteInTheMiddle(() => response.end.apply(this, arguments), error => { | ||
if (error) { | ||
@@ -347,3 +343,3 @@ utils.setSpanWithError(span, error); | ||
if (instrumentation._getConfig().applyCustomAttributesOnSpan) { | ||
(0, instrumentation_1.safeExecuteInTheMiddle)(() => instrumentation._getConfig().applyCustomAttributesOnSpan(span, request, response), () => { }, true); | ||
instrumentation_1.safeExecuteInTheMiddle(() => instrumentation._getConfig().applyCustomAttributesOnSpan(span, request, response), () => { }, true); | ||
} | ||
@@ -353,3 +349,3 @@ instrumentation._closeHttpSpan(span); | ||
}; | ||
return (0, instrumentation_1.safeExecuteInTheMiddle)(() => original.apply(this, [event, ...args]), error => { | ||
return instrumentation_1.safeExecuteInTheMiddle(() => original.apply(this, [event, ...args]), error => { | ||
if (error) { | ||
@@ -390,4 +386,3 @@ utils.setSpanWithError(span, error); | ||
const operationName = `${component.toUpperCase()} ${method}`; | ||
const hostname = optionsParsed.hostname || | ||
((_a = optionsParsed.host) === null || _a === void 0 ? void 0 : _a.replace(/^(.*)(:[0-9]{1,5})/, '$1')) || | ||
const hostname = optionsParsed.hostname || ((_a = optionsParsed.host) === null || _a === void 0 ? void 0 : _a.replace(/^(.*)(:[0-9]{1,5})/, '$1')) || | ||
'localhost'; | ||
@@ -419,3 +414,3 @@ const attributes = utils.getOutgoingRequestAttributes(optionsParsed, { | ||
} | ||
const request = (0, instrumentation_1.safeExecuteInTheMiddle)(() => original.apply(this, [optionsParsed, ...args]), error => { | ||
const request = instrumentation_1.safeExecuteInTheMiddle(() => original.apply(this, [optionsParsed, ...args]), error => { | ||
if (error) { | ||
@@ -463,7 +458,7 @@ utils.setSpanWithError(span, error); | ||
_callResponseHook(span, response) { | ||
(0, instrumentation_1.safeExecuteInTheMiddle)(() => this._getConfig().responseHook(span, response), () => { }, true); | ||
instrumentation_1.safeExecuteInTheMiddle(() => this._getConfig().responseHook(span, response), () => { }, true); | ||
} | ||
_callRequestHook(span, request) { | ||
try { | ||
(0, instrumentation_1.safeExecuteInTheMiddle)(() => this._getConfig().requestHook(span, request), () => { }, false // we need to raise error but on throw if its the type we would raise | ||
instrumentation_1.safeExecuteInTheMiddle(() => this._getConfig().requestHook(span, request), () => { }, false // we need to raise error but on throw if its the type we would raise | ||
); | ||
@@ -481,3 +476,3 @@ } | ||
if (typeof hookFunc === 'function') { | ||
return (0, instrumentation_1.safeExecuteInTheMiddle)(() => hookFunc(request), () => { }, true); | ||
return instrumentation_1.safeExecuteInTheMiddle(() => hookFunc(request), () => { }, true); | ||
} | ||
@@ -484,0 +479,0 @@ } |
@@ -30,3 +30,3 @@ "use strict"; | ||
const { localAddress, localPort, remoteAddress, remotePort } = socket; | ||
const rpcMetadata = (0, core_1.getRPCMetadata)(api_1.context.active()); | ||
const rpcMetadata = core_1.getRPCMetadata(api_1.context.active()); | ||
const attributes = { | ||
@@ -82,7 +82,7 @@ [semantic_conventions_1.SemanticAttributes.NET_HOST_IP]: localAddress, | ||
HypertraceAgent_1.hypertraceDomain.run(function () { | ||
throw (0, Filter_1.filterError)(); | ||
throw Filter_1.filterError(); | ||
}); | ||
} | ||
else { | ||
throw (0, Filter_1.filterError)(); | ||
throw Filter_1.filterError(); | ||
} | ||
@@ -135,3 +135,3 @@ } | ||
HypertraceAgent_1.hypertraceDomain.add(request); | ||
throw (0, Filter_1.filterError)(); | ||
throw Filter_1.filterError(); | ||
} | ||
@@ -144,3 +144,3 @@ else { | ||
// @ts-ignore | ||
request.next((0, Filter_1.filterError)()); | ||
request.next(Filter_1.filterError()); | ||
} | ||
@@ -147,0 +147,0 @@ } |
@@ -59,6 +59,6 @@ "use strict"; | ||
this._hooks.push(hookFn); | ||
(0, require_in_the_middle_1.default)([module.name], { internals: true }, hookFn); | ||
require_in_the_middle_1.default([module.name], { internals: true }, hookFn); | ||
// @ts-ignore | ||
(0, import_in_the_middle_1.default)([module.name], { internals: true }, hookFn); | ||
import_in_the_middle_1.default([module.name], { internals: true }, hookFn); | ||
} | ||
}; |
@@ -40,2 +40,2 @@ import { InstrumentationBase, InstrumentationConfig, InstrumentationNodeModuleDefinition } from '@opentelemetry/instrumentation'; | ||
} | ||
export declare const isLayerIgnored: (type: KoaLayerType, config?: KoaInstrumentationConfig) => boolean; | ||
export declare const isLayerIgnored: (type: KoaLayerType, config?: KoaInstrumentationConfig | undefined) => boolean; |
"use strict"; | ||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = 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); | ||
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } }); | ||
}) : (function(o, m, k, k2) { | ||
@@ -58,3 +54,3 @@ if (k2 === undefined) k2 = k; | ||
api.diag.debug('Patching Koa'); | ||
if ((0, instrumentation_1.isWrapped)(moduleExports.prototype.use)) { | ||
if (instrumentation_1.isWrapped(moduleExports.prototype.use)) { | ||
this._unwrap(moduleExports.prototype, 'use'); | ||
@@ -66,3 +62,3 @@ } | ||
api.diag.debug('Unpatching Koa'); | ||
if ((0, instrumentation_1.isWrapped)(moduleExports.prototype.use)) { | ||
if (instrumentation_1.isWrapped(moduleExports.prototype.use)) { | ||
this._unwrap(moduleExports.prototype, 'use'); | ||
@@ -125,3 +121,3 @@ } | ||
if (middlewareLayer[types_1.kLayerPatched] === true || | ||
(0, exports.isLayerIgnored)(layerType, this._config)) { | ||
exports.isLayerIgnored(layerType, this._config)) { | ||
return middlewareLayer; | ||
@@ -136,3 +132,3 @@ } | ||
} | ||
const metadata = (0, utils_1.getMiddlewareMetadata)(context, middlewareLayer, isRouter, layerPath); | ||
const metadata = utils_1.getMiddlewareMetadata(context, middlewareLayer, isRouter, layerPath); | ||
// diff | ||
@@ -147,3 +143,3 @@ // instead of generating a new span for koa we need to use the already | ||
// end of diff | ||
const rpcMetadata = (0, core_1.getRPCMetadata)(api.context.active()); | ||
const rpcMetadata = core_1.getRPCMetadata(api.context.active()); | ||
if (metadata.attributes[AttributeNames_1.AttributeNames.KOA_TYPE] === types_1.KoaLayerType.ROUTER && | ||
@@ -194,5 +190,4 @@ (rpcMetadata === null || rpcMetadata === void 0 ? void 0 : rpcMetadata.type) === core_1.RPCType.HTTP) { | ||
var _a; | ||
return !!(Array.isArray(config === null || config === void 0 ? void 0 : config.ignoreLayersType) && | ||
((_a = config === null || config === void 0 ? void 0 : config.ignoreLayersType) === null || _a === void 0 ? void 0 : _a.includes(type))); | ||
return !!(Array.isArray(config === null || config === void 0 ? void 0 : config.ignoreLayersType) && ((_a = config === null || config === void 0 ? void 0 : config.ignoreLayersType) === null || _a === void 0 ? void 0 : _a.includes(type))); | ||
}; | ||
exports.isLayerIgnored = isLayerIgnored; |
@@ -17,3 +17,3 @@ "use strict"; | ||
if (metadataCaptureEnabled && span) { | ||
(0, GrpcJsHypertraceInstrumentation_1.addMetadataToSpan)(span, arguments[0], 'response'); | ||
GrpcJsHypertraceInstrumentation_1.addMetadataToSpan(span, arguments[0], 'response'); | ||
} | ||
@@ -25,3 +25,3 @@ return original.apply(this, arguments); | ||
function patchGrpc() { | ||
if (!(0, ExpressWrapper_1.available)('@grpc/grpc-js') || patched) { | ||
if (!ExpressWrapper_1.available('@grpc/grpc-js') || patched) { | ||
return; | ||
@@ -28,0 +28,0 @@ } |
@@ -17,3 +17,3 @@ "use strict"; | ||
function patchSails() { | ||
if (!(0, ExpressWrapper_1.available)('sails')) { | ||
if (!ExpressWrapper_1.available('sails')) { | ||
return; | ||
@@ -20,0 +20,0 @@ } |
@@ -11,3 +11,3 @@ "use strict"; | ||
const validLogLevels = ['debug', 'info', 'warn', 'error']; | ||
let configuredLogLevel = (0, envSettings_1.getEnvValue)('LOG_LEVEL'); | ||
let configuredLogLevel = envSettings_1.getEnvValue('LOG_LEVEL'); | ||
if (configuredLogLevel == null) { | ||
@@ -14,0 +14,0 @@ configuredLogLevel = 'info'; |
{ | ||
"name": "@hypertrace/nodejsagent", | ||
"version": "1.6.1", | ||
"version": "1.7.0", | ||
"description": "Hypertrace Node.js Agent", | ||
@@ -42,3 +42,3 @@ "author": "Traceable Inc.", | ||
"opentelemetry-instrumentation-mongoose": "^0.26.1", | ||
"protobufjs": "^6.11.4", | ||
"protobufjs": "^7.2.5", | ||
"require-in-the-middle": "5.1.0", | ||
@@ -87,2 +87,3 @@ "semver": "^7.5.4", | ||
"pg": "^8.7.1", | ||
"protobufjs-cli": "^1.1.2", | ||
"reflect-metadata": "^0.1.13", | ||
@@ -106,2 +107,2 @@ "rimraf": "^3.0.2", | ||
} | ||
} | ||
} |
Sorry, the diff of this file is too big to display
428684
7882
48
Updatedprotobufjs@^7.2.5