-
Notifications
You must be signed in to change notification settings - Fork 3.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add session -> exchange metrics for unroutable_returned and unroutable_dropped Add session -> exchange metrics for accepted WIP Add seesion <-> queue stats Single ETS session table Expose per session metrics in Prometheus Add 'rabbitmqctl list_sessions' CLI command list_channels queries into each channel proc. This commit decides that list_sessions reads the local ETS table instead. Each node sends its session infos directly to the CLI node to avoid large amounts of data being transferred acrosss RabbitMQ nodes. Advantages: * Same code path is used for Prometheus, Management UI, and CLI because they all query the same single source of truth: ETS table `session_metrics`. * Avoid waking up potentially hundreds of thousands of processes at the same time. Disadvantages: * Data is slightly old because the session emits stats every interval (5 seconds by default). But this shouldn't matter for this CLI command.
- Loading branch information
Showing
9 changed files
with
712 additions
and
146 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains 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 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 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 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
84 changes: 84 additions & 0 deletions
84
deps/rabbitmq_cli/lib/rabbitmq/cli/ctl/commands/list_sessions_command.ex
This file contains 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,84 @@ | ||
## This Source Code Form is subject to the terms of the Mozilla Public | ||
## License, v. 2.0. If a copy of the MPL was not distributed with this | ||
## file, You can obtain one at https://mozilla.org/MPL/2.0/. | ||
## | ||
## Copyright (c) 2007-2023 Broadcom. All Rights Reserved. The term “Broadcom” refers to Broadcom Inc. and/or its subsidiaries. All rights reserved. | ||
## | ||
|
||
defmodule RabbitMQ.CLI.Ctl.Commands.ListSessionsCommand do | ||
alias RabbitMQ.CLI.Core.{DocGuide, Helpers} | ||
alias RabbitMQ.CLI.Ctl.{InfoKeys, RpcStream} | ||
|
||
@behaviour RabbitMQ.CLI.CommandBehaviour | ||
|
||
def scopes(), do: [:ctl, :diagnostics] | ||
|
||
@info_keys ~w(pid name connection_pid channel_number user vhost handle_max | ||
in_attach in_flow in_transfer in_disposition in_detach)a | ||
|
||
def info_keys(), do: @info_keys | ||
|
||
def merge_defaults([], opts) do | ||
merge_defaults(~w(pid name user), opts) | ||
end | ||
|
||
def merge_defaults(args, opts) do | ||
{args, Map.merge(%{table_headers: true}, opts)} | ||
end | ||
|
||
def validate(args, _) do | ||
case InfoKeys.validate_info_keys(args, @info_keys) do | ||
{:ok, _} -> :ok | ||
err -> err | ||
end | ||
end | ||
|
||
use RabbitMQ.CLI.Core.RequiresRabbitAppRunning | ||
|
||
def run([], opts) do | ||
run(~w(pid name user) |> Enum.map(&to_charlist/1), opts) | ||
end | ||
|
||
def run([_ | _] = args, %{node: node_name, timeout: timeout}) do | ||
info_keys = InfoKeys.prepare_info_keys(args) | ||
broker_keys = InfoKeys.broker_keys(info_keys) | ||
|
||
Helpers.with_nodes_in_cluster(node_name, fn nodes -> | ||
RpcStream.receive_list_items( | ||
node_name, | ||
:rabbit_amqp_session, | ||
:emit_info_all, | ||
[nodes, broker_keys], | ||
timeout, | ||
info_keys, | ||
Kernel.length(nodes) | ||
) | ||
end) | ||
end | ||
|
||
use RabbitMQ.CLI.DefaultOutput | ||
|
||
def formatter(), do: RabbitMQ.CLI.Formatters.Table | ||
|
||
def banner(_, _), do: "Listing AMQP 1.0 sessions ..." | ||
|
||
def usage() do | ||
"list_sessions [--no-table-headers] [<column> ...]" | ||
end | ||
|
||
def usage_additional() do | ||
[ | ||
["<column>", "must be one of " <> Enum.join(Enum.sort(@info_keys), ", ")] | ||
] | ||
end | ||
|
||
def usage_doc_guides() do | ||
[ | ||
DocGuide.amqp() | ||
] | ||
end | ||
|
||
def help_section(), do: :observability_and_health_checks | ||
|
||
def description(), do: "Lists all AMQP 1.0 sessions" | ||
end |
This file contains 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
Oops, something went wrong.