Skip to content
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

Adds lag_in_actions to metrics #811

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

- Added cluster_status to lavinmqctl [#787](https://github.com/cloudamqp/lavinmq/pull/787)
- Added deliver_get to message_stats [#793](https://github.com/cloudamqp/lavinmq/pull/793)
- Added lag_in_actions to metrics [#811](https://github.com/cloudamqp/lavinmq/pull/811)

## [2.0.0-rc.4] - 2024-08-21

Expand Down
5 changes: 5 additions & 0 deletions src/lavinmq/clustering/follower.cr
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,7 @@ module LavinMQ
sent_bytes: @sent_bytes,
acked_bytes: @acked_bytes,
lag_in_bytes: lag_in_bytes,
lag_in_actions: lag_in_actions,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We talked about calling it clustering_actions_queue_size instead

compression_ratio: @lz4.compression_ratio,
uncompressed_bytes: @lz4.uncompressed_bytes,
compressed_bytes: @lz4.compressed_bytes,
Expand All @@ -187,6 +188,10 @@ module LavinMQ
def lag_in_bytes : Int64
@sent_bytes - @acked_bytes
end

def lag_in_actions : Int32
@actions.size
end
end
end
end
5 changes: 5 additions & 0 deletions src/lavinmq/http/controller/prometheus.cr
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,11 @@ module LavinMQ
value: f.lag_in_bytes,
type: "gauge",
help: "Bytes that hasn't been synchronized with the follower yet"})
writer.write({name: "follower_lag_in_actions",
labels: {id: f.id.to_s(36)},
value: f.lag_in_actions,
type: "gauge",
help: "Actions that hasn't been synchronized with the follower yet"})
end
end

Expand Down
7 changes: 7 additions & 0 deletions src/stdlib/channel.cr
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,11 @@ class Channel(T)
ensure
@lock.unlock
end

def size : Int32
if queue = @queue
return queue.size
end
0i32
end
end
Loading