feat: integrate grafana and prometheus#60
Merged
Dejmenek merged 6 commits intoMay 13, 2026
Conversation
Added OpenTelemetry.Exporter.OpenTelemetryProtocol (v1.15.3) to enable exporting telemetry data using the OpenTelemetry Protocol (OTLP). Updated Directory.Packages.props, TournamentAPI.csproj, and packages.lock.json to reflect this addition. This allows integration with observability backends such as Jaeger, Prometheus, or OpenTelemetry Collector.
Added Prometheus and Grafana services to docker-compose.yml for monitoring and visualization. Configured Prometheus with OTLP receiver and persistent storage. Exposed ports 5431 (Prometheus) and 3000 (Grafana). Defined named volumes for data persistence.
Refactor TournamentMetrics to use an UpDownCounter for tracking active tournaments instead of an observable gauge. Remove database polling and update the metric in real-time by calling TournamentOpened() and TournamentClosed() when tournaments are created, updated, or deleted. Inject TournamentMetrics into mutation methods to support this change. This improves accuracy and performance of the active tournaments metric.
Removed TournamentMetrics as a hosted service, keeping only its singleton registration. Replaced the console metrics exporter with an OTLP exporter configured for HTTP Protobuf, sending metrics to http://localhost:5431/api/v1/otlp/v1/metrics.
Added global scrape_interval of 15s in prometheus.yml. Configured a new 'prometheus' job with HTTP scheme, 10s scrape interval, 5s scrape timeout, and static target 'localhost:9090'.
Added a "Running the API" section to the README with detailed steps for starting Prometheus and Grafana via Docker Compose, running the .NET 9 API, and connecting Grafana to Prometheus for metrics visualization. Includes prerequisites and service URLs for easier setup.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Implements OTLP metrics export to Prometheus and visualization with Grafana, refactors tournament metrics tracking, and provides local observability setup and documentation.
Changes