Improve observability (#834)

* API generation

* Added correlation id support

* Updated docs

* Updated test

* Updated code generation

* API generation

* Updated code generation

* Added support for client name and custom context object

* Updated docs

* Updated test

* Fix docs

* Updated docs

* Added id support also for sniffing

* Updated test

* Update docs/observability.asciidoc

Co-Authored-By: delvedor <delvedor@users.noreply.github.com>

* Update docs/observability.asciidoc

Co-Authored-By: delvedor <delvedor@users.noreply.github.com>

* Apply suggestions

* Update docs/configuration.asciidoc

Co-Authored-By: delvedor <delvedor@users.noreply.github.com>

* Update docs/configuration.asciidoc

Co-Authored-By: delvedor <delvedor@users.noreply.github.com>

* Update docs/observability.asciidoc

Co-Authored-By: delvedor <delvedor@users.noreply.github.com>

* Update docs/observability.asciidoc

Co-Authored-By: delvedor <delvedor@users.noreply.github.com>

* Update docs/observability.asciidoc

Co-Authored-By: delvedor <delvedor@users.noreply.github.com>

* Apply suggestions

* Updated README.md

* Fixed test

* Addressed suggestions
This commit is contained in:
Tomas Della Vedova
2019-05-03 17:23:40 +02:00
committed by delvedor
parent 9dacd9d9ee
commit b1458e3511
279 changed files with 2436 additions and 142 deletions

28
lib/Transport.d.ts vendored
View File

@ -29,6 +29,10 @@ export interface nodeFilterFn {
(connection: Connection): boolean;
}
export interface generateRequestIdFn {
(params: TransportRequestParams, options: TransportRequestOptions): any;
}
declare type noopFn = (...args: any[]) => void;
declare type emitFn = (event: string | symbol, ...args: any[]) => boolean;
@ -47,17 +51,22 @@ interface TransportOptions {
nodeFilter?: nodeFilterFn;
nodeSelector?: string | nodeSelectorFn;
headers?: anyObject;
generateRequestId?: generateRequestIdFn;
name: string;
}
export interface RequestEvent<T = any> {
export interface RequestEvent<T = any, C = any> {
body: T;
statusCode: number | null;
headers: anyObject | null;
warnings: string[] | null;
meta: {
context: C;
name: string;
request: {
params: TransportRequestParams;
options: TransportRequestOptions;
id: any;
};
connection: Connection;
attempts: number;
@ -71,7 +80,7 @@ export interface RequestEvent<T = any> {
// ApiResponse and RequestEvent are the same thing
// we are doing this for have more clear names
export interface ApiResponse<T = any> extends RequestEvent<T> {}
export interface ApiResponse<T = any, C = any> extends RequestEvent<T, C> {}
declare type anyObject = {
[key: string]: any;
@ -93,6 +102,8 @@ export interface TransportRequestOptions {
headers?: anyObject;
querystring?: anyObject;
compression?: string;
id?: any;
context?: any;
warnings?: [string];
}
@ -100,6 +111,15 @@ export interface TransportRequestCallback {
abort: () => void;
}
export interface TransportGetConnectionOptions {
requestId: string;
}
export interface TransportSniffOptions {
reason: string;
requestId?: string;
}
export default class Transport {
static sniffReasons: {
SNIFF_ON_START: string;
@ -123,8 +143,8 @@ export default class Transport {
constructor(opts: TransportOptions);
request(params: TransportRequestParams, options?: TransportRequestOptions): Promise<ApiResponse>;
request(params: TransportRequestParams, options?: TransportRequestOptions, callback?: (err: Error | null, result: ApiResponse) => void): TransportRequestCallback;
getConnection(): Connection | null;
sniff(callback?: (...args: any[]) => void): void;
getConnection(opts: TransportGetConnectionOptions): Connection | null;
sniff(opts?: TransportSniffOptions, callback?: (...args: any[]) => void): void;
}
export {};