@avanor/sdk-express
v0.1.2
Published
Avanor SDK — Express/Fastify auto-instrumentation
Maintainers
Readme
@avanor/sdk-express
Avanor SDK — Express/Fastify auto-instrumentation.
Drop-in middleware/plugin for Express (4 or 5) and Fastify (4 or 5). Captures
every request as an http.request span and forwards via @avanor/sdk.
Install
npm install @avanor/sdk @avanor/sdk-expressAdd express or fastify to your dependencies if they aren't already.
Express quickstart
import express from 'express';
import { Avanor } from '@avanor/sdk';
import { expressMiddleware } from '@avanor/sdk-express';
Avanor.init({
apiKey: process.env.AVANOR_API_KEY!,
environment: process.env.NODE_ENV ?? 'dev',
service: 'broker-portal',
});
const app = express();
app.use(expressMiddleware());Fastify quickstart
import Fastify from 'fastify';
import { Avanor } from '@avanor/sdk';
import { fastifyPlugin } from '@avanor/sdk-express';
Avanor.init({
apiKey: process.env.AVANOR_API_KEY!,
environment: process.env.NODE_ENV ?? 'dev',
service: 'broker-portal',
});
const fastify = Fastify();
await fastify.register(fastifyPlugin);Attributes captured per request
http.methodhttp.target(URL minus query string)http.status_codehttp.user_agent(truncated to 128 chars)
No-op safety
If Avanor.init(...) has not been called the middleware is a no-op and logs
once per process. If neither express nor fastify is installed at runtime,
the adapter still loads without throwing.
Docs
https://docs.avanor.ai/sdk/recipes/express-openai
License
Avanor Source License v1 (BSL-modeled, 4-year Apache 2.0 sunset) — see LICENSE.
