Skip to content

Commit

Permalink
Fix other TypeScript errors
Browse files Browse the repository at this point in the history
  • Loading branch information
Stephen Belanger committed Jan 2, 2024
1 parent d9edad8 commit 721ddff
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 29 deletions.
58 changes: 30 additions & 28 deletions docs/test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { performance } from 'perf_hooks'
import ddTrace, { tracer, Tracer, TracerOptions, Span, SpanContext, SpanOptions, Scope, User } from '..';
import type { plugins } from '..';
import { opentelemetry } from '..';
import { formats, kinds, priority, tags, types } from '../ext';
import { BINARY, HTTP_HEADERS, LOG, TEXT_MAP } from '../ext/formats';
Expand Down Expand Up @@ -157,64 +158,64 @@ const httpOptions = {
middleware: true
};

const httpServerOptions = {
const httpServerOptions: plugins.HttpServer = {
...httpOptions,
hooks: {
request: (span: Span, req, res) => {}
request: (span?: Span, req?, res?) => {}
}
};

const httpClientOptions = {
const httpClientOptions: plugins.HttpClient = {
...httpOptions,
splitByDomain: true,
propagationBlocklist: ['url', /url/, url => true],
hooks: {
request: (span: Span, req, res) => {}
request: (span?: Span, req?, res?) => { }
}
};

const http2ServerOptions = {
const http2ServerOptions: plugins.Http2Server = {
...httpOptions
};

const http2ClientOptions = {
const http2ClientOptions: plugins.Http2Client = {
...httpOptions,
splitByDomain: true
};

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

const graphqlOptions = {
const graphqlOptions: plugins.graphql = {
service: 'test',
depth: 2,
source: true,
variables: ({ foo, baz }) => ({ foo }),
collapse: false,
signature: false,
hooks: {
execute: (span: Span, args, res) => {},
validate: (span: Span, document, errors) => {},
parse: (span: Span, source, document) => {}
execute: (span?: Span, args?, res?) => {},
validate: (span?: Span, document?, errors?) => {},
parse: (span?: Span, source?, document?) => {}
}
};

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

const awsSdkOptions = {
const awsSdkOptions: plugins.aws_sdk = {
service: 'test',
splitByAwsService: false,
hooks: {
request: (span: Span, response) => {},
request: (span?: Span, response?) => {},
},
s3: false,
sqs: {
Expand All @@ -223,33 +224,32 @@ const awsSdkOptions = {
}
};

const redisOptions = {
const redisOptions: plugins.redis = {
service: 'test',
allowlist: ['info', /auth/i, command => true],
blocklist: ['info', /auth/i, command => true],
};

const sharedbOptions = {
const sharedbOptions: plugins.sharedb = {
service: 'test',
hooks: {
receive: (span: Span, request) => {},
reply: (span: Span, request, reply) => {},
receive: (span?: Span, request?) => {},
reply: (span?: Span, request?, reply?) => {},
},
};

const moleculerOptions = {
const moleculerOptions: plugins.moleculer = {
service: 'test',
client: false,
params: true,
server: {
meta: true
}
};

const openSearchOptions = {
const openSearchOptions: plugins.opensearch = {
service: 'test',
hooks: {
query: (span: Span, params) => {},
query: (span?: Span, params?) => {},
},
};

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

span = tracer.startSpan('test');
span = tracer.startSpan('test', {});
span = tracer.startSpan('test', { childOf: span });
span = tracer.startSpan('test', {
childOf: span || span.context(),
childOf: span.context(),
references: [],
startTime: 123456789.1234,
tags: {
Expand All @@ -382,16 +383,17 @@ promise = tracer.wrap('test', () => Promise.resolve())()

const carrier = {}

tracer.inject(span || span.context(), HTTP_HEADERS, carrier);
context = tracer.extract(HTTP_HEADERS, carrier);
tracer.inject(span, HTTP_HEADERS, carrier);
tracer.inject(span.context(), HTTP_HEADERS, carrier);
context = tracer.extract(HTTP_HEADERS, carrier)!;

traceId = context.toTraceId();
spanId = context.toSpanId();
traceparent = context.toTraceparent();

const scope = tracer.scope()

span = scope.active();
span = scope.active()!;

const activateStringType: string = scope.activate(span, () => 'test');
const activateVoidType: void = scope.activate(span, () => {});
Expand Down
2 changes: 1 addition & 1 deletion index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -884,7 +884,7 @@ interface Analyzable {
measured?: boolean | { [key: string]: boolean };
}

declare namespace plugins {
export declare namespace plugins {
/** @hidden */
interface Integration {
/**
Expand Down

0 comments on commit 721ddff

Please sign in to comment.