C
CanxJS
v1.6.2
  • Learn
  • Blog
  • Showcase
C
CanxJS

Ultra-fast async MVC backend framework for Bun. Build production-ready APIs with elegance and speed.

Resources

  • Documentation
  • Learn
  • Blog
  • Showcase

Documentation

  • Introduction
  • Installation
  • Core Concepts
  • CLI Commands
  • API Reference

Legal

  • Privacy Policy
  • Terms of Service

© 2026 CanxJS. All rights reserved.

Built with ❤️ for Candra Kirana

  • Cluster Mode
  • Microservices
  • Observability
  • Security Layers
  • Universal Signals
  • Canx Flow
  • Maintenance
Enterprise

Observability

Gain deep insights into your application performance with Prometheus metrics and OpenTelemetry distributed tracing. Compatible with Jaeger, Zipkin, and Datadog.

Prometheus Metrics

Automatic HTTP, CPU, and memory metrics exposed at /metrics endpoint.

Distributed Tracing

Track requests across microservices with OpenTelemetry support.

Custom Metrics

Create counters, histograms, and gauges for your business logic.

Error Tracking

Automatic exception recording in spans for debugging.

Prometheus Metrics

CanxJS automatically exposes default metrics (CPU, Memory, HTTP latency) at /metrics. Add custom metrics for your business logic.

services/analytics.ts
1import { metrics } from 'canxjs';
2
3// Counter - track occurrences
4metrics.increment('users_registered_total');
5metrics.increment('api_requests_total', { endpoint: '/users' });
6
7// Histogram - track durations
8metrics.recordDuration('db_query_duration_ms', 150);
9metrics.recordDuration('http_request_duration_ms', 45, {
10 method: 'GET',
11 route: '/api/users'
12});
13
14// Gauge - track current values
15metrics.gauge('active_connections', 42);
16metrics.gauge('queue_size', await queue.size());

Distributed Tracing

Use the @Trace decorator for automatic span creation, or create spans manually for fine-grained control.

controllers/OrderController.ts
1import { Trace, createSpan } from 'canxjs';
2
3class OrderController {
4
5 @Trace('order.process')
6 async create(req: Request) {
7 // Automatic span creation
8 await this.validate(req);
9 await this.charge(req);
10 await this.notify(req);
11 }
12
13 async validate(req: Request) {
14 // Manual span creation
15 const span = createSpan('order.validate');
16 try {
17 // validation logic...
18 span.setStatus('ok');
19 } catch (e) {
20 span.recordException(e);
21 throw e;
22 } finally {
23 span.end();
24 }
25 }
26}

Exporters

ExporterUse CaseConfig
jaegerSelf-hosted tracingJAEGER_ENDPOINT
zipkinSelf-hosted tracingZIPKIN_URL
otlpOpenTelemetry CollectorOTEL_EXPORTER_URL
datadogManaged serviceDD_API_KEY

Configuration

config/observability.ts
1// config/observability.ts
2export default {
3 metrics: {
4 enabled: true,
5 endpoint: '/metrics', // Prometheus scrape endpoint
6 prefix: 'canx_', // Metric name prefix
7 },
8 tracing: {
9 enabled: true,
10 exporter: 'jaeger', // or 'zipkin', 'otlp'
11 serviceName: 'my-app',
12 sampleRate: 0.1, // Sample 10% in production
13 }
14};

Next Steps

Explore other enterprise features for production-ready systems.