intentkit-otel
v1.0.0
Published
OpenTelemetry middleware for IntentKit — export telemetry to DataDog, Grafana, New Relic
Downloads
105
Maintainers
Readme
intentkit-otel
OpenTelemetry middleware for IntentKit. Exports function call telemetry as OTLP spans to any compatible backend (DataDog, Grafana Cloud, New Relic, Jaeger, etc.).
Install
npm install intentkit-otelUsage
import { IntentRegistry, serve } from 'intentkit';
import { createOtelMiddleware } from 'intentkit-otel';
const { middleware, shutdown } = createOtelMiddleware({
endpoint: 'http://localhost:4318/v1/traces',
serviceName: 'my-agent-service',
});
const registry = new IntentRegistry()
.use(middleware)
.register(/* your functions */);
await serve({ registry, context });
// On process exit:
process.on('SIGTERM', async () => {
await shutdown();
process.exit(0);
});Span Attributes
Every function call produces a span with:
| Attribute | Description |
|---|---|
| intentkit.function.name | Function name (e.g., create_task) |
| intentkit.caller.role | Caller's role (e.g., admin) |
| intentkit.caller.capabilities | Comma-separated capabilities |
| intentkit.request.id | Unique request UUID |
| intentkit.status | success or error |
| intentkit.duration_ms | Execution time in milliseconds |
| intentkit.events.count | Number of events emitted |
| intentkit.events.names | Comma-separated event names |
Backend Configuration
DataDog
createOtelMiddleware({
endpoint: 'https://trace.agent.datadoghq.com/v1/traces',
serviceName: 'my-service',
headers: { 'DD-API-KEY': process.env.DD_API_KEY! },
});Grafana Cloud
createOtelMiddleware({
endpoint: 'https://otlp-gateway-prod-us-central-0.grafana.net/otlp/v1/traces',
serviceName: 'my-service',
headers: { Authorization: `Basic ${btoa(`${instanceId}:${apiKey}`)}` },
});New Relic
createOtelMiddleware({
endpoint: 'https://otlp.nr-data.net/v1/traces',
serviceName: 'my-service',
headers: { 'api-key': process.env.NEW_RELIC_LICENSE_KEY! },
});Local (Jaeger)
createOtelMiddleware({
endpoint: 'http://localhost:4318/v1/traces',
serviceName: 'my-service',
});License
MIT
