createInstrumentation() function
Home > @rimitive/core > createInstrumentation
createInstrumentation() function
Section titled “createInstrumentation() function”Create an instrumentation context from configuration.
This is the main entry point for setting up instrumentation. Returns undefined if instrumentation is disabled, allowing safe optional chaining in production.
Type overloads provide precise return types: - enabled: false → always returns undefined - enabled: true with providers → always returns InstrumentationContext - Otherwise → InstrumentationContext | undefined
Signature:
export declare function createInstrumentation(config: InstrumentationConfig & { enabled: false;}): undefined;Parameters
Section titled “Parameters”|
Parameter |
Type |
Description |
|---|---|---|
|
config |
InstrumentationConfig & { enabled: false; } |
Returns:
undefined
Example 1
Section titled “Example 1”Basic usage
import { createInstrumentation, devtoolsProvider, compose } from '@rimitive/core';import { SignalModule, ComputedModule } from '@rimitive/signals/extend';
const instrumentation = createInstrumentation({ enabled: import.meta.env.DEV, providers: [devtoolsProvider()],});
// Use with composeconst svc = compose(SignalModule, ComputedModule, { instrumentation });Example 2
Section titled “Example 2”Production-safe pattern
// Returns undefined in production (enabled: false)const instrumentation = createInstrumentation({ enabled: false, providers: [],});
// Type is `undefined`, no runtime overheadExample 3
Section titled “Example 3”Multiple providers
const instrumentation = createInstrumentation({ providers: [ devtoolsProvider(), analyticsProvider(), loggingProvider({ verbose: true }), ],});