Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
style(instrumentation-ioredis): use default config
  • Loading branch information
Amir Blum committed Mar 4, 2021
commit 245efa3416372162089fcaf480ca558d4d08fa64
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,22 @@ import { IORedisInstrumentationConfig } from './types';
import { traceConnection, traceSendCommand } from './utils';
import { VERSION } from './version';

const DEFAULT_CONFIG: IORedisInstrumentationConfig = {
requireParentSpan: true,
};

export class IORedisInstrumentation extends InstrumentationBase<
typeof ioredisTypes
> {
static readonly DB_SYSTEM = 'redis';
readonly supportedVersions = ['>1 <5'];

constructor(protected _config: IORedisInstrumentationConfig = {}) {
super('@opentelemetry/instrumentation-ioredis', VERSION, _config);
constructor(_config: IORedisInstrumentationConfig = {}) {
super(
'@opentelemetry/instrumentation-ioredis',
VERSION,
Object.assign({}, DEFAULT_CONFIG, _config)
);
}

init(): InstrumentationNodeModuleDefinition<typeof ioredisTypes>[] {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,11 +93,9 @@ export const traceSendCommand = (
if (arguments.length < 1 || typeof cmd !== 'object') {
return original.apply(this, arguments);
}
// Do not trace if there is not parent span
if (
config?.requireParentSpan !== false &&
getSpan(context.active()) === undefined
) {

const hasNoParentSpan = getSpan(context.active()) === undefined;
if (config?.requireParentSpan === true && hasNoParentSpan) {
return original.apply(this, arguments);
}

Expand Down