4e89e92b65
Security fix: Move Prometheus metrics endpoint from main HTTP port to dedicated port 9090 to prevent external exposure of metrics data. Changes: - Use prometheus_client.start_http_server() for dedicated metrics server - Remove /metrics route from main application routes - Metrics now only accessible on port 9090 (configurable via METRICS_PORT) - Main application port no longer serves /metrics endpoint This follows security best practice of isolating monitoring endpoints from application traffic. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
32 lines
872 B
Python
32 lines
872 B
Python
"""
|
|
Observability module for the Nextcloud MCP Server.
|
|
|
|
This module provides:
|
|
- Prometheus metrics collection
|
|
- OpenTelemetry distributed tracing
|
|
- Enhanced structured logging with trace correlation
|
|
- Monitoring middleware for Starlette/FastAPI
|
|
|
|
Usage:
|
|
from nextcloud_mcp_server.observability import setup_observability
|
|
|
|
# In app.py lifespan
|
|
setup_observability(app, config)
|
|
"""
|
|
|
|
from nextcloud_mcp_server.observability.logging_config import (
|
|
get_uvicorn_logging_config,
|
|
setup_logging,
|
|
)
|
|
from nextcloud_mcp_server.observability.metrics import setup_metrics
|
|
from nextcloud_mcp_server.observability.middleware import ObservabilityMiddleware
|
|
from nextcloud_mcp_server.observability.tracing import setup_tracing
|
|
|
|
__all__ = [
|
|
"setup_logging",
|
|
"get_uvicorn_logging_config",
|
|
"setup_metrics",
|
|
"setup_tracing",
|
|
"ObservabilityMiddleware",
|
|
]
|