Express
- Install dependencies.
npm install iudex
- Create a file called
instrument.ts
or instrument.js
(can be in the same directory as your server). - Import and run
instrument
in instrument.ts
.
import { instrument } from 'iudex';
instrument({
serviceName: <your_service_name>,
iudexApiKey: <your_api_key>,
githubUrl: <your_github_url_here>,
});
- Add the require flag when running your server, e.g.
-r ./instrument.ts
- Example:
node -r ./instrument.js ./app.js
- Example:
bun run -r ./instrument.ts ./app.ts
Fastify
- Install dependencies.
npm install iudex
- Create a file called
instrument.ts
or instrument.js
(can be in the same directory as your server). - Import and run
instrument
in instrument.ts
.
import { instrument } from 'iudex';
instrument({
serviceName: <your_service_name>,
iudexApiKey: <your_api_key>,
githubUrl: <your_github_url_here>,
});
- In your Fastify file (likely
server.ts
), add iudexFastify.logger
to the Fastify config.
import { iudexFastify } from '../src/instrumentation/index';
const fastify = Fastify({
logger: {
...iudexFastify.logger,
level: 'info',
},
});
- Add the require flag when running your server, e.g.
-r ./instrument.ts
- Example:
node -r ./instrument.js ./server.js
- Example:
bun run -r ./instrument.ts ./server.ts
Lambda
- Install dependencies.
npm install iudex
- At the top of your lambda handler file, add instrumentation.
import { instrument, withTracing } from 'iudex';
instrument({
serviceName: <your_service_name>,
iudexApiKey: <your_api_key>,
githubUrl: <your_github_url_here>,
});
- Wrap all functions you want traced with
withTracing
.
export const handler = withTracing(() => {
...
});
Pino
- Install dependencies.
npm install iudex
- Find your where you instantiate your pino logger and add Iudex params.
import pino from 'pino';
import { iudexPino } from 'iudex';
const logger = pino(...iudexPino.args);
Pino config
If you have configured pino, use iudexPino.options
and iudexPino.destination
separately.
iudexPino.options
sets the mixin
propertyiudexPino.destination
sets the write
property
import pino from 'pino';
import { iudexPino } from 'iudex';
const logger = pino(iudexPino.options, iudexPino.destination);