InstrumentationProvider type
Home > @rimitive/core > InstrumentationProvider
InstrumentationProvider type
Section titled “InstrumentationProvider type”An instrumentation provider that receives and processes events.
Providers are the output targets for instrumentation data. Examples: DevTools, logging, analytics, performance monitoring.
Signature:
export type InstrumentationProvider = { name: string; init(contextId: string, contextName: string): void; emit(event: InstrumentationEvent): void; register<T>(resource: T, type: string, name?: string): { id: string; resource: T; }; dispose?(): void;};References: InstrumentationEvent
Example
Section titled “Example”Custom logging provider
const loggingProvider: InstrumentationProvider = { name: 'console-logger',
init(contextId, contextName) { console.log(`[${contextName}] Instrumentation started`); },
emit(event) { console.log(`[${event.type}]`, event.data); },
register(resource, type, name) { const id = crypto.randomUUID(); console.log(`Registered ${type}: ${name ?? id}`); return { id, resource }; },
dispose() { console.log('Instrumentation stopped'); },};