@sentry/node 10.50.0 → 10.52.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/cjs/index.js +4 -4
- package/build/cjs/integrations/http.js +18 -145
- package/build/cjs/integrations/http.js.map +1 -1
- package/build/cjs/integrations/tracing/index.js +21 -22
- package/build/cjs/integrations/tracing/index.js.map +1 -1
- package/build/cjs/integrations/tracing/langgraph/instrumentation.js +70 -25
- package/build/cjs/integrations/tracing/langgraph/instrumentation.js.map +1 -1
- package/build/cjs/integrations/tracing/prisma.js +6 -2
- package/build/cjs/integrations/tracing/prisma.js.map +1 -1
- package/build/cjs/integrations/tracing/{redis.js → redis/index.js} +18 -10
- package/build/cjs/integrations/tracing/redis/index.js.map +1 -0
- package/build/cjs/integrations/tracing/redis/redis-dc-subscriber.js +186 -0
- package/build/cjs/integrations/tracing/redis/redis-dc-subscriber.js.map +1 -0
- package/build/cjs/integrations/tracing/redis/vendored/ioredis-instrumentation.js +255 -0
- package/build/cjs/integrations/tracing/redis/vendored/ioredis-instrumentation.js.map +1 -0
- package/build/cjs/integrations/tracing/redis/vendored/redis-common.js +74 -0
- package/build/cjs/integrations/tracing/redis/vendored/redis-common.js.map +1 -0
- package/build/cjs/integrations/tracing/redis/vendored/redis-instrumentation.js +685 -0
- package/build/cjs/integrations/tracing/redis/vendored/redis-instrumentation.js.map +1 -0
- package/build/cjs/integrations/tracing/redis/vendored/semconv.js +47 -0
- package/build/cjs/integrations/tracing/redis/vendored/semconv.js.map +1 -0
- package/build/cjs/utils/redisCache.js.map +1 -1
- package/build/esm/index.js +1 -1
- package/build/esm/integrations/http.js +21 -146
- package/build/esm/integrations/http.js.map +1 -1
- package/build/esm/integrations/tracing/index.js +2 -3
- package/build/esm/integrations/tracing/index.js.map +1 -1
- package/build/esm/integrations/tracing/langgraph/instrumentation.js +71 -26
- package/build/esm/integrations/tracing/langgraph/instrumentation.js.map +1 -1
- package/build/esm/integrations/tracing/prisma.js +6 -2
- package/build/esm/integrations/tracing/prisma.js.map +1 -1
- package/build/esm/integrations/tracing/{redis.js → redis/index.js} +17 -9
- package/build/esm/integrations/tracing/redis/index.js.map +1 -0
- package/build/esm/integrations/tracing/redis/redis-dc-subscriber.js +184 -0
- package/build/esm/integrations/tracing/redis/redis-dc-subscriber.js.map +1 -0
- package/build/esm/integrations/tracing/redis/vendored/ioredis-instrumentation.js +253 -0
- package/build/esm/integrations/tracing/redis/vendored/ioredis-instrumentation.js.map +1 -0
- package/build/esm/integrations/tracing/redis/vendored/redis-common.js +72 -0
- package/build/esm/integrations/tracing/redis/vendored/redis-common.js.map +1 -0
- package/build/esm/integrations/tracing/redis/vendored/redis-instrumentation.js +683 -0
- package/build/esm/integrations/tracing/redis/vendored/redis-instrumentation.js.map +1 -0
- package/build/esm/integrations/tracing/redis/vendored/semconv.js +39 -0
- package/build/esm/integrations/tracing/redis/vendored/semconv.js.map +1 -0
- package/build/esm/package.json +1 -1
- package/build/esm/utils/redisCache.js.map +1 -1
- package/build/types/integrations/http.d.ts +8 -15
- package/build/types/integrations/http.d.ts.map +1 -1
- package/build/types/integrations/tracing/index.d.ts.map +1 -1
- package/build/types/integrations/tracing/langgraph/instrumentation.d.ts +1 -1
- package/build/types/integrations/tracing/langgraph/instrumentation.d.ts.map +1 -1
- package/build/types/integrations/tracing/prisma.d.ts.map +1 -1
- package/build/types/integrations/tracing/{redis.d.ts → redis/index.d.ts} +3 -3
- package/build/types/integrations/tracing/redis/index.d.ts.map +1 -0
- package/build/types/integrations/tracing/redis/redis-dc-subscriber.d.ts +17 -0
- package/build/types/integrations/tracing/redis/redis-dc-subscriber.d.ts.map +1 -0
- package/build/types/integrations/tracing/redis/vendored/ioredis-instrumentation.d.ts +15 -0
- package/build/types/integrations/tracing/redis/vendored/ioredis-instrumentation.d.ts.map +1 -0
- package/build/types/integrations/tracing/redis/vendored/redis-common.d.ts +6 -0
- package/build/types/integrations/tracing/redis/vendored/redis-common.d.ts.map +1 -0
- package/build/types/integrations/tracing/redis/vendored/redis-instrumentation.d.ts +16 -0
- package/build/types/integrations/tracing/redis/vendored/redis-instrumentation.d.ts.map +1 -0
- package/build/types/integrations/tracing/redis/vendored/semconv.d.ts +8 -0
- package/build/types/integrations/tracing/redis/vendored/semconv.d.ts.map +1 -0
- package/build/types/integrations/tracing/redis/vendored/types.d.ts +58 -0
- package/build/types/integrations/tracing/redis/vendored/types.d.ts.map +1 -0
- package/build/types/utils/redisCache.d.ts +1 -1
- package/build/types/utils/redisCache.d.ts.map +1 -1
- package/build/types-ts3.8/integrations/http.d.ts +8 -15
- package/build/types-ts3.8/integrations/tracing/langgraph/instrumentation.d.ts +1 -1
- package/build/types-ts3.8/integrations/tracing/{redis.d.ts → redis/index.d.ts} +3 -3
- package/build/types-ts3.8/integrations/tracing/redis/redis-dc-subscriber.d.ts +17 -0
- package/build/types-ts3.8/integrations/tracing/redis/vendored/ioredis-instrumentation.d.ts +15 -0
- package/build/types-ts3.8/integrations/tracing/redis/vendored/redis-common.d.ts +6 -0
- package/build/types-ts3.8/integrations/tracing/redis/vendored/redis-instrumentation.d.ts +16 -0
- package/build/types-ts3.8/integrations/tracing/redis/vendored/semconv.d.ts +8 -0
- package/build/types-ts3.8/integrations/tracing/redis/vendored/types.d.ts +58 -0
- package/build/types-ts3.8/utils/redisCache.d.ts +1 -1
- package/package.json +4 -6
- package/build/cjs/integrations/tracing/redis.js.map +0 -1
- package/build/esm/integrations/tracing/redis.js.map +0 -1
- package/build/types/integrations/tracing/redis.d.ts.map +0 -1
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { InstrumentationBase, InstrumentationNodeModuleDefinition, SemconvStability } from '@opentelemetry/instrumentation';
|
|
2
|
+
import { IORedisInstrumentationConfig } from './types';
|
|
3
|
+
export declare class IORedisInstrumentation extends InstrumentationBase<IORedisInstrumentationConfig> {
|
|
4
|
+
_netSemconvStability: SemconvStability;
|
|
5
|
+
_dbSemconvStability: SemconvStability;
|
|
6
|
+
constructor(config?: IORedisInstrumentationConfig);
|
|
7
|
+
_setSemconvStabilityFromEnv(): void;
|
|
8
|
+
setConfig(config?: IORedisInstrumentationConfig): void;
|
|
9
|
+
init(): InstrumentationNodeModuleDefinition[];
|
|
10
|
+
private _patchSendCommand;
|
|
11
|
+
private _patchConnection;
|
|
12
|
+
private _traceSendCommand;
|
|
13
|
+
private _traceConnection;
|
|
14
|
+
}
|
|
15
|
+
//# sourceMappingURL=ioredis-instrumentation.d.ts.map
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Given the redis command name and arguments, return a combination of the
|
|
3
|
+
* command name + the allowed arguments according to `serializationSubsets`.
|
|
4
|
+
*/
|
|
5
|
+
export declare const defaultDbStatementSerializer: (cmdName: string, cmdArgs: Array<string | Buffer | number | any[]>) => string;
|
|
6
|
+
//# sourceMappingURL=redis-common.d.ts.map
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { TracerProvider } from '@opentelemetry/api';
|
|
2
|
+
import { InstrumentationBase } from '@opentelemetry/instrumentation';
|
|
3
|
+
import { RedisInstrumentationConfig } from './types';
|
|
4
|
+
export declare class RedisInstrumentation extends InstrumentationBase<RedisInstrumentationConfig> {
|
|
5
|
+
private instrumentationV2_V3;
|
|
6
|
+
private instrumentationV4_V5;
|
|
7
|
+
private initialized;
|
|
8
|
+
constructor(config?: RedisInstrumentationConfig);
|
|
9
|
+
setConfig(config?: RedisInstrumentationConfig): void;
|
|
10
|
+
init(): void;
|
|
11
|
+
getModuleDefinitions(): import("@opentelemetry/instrumentation").InstrumentationModuleDefinition[];
|
|
12
|
+
setTracerProvider(tracerProvider: TracerProvider): void;
|
|
13
|
+
enable(): void;
|
|
14
|
+
disable(): void;
|
|
15
|
+
}
|
|
16
|
+
//# sourceMappingURL=redis-instrumentation.d.ts.map
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export declare const ATTR_DB_CONNECTION_STRING = "db.connection_string";
|
|
2
|
+
export declare const ATTR_DB_STATEMENT = "db.statement";
|
|
3
|
+
export declare const ATTR_DB_SYSTEM = "db.system";
|
|
4
|
+
export declare const ATTR_NET_PEER_NAME = "net.peer.name";
|
|
5
|
+
export declare const ATTR_NET_PEER_PORT = "net.peer.port";
|
|
6
|
+
export declare const DB_SYSTEM_NAME_VALUE_REDIS = "redis";
|
|
7
|
+
export declare const DB_SYSTEM_VALUE_REDIS = "redis";
|
|
8
|
+
//# sourceMappingURL=semconv.d.ts.map
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { Span } from '@opentelemetry/api';
|
|
2
|
+
import { InstrumentationConfig, SemconvStability } from '@opentelemetry/instrumentation';
|
|
3
|
+
/**
|
|
4
|
+
* Function that can be used to serialize db.statement tag
|
|
5
|
+
* @param cmdName - The name of the command (eg. set, get, mset)
|
|
6
|
+
* @param cmdArgs - Array of arguments passed to the command
|
|
7
|
+
* @returns serialized string that will be used as the db.statement attribute.
|
|
8
|
+
*/
|
|
9
|
+
export type DbStatementSerializer = (cmdName: string, cmdArgs: Array<string | Buffer>) => string;
|
|
10
|
+
/**
|
|
11
|
+
* Function that can be used to add custom attributes to span on response from redis server
|
|
12
|
+
*/
|
|
13
|
+
export interface RedisResponseCustomAttributeFunction {
|
|
14
|
+
(span: Span, cmdName: string, cmdArgs: Array<string | Buffer>, response: unknown): void;
|
|
15
|
+
}
|
|
16
|
+
export interface RedisInstrumentationConfig extends InstrumentationConfig {
|
|
17
|
+
/** Custom serializer function for the db.statement tag */
|
|
18
|
+
dbStatementSerializer?: DbStatementSerializer;
|
|
19
|
+
/** Function for adding custom attributes on db response */
|
|
20
|
+
responseHook?: RedisResponseCustomAttributeFunction;
|
|
21
|
+
/** Require parent to create redis span, default when unset is false */
|
|
22
|
+
requireParentSpan?: boolean;
|
|
23
|
+
/**
|
|
24
|
+
* Controls which semantic-convention attributes are emitted on spans.
|
|
25
|
+
* Default: 'OLD'.
|
|
26
|
+
*/
|
|
27
|
+
semconvStability?: SemconvStability;
|
|
28
|
+
}
|
|
29
|
+
export type CommandArgs = Array<string | Buffer | number | any[]>;
|
|
30
|
+
/**
|
|
31
|
+
* Function that can be used to serialize db.statement tag for ioredis
|
|
32
|
+
*/
|
|
33
|
+
export type IORedisDbStatementSerializer = (cmdName: string, cmdArgs: CommandArgs) => string;
|
|
34
|
+
export interface IORedisRequestHookInformation {
|
|
35
|
+
moduleVersion?: string;
|
|
36
|
+
cmdName: string;
|
|
37
|
+
cmdArgs: CommandArgs;
|
|
38
|
+
}
|
|
39
|
+
export interface RedisRequestCustomAttributeFunction {
|
|
40
|
+
(span: Span, requestInfo: IORedisRequestHookInformation): void;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Function that can be used to add custom attributes to span on response from redis server (ioredis)
|
|
44
|
+
*/
|
|
45
|
+
export interface IORedisResponseCustomAttributeFunction {
|
|
46
|
+
(span: Span, cmdName: string, cmdArgs: CommandArgs, response: unknown): void;
|
|
47
|
+
}
|
|
48
|
+
export interface IORedisInstrumentationConfig extends InstrumentationConfig {
|
|
49
|
+
/** Custom serializer function for the db.statement tag */
|
|
50
|
+
dbStatementSerializer?: IORedisDbStatementSerializer;
|
|
51
|
+
/** Function for adding custom attributes on db request */
|
|
52
|
+
requestHook?: RedisRequestCustomAttributeFunction;
|
|
53
|
+
/** Function for adding custom attributes on db response */
|
|
54
|
+
responseHook?: IORedisResponseCustomAttributeFunction;
|
|
55
|
+
/** Require parent to create ioredis span, default when unset is true */
|
|
56
|
+
requireParentSpan?: boolean;
|
|
57
|
+
}
|
|
58
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
export type IORedisCommandArgs = Array<string | Buffer | number | unknown[]>;
|
|
2
2
|
export declare const GET_COMMANDS: string[];
|
|
3
3
|
export declare const SET_COMMANDS: string[];
|
|
4
4
|
/** Checks if a given command is in the list of redis commands.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sentry/node",
|
|
3
|
-
"version": "10.
|
|
3
|
+
"version": "10.52.0",
|
|
4
4
|
"description": "Sentry Node SDK using OpenTelemetry for performance instrumentation",
|
|
5
5
|
"repository": "git://github.com/getsentry/sentry-javascript.git",
|
|
6
6
|
"homepage": "https://github.com/getsentry/sentry-javascript/tree/master/packages/node",
|
|
@@ -76,7 +76,6 @@
|
|
|
76
76
|
"@opentelemetry/instrumentation-graphql": "0.62.0",
|
|
77
77
|
"@opentelemetry/instrumentation-hapi": "0.60.0",
|
|
78
78
|
"@opentelemetry/instrumentation-http": "0.214.0",
|
|
79
|
-
"@opentelemetry/instrumentation-ioredis": "0.62.0",
|
|
80
79
|
"@opentelemetry/instrumentation-kafkajs": "0.23.0",
|
|
81
80
|
"@opentelemetry/instrumentation-knex": "0.58.0",
|
|
82
81
|
"@opentelemetry/instrumentation-koa": "0.62.0",
|
|
@@ -86,15 +85,14 @@
|
|
|
86
85
|
"@opentelemetry/instrumentation-mysql": "0.60.0",
|
|
87
86
|
"@opentelemetry/instrumentation-mysql2": "0.60.0",
|
|
88
87
|
"@opentelemetry/instrumentation-pg": "0.66.0",
|
|
89
|
-
"@opentelemetry/instrumentation-redis": "0.62.0",
|
|
90
88
|
"@opentelemetry/instrumentation-tedious": "0.33.0",
|
|
91
89
|
"@opentelemetry/sdk-trace-base": "^2.6.1",
|
|
92
90
|
"@opentelemetry/semantic-conventions": "^1.40.0",
|
|
93
91
|
"@prisma/instrumentation": "7.6.0",
|
|
94
92
|
"@fastify/otel": "0.18.0",
|
|
95
|
-
"@sentry/core": "10.
|
|
96
|
-
"@sentry/node-core": "10.
|
|
97
|
-
"@sentry/opentelemetry": "10.
|
|
93
|
+
"@sentry/core": "10.52.0",
|
|
94
|
+
"@sentry/node-core": "10.52.0",
|
|
95
|
+
"@sentry/opentelemetry": "10.52.0",
|
|
98
96
|
"import-in-the-middle": "^3.0.0"
|
|
99
97
|
},
|
|
100
98
|
"devDependencies": {
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"redis.js","sources":["../../../../src/integrations/tracing/redis.ts"],"sourcesContent":["import type { Span } from '@opentelemetry/api';\nimport type { RedisResponseCustomAttributeFunction } from '@opentelemetry/instrumentation-ioredis';\nimport { IORedisInstrumentation } from '@opentelemetry/instrumentation-ioredis';\nimport { RedisInstrumentation } from '@opentelemetry/instrumentation-redis';\nimport type { IntegrationFn } from '@sentry/core';\nimport {\n defineIntegration,\n SEMANTIC_ATTRIBUTE_CACHE_HIT,\n SEMANTIC_ATTRIBUTE_CACHE_ITEM_SIZE,\n SEMANTIC_ATTRIBUTE_CACHE_KEY,\n SEMANTIC_ATTRIBUTE_SENTRY_OP,\n SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN,\n spanToJSON,\n truncate,\n} from '@sentry/core';\nimport { generateInstrumentOnce } from '@sentry/node-core';\nimport {\n calculateCacheItemSize,\n GET_COMMANDS,\n getCacheKeySafely,\n getCacheOperation,\n isInCommands,\n shouldConsiderForCache,\n} from '../../utils/redisCache';\n\ninterface RedisOptions {\n /**\n * Define cache prefixes for cache keys that should be captured as a cache span.\n *\n * Setting this to, for example, `['user:']` will capture cache keys that start with `user:`.\n */\n cachePrefixes?: string[];\n /**\n * Maximum length of the cache key added to the span description. If the key exceeds this length, it will be truncated.\n *\n * Passing `0` will use the full cache key without truncation.\n *\n * By default, the full cache key is used.\n */\n maxCacheKeyLength?: number;\n}\n\nconst INTEGRATION_NAME = 'Redis';\n\n/* Only exported for testing purposes */\nexport let _redisOptions: RedisOptions = {};\n\n/* Only exported for testing purposes */\nexport const cacheResponseHook: RedisResponseCustomAttributeFunction = (\n span: Span,\n redisCommand,\n cmdArgs,\n response,\n) => {\n span.setAttribute(SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN, 'auto.db.otel.redis');\n\n const safeKey = getCacheKeySafely(redisCommand, cmdArgs);\n const cacheOperation = getCacheOperation(redisCommand);\n\n if (\n !safeKey ||\n !cacheOperation ||\n !_redisOptions.cachePrefixes ||\n !shouldConsiderForCache(redisCommand, safeKey, _redisOptions.cachePrefixes)\n ) {\n // not relevant for cache\n return;\n }\n\n // otel/ioredis seems to be using the old standard, as there was a change to those params: https://github.com/open-telemetry/opentelemetry-specification/issues/3199\n // We are using params based on the docs: https://opentelemetry.io/docs/specs/semconv/attributes-registry/network/\n const networkPeerAddress = spanToJSON(span).data['net.peer.name'];\n const networkPeerPort = spanToJSON(span).data['net.peer.port'];\n if (networkPeerPort && networkPeerAddress) {\n span.setAttributes({ 'network.peer.address': networkPeerAddress, 'network.peer.port': networkPeerPort });\n }\n\n const cacheItemSize = calculateCacheItemSize(response);\n\n if (cacheItemSize) {\n span.setAttribute(SEMANTIC_ATTRIBUTE_CACHE_ITEM_SIZE, cacheItemSize);\n }\n\n if (isInCommands(GET_COMMANDS, redisCommand) && cacheItemSize !== undefined) {\n span.setAttribute(SEMANTIC_ATTRIBUTE_CACHE_HIT, cacheItemSize > 0);\n }\n\n span.setAttributes({\n [SEMANTIC_ATTRIBUTE_SENTRY_OP]: cacheOperation,\n [SEMANTIC_ATTRIBUTE_CACHE_KEY]: safeKey,\n });\n\n // todo: change to string[] once EAP supports it\n const spanDescription = safeKey.join(', ');\n\n span.updateName(\n _redisOptions.maxCacheKeyLength ? truncate(spanDescription, _redisOptions.maxCacheKeyLength) : spanDescription,\n );\n};\n\nconst instrumentIORedis = generateInstrumentOnce(`${INTEGRATION_NAME}.IORedis`, () => {\n return new IORedisInstrumentation({\n responseHook: cacheResponseHook,\n });\n});\n\nconst instrumentRedisModule = generateInstrumentOnce(`${INTEGRATION_NAME}.Redis`, () => {\n return new RedisInstrumentation({\n responseHook: cacheResponseHook,\n });\n});\n\n/** To be able to preload all Redis OTel instrumentations with just one ID (\"Redis\"), all the instrumentations are generated in this one function */\nexport const instrumentRedis = Object.assign(\n (): void => {\n instrumentIORedis();\n instrumentRedisModule();\n\n // todo: implement them gradually\n // new LegacyRedisInstrumentation({}),\n },\n { id: INTEGRATION_NAME },\n);\n\nconst _redisIntegration = ((options: RedisOptions = {}) => {\n return {\n name: INTEGRATION_NAME,\n setupOnce() {\n _redisOptions = options;\n instrumentRedis();\n },\n };\n}) satisfies IntegrationFn;\n\n/**\n * Adds Sentry tracing instrumentation for the [redis](https://www.npmjs.com/package/redis) and\n * [ioredis](https://www.npmjs.com/package/ioredis) libraries.\n *\n * For more information, see the [`redisIntegration` documentation](https://docs.sentry.io/platforms/javascript/guides/node/configuration/integrations/redis/).\n *\n * @example\n * ```javascript\n * const Sentry = require('@sentry/node');\n *\n * Sentry.init({\n * integrations: [Sentry.redisIntegration()],\n * });\n * ```\n */\nexport const redisIntegration = defineIntegration(_redisIntegration);\n"],"names":["_redisOptions","SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN","getCacheKeySafely","getCacheOperation","shouldConsiderForCache","spanToJSON","calculateCacheItemSize","SEMANTIC_ATTRIBUTE_CACHE_ITEM_SIZE","isInCommands","GET_COMMANDS","SEMANTIC_ATTRIBUTE_CACHE_HIT","SEMANTIC_ATTRIBUTE_SENTRY_OP","SEMANTIC_ATTRIBUTE_CACHE_KEY","truncate","generateInstrumentOnce","IORedisInstrumentation","RedisInstrumentation","defineIntegration"],"mappings":";;;;;;;;AA0CA,MAAM,gBAAA,GAAmB,OAAO;;AAEhC;AACWA,qBAAa,GAAiB;;AAEzC;AACO,MAAM,iBAAiB,GAAyC;AACvE,EAAE,IAAI;AACN,EAAE,YAAY;AACd,EAAE,OAAO;AACT,EAAE,QAAQ;AACV,KAAK;AACL,EAAE,IAAI,CAAC,YAAY,CAACC,qCAAgC,EAAE,oBAAoB,CAAC;;AAE3E,EAAE,MAAM,UAAUC,4BAAiB,CAAC,YAAY,EAAE,OAAO,CAAC;AAC1D,EAAE,MAAM,cAAA,GAAiBC,4BAAiB,CAAC,YAAY,CAAC;;AAExD,EAAE;AACF,IAAI,CAAC,OAAA;AACL,IAAI,CAAC,cAAA;AACL,IAAI,CAACH,qBAAa,CAAC,aAA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AAA,gBAAA,CAAA,QAAA,CAAA,EAAA,MAAA;AACA,EAAA,OAAA,IAAAC,6CAAA,CAAA;AACA,IAAA,YAAA,EAAA,iBAAA;AACA,GAAA,CAAA;AACA,CAAA,CAAA;;AAEA,MAAA,qBAAA,GAAAD,+BAAA,CAAA,CAAA,EAAA,gBAAA,CAAA,MAAA,CAAA,EAAA,MAAA;AACA,EAAA,OAAA,IAAAE,yCAAA,CAAA;AACA,IAAA,YAAA,EAAA,iBAAA;AACA,GAAA,CAAA;AACA,CAAA,CAAA;;AAEA;AACA,MAAA,eAAA,GAAA,MAAA,CAAA,MAAA;AACA,EAAA,MAAA;AACA,IAAA,iBAAA,EAAA;AACA,IAAA,qBAAA,EAAA;;AAEA;AACA;AACA,EAAA,CAAA;AACA,EAAA,EAAA,EAAA,EAAA,gBAAA,EAAA;AACA;;AAEA,MAAA,iBAAA,IAAA,CAAA,OAAA,GAAA,EAAA,KAAA;AACA,EAAA,OAAA;AACA,IAAA,IAAA,EAAA,gBAAA;AACA,IAAA,SAAA,GAAA;AACA,MAAAhB,qBAAA,GAAA,OAAA;AACA,MAAA,eAAA,EAAA;AACA,IAAA,CAAA;AACA,GAAA;AACA,CAAA,CAAA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAA,gBAAA,GAAAiB,sBAAA,CAAA,iBAAA;;;;;;"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"redis.js","sources":["../../../../src/integrations/tracing/redis.ts"],"sourcesContent":["import type { Span } from '@opentelemetry/api';\nimport type { RedisResponseCustomAttributeFunction } from '@opentelemetry/instrumentation-ioredis';\nimport { IORedisInstrumentation } from '@opentelemetry/instrumentation-ioredis';\nimport { RedisInstrumentation } from '@opentelemetry/instrumentation-redis';\nimport type { IntegrationFn } from '@sentry/core';\nimport {\n defineIntegration,\n SEMANTIC_ATTRIBUTE_CACHE_HIT,\n SEMANTIC_ATTRIBUTE_CACHE_ITEM_SIZE,\n SEMANTIC_ATTRIBUTE_CACHE_KEY,\n SEMANTIC_ATTRIBUTE_SENTRY_OP,\n SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN,\n spanToJSON,\n truncate,\n} from '@sentry/core';\nimport { generateInstrumentOnce } from '@sentry/node-core';\nimport {\n calculateCacheItemSize,\n GET_COMMANDS,\n getCacheKeySafely,\n getCacheOperation,\n isInCommands,\n shouldConsiderForCache,\n} from '../../utils/redisCache';\n\ninterface RedisOptions {\n /**\n * Define cache prefixes for cache keys that should be captured as a cache span.\n *\n * Setting this to, for example, `['user:']` will capture cache keys that start with `user:`.\n */\n cachePrefixes?: string[];\n /**\n * Maximum length of the cache key added to the span description. If the key exceeds this length, it will be truncated.\n *\n * Passing `0` will use the full cache key without truncation.\n *\n * By default, the full cache key is used.\n */\n maxCacheKeyLength?: number;\n}\n\nconst INTEGRATION_NAME = 'Redis';\n\n/* Only exported for testing purposes */\nexport let _redisOptions: RedisOptions = {};\n\n/* Only exported for testing purposes */\nexport const cacheResponseHook: RedisResponseCustomAttributeFunction = (\n span: Span,\n redisCommand,\n cmdArgs,\n response,\n) => {\n span.setAttribute(SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN, 'auto.db.otel.redis');\n\n const safeKey = getCacheKeySafely(redisCommand, cmdArgs);\n const cacheOperation = getCacheOperation(redisCommand);\n\n if (\n !safeKey ||\n !cacheOperation ||\n !_redisOptions.cachePrefixes ||\n !shouldConsiderForCache(redisCommand, safeKey, _redisOptions.cachePrefixes)\n ) {\n // not relevant for cache\n return;\n }\n\n // otel/ioredis seems to be using the old standard, as there was a change to those params: https://github.com/open-telemetry/opentelemetry-specification/issues/3199\n // We are using params based on the docs: https://opentelemetry.io/docs/specs/semconv/attributes-registry/network/\n const networkPeerAddress = spanToJSON(span).data['net.peer.name'];\n const networkPeerPort = spanToJSON(span).data['net.peer.port'];\n if (networkPeerPort && networkPeerAddress) {\n span.setAttributes({ 'network.peer.address': networkPeerAddress, 'network.peer.port': networkPeerPort });\n }\n\n const cacheItemSize = calculateCacheItemSize(response);\n\n if (cacheItemSize) {\n span.setAttribute(SEMANTIC_ATTRIBUTE_CACHE_ITEM_SIZE, cacheItemSize);\n }\n\n if (isInCommands(GET_COMMANDS, redisCommand) && cacheItemSize !== undefined) {\n span.setAttribute(SEMANTIC_ATTRIBUTE_CACHE_HIT, cacheItemSize > 0);\n }\n\n span.setAttributes({\n [SEMANTIC_ATTRIBUTE_SENTRY_OP]: cacheOperation,\n [SEMANTIC_ATTRIBUTE_CACHE_KEY]: safeKey,\n });\n\n // todo: change to string[] once EAP supports it\n const spanDescription = safeKey.join(', ');\n\n span.updateName(\n _redisOptions.maxCacheKeyLength ? truncate(spanDescription, _redisOptions.maxCacheKeyLength) : spanDescription,\n );\n};\n\nconst instrumentIORedis = generateInstrumentOnce(`${INTEGRATION_NAME}.IORedis`, () => {\n return new IORedisInstrumentation({\n responseHook: cacheResponseHook,\n });\n});\n\nconst instrumentRedisModule = generateInstrumentOnce(`${INTEGRATION_NAME}.Redis`, () => {\n return new RedisInstrumentation({\n responseHook: cacheResponseHook,\n });\n});\n\n/** To be able to preload all Redis OTel instrumentations with just one ID (\"Redis\"), all the instrumentations are generated in this one function */\nexport const instrumentRedis = Object.assign(\n (): void => {\n instrumentIORedis();\n instrumentRedisModule();\n\n // todo: implement them gradually\n // new LegacyRedisInstrumentation({}),\n },\n { id: INTEGRATION_NAME },\n);\n\nconst _redisIntegration = ((options: RedisOptions = {}) => {\n return {\n name: INTEGRATION_NAME,\n setupOnce() {\n _redisOptions = options;\n instrumentRedis();\n },\n };\n}) satisfies IntegrationFn;\n\n/**\n * Adds Sentry tracing instrumentation for the [redis](https://www.npmjs.com/package/redis) and\n * [ioredis](https://www.npmjs.com/package/ioredis) libraries.\n *\n * For more information, see the [`redisIntegration` documentation](https://docs.sentry.io/platforms/javascript/guides/node/configuration/integrations/redis/).\n *\n * @example\n * ```javascript\n * const Sentry = require('@sentry/node');\n *\n * Sentry.init({\n * integrations: [Sentry.redisIntegration()],\n * });\n * ```\n */\nexport const redisIntegration = defineIntegration(_redisIntegration);\n"],"names":[],"mappings":";;;;;;AA0CA,MAAM,gBAAA,GAAmB,OAAO;;AAEhC;AACO,IAAI,aAAa,GAAiB;;AAEzC;AACO,MAAM,iBAAiB,GAAyC;AACvE,EAAE,IAAI;AACN,EAAE,YAAY;AACd,EAAE,OAAO;AACT,EAAE,QAAQ;AACV,KAAK;AACL,EAAE,IAAI,CAAC,YAAY,CAAC,gCAAgC,EAAE,oBAAoB,CAAC;;AAE3E,EAAE,MAAM,UAAU,iBAAiB,CAAC,YAAY,EAAE,OAAO,CAAC;AAC1D,EAAE,MAAM,cAAA,GAAiB,iBAAiB,CAAC,YAAY,CAAC;;AAExD,EAAE;AACF,IAAI,CAAC,OAAA;AACL,IAAI,CAAC,cAAA;AACL,IAAI,CAAC,aAAa,CAAC,aAAA;AACnB,IAAI,CAAC,sBAAsB,CAAC,YAAY,EAAE,OAAO,EAAE,aAAa,CAAC,aAAa;AAC9E,IAAI;AACJ;AACA,IAAI;AACJ,EAAE;;AAEF;AACA;AACA,EAAE,MAAM,kBAAA,GAAqB,UAAU,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,eAAe,CAAC;AACnE,EAAE,MAAM,eAAA,GAAkB,UAAU,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,eAAe,CAAC;AAChE,EAAE,IAAI,eAAA,IAAmB,kBAAkB,EAAE;AAC7C,IAAI,IAAI,CAAC,aAAa,CAAC,EAAE,sBAAsB,EAAE,kBAAkB,EAAE,mBAAmB,EAAE,eAAA,EAAiB,CAAC;AAC5G,EAAE;;AAEF,EAAE,MAAM,aAAA,GAAgB,sBAAsB,CAAC,QAAQ,CAAC;;AAExD,EAAE,IAAI,aAAa,EAAE;AACrB,IAAI,IAAI,CAAC,YAAY,CAAC,kCAAkC,EAAE,aAAa,CAAC;AACxE,EAAE;;AAEF,EAAE,IAAI,YAAY,CA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MAAA,eAAA,EAAA;AACA,IAAA,CAAA;AACA,GAAA;AACA,CAAA,CAAA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAA,gBAAA,GAAA,iBAAA,CAAA,iBAAA;;;;"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"redis.d.ts","sourceRoot":"","sources":["../../../../src/integrations/tracing/redis.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,oCAAoC,EAAE,MAAM,wCAAwC,CAAC;AAwBnG,UAAU,YAAY;IACpB;;;;OAIG;IACH,aAAa,CAAC,EAAE,MAAM,EAAE,CAAC;IACzB;;;;;;OAMG;IACH,iBAAiB,CAAC,EAAE,MAAM,CAAC;CAC5B;AAKD,eAAO,IAAI,aAAa,EAAE,YAAiB,CAAC;AAG5C,eAAO,MAAM,iBAAiB,EAAE,oCAkD/B,CAAC;AAcF,qJAAqJ;AACrJ,eAAO,MAAM,eAAe,SACtB,IAAI;;CAQT,CAAC;AAYF;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,gBAAgB,4EAAuC,CAAC"}
|