Skip to content

Commit

Permalink
Use Span rather than opentracing.Span in d.ts plugin hooks (#2982)
Browse files Browse the repository at this point in the history
  • Loading branch information
Stephen Belanger authored Apr 12, 2023
1 parent 2f0b0a7 commit f72976b
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 18 deletions.
34 changes: 24 additions & 10 deletions docs/test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ const httpOptions = {
const httpServerOptions = {
...httpOptions,
hooks: {
request: (span, req, res) => {}
request: (span: Span, req, res) => {}
}
};

Expand All @@ -142,7 +142,7 @@ const httpClientOptions = {
splitByDomain: true,
propagationBlocklist: ['url', /url/, url => true],
hooks: {
request: (span, req, res) => {}
request: (span: Span, req, res) => {}
}
};

Expand All @@ -155,6 +155,13 @@ const http2ClientOptions = {
splitByDomain: true
};

const nextOptions = {
service: 'test',
hooks: {
request: (span: Span, params) => { },
},
};

const graphqlOptions = {
service: 'test',
depth: 2,
Expand All @@ -163,24 +170,24 @@ const graphqlOptions = {
collapse: false,
signature: false,
hooks: {
execute: (span, args, res) => {},
validate: (span, document, errors) => {},
parse: (span, source, document) => {}
execute: (span: Span, args, res) => {},
validate: (span: Span, document, errors) => {},
parse: (span: Span, source, document) => {}
}
};

const elasticsearchOptions = {
service: 'test',
hooks: {
query: (span, params) => {},
query: (span: Span, params) => {},
},
};

const awsSdkOptions = {
service: 'test',
splitByAwsService: false,
hooks: {
request: (span, response) => {},
request: (span: Span, response) => {},
},
s3: false,
sqs: {
Expand All @@ -198,8 +205,8 @@ const redisOptions = {
const sharedbOptions = {
service: 'test',
hooks: {
receive: (span, request) => {},
reply: (span, request, reply) => {},
receive: (span: Span, request) => {},
reply: (span: Span, request, reply) => {},
},
};

Expand All @@ -215,12 +222,13 @@ const moleculerOptions = {
const openSearchOptions = {
service: 'test',
hooks: {
query: (span, params) => {},
query: (span: Span, params) => {},
},
};

tracer.use('amqp10');
tracer.use('amqplib');
tracer.use('aws-sdk');
tracer.use('aws-sdk', awsSdkOptions);
tracer.use('bunyan');
tracer.use('couchbase');
Expand All @@ -231,13 +239,15 @@ tracer.use('cypress');
tracer.use('cucumber')
tracer.use('cucumber', { service: 'cucumber-service' });
tracer.use('dns');
tracer.use('elasticsearch');
tracer.use('elasticsearch', elasticsearchOptions);
tracer.use('express');
tracer.use('express', httpServerOptions);
tracer.use('fastify');
tracer.use('fastify', httpServerOptions);
tracer.use('generic-pool');
tracer.use('google-cloud-pubsub');
tracer.use('graphql');
tracer.use('graphql', graphqlOptions);
tracer.use('graphql', { variables: ['foo', 'bar'] });
tracer.use('grpc');
Expand Down Expand Up @@ -272,6 +282,7 @@ tracer.use('koa');
tracer.use('koa', httpServerOptions);
tracer.use('mariadb', { service: () => `my-custom-mariadb` })
tracer.use('memcached');
tracer.use('microgateway-core');
tracer.use('microgateway-core', httpServerOptions);
tracer.use('mocha');
tracer.use('mocha', { service: 'mocha-service' });
Expand All @@ -284,6 +295,8 @@ tracer.use('mysql2');
tracer.use('mysql2', { service: () => `my-custom-mysql2` });
tracer.use('net');
tracer.use('next');
tracer.use('next', nextOptions);
tracer.use('opensearch');
tracer.use('opensearch', openSearchOptions);
tracer.use('oracledb');
tracer.use('oracledb', { service: params => `${params.host}-${params.database}` });
Expand All @@ -299,6 +312,7 @@ tracer.use('restify');
tracer.use('restify', httpServerOptions);
tracer.use('rhea');
tracer.use('router');
tracer.use('sharedb');
tracer.use('sharedb', sharedbOptions);
tracer.use('tedious');
tracer.use('winston');
Expand Down
16 changes: 8 additions & 8 deletions index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -871,7 +871,7 @@ declare namespace plugins {
/**
* Hook to execute just before the request span finishes.
*/
request?: (span?: opentracing.Span, req?: IncomingMessage, res?: ServerResponse) => any;
request?: (span?: Span, req?: IncomingMessage, res?: ServerResponse) => any;
};

/**
Expand Down Expand Up @@ -907,7 +907,7 @@ declare namespace plugins {
/**
* Hook to execute just before the request span finishes.
*/
request?: (span?: opentracing.Span, req?: ClientRequest, res?: IncomingMessage) => any;
request?: (span?: Span, req?: ClientRequest, res?: IncomingMessage) => any;
};

/**
Expand Down Expand Up @@ -997,7 +997,7 @@ declare namespace plugins {
/**
* Hook to execute just before the aws span finishes.
*/
request?: (span?: opentracing.Span, response?: anyObject) => any;
request?: (span?: Span, response?: anyObject) => any;
};

/**
Expand Down Expand Up @@ -1066,7 +1066,7 @@ declare namespace plugins {
/**
* Hook to execute just before the query span finishes.
*/
query?: (span?: opentracing.Span, params?: TransportRequestParams) => any;
query?: (span?: Span, params?: TransportRequestParams) => any;
};
}

Expand Down Expand Up @@ -1235,7 +1235,7 @@ declare namespace plugins {
* Hook to execute just before the request span finishes.
*/
request?: (
span?: opentracing.Span,
span?: Span,
req?: IncomingMessage | ClientRequest,
res?: ServerResponse | IncomingMessage
) => any;
Expand Down Expand Up @@ -1428,7 +1428,7 @@ declare namespace plugins {
/**
* Hook to execute just before the request span finishes.
*/
request?: (span?: opentracing.Span, req?: IncomingMessage, res?: ServerResponse) => any;
request?: (span?: Span, req?: IncomingMessage, res?: ServerResponse) => any;
};
}

Expand Down Expand Up @@ -1547,12 +1547,12 @@ declare namespace plugins {
/**
* Hook to execute just when the span is created.
*/
receive?: (span?: opentracing.Span, request?: any) => any;
receive?: (span?: Span, request?: any) => any;

/**
* Hook to execute just when the span is finished.
*/
reply?: (span?: opentracing.Span, request?: any, response?: any) => any;
reply?: (span?: Span, request?: any, response?: any) => any;
};
}

Expand Down

0 comments on commit f72976b

Please sign in to comment.