Repository navigation
Open Source APM/Observability 운영 경로 설계 및 구현 #149
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
16e7571
docs: add implementation plan for APM observability
seonghobae e8b51e0
feat(observability): add open source APM stack and backend instrument…
seonghobae 2609d30
fix(deps): add setuptools to resolve pkg_resources missing error in CI
seonghobae 5f91c8b
fix(deps): pin setuptools < 71 to support opentelemetry pkg_resources…
seonghobae 65f09b1
fix(security): resolve CORS overly permissive configuration and crede…
seonghobae File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| import pytest | ||
|
seonghobae marked this conversation as resolved.
|
||
| import subprocess | ||
|
seonghobae marked this conversation as resolved.
seonghobae marked this conversation as resolved.
coderabbitai[bot] marked this conversation as resolved.
|
||
| from pathlib import Path | ||
|
|
||
| def test_observability_compose_file_exists(): | ||
| assert Path("../docker-compose.observability.yml").exists() | ||
|
|
||
| def test_observability_provisioning_exists(): | ||
| assert Path("../observability/grafana/provisioning/datasources/datasources.yaml").exists() | ||
| assert Path("../observability/prometheus.yml").exists() | ||
| assert Path("../observability/tempo.yaml").exists() | ||
|
seonghobae marked this conversation as resolved.
coderabbitai[bot] marked this conversation as resolved.
|
||
|
|
||
| def test_backend_exposes_metrics_endpoint(): | ||
| from main import app | ||
| from fastapi.testclient import TestClient | ||
|
|
||
| with TestClient(app, headers={"X-User-Id": "testuser"}) as client: | ||
| # Before instrumentation, it might be 404, but after it should be 200 | ||
| response = client.get("/metrics") | ||
| # Ensure it is added as part of the APM implementation | ||
| assert response.status_code == 200 | ||
| assert "python_info" in response.text or "process_" in response.text | ||
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| services: | ||
| prometheus: | ||
| image: prom/prometheus:v2.51.2 | ||
| command: | ||
| - '--config.file=/etc/prometheus/prometheus.yml' | ||
| ports: | ||
| - "9090:9090" | ||
| volumes: | ||
| - ./observability/prometheus.yml:/etc/prometheus/prometheus.yml:ro | ||
|
|
||
|
coderabbitai[bot] marked this conversation as resolved.
|
||
| grafana: | ||
| image: grafana/grafana:11.5.0 | ||
| ports: | ||
| - "3000:3000" | ||
| environment: | ||
|
seonghobae marked this conversation as resolved.
|
||
| - GF_AUTH_ANONYMOUS_ENABLED=true | ||
| - GF_AUTH_ANONYMOUS_ORG_ROLE=Admin | ||
|
coderabbitai[bot] marked this conversation as resolved.
|
||
| volumes: | ||
| - ./observability/grafana/provisioning:/etc/grafana/provisioning | ||
|
|
||
| loki: | ||
| image: grafana/loki:2.9.8 | ||
| ports: | ||
| - "3100:3100" | ||
| command: -config.file=/etc/loki/local-config.yaml | ||
|
|
||
| tempo: | ||
| image: grafana/tempo:2.4.1 | ||
| command: [ "-config.file=/etc/tempo.yaml" ] | ||
| volumes: | ||
| - ./observability/tempo.yaml:/etc/tempo.yaml:ro | ||
| ports: | ||
| - "3200:3200" | ||
| - "4317:4317" # otlp grpc | ||
| - "4318:4318" # otlp http | ||
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| # Open Source APM & Observability Implementation Plan | ||
|
|
||
| ## Overview | ||
| Implement OpenTelemetry, Prometheus, Grafana, Loki, and Tempo for Open Source Application Performance Monitoring (APM). | ||
|
|
||
| ## Reference | ||
| - Target Issue: #135 (Closed for design, but we will reopen/implement) | ||
|
|
||
| ## Architecture | ||
| - **Grafana**: Dashboards and visualization. | ||
| - **Prometheus**: Metrics backend. | ||
| - **Loki**: Log aggregation. | ||
| - **Tempo**: Distributed tracing. | ||
| - **Alloy / OpenTelemetry Collector**: Receive traces/metrics from FastAPI/Next.js and route to backends. | ||
|
|
||
| ## Tasks | ||
| 1. Create `docker-compose.observability.yml` to provision Grafana, Prometheus, Loki, and Tempo. | ||
| 2. Update backend FastAPI application to include OpenTelemetry instrumentation. | ||
| - `opentelemetry-instrumentation-fastapi` | ||
| - `opentelemetry-exporter-otlp` | ||
| 3. Update frontend Next.js to expose basic metrics or tracing if applicable. | ||
| 4. Set up Grafana provisioning (Datasources for Prometheus, Loki, Tempo). | ||
| 5. Verify via live tests that the stack comes up and endpoints return 200 OK. |
15 changes: 15 additions & 0 deletions
15
observability/grafana/provisioning/datasources/datasources.yaml
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| apiVersion: 1 | ||
| datasources: | ||
| - name: Prometheus | ||
| type: prometheus | ||
| access: proxy | ||
| url: http://prometheus:9090 | ||
| isDefault: true | ||
| - name: Tempo | ||
| type: tempo | ||
| access: proxy | ||
| url: http://tempo:3200 | ||
| - name: Loki | ||
| type: loki | ||
| access: proxy | ||
| url: http://loki:3100 |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| global: | ||
| scrape_interval: 15s | ||
|
|
||
| scrape_configs: | ||
| - job_name: 'backend' | ||
| static_configs: | ||
| - targets: ['backend:8000'] | ||
|
seonghobae marked this conversation as resolved.
|
||
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| server: | ||
| http_listen_port: 3200 | ||
|
|
||
| distributor: | ||
| receivers: | ||
| otlp: | ||
| protocols: | ||
| http: | ||
| grpc: | ||
|
|
||
| ingester: | ||
| max_block_bytes: 1000000 | ||
| max_block_duration: 5m | ||
|
|
||
| compactor: | ||
| compaction: | ||
| compaction_window: 1h | ||
| max_block_bytes: 100000000 | ||
| block_retention: 1h | ||
|
seonghobae marked this conversation as resolved.
|
||
| compacted_block_retention: 10m | ||
|
|
||
| storage: | ||
| trace: | ||
| backend: local | ||
| wal: | ||
| path: /tmp/tempo/wal | ||
| local: | ||
| path: /tmp/tempo/blocks | ||
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.