@microsoft/teams.api
Version:
<p> <a href="https://www.npmjs.com/package/@microsoft/teams.api" target="_blank"> <img src="https://img.shields.io/npm/v/@microsoft/teams.api/latest" /> </a> <a href="https://www.npmjs.com/package/@microsoft/teams.api?activeTab=code" t
41 lines (38 loc) • 1.78 kB
text/typescript
import { Span } from '@opentelemetry/api';
import { AxiosResponse } from 'axios';
import { Middleware, MiddlewareContext, MiddlewareNext } from '@microsoft/teams.common';
import { ConversationActivityOperation } from '../diagnostics/constants.mjs';
type ApiOutboundTelemetryMetadata = {
readonly operation: ConversationActivityOperation;
readonly attributes: Record<string, string>;
readonly onResponse?: (span: Span, res: AxiosResponse) => void | Promise<void>;
};
/**
* @internal
* Creates SDK-private request metadata for API outbound telemetry.
*
* API client methods use this immediately before calling the shared
* `HttpClient` so outbound telemetry middleware can create the span and
* metrics without each method managing telemetry mechanics directly.
*/
declare function withApiOutboundTelemetry(metadata: ApiOutboundTelemetryMetadata, extensions?: Record<string, unknown>): Record<string, unknown>;
/**
* @internal
* Ensures Teams API outbound telemetry middleware is registered once.
*
* API client construction calls this after creating or receiving the common
* `HttpClient`; callers can inspect `client.middlewares` for dedupe.
*/
declare function ensureApiOutboundTelemetryMiddleware(client: {
readonly middlewares: readonly Middleware[];
use(middleware: Middleware): number;
}): void;
/**
* @internal
* Common HTTP middleware that owns Teams API outbound span lifecycle, metrics,
* exception recording, and optional response hooks.
*/
declare class ApiOutboundTelemetryMiddleware implements Middleware {
invoke<R = AxiosResponse, D = any>(context: MiddlewareContext<D>, next: MiddlewareNext<R>): Promise<R>;
}
export { ApiOutboundTelemetryMiddleware, ensureApiOutboundTelemetryMiddleware, withApiOutboundTelemetry };