{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":";AAAA;;;GAGG","sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport { InstrumentationConfig } from '@opentelemetry/instrumentation';\nimport { Span } from '@opentelemetry/api';\n\nexport type CommandArgs = Array<string | Buffer | number | any[]>;\n\n/**\n * Function that can be used to serialize db.statement tag\n * @param cmdName - The name of the command (eg. set, get, mset)\n * @param cmdArgs - Array of arguments passed to the command\n *\n * @returns serialized string that will be used as the db.statement attribute.\n */\nexport type DbStatementSerializer = (\n  cmdName: string,\n  cmdArgs: CommandArgs\n) => string;\n\nexport interface IORedisRequestHookInformation {\n  moduleVersion?: string;\n  cmdName: string;\n  cmdArgs: CommandArgs;\n}\n\nexport interface RedisRequestCustomAttributeFunction {\n  (span: Span, requestInfo: IORedisRequestHookInformation): void;\n}\n\n/**\n * Function that can be used to add custom attributes to span on response from redis server\n * @param span - The span created for the redis command, on which attributes can be set\n * @param cmdName - The name of the command (eg. set, get, mset)\n * @param cmdArgs - Array of arguments passed to the command\n * @param response - The response object which is returned to the user who called this command.\n *  Can be used to set custom attributes on the span.\n *  The type of the response varies depending on the specific command.\n */\nexport interface RedisResponseCustomAttributeFunction {\n  (span: Span, cmdName: string, cmdArgs: CommandArgs, response: unknown): void;\n}\n\n/**\n * Options available for the IORedis Instrumentation (see [documentation](https://github.com/open-telemetry/opentelemetry-js-contrib/blob/main/packages/instrumentation-ioredis/README.md#ioredis-instrumentation-options))\n */\nexport interface IORedisInstrumentationConfig extends InstrumentationConfig {\n  /** Custom serializer function for the db.statement tag */\n  dbStatementSerializer?: DbStatementSerializer;\n\n  /** Function for adding custom attributes on db request */\n  requestHook?: RedisRequestCustomAttributeFunction;\n\n  /** Function for adding custom attributes on db response */\n  responseHook?: RedisResponseCustomAttributeFunction;\n\n  /** Require parent to create ioredis span, default when unset is true */\n  requireParentSpan?: boolean;\n}\n"]}