Skip to content

Commit

Permalink
ENG-2031: Attempting to add more logging to the producer stage
Browse files Browse the repository at this point in the history
This does not work as expected yet. I'm not seeing any logs. I probably
have something wrong in the pattern match. The shape of the data
is different in the producer stage.
  • Loading branch information
CuriousCurmudgeon committed Oct 15, 2024
1 parent 1eaa4ce commit ff534c0
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
3 changes: 2 additions & 1 deletion lib/broadway/topology/producer_stage.ex
Original file line number Diff line number Diff line change
Expand Up @@ -307,13 +307,14 @@ defmodule Broadway.Topology.ProducerStage do

defp rate_limit_and_buffer_messages(%{rate_limiting: rate_limiting} = state) do
%{message_buffer: buffer, rate_limiter: rate_limiter, draining?: draining?} = rate_limiting
dbg(state)
# dbg(state)

{rate_limiting, messages_to_emit} =
case RateLimiter.get_currently_allowed(rate_limiter) do
# No point in trying to emit messages if no messages are allowed. In that case,
# we close the rate limiting and don't emit anything.
allowed when allowed <= 0 ->
Utility.maybe_log("Rate limiting closed", state)
{%{rate_limiting | state: :closed}, []}

allowed ->
Expand Down
15 changes: 11 additions & 4 deletions lib/broadway/utility.ex
Original file line number Diff line number Diff line change
@@ -1,11 +1,18 @@
defmodule Broadway.Utility do
require Logger

@queues [
"text.carrier.tmobile.tcr_campaign.1.sms.messages",
"text.provider.bandwidth.sms.messages"
]

def maybe_log(message, %{context: %{config: %{queue: queue}}})
when queue in [
"text.carrier.tmobile.tcr_campaign.1.sms.messages",
"text.provider.bandwidth.sms.messages"
] do
when queue in @queues do
Logger.info("Queue: #{queue} #{message}")
end

def maybe_log(message, %{module_state: %{config: %{queue: queue}}})
when queue in @queues do
Logger.info("Queue: #{queue} #{message}")
end

Expand Down

0 comments on commit ff534c0

Please sign in to comment.