Sixth item of the v1.0.6 backlog. `RabbitMQEventBus.Publish` returned the
broker error but did not log it. Callers that wrap Publish in
fire-and-forget (`_ = eb.Publish(...)`) lost events with zero trace —
during an RMQ outage the backend would quietly shed work and operators
only noticed via downstream symptoms (missing notifications, stuck
async jobs, etc.).
Changes
* `Publish` now emits a structured ERROR with the exchange,
routing_key, payload_bytes, content_type, and message_id on every
broker failure. The function still returns the error so call-sites
that actually check it keep working exactly as before.
* The pre-existing "EventBus disabled" warning is kept but upgraded
with payload_bytes so dashboards can quantify drops when RMQ is
intentionally off (tests, dev without docker-compose --profile).
* `infrastructure/eventbus/rabbitmq.go:PublishEvent` (the newer,
event-sourcing variant) already had this pattern — this commit
brings the legacy path in line.
Tests
* 2 new tests in `rabbitmq_test.go`:
- disabled bus emits a single WARN with structured context and
returns EventBusUnavailableError
- nil logger path stays panic-free (legacy callers construct
bus without a logger)
* Broker-side failure path (closed channel) is not unit-tested here
because amqp091-go types don't expose a mockable channel without
spinning up a real RMQ — covered by the existing integration test
in `internal/integration/e2e_test.go`.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>