UNPKG

observ-metrics

Version:

Frontend monitoring library that eliminates noise and adds business context to OpenTelemetry data

55 lines 2.08 kB
/** * Domain-driven instrumentation that adds business context to telemetry * Organizes monitoring by business domains rather than technical components */ import type { DomainConfig, UserContext, ApiCallContext, InstrumentationResult, DomainInstrumentor as IDomainInstrumentor, TelemetryEvent } from '../types'; export declare class DomainInstrumentor implements IDomainInstrumentor { private domain; private userContext; private onEvent?; private tracer; private meter; private domainMetrics; constructor(domain: DomainConfig, userContext: UserContext, onEvent?: ((event: TelemetryEvent) => void) | undefined); private initializeMetrics; /** * Instrument API calls with business context */ instrumentApiCall(name: string, endpoint: string, method?: string, context?: ApiCallContext): Promise<InstrumentationResult>; /** * Instrument user journey steps with conversion tracking */ instrumentUserJourney(journeyName: string, stepName: string, operation: () => Promise<any>): Promise<InstrumentationResult>; /** * Record business-specific metrics */ recordBusinessMetric(metricName: string, value: number, context?: Record<string, any>): void; /** * Track errors with business context */ trackError(error: Error, context?: Record<string, any>): void; private executeApiCall; private createBusinessContext; private getApiBusinessImpact; private getJourneyBusinessImpact; private getMetricBusinessImpact; private getSlaViolationSeverity; private getStepNumber; private emitTelemetryEvent; /** * Get domain-specific statistics */ getStats(): { domain: string; priority: "critical" | "high" | "medium" | "low"; slaTarget: number; errorThreshold: number; features: string[]; userContext: { segment: string; authenticated: boolean; deviceType: "mobile" | "tablet" | "desktop"; }; }; } //# sourceMappingURL=DomainInstrumentor.d.ts.map