Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,7 @@ graphql_api_assignment-*.tar

.cursor/

.elixir_ls

.env*

3 changes: 3 additions & 0 deletions .iex.exs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
alias GraphqlApiAssignment.HashringCounter

name = HashringCounter.hash_ring_name()
17 changes: 16 additions & 1 deletion config/config.exs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,10 @@ config :graphql_api_assignment, GraphqlApiAssignment.Repo,
database: "graphql_api_assignment_repo",
username: "user",
password: "password",
hostname: "localhost"
hostname: "localhost",
show_sensitive_data_on_connection_error: true,
log: :debug,
stacktrace: true

config :graphql_api_assignment,
ecto_repos: [GraphqlApiAssignment.Repo]
Expand All @@ -30,6 +33,18 @@ config :prometheus_telemetry,
ecto_max_query_length: 150,
ecto_known_query_module: nil

config :request_cache_plug,
enabled?: true,
verbose?: false,
graphql_paths: ["/graphiql", "/graphql"],
request_cache_module: GraphqlApiAssignment.RedixPool

config :libring,
rings: [
ring_a: [monitor_nodes: true],
ring_b: [monitor_nodes: true]
]

# Configures the endpoint
config :graphql_api_assignment, GraphqlApiAssignmentWeb.Endpoint,
url: [host: "localhost"],
Expand Down
6 changes: 5 additions & 1 deletion config/test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,11 @@ config :graphql_api_assignment, GraphqlApiAssignment.Repo,
username: "user",
password: "password",
hostname: "localhost",
pool: Ecto.Adapters.SQL.Sandbox
pool: Ecto.Adapters.SQL.Sandbox,
show_sensitive_data_on_connection_error: true,
log: :debug,
stacktrace: true,
pool_size: 10

# In test we don't send emails
config :graphql_api_assignment, GraphqlApiAssignment.Mailer, adapter: Swoosh.Adapters.Test
Expand Down
41 changes: 41 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
networks:
monitoring:
driver: bridge

services:
prometheus:
image: prom/prometheus:v3.1.0
container_name: prometheus
ports:
- "9090:9090"
volumes:
- ./prom_config.yml:/etc/prometheus/prometheus.yml
networks:
- monitoring


grafana:
image: grafana/grafana:11.6.0
container_name: grafana
ports:
- "3000:3000"
environment:
- GF_SECURITY_ADMIN_USER=admin
- GF_SECURITY_ADMIN_PASSWORD=admin
networks:
- monitoring
depends_on:
- prometheus

postgres:
image: postgres:14
container_name: postgres
restart: always
environment:
POSTGRES_USER: user
POSTGRES_PASSWORD: password
POSTGRES_DB: graphql_api_assignment_repo
ports:
- "5432:5432"
networks:
- monitoring
232 changes: 232 additions & 0 deletions grafana/custom/hash_ring_export.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,232 @@
{
"annotations": {
"list": [
{
"builtIn": 1,
"datasource": {
"type": "grafana",
"uid": "-- Grafana --"
},
"enable": true,
"hide": true,
"iconColor": "rgba(0, 211, 255, 1)",
"name": "Annotations & Alerts",
"type": "dashboard"
}
]
},
"editable": true,
"fiscalYearStartMonth": 0,
"graphTooltip": 0,
"id": 8,
"links": [],
"panels": [
{
"datasource": {
"type": "prometheus",
"uid": "eeifd9qqffev4c"
},
"fieldConfig": {
"defaults": {
"color": {
"mode": "palette-classic"
},
"custom": {
"axisBorderShow": false,
"axisCenteredZero": false,
"axisColorMode": "text",
"axisLabel": "",
"axisPlacement": "auto",
"barAlignment": 0,
"barWidthFactor": 0.6,
"drawStyle": "line",
"fillOpacity": 0,
"gradientMode": "none",
"hideFrom": {
"legend": false,
"tooltip": false,
"viz": false
},
"insertNulls": false,
"lineInterpolation": "linear",
"lineWidth": 1,
"pointSize": 5,
"scaleDistribution": {
"type": "linear"
},
"showPoints": "auto",
"spanNulls": false,
"stacking": {
"group": "A",
"mode": "none"
},
"thresholdsStyle": {
"mode": "off"
}
},
"mappings": [],
"thresholds": {
"mode": "absolute",
"steps": [
{
"color": "green"
},
{
"color": "red",
"value": 80
}
]
}
},
"overrides": []
},
"gridPos": {
"h": 8,
"w": 12,
"x": 0,
"y": 0
},
"id": 1,
"options": {
"legend": {
"calcs": [],
"displayMode": "list",
"placement": "bottom",
"showLegend": true
},
"tooltip": {
"hideZeros": false,
"mode": "single",
"sort": "none"
}
},
"pluginVersion": "11.6.0",
"targets": [
{
"datasource": {
"type": "prometheus",
"uid": "eeifd9qqffev4c"
},
"editorMode": "code",
"expr": "rate(grapql_api_hash_ring_get_duration_millisecond_bucket[1m])",
"legendFormat": "__auto",
"range": true,
"refId": "A"
}
],
"title": "Hash Ring Get Duration",
"type": "timeseries"
},
{
"datasource": {
"type": "prometheus",
"uid": "eeifd9qqffev4c"
},
"fieldConfig": {
"defaults": {
"color": {
"mode": "palette-classic"
},
"custom": {
"axisBorderShow": false,
"axisCenteredZero": false,
"axisColorMode": "text",
"axisLabel": "",
"axisPlacement": "auto",
"barAlignment": 0,
"barWidthFactor": 0.6,
"drawStyle": "line",
"fillOpacity": 0,
"gradientMode": "none",
"hideFrom": {
"legend": false,
"tooltip": false,
"viz": false
},
"insertNulls": false,
"lineInterpolation": "linear",
"lineWidth": 1,
"pointSize": 5,
"scaleDistribution": {
"type": "linear"
},
"showPoints": "auto",
"spanNulls": false,
"stacking": {
"group": "A",
"mode": "none"
},
"thresholdsStyle": {
"mode": "off"
}
},
"mappings": [],
"thresholds": {
"mode": "absolute",
"steps": [
{
"color": "green"
},
{
"color": "red",
"value": 80
}
]
}
},
"overrides": []
},
"gridPos": {
"h": 8,
"w": 12,
"x": 12,
"y": 0
},
"id": 2,
"options": {
"legend": {
"calcs": [],
"displayMode": "list",
"placement": "bottom",
"showLegend": true
},
"tooltip": {
"hideZeros": false,
"mode": "single",
"sort": "none"
}
},
"pluginVersion": "11.6.0",
"targets": [
{
"datasource": {
"type": "prometheus",
"uid": "eeifd9qqffev4c"
},
"editorMode": "code",
"expr": "rate(grapql_api_hash_ring_put_duration_millisecond_bucket[1m])",
"legendFormat": "__auto",
"range": true,
"refId": "A"
}
],
"title": "Hash Ring Put Duration",
"type": "timeseries"
}
],
"preload": false,
"schemaVersion": 41,
"tags": [],
"templating": {
"list": []
},
"time": {
"from": "now-6h",
"to": "now"
},
"timepicker": {},
"timezone": "browser",
"title": "Hash Ring",
"uid": "feifig66c1n9cb",
"version": 1
}
Loading