Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@instana/core

Package Overview
Dependencies
Maintainers
3
Versions
258
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@instana/core - npm Package Compare versions

Comparing version 1.67.2 to 1.68.0

src/tracing/instrumentation/frameworks/hapi.js

8

package.json
{
"name": "@instana/core",
"version": "1.67.2",
"version": "1.68.0",
"description": "Core library for Instana's Node.js packages",

@@ -118,9 +118,9 @@ "main": "src/index.js",

"devDependencies": {
"eslint": "^4.19.1",
"eslint": "^5.16.0",
"eslint-config-airbnb": "^17.1.0",
"eslint-plugin-mocha": "^4.12.1",
"eslint-plugin-mocha": "^5.3.0",
"mocha": "^5.2.0",
"prettier": "^1.16.4"
},
"gitHead": "aaf57f2d78c2a9c989c2052b52e7eae3343da4e5"
"gitHead": "f5b2b2172822ddffbaf10588143042fcb98b3af5"
}
'use strict';
var log = require('./logger');
var normalizeConfig = require('./util/normalizeConfig');

@@ -19,4 +20,6 @@ // Require this first to ensure that we have non-instrumented http available.

log.init(config);
config = normalizeConfig(config);
exports.secrets.init(config);
exports.util.requireHook.init(config);
exports.tracing.init(config, downstreamConnection, processIdentityProvider);
};

@@ -15,2 +15,3 @@ 'use strict';

exports.init = function init(config) {
config = config || {};
if (

@@ -17,0 +18,0 @@ config.logger &&

@@ -24,3 +24,3 @@ 'use strict';

exports.activate = function(config) {
timeBetweenHealthcheckCalls = config.timeBetweenHealthcheckCalls || 3000;
timeBetweenHealthcheckCalls = config.metrics.timeBetweenHealthcheckCalls;

@@ -27,0 +27,0 @@ if (adminPluginHealthcheck != null) {

@@ -146,2 +146,7 @@ 'use strict';

exports.init = function init(config) {
// Init from config/env vars. Might be overwritten from agent response later (via setMatcher);
exports.isSecret = exports.matchers[config.secrets.matcherMode](config.secrets.keywords);
};
exports.setMatcher = function setMatcher(matcherId, secretsList) {

@@ -148,0 +153,0 @@ if (!(typeof matcherId === 'string')) {

@@ -12,7 +12,2 @@ 'use strict';

var logger;
logger = require('../logger').getLogger('tracing', function(newLogger) {
logger = newLogger;
});
var tracingEnabled = false;

@@ -36,2 +31,3 @@ var automaticTracingEnabled = false;

'./instrumentation/frameworks/fastify',
'./instrumentation/frameworks/hapi',
'./instrumentation/frameworks/koa',

@@ -56,6 +52,5 @@ './instrumentation/loggers/bunyan',

config = _config;
setDefaults();
tracingEnabled = shouldEnableTracing();
automaticTracingEnabled = tracingEnabled && shouldEnableAutomaticTracing();
tracingEnabled = config.tracing.enabled;
automaticTracingEnabled = config.tracing.automaticTracingEnabled;

@@ -80,48 +75,2 @@ if (tracingEnabled) {

function setDefaults() {
config.tracing = config.tracing || {};
config.tracing.enabled = config.tracing.enabled !== false;
config.tracing.http = config.tracing.http || {};
if (!config.tracing.http.extraHttpHeadersToCapture) {
config.tracing.http.extraHttpHeadersToCapture = extraHeaders;
} else if (!Array.isArray(config.tracing.http.extraHttpHeadersToCapture)) {
logger.warn(
'Invalid configuration: config.tracing.http.extraHttpHeadersToCapture is not an array, ' +
'the value will be ignored: ' +
JSON.stringify(config.tracing.http.extraHttpHeadersToCapture)
);
config.tracing.http.extraHttpHeadersToCapture = extraHeaders;
}
}
function shouldEnableTracing() {
if (config.tracing && config.tracing.enabled === false) {
logger.info('Not enabling manual tracing as tracing is not enabled via config.');
return false;
}
return true;
}
function shouldEnableAutomaticTracing() {
if (config.tracing && config.tracing.enabled === false) {
logger.info('Not enabling automatic tracing as tracing is not enabled via config.');
return false;
}
if (config.tracing && config.tracing.disableAutomaticTracing) {
logger.info('Not enabling automatic tracing as automatic tracing is disabled via config.');
return false;
}
if (!exports.supportedVersion(process.versions.node)) {
logger.info(
'Not enabling automatic tracing, this is an unsupported version of Node.js. ' +
'See: https://docs.instana.io/ecosystem/node-js/#supported-nodejs-versions'
);
return false;
}
return true;
}
exports.supportedVersion = function supportedVersion(version) {

@@ -128,0 +77,0 @@ return semver.satisfies(version, '^4.5 || ^5.10 || ^6 || ^7 || ^8.2.1 || ^9.1.0 || ^10.4.0 || ^11 || >=12.0.0');

@@ -36,12 +36,2 @@ 'use strict';

var parentSpan = cls.getCurrentSpan();
if (parentSpan) {
logger.warn(
'Cannot start an HTTP(S) entry span when another span is already active. Currently, the following span is ' +
'active: ' +
JSON.stringify(parentSpan)
);
return realEmit.apply(originalThis, originalArgs);
}
return cls.ns.runAndReturn(function() {

@@ -57,2 +47,13 @@ // Respect any incoming tracing level headers

var parentSpan = cls.getCurrentSpan();
if (parentSpan) {
logger.warn(
'Cannot start an HTTP(S) entry span for ' +
(req ? req.url : '(URL not available)') +
' when another span is already active. Currently, the following span is active: ' +
JSON.stringify(parentSpan)
);
return realEmit.apply(originalThis, originalArgs);
}
var incomingTraceId = getExistingTraceId(req);

@@ -59,0 +60,0 @@ var incomingParentSpanId = getExistingSpanId(req);

@@ -173,3 +173,3 @@ 'use strict';

exports.init = function init(config, _processIdentityProvider) {
if (typeof config.serviceName === 'string' && config.serviceName) {
if (config.serviceName) {
serviceName = config.serviceName;

@@ -176,0 +176,0 @@ }

@@ -19,4 +19,4 @@ 'use strict';

downstreamConnection = _downstreamConnection;
maxBufferedSpans = config.tracing.maxBufferedSpans || 1000;
forceTransmissionStartingAt = config.tracing.forceTransmissionStartingAt || 500;
maxBufferedSpans = config.tracing.maxBufferedSpans;
forceTransmissionStartingAt = config.tracing.forceTransmissionStartingAt;
};

@@ -23,0 +23,0 @@

@@ -6,55 +6,8 @@ 'use strict';

var logger;
logger = require('../logger').getLogger('tracing/util', function(newLogger) {
logger = newLogger;
});
var stackTraceLength = 10;
var defaultStackTraceLength = 10;
var stackTraceLength = 0;
exports.init = function(config) {
if (config.tracing.stackTraceLength != null) {
if (typeof config.tracing.stackTraceLength === 'number') {
stackTraceLength = normalizeNumericalStackTraceLength(config.tracing.stackTraceLength);
} else if (typeof config.tracing.stackTraceLength === 'string') {
stackTraceLength = parseInt(config.tracing.stackTraceLength, 10);
if (!isNaN(stackTraceLength)) {
stackTraceLength = normalizeNumericalStackTraceLength(stackTraceLength);
} else {
logger.warn(
'The value of config.tracing.stackTraceLength ("%s") has type string and cannot be parsed to a numerical ' +
'value. Assuming the default stack trace length %s.',
config.tracing.stackTraceLength,
defaultStackTraceLength
);
stackTraceLength = defaultStackTraceLength;
}
} else {
logger.warn(
'The value of config.tracing.stackTraceLength has the non-supported type %s (the value is "%s"). Assuming ' +
'the default stack trace length %s.',
typeof config.tracing.stackTraceLength,
config.tracing.stackTraceLength,
defaultStackTraceLength
);
stackTraceLength = defaultStackTraceLength;
}
} else {
stackTraceLength = defaultStackTraceLength;
}
stackTraceLength = config.tracing.stackTraceLength;
};
function normalizeNumericalStackTraceLength(numericalLength) {
// just in case folks provide non-integral numbers or negative numbers
var normalized = Math.abs(Math.round(numericalLength));
if (normalized !== numericalLength) {
logger.warn(
'Normalized the provided value of config.tracing.stackTraceLength ("%s") to %s.',
numericalLength,
normalized
);
}
return normalized;
}
exports.getStackTrace = function getStackTrace(referenceFunction) {

@@ -61,0 +14,0 @@ return stackTrace.captureStackTrace(stackTraceLength, referenceFunction);

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc