Skip to content

Commit

Permalink
fix: import type and remove unneeded type
Browse files Browse the repository at this point in the history
Signed-off-by: Naseem <[email protected]>
  • Loading branch information
Naseem committed Sep 8, 2020
1 parent fb86c6f commit 54161a0
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 14 deletions.
2 changes: 1 addition & 1 deletion plugins/node/opentelemetry-plugin-ioredis/src/ioredis.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
*/

import { BasePlugin } from '@opentelemetry/core';
import * as ioredisTypes from 'ioredis';
import type * as ioredisTypes from 'ioredis';
import * as shimmer from 'shimmer';
import { IoredisPluginConfig } from './types';
import { traceConnection, traceSendCommand } from './utils';
Expand Down
7 changes: 1 addition & 6 deletions plugins/node/opentelemetry-plugin-ioredis/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/

import * as ioredisTypes from 'ioredis';
import type * as ioredisTypes from 'ioredis';
import { PluginConfig } from '@opentelemetry/api';

export interface IoredisCommand {
Expand All @@ -26,11 +26,6 @@ export interface IoredisCommand {
name: string;
}

export interface IoredisPluginClientTypes {
// https:/luin/ioredis/blob/master/API.md
options: ioredisTypes.RedisOptions;
}

/**
* Function that can be used to serialize db.statement tag
* @param cmdName - The name of the command (eg. set, get, mset)
Expand Down
10 changes: 3 additions & 7 deletions plugins/node/opentelemetry-plugin-ioredis/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,9 @@
* limitations under the License.
*/

import * as ioredisTypes from 'ioredis';
import type * as ioredisTypes from 'ioredis';
import { Tracer, SpanKind, Span, CanonicalCode } from '@opentelemetry/api';
import {
IoredisPluginClientTypes,
IoredisCommand,
IoredisPluginConfig,
DbStatementSerializer,
Expand All @@ -41,7 +40,7 @@ const endSpan = (span: Span, err: NodeJS.ErrnoException | null | undefined) => {
};

export const traceConnection = (tracer: Tracer, original: Function) => {
return function (this: ioredisTypes.Redis & IoredisPluginClientTypes) {
return function (this: ioredisTypes.Redis) {
const span = tracer.startSpan('connect', {
kind: SpanKind.CLIENT,
attributes: {
Expand Down Expand Up @@ -82,10 +81,7 @@ export const traceSendCommand = (
) => {
const dbStatementSerializer =
config?.dbStatementSerializer || defaultDbStatementSerializer;
return function (
this: ioredisTypes.Redis & IoredisPluginClientTypes,
cmd?: IoredisCommand
) {
return function (this: ioredisTypes.Redis, cmd?: IoredisCommand) {
if (arguments.length < 1 || typeof cmd !== 'object') {
return original.apply(this, arguments);
}
Expand Down

0 comments on commit 54161a0

Please sign in to comment.