armature-analytics 0.1.1

API analytics and usage tracking for Armature framework
Documentation

API Analytics Module for Armature Framework

Provides comprehensive API usage tracking, rate limit insights, and error monitoring.

Features

  • Request Metrics: Track requests per endpoint, method, and status code
  • Latency Tracking: P50, P90, P95, P99 latency percentiles
  • Error Rates: Monitor error rates by endpoint and error type
  • Rate Limit Insights: Track rate limit hits, rejections, and usage patterns
  • Throughput Monitoring: Requests per second, minute, hour
  • Real-time Dashboard: JSON endpoint for analytics data

Quick Start

use armature_analytics::{Analytics, AnalyticsMiddleware};
use armature_core::Application;

let analytics = Analytics::new(AnalyticsConfig::default());

let app = Application::new(container, router)
    .middleware(AnalyticsMiddleware::new(analytics.clone()));

// Access analytics endpoint
// GET /api/_analytics -> JSON dashboard data

Architecture

┌─────────────────────────────────────────────────────────────┐
│                        Requests                              │
└─────────────────────────┬───────────────────────────────────┘
                          │
                          ▼
┌─────────────────────────────────────────────────────────────┐
│                 AnalyticsMiddleware                          │
│  - Captures request/response metadata                        │
│  - Records timing, status, errors                            │
└─────────────────────────┬───────────────────────────────────┘
                          │
                          ▼
┌─────────────────────────────────────────────────────────────┐
│                    MetricsCollector                          │
│  ┌──────────┐ ┌──────────┐ ┌──────────┐ ┌──────────┐       │
│  │ Requests │ │ Latency  │ │  Errors  │ │Rate Limit│       │
│  │ Counter  │ │Histogram │ │ Tracker  │ │ Insights │       │
│  └──────────┘ └──────────┘ └──────────┘ └──────────┘       │
└─────────────────────────┬───────────────────────────────────┘
                          │
                          ▼
┌─────────────────────────────────────────────────────────────┐
│                    Export Backends                           │
│  ┌──────────┐ ┌──────────┐ ┌──────────┐                     │
│  │   JSON   │ │Prometheus│ │  Custom  │                     │
│  └──────────┘ └──────────┘ └──────────┘                     │
└─────────────────────────────────────────────────────────────┘