APM Setup
Set up Application Performance Monitoring to track response times, throughput, and performance metrics across your applications.
Overview
QODRYX APM provides real-time visibility into your application's performance. Track request latency, database queries, external API calls, and identify performance bottlenecks before they impact users.
Response Time
P50, P95, P99 latencies
Throughput
Requests per minute
Traces
Distributed tracing
Installation
Install the QODRYX APM agent for your runtime:
Node.js
npm install @qodryx/apmPython
pip install qodryx-apmConfiguration
Initialize the APM agent at the start of your application:
Node.js / Express
// Initialize APM at the very top of your entry file
const qodryx = require('@qodryx/apm');
qodryx.init({
apiKey: process.env.QODRYX_API_KEY,
serviceName: 'my-api',
environment: process.env.NODE_ENV,
// Optional configurations
sampleRate: 1.0, // 100% sampling
captureBody: true, // Capture request/response bodies
captureHeaders: true, // Capture HTTP headers
// Database instrumentation
instrumentations: {
postgres: true,
mongodb: true,
redis: true,
}
});
// Your application code
const express = require('express');
const app = express();
// APM automatically instruments Express routes
app.get('/api/users', async (req, res) => {
// This request will be traced automatically
const users = await db.query('SELECT * FROM users');
res.json(users);
});Next.js
// Next.js 13+ instrumentation file
export async function register() {
if (process.env.NEXT_RUNTIME === 'nodejs') {
const qodryx = await import('@qodryx/apm');
qodryx.init({
apiKey: process.env.QODRYX_API_KEY,
serviceName: 'my-nextjs-app',
environment: process.env.NODE_ENV,
});
}
}Custom Spans
Create custom spans to trace specific operations:
const qodryx = require('@qodryx/apm');
async function processOrder(orderId) {
// Create a custom span
return qodryx.startSpan('process-order', async (span) => {
span.setTag('order.id', orderId);
// Child span for payment processing
await qodryx.startSpan('payment-processing', async (paymentSpan) => {
const result = await chargeCard(orderId);
paymentSpan.setTag('payment.status', result.status);
return result;
});
// Child span for inventory update
await qodryx.startSpan('inventory-update', async () => {
await updateInventory(orderId);
});
span.setTag('order.status', 'completed');
});
}Custom Metrics
Track custom business metrics:
const qodryx = require('@qodryx/apm');
// Counter - track occurrences
qodryx.metrics.increment('orders.created', {
region: 'us-east',
plan: 'pro'
});
// Gauge - track current values
qodryx.metrics.gauge('queue.length', queueSize);
// Histogram - track distributions
qodryx.metrics.histogram('order.value', orderAmount, {
currency: 'USD'
});
// Timing - track durations
const timer = qodryx.metrics.startTimer('external_api.duration');
await callExternalAPI();
timer.end({ api: 'stripe' });Dashboard
View APM data in the QODRYX dashboard:
Visualize service dependencies
Search and analyze traces
Track metrics over time
Identify bottlenecks
Supported Frameworks
Automatic instrumentation for popular frameworks:
- Node.js: Express, Fastify, Koa, Hapi, Next.js, NestJS
- Python: Django, Flask, FastAPI, Starlette
- Databases: PostgreSQL, MySQL, MongoDB, Redis, Elasticsearch
- Message Queues: RabbitMQ, Kafka, SQS
- HTTP Clients: Axios, fetch, requests