Skip to content

Commit

Permalink
Add grafana metrics
Browse files Browse the repository at this point in the history
  • Loading branch information
avilagaston9 committed May 30, 2024
1 parent 5e03810 commit 0c5e2de
Show file tree
Hide file tree
Showing 3 changed files with 228 additions and 5 deletions.
11 changes: 8 additions & 3 deletions lib/lambda_ethereum_consensus/fork_choice/fork_choice.ex
Original file line number Diff line number Diff line change
Expand Up @@ -230,12 +230,17 @@ defmodule LambdaEthereumConsensus.ForkChoice do
end

defp persist_fork_choice_store(store) do
StoreDb.persist_fork_choice_store(store)
Logger.debug("[Fork choice] Store persisted")
:telemetry.span([:fork_choice, :persist], %{}, fn ->
{StoreDb.persist_fork_choice_store(store), %{}}
end)
end

defp fetch_fork_choice_store!() do
{:ok, store} = StoreDb.fetch_fork_choice_store()
{:ok, store} =
:telemetry.span([:fork_choice, :fetch], %{}, fn ->
{StoreDb.fetch_fork_choice_store(), %{}}
end)

store
end
end
16 changes: 15 additions & 1 deletion lib/lambda_ethereum_consensus/telemetry.ex
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,21 @@ defmodule LambdaEthereumConsensus.Telemetry do
last_value("vm.uptime.total", unit: :millisecond),

# Db Metrics
last_value("db.size.total", unit: :byte)
last_value("db.size.total", unit: :byte),

# ForkChoice Metrics
last_value("fork_choice.persist.stop.duration",
unit: {:native, :millisecond}
),
last_value("fork_choice.persist.exception.duration",
unit: {:native, :millisecond}
),
last_value("fork_choice.fetch.stop.duration",
unit: {:native, :millisecond}
),
last_value("fork_choice.fetch.exception.duration",
unit: {:native, :millisecond}
)
]
end

Expand Down
206 changes: 205 additions & 1 deletion metrics/grafana/provisioning/dashboards/home.json
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,210 @@
"title": "Database size",
"type": "timeseries"
},
{
"datasource": {
"type": "prometheus",
"uid": "PBFA97CFB590B2093"
},
"targets": [
{
"refId": "A",
"expr": "fork_choice_persist_stop_duration",
"range": true,
"instant": true,
"datasource": {
"type": "prometheus",
"uid": "PBFA97CFB590B2093"
},
"editorMode": "builder",
"legendFormat": "__auto",
"useBackend": false,
"disableTextWrap": false,
"fullMetaSearch": false,
"includeNullMetadata": true,
"hide": false
}
],
"type": "timeseries",
"title": "ForkChoice Persisting Store Duration",
"gridPos": {
"x": 0,
"y": 0,
"w": 12,
"h": 8
},
"options": {
"tooltip": {
"mode": "single",
"sort": "none",
"maxHeight": 600
},
"legend": {
"showLegend": false,
"displayMode": "list",
"placement": "bottom",
"calcs": []
}
},
"fieldConfig": {
"defaults": {
"custom": {
"drawStyle": "line",
"lineInterpolation": "linear",
"barAlignment": 0,
"lineWidth": 2,
"fillOpacity": 0,
"gradientMode": "none",
"spanNulls": false,
"insertNulls": false,
"showPoints": "auto",
"pointSize": 1,
"stacking": {
"mode": "none",
"group": "A"
},
"axisPlacement": "auto",
"axisLabel": "",
"axisColorMode": "text",
"axisBorderShow": false,
"scaleDistribution": {
"type": "linear"
},
"axisCenteredZero": false,
"hideFrom": {
"tooltip": false,
"viz": false,
"legend": false
},
"thresholdsStyle": {
"mode": "off"
}
},
"color": {
"mode": "palette-classic"
},
"mappings": [],
"thresholds": {
"mode": "absolute",
"steps": [
{
"value": null,
"color": "green"
},
{
"value": 80,
"color": "red"
}
]
},
"unit": "ms"
},
"overrides": []
},
"id": 25
},
{
"datasource": {
"type": "prometheus",
"uid": "PBFA97CFB590B2093"
},
"targets": [
{
"refId": "A",
"expr": "fork_choice_fetch_stop_duration",
"range": true,
"instant": true,
"datasource": {
"type": "prometheus",
"uid": "PBFA97CFB590B2093"
},
"editorMode": "builder",
"legendFormat": "__auto",
"useBackend": false,
"disableTextWrap": false,
"fullMetaSearch": false,
"includeNullMetadata": true,
"hide": false
}
],
"type": "timeseries",
"title": "ForkChoice Fetching Store Duration",
"gridPos": {
"x": 0,
"y": 0,
"w": 12,
"h": 8
},
"options": {
"tooltip": {
"mode": "single",
"sort": "none",
"maxHeight": 600
},
"legend": {
"showLegend": false,
"displayMode": "list",
"placement": "bottom",
"calcs": []
}
},
"fieldConfig": {
"defaults": {
"custom": {
"drawStyle": "line",
"lineInterpolation": "linear",
"barAlignment": 0,
"lineWidth": 2,
"fillOpacity": 0,
"gradientMode": "none",
"spanNulls": false,
"insertNulls": false,
"showPoints": "auto",
"pointSize": 1,
"stacking": {
"mode": "none",
"group": "A"
},
"axisPlacement": "auto",
"axisLabel": "",
"axisColorMode": "text",
"axisBorderShow": false,
"scaleDistribution": {
"type": "linear"
},
"axisCenteredZero": false,
"hideFrom": {
"tooltip": false,
"viz": false,
"legend": false
},
"thresholdsStyle": {
"mode": "off"
}
},
"color": {
"mode": "palette-classic"
},
"mappings": [],
"thresholds": {
"mode": "absolute",
"steps": [
{
"value": null,
"color": "green"
},
{
"value": 80,
"color": "red"
}
]
},
"unit": "ms"
},
"overrides": []
},
"id": 26
},
{
"datasource": {
"type": "prometheus",
Expand Down Expand Up @@ -2161,4 +2365,4 @@
"uid": "90EXFQnIk",
"version": 1,
"weekStart": ""
}
}

0 comments on commit 0c5e2de

Please sign in to comment.