Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: RD-13785-Disable-redis-instrumentation #535

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
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
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ This setting is independent from `LUMIGO_DEBUG`, that is, `LUMIGO_DEBUG` does no
* `LUMIGO_SWITCH_OFF=TRUE`: This option disables the Lumigo OpenTelemetry Distro entirely; no instrumentation will be injected, no tracing data will be collected.
* `LUMIGO_AUTO_FILTER_EMPTY_SQS`: This option enables the automatic filtering of empty SQS messages from being sent to Lumigo SaaS. For more information, refer to the [Filtering out empty SQS messages](#filtering-out-empty-sqs-messages) section.
* `LUMIGO_DISABLE_PG_INSTRUMENTATION=true`: This option disables the automatic instrumentation of [postgres](https://www.npmjs.com/package/pg).
* `LUMIGO_DISABLE_REDIS_INSTRUMENTATION=true`: This option disables the automatic instrumentation of [redis](https://www.npmjs.com/package/redis).
* `LUMIGO_DISABLE_NEST_INSTRUMENTATION=true`: This option disables the automatic instrumentation of [@nestjs/core](https://www.npmjs.com/package/@nestjs/core).
* `LUMIGO_SECRET_MASKING_REGEX='["regex1", "regex2"]'`: Prevents Lumigo from sending keys that match the supplied regular expressions in process environment data, HTTP headers, payloads and queries. All regular expressions are case-insensitive. The "magic" value `all` will redact everything. By default, Lumigo applies the following regular expressions: `[".*pass.*", ".*key.*", ".*secret.*", ".*credential.*", ".*passphrase.*"]`. More fine-grained settings can be applied via the following environment variables, which will override `LUMIGO_SECRET_MASKING_REGEX` for a specific type of data:
* `LUMIGO_SECRET_MASKING_REGEX_HTTP_REQUEST_BODIES` applies secret redaction to HTTP request bodies
Expand Down
17 changes: 16 additions & 1 deletion src/instrumentations/redis/RedisInstrumentation.test.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,28 @@
import LumigoRedisInstrumentation from './RedisInstrumentation';
import child_process from 'child_process';

describe('LumigoRedisInstrumentation', () => {
const oldEnv = Object.assign({}, process.env);
beforeEach(() => {
process.env = { ...oldEnv };
});

afterEach(() => {
jest.clearAllMocks();
process.env = { ...oldEnv };
});

let lumigoRedisInstrumentation = new LumigoRedisInstrumentation();

test('getInstrumentedModule should return "redis"', () => {
test('disable redis instrumentation', () => {
const child_process = require('child_process');
child_process.execSync('npm install [email protected]', { stdio: 'inherit' });

process.env.LUMIGO_DISABLE_REDIS_INSTRUMENTATION = 'true';
expect(lumigoRedisInstrumentation.isApplicable()).toEqual(false);
});

test('getInstrumentedModule should return "redis and be applicable"', () => {
expect(lumigoRedisInstrumentation.getInstrumentedModule()).toEqual('redis');
});
});
7 changes: 7 additions & 0 deletions src/instrumentations/redis/RedisInstrumentation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,13 @@ import { getSpanAttributeMaxLength } from '../../utils';
import { TracingInstrumentor } from '../instrumentor';

export default class LumigoRedisInstrumentation extends TracingInstrumentor<RedisInstrumentation> {
override isApplicable(): boolean {
return (
super.isApplicable() &&
process.env.LUMIGO_DISABLE_REDIS_INSTRUMENTATION?.toLocaleLowerCase() !== 'true'
);
}

getInstrumentedModule(): string {
return 'redis';
}
Expand Down
Loading