68 lines
2.1 KiB
TypeScript
68 lines
2.1 KiB
TypeScript
import { type EventType, type ErrorDetails } from './schema';
|
|
import type { ITelemetrySink } from './sink/sink-interface';
|
|
import type { Context } from '../../api/context';
|
|
import type { CliIoHost } from '../io-host/cli-io-host';
|
|
export interface TelemetrySessionProps {
|
|
readonly ioHost: CliIoHost;
|
|
readonly client: ITelemetrySink;
|
|
readonly arguments: any;
|
|
readonly context: Context;
|
|
}
|
|
export interface TelemetryEvent {
|
|
readonly eventType: EventType;
|
|
readonly duration: number;
|
|
readonly error?: ErrorDetails;
|
|
readonly counters?: Record<string, number>;
|
|
}
|
|
/**
|
|
* Timer of a single event
|
|
*/
|
|
export interface Timing {
|
|
/**
|
|
* Total time spent in this operation
|
|
*/
|
|
totalMs: number;
|
|
/**
|
|
* Count of operations that together took `totalMs`.
|
|
*/
|
|
count: number;
|
|
}
|
|
export declare class TelemetrySession {
|
|
private readonly props;
|
|
private ioHost;
|
|
private client;
|
|
private _sessionInfo?;
|
|
private span?;
|
|
private count;
|
|
constructor(props: TelemetrySessionProps);
|
|
begin(): Promise<void>;
|
|
attachRegion(region: string): Promise<void>;
|
|
/**
|
|
* Attach a language guess
|
|
*/
|
|
attachLanguage(language: string | undefined): void;
|
|
/**
|
|
* Attach our best guess at running under an agent or not
|
|
*/
|
|
attachAgent(isAgent: boolean | undefined): void;
|
|
/**
|
|
* Attach the CDK library version
|
|
*
|
|
* By default the telemetry will guess at the CDK library version if it so
|
|
* happens that the CDK project is an NPM project and the CDK CLI is executed
|
|
* in the root of NPM project with `aws-cdk-lib` available in `node_modules`.
|
|
* This may succeed or may fail.
|
|
*
|
|
* Once we have produced and loaded the cloud assembly more accurate
|
|
* information becomes available that we can add in.
|
|
*/
|
|
attachCdkLibVersion(libVersion: string): void;
|
|
/**
|
|
* When the command is complete, so is the CliIoHost. Ends the span of the entire CliIoHost
|
|
* and notifies with an optional error message in the data.
|
|
*/
|
|
end(error?: ErrorDetails): Promise<void>;
|
|
emit(event: TelemetryEvent): Promise<void>;
|
|
private get sessionInfo();
|
|
}
|