Skip to content

Exporters

JSONL

JSONL exporter with size/time-based rotation.

Design: - Append to an active temp file: profilis-active.jsonl.tmp - On rotation, atomically rename temp -> profilis-YYYYmmdd-HHMMSS.jsonl - Thread-safe via an internal lock; safe as an AsyncCollector sink by exposing call(batch). - Uses orjson if available; falls back to stdlib json with ensure_ascii=False for unicode safety.

JSONLExporter

finalize()

Finalize any pending rotation - useful for collector cleanup.

Console

Console exporter (stdout). Collector-ready via call(batch).

Prometheus

Prometheus exporter: counters and histograms for HTTP, functions, and DB.

Metrics: - HTTP: profilis_http_requests_total, profilis_http_request_duration_seconds - Functions: profilis_function_calls_total, profilis_function_duration_seconds - DB: profilis_db_queries_total, profilis_db_query_duration_seconds - Collector health (optional): profilis_events_dropped_total, profilis_queue_depth Use register_collector_health_metrics(registry, collector) to expose them.

Labels: service, instance, worker, route, status (HTTP), function (FN), db_vendor (DB). Buckets: [0.005, 0.01, 0.025, 0.05, 0.1, 0.25, 0.5, 1, 2, 5, 10] seconds.

Use as an AsyncCollector sink; optionally compose with other sinks: registry = CollectorRegistry() prom = PrometheusExporter(registry, service="myapp") def sink(batch): console_exporter(batch) prom(batch) collector = AsyncCollector(sink, ...)

PrometheusExporter

Sink that updates Prometheus counters and histograms from REQ/HTTP/FN/DB events.

make_asgi_app(registry=None)

Return an ASGI app that serves /metrics (Prometheus text format).

Use with Starlette: app.mount("/metrics", make_asgi_app(registry)) Or with FastAPI: app.mount("/metrics", make_asgi_app(registry))

make_metrics_blueprint(registry=None, url_prefix='')

Return a Flask blueprint that serves GET /metrics (Prometheus text format).

Usage

from profilis.exporters.prometheus import make_metrics_blueprint app.register_blueprint(make_metrics_blueprint(registry)) # route at /metrics

register_collector_health_metrics(registry, collector)

Register health metrics for an AsyncCollector: profilis_events_dropped_total, profilis_queue_depth.

Call after creating your AsyncCollector and pass the same registry used for PrometheusExporter

collector = AsyncCollector(sink, ...) register_collector_health_metrics(registry, collector)