elastic-apm-node
Version:
The official Elastic APM agent for Node.js
74 lines (60 loc) • 1.39 kB
JavaScript
/*
* Copyright Elasticsearch B.V. and other contributors where applicable.
* Licensed under the BSD 2-Clause License; you may not use this file except in
* compliance with the BSD 2-Clause License.
*/
;
// A no-op (does nothing) APM Client -- i.e. the APM server client API
// provided by elastic-apm-http-client.
//
// This is used for some configurations (when `disableSend=true` or when
// `contextPropagationOnly=true`) and in some tests.
class NoopApmClient {
config(opts) {}
addMetadataFilter(fn) {}
setExtraMetadata(metadata) {}
lambdaStart() {}
lambdaShouldRegisterTransactions() {
return true;
}
lambdaRegisterTransaction(trans, awsRequestId) {}
sendSpan(span, cb) {
if (cb) {
process.nextTick(cb);
}
}
sendTransaction(transaction, cb) {
if (cb) {
process.nextTick(cb);
}
}
sendError(_error, cb) {
if (cb) {
process.nextTick(cb);
}
}
sendMetricSet(metricset, cb) {
if (cb) {
process.nextTick(cb);
}
}
flush(opts, cb) {
if (typeof opts === 'function') {
cb = opts;
opts = {};
} else if (!opts) {
opts = {};
}
if (cb) {
process.nextTick(cb);
}
}
supportsKeepingUnsampledTransaction() {
return true;
}
// Inherited from Writable, called in agent.js.
destroy() {}
}
module.exports = {
NoopApmClient,
};