Vitest
autotel-vitest gives each Vitest test a parent span, so all instrumented calls become child spans filterable by test.
Installation
Section titled “Installation”npm install autotel autotel-vitestnpm install --save-dev vitest1. globalSetup
Section titled “1. globalSetup”import { init } from 'autotel';
export default function globalSetup() { init({ service: 'unit-tests' });}2. Vitest Config
Section titled “2. Vitest Config”import { defineConfig } from 'vitest/config';
export default defineConfig({ test: { globalSetup: './globalSetup.ts', },});3. Use the Fixture
Section titled “3. Use the Fixture”import { test, expect } from 'autotel-vitest';
test('creates user', async () => { await userService.createUser({ email: 'test@example.com' });});The fixture is auto: true, so every test gets a parent span automatically.
What You Get
Section titled “What You Get”- One span per test with attributes:
test.name,test.file,test.suite - All
autotelcalls during the test become child spans - Test spans and server spans appear as one trace in your OTLP backend
Reporter
Section titled “Reporter”Add the optional reporter for runner-level test/suite spans:
import { defineConfig } from 'vitest/config';
export default defineConfig({ test: { globalSetup: './globalSetup.ts', reporters: [['autotel-vitest/reporter', {}]], },});Examples
Section titled “Examples”example-vitest— Vitest with per-test spans, runner reporter, and HTTP trace-context propagation to a self-contained server.
Testing Utilities
Section titled “Testing Utilities”Re-exported from autotel/testing:
import { createTraceCollector, assertTraceCreated, assertTraceSucceeded,} from 'autotel-vitest';