-
Notifications
You must be signed in to change notification settings - Fork 129
fix(guard): add metrics #2480
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
Closed
MasterPtato
wants to merge
1
commit into
05-30-chore_expose_namespace_in_otel_attributes
from
05-27-fix_guard_add_metrics
Closed
fix(guard): add metrics #2480
Changes from all commits
Commits
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
| Original file line number | Diff line number | Diff line change | ||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -229,6 +229,14 @@ pub async fn gen_initialize( | |||||||||||||||||
| )?); | ||||||||||||||||||
| script.push(components::rivet::guard::fetch_tls(server_token)?); | ||||||||||||||||||
| script.push(components::rivet::guard::configure(config)?); | ||||||||||||||||||
|
|
||||||||||||||||||
| prometheus_targets.insert( | ||||||||||||||||||
| "guard".into(), | ||||||||||||||||||
| components::vector::PrometheusTarget { | ||||||||||||||||||
| endpoint: "http://127.0.0.1:8091".into(), | ||||||||||||||||||
| scrape_interval: 15, | ||||||||||||||||||
| }, | ||||||||||||||||||
|
Comment on lines
+235
to
+238
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. logic: Missing /metrics path in endpoint URL which is required for Prometheus scraping
Suggested change
|
||||||||||||||||||
| ); | ||||||||||||||||||
| } | ||||||||||||||||||
| } | ||||||||||||||||||
|
|
||||||||||||||||||
|
|
||||||||||||||||||
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 |
|---|---|---|
| @@ -1,29 +1,80 @@ | ||
| use lazy_static::lazy_static; | ||
| use rivet_metrics::prometheus::*; | ||
| use rivet_metrics::{prometheus::*, REGISTRY}; | ||
|
|
||
| lazy_static! { | ||
| pub static ref ACTOR_REQUEST_TOTAL: IntCounterVec = register_int_counter_vec!( | ||
| "actor_request_total", | ||
| // MARK: Internal | ||
| pub static ref ROUTE_CACHE_SIZE: IntGauge = register_int_gauge_with_registry!( | ||
| "guard_route_cache_size", | ||
| "Number of entries in the route cache", | ||
| *REGISTRY, | ||
| ).unwrap(); | ||
| pub static ref RATE_LIMITER_COUNT: IntGauge = register_int_gauge_with_registry!( | ||
| "guard_rate_limiter_count", | ||
| "Number of active rate limiters", | ||
| *REGISTRY, | ||
| ).unwrap(); | ||
| pub static ref IN_FLIGHT_COUNTER_COUNT: IntGauge = register_int_gauge_with_registry!( | ||
| "guard_in_flight_counter_count", | ||
| "Number of active in-flight counters", | ||
| *REGISTRY, | ||
| ) | ||
| .unwrap(); | ||
|
|
||
| // MARK: TCP | ||
| pub static ref TCP_CONNECTION_TOTAL: IntCounter = register_int_counter_with_registry!( | ||
| "guard_tcp_connection_total", | ||
| "Total number of TCP connections ever", | ||
| *REGISTRY, | ||
| ) | ||
| .unwrap(); | ||
| pub static ref TCP_CONNECTION_PENDING: IntGauge = register_int_gauge_with_registry!( | ||
| "guard_tcp_connection_pending", | ||
| "Total number of open TCP connections", | ||
| *REGISTRY, | ||
| ) | ||
| .unwrap(); | ||
| pub static ref TCP_CONNECTION_DURATION: Histogram = register_histogram_with_registry!( | ||
| "guard_tcp_connection_duration", | ||
| "TCP connection duration in seconds", | ||
| *REGISTRY, | ||
| ) | ||
| .unwrap(); | ||
|
|
||
| // MARK: Pre-proxy | ||
| pub static ref RESOLVE_ROUTE_DURATION: Histogram = register_histogram_with_registry!( | ||
| "guard_resolve_route_duration", | ||
| "Time to resolve request route in seconds", | ||
| *REGISTRY, | ||
| ) | ||
| .unwrap(); | ||
|
|
||
| // MARK: Proxy requests | ||
| pub static ref PROXY_REQUEST_TOTAL: IntCounterVec = register_int_counter_vec_with_registry!( | ||
| "guard_proxy_request_total", | ||
| "Total number of requests to actor", | ||
| &["actor_id", "server_id", "method", "path"] | ||
| &["actor_id", "server_id", "method", "path"], | ||
| *REGISTRY, | ||
| ) | ||
| .unwrap(); | ||
| pub static ref ACTOR_REQUEST_PENDING: IntGaugeVec = register_int_gauge_vec!( | ||
| "actor_request_pending", | ||
| pub static ref PROXY_REQUEST_PENDING: IntGaugeVec = register_int_gauge_vec_with_registry!( | ||
| "guard_proxy_request_pending", | ||
| "Number of pending requests to actor", | ||
| &["actor_id", "server_id", "method", "path"] | ||
| &["actor_id", "server_id", "method", "path"], | ||
| *REGISTRY, | ||
| ) | ||
| .unwrap(); | ||
| pub static ref ACTOR_REQUEST_DURATION: HistogramVec = register_histogram_vec!( | ||
| "actor_request_duration_seconds", | ||
| pub static ref PROXY_REQUEST_DURATION: HistogramVec = register_histogram_vec_with_registry!( | ||
| "guard_proxy_request_duration", | ||
| "Request duration in seconds", | ||
| &["actor_id", "server_id", "status"] | ||
| &["actor_id", "server_id", "status"], | ||
| *REGISTRY, | ||
| ) | ||
| .unwrap(); | ||
| pub static ref ACTOR_REQUEST_ERRORS: IntCounterVec = register_int_counter_vec!( | ||
| "actor_request_errors_total", | ||
| pub static ref PROXY_REQUEST_ERROR: IntCounterVec = register_int_counter_vec_with_registry!( | ||
| "guard_proxy_request_errors_total", | ||
| "Total number of errors when proxying requests to actor", | ||
| &["actor_id", "server_id", "error_type"] | ||
| &["actor_id", "server_id", "error_type"], | ||
| *REGISTRY, | ||
| ) | ||
| .unwrap(); | ||
| } |
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
logic: Port 8091 is already used by the worker service (see line 215). Consider using a different port for guard metrics to avoid conflicts.