Skip to content

Commit 014dc7f

Browse files
committed
small code style changes
1 parent 54168c8 commit 014dc7f

File tree

3 files changed

+9
-7
lines changed

3 files changed

+9
-7
lines changed

packages/node/src/integrations/tracing/redis.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,9 @@ let _redisOptions: RedisOptions = {};
2929
export const instrumentRedis = generateInstrumentOnce(INTEGRATION_NAME, () => {
3030
return new IORedisInstrumentation({
3131
responseHook: (span, redisCommand, cmdArgs, response) => {
32-
const safeKey = getCacheKeySafely(redisCommand, cmdArgs);
33-
3432
span.setAttribute(SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN, 'auto.db.otel.redis');
3533

34+
const safeKey = getCacheKeySafely(redisCommand, cmdArgs);
3635
const cacheOperation = getCacheOperation(redisCommand);
3736

3837
if (

packages/node/src/utils/redisCache.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,14 +56,17 @@ export function getCacheKeySafely(redisCommand: string, cmdArgs: IORedisCommandA
5656

5757
/** Determines whether a redis operation should be considered as "cache operation" by checking if a key is prefixed.
5858
* We only support certain commands (such as 'set', 'get', 'mget'). */
59-
export function shouldConsiderForCache(redisCommand: string, key: string[], prefixes: string[]): boolean {
59+
export function shouldConsiderForCache(redisCommand: string, keys: string[], prefixes: string[]): boolean {
6060
if (!getCacheOperation(redisCommand)) {
6161
return false;
6262
}
6363

64-
return key.reduce((prev, key) => {
65-
return prev || keyHasPrefix(key, prefixes);
66-
}, false);
64+
for (const key of keys) {
65+
if (keyHasPrefix(key, prefixes)) {
66+
return true;
67+
}
68+
}
69+
return false;
6770
}
6871

6972
/** Calculates size based on the cache response value */

packages/opentelemetry/src/utils/parseSpanDescription.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ export function parseSpanDescription(span: AbstractSpan): SpanDescription {
5151

5252
// If db.type exists then this is a database call span
5353
// If the Redis DB is used as a cache, the span description should not be changed
54-
if (dbSystem && (!attributes[SEMANTIC_ATTRIBUTE_SENTRY_OP] || !opIsCache)) {
54+
if (dbSystem && !opIsCache) {
5555
return descriptionForDbSystem({ attributes, name });
5656
}
5757

0 commit comments

Comments
 (0)