@opentelemetry/instrumentation-aws-sdk
Version:
OpenTelemetry instrumentation for `aws-sdk` and `@aws-sdk/client-*` clients for various AWS services
79 lines • 3.45 kB
TypeScript
import { Span } from '@opentelemetry/api';
import { InstrumentationConfig } from '@opentelemetry/instrumentation';
export type CommandInput = Record<string, any>;
/**
* These are normalized request and response.
* They organize the relevant data in one interface which can be processed in a
* uniform manner in hooks
*/
export interface NormalizedRequest {
serviceName: string;
commandName: string;
commandInput: CommandInput;
region?: string;
}
export interface NormalizedResponse {
data: any;
request: NormalizedRequest;
requestId: string;
}
export interface AwsSdkRequestHookInformation {
moduleVersion?: string;
request: NormalizedRequest;
}
export interface AwsSdkRequestCustomAttributeFunction {
(span: Span, requestInfo: AwsSdkRequestHookInformation): void;
}
export interface AwsSdkResponseHookInformation {
moduleVersion?: string;
response: NormalizedResponse;
}
/**
* span can be used to add custom attributes, or for any other need.
* response is the object that is returned to the user calling the aws-sdk operation.
* The response type and attributes on the response are client-specific.
*/
export interface AwsSdkResponseCustomAttributeFunction {
(span: Span, responseInfo: AwsSdkResponseHookInformation): void;
}
/**
* span can be used to modify the status.
* As we have no response object, the request can be used to determine the failed aws-sdk operation.
*/
export interface AwsSdkExceptionCustomAttributeFunction {
(span: Span, requestInfo: AwsSdkRequestHookInformation, err: any): void;
}
export type AwsSdkDynamoDBStatementSerializer = (operation: string, commandInput: CommandInput) => string | undefined;
export interface AwsSdkInstrumentationConfig extends InstrumentationConfig {
/** hook for adding custom attributes before request is sent to aws */
preRequestHook?: AwsSdkRequestCustomAttributeFunction;
/** hook for adding custom attributes when response is received from aws */
responseHook?: AwsSdkResponseCustomAttributeFunction;
/**
* Hook for adding custom attributes when exception is received from aws.
* This hook is only available with aws sdk v3
*/
exceptionHook?: AwsSdkExceptionCustomAttributeFunction;
/** custom serializer function for the db.statement attribute in DynamoDB spans */
dynamoDBStatementSerializer?: AwsSdkDynamoDBStatementSerializer;
/**
* Most aws operation use http request under the hood.
* if http instrumentation is enabled, each aws operation will also create
* an http/s child describing the communication with amazon servers.
* Setting the `suppressInternalInstrumentation` config value to `true` will
* cause the instrumentation to suppress instrumentation of underlying operations,
* effectively causing those http spans to be non-recordable.
*/
suppressInternalInstrumentation?: boolean;
/**
* In some cases the context propagation headers may be found in the message payload
* rather than the message attribute.
* When this field is turned on the instrumentation will parse the payload and extract the
* context from there.
* Even if the field is on and MessageAttribute contains context propagation field are present,
* the MessageAttribute will get priority.
* By default it is off.
*/
sqsExtractContextPropagationFromPayload?: boolean;
}
//# sourceMappingURL=types.d.ts.map