Skip to content

Commit 0547232

Browse files
author
Stephen Belanger
committed
Fix other TypeScript errors
1 parent 48f58f6 commit 0547232

File tree

2 files changed

+35
-31
lines changed

2 files changed

+35
-31
lines changed

docs/test.ts

+30-28
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { performance } from 'perf_hooks'
22
import ddTrace, { tracer, Tracer, TracerOptions, Span, SpanContext, SpanOptions, Scope, User } from '..';
3+
import type { plugins } from '..';
34
import { opentelemetry } from '..';
45
import { formats, kinds, priority, tags, types } from '../ext';
56
import { BINARY, HTTP_HEADERS, LOG, TEXT_MAP } from '../ext/formats';
@@ -157,64 +158,64 @@ const httpOptions = {
157158
middleware: true
158159
};
159160

160-
const httpServerOptions = {
161+
const httpServerOptions: plugins.HttpServer = {
161162
...httpOptions,
162163
hooks: {
163-
request: (span: Span, req, res) => {}
164+
request: (span?: Span, req?, res?) => {}
164165
}
165166
};
166167

167-
const httpClientOptions = {
168+
const httpClientOptions: plugins.HttpClient = {
168169
...httpOptions,
169170
splitByDomain: true,
170171
propagationBlocklist: ['url', /url/, url => true],
171172
hooks: {
172-
request: (span: Span, req, res) => {}
173+
request: (span?: Span, req?, res?) => { }
173174
}
174175
};
175176

176-
const http2ServerOptions = {
177+
const http2ServerOptions: plugins.Http2Server = {
177178
...httpOptions
178179
};
179180

180-
const http2ClientOptions = {
181+
const http2ClientOptions: plugins.Http2Client = {
181182
...httpOptions,
182183
splitByDomain: true
183184
};
184185

185-
const nextOptions = {
186+
const nextOptions: plugins.next = {
186187
service: 'test',
187188
hooks: {
188-
request: (span: Span, params) => { },
189+
request: (span?: Span, params?) => { },
189190
},
190191
};
191192

192-
const graphqlOptions = {
193+
const graphqlOptions: plugins.graphql = {
193194
service: 'test',
194195
depth: 2,
195196
source: true,
196197
variables: ({ foo, baz }) => ({ foo }),
197198
collapse: false,
198199
signature: false,
199200
hooks: {
200-
execute: (span: Span, args, res) => {},
201-
validate: (span: Span, document, errors) => {},
202-
parse: (span: Span, source, document) => {}
201+
execute: (span?: Span, args?, res?) => {},
202+
validate: (span?: Span, document?, errors?) => {},
203+
parse: (span?: Span, source?, document?) => {}
203204
}
204205
};
205206

206-
const elasticsearchOptions = {
207+
const elasticsearchOptions: plugins.elasticsearch = {
207208
service: 'test',
208209
hooks: {
209-
query: (span: Span, params) => {},
210+
query: (span?: Span, params?) => {},
210211
},
211212
};
212213

213-
const awsSdkOptions = {
214+
const awsSdkOptions: plugins.aws_sdk = {
214215
service: 'test',
215216
splitByAwsService: false,
216217
hooks: {
217-
request: (span: Span, response) => {},
218+
request: (span?: Span, response?) => {},
218219
},
219220
s3: false,
220221
sqs: {
@@ -223,33 +224,32 @@ const awsSdkOptions = {
223224
}
224225
};
225226

226-
const redisOptions = {
227+
const redisOptions: plugins.redis = {
227228
service: 'test',
228229
allowlist: ['info', /auth/i, command => true],
229230
blocklist: ['info', /auth/i, command => true],
230231
};
231232

232-
const sharedbOptions = {
233+
const sharedbOptions: plugins.sharedb = {
233234
service: 'test',
234235
hooks: {
235-
receive: (span: Span, request) => {},
236-
reply: (span: Span, request, reply) => {},
236+
receive: (span?: Span, request?) => {},
237+
reply: (span?: Span, request?, reply?) => {},
237238
},
238239
};
239240

240-
const moleculerOptions = {
241+
const moleculerOptions: plugins.moleculer = {
241242
service: 'test',
242243
client: false,
243-
params: true,
244244
server: {
245245
meta: true
246246
}
247247
};
248248

249-
const openSearchOptions = {
249+
const openSearchOptions: plugins.opensearch = {
250250
service: 'test',
251251
hooks: {
252-
query: (span: Span, params) => {},
252+
query: (span?: Span, params?) => {},
253253
},
254254
};
255255

@@ -356,8 +356,9 @@ tracer.use('express', { measured: true });
356356

357357
span = tracer.startSpan('test');
358358
span = tracer.startSpan('test', {});
359+
span = tracer.startSpan('test', { childOf: span });
359360
span = tracer.startSpan('test', {
360-
childOf: span || span.context(),
361+
childOf: span.context(),
361362
references: [],
362363
startTime: 123456789.1234,
363364
tags: {
@@ -382,16 +383,17 @@ promise = tracer.wrap('test', () => Promise.resolve())()
382383

383384
const carrier = {}
384385

385-
tracer.inject(span || span.context(), HTTP_HEADERS, carrier);
386-
context = tracer.extract(HTTP_HEADERS, carrier);
386+
tracer.inject(span, HTTP_HEADERS, carrier);
387+
tracer.inject(span.context(), HTTP_HEADERS, carrier);
388+
context = tracer.extract(HTTP_HEADERS, carrier)!;
387389

388390
traceId = context.toTraceId();
389391
spanId = context.toSpanId();
390392
traceparent = context.toTraceparent();
391393

392394
const scope = tracer.scope()
393395

394-
span = scope.active();
396+
span = scope.active()!;
395397

396398
const activateStringType: string = scope.activate(span, () => 'test');
397399
const activateVoidType: void = scope.activate(span, () => {});

index.d.ts

+5-3
Original file line numberDiff line numberDiff line change
@@ -884,7 +884,7 @@ interface Analyzable {
884884
measured?: boolean | { [key: string]: boolean };
885885
}
886886

887-
declare namespace plugins {
887+
export declare namespace plugins {
888888
/** @hidden */
889889
interface Integration {
890890
/**
@@ -1381,7 +1381,8 @@ declare namespace plugins {
13811381
*/
13821382
interface ioredis extends Instrumentation {
13831383
/**
1384-
* List of commands that should be instrumented.
1384+
* List of commands that should be instrumented. Commands must be in
1385+
* lowercase for example 'xread'.
13851386
*
13861387
* @default /^.*$/
13871388
*/
@@ -1397,7 +1398,8 @@ declare namespace plugins {
13971398

13981399
/**
13991400
* List of commands that should not be instrumented. Takes precedence over
1400-
* allowlist if a command matches an entry in both.
1401+
* allowlist if a command matches an entry in both. Commands must be in
1402+
* lowercase for example 'xread'.
14011403
*
14021404
* @default []
14031405
*/

0 commit comments

Comments
 (0)