Class CompositeAgentEventPublisher

java.lang.Object
com.tnsai.observability.events.CompositeAgentEventPublisher
All Implemented Interfaces:
AgentEventPublisher

public class CompositeAgentEventPublisher extends Object implements AgentEventPublisher
Fan-out AgentEventPublisher — broadcasts each event to every delegate. A failure in one delegate is logged but does not stop delivery to the others — observability sinks must be best-effort, never application-affecting.

Used internally by the framework when multiple publishers are discovered via ServiceLoader; consumers can also wrap an explicit list when they want deterministic delivery order.

Since:
0.5.0 (issue #78)
  • Constructor Details

  • Method Details

    • publish

      public void publish(TnsAIEvent event)
      Description copied from interface: AgentEventPublisher
      Publish a single event. Implementations must be safe to call from any thread; they may queue, batch, or write directly. Errors during publication must not propagate to the caller — log and drop.
      Specified by:
      publish in interface AgentEventPublisher
    • publish

      public void publish(TnsAIEvent event, EventLevel level, EventContext context)
      Description copied from interface: AgentEventPublisher
      Publish a single event with explicit level / context overrides. Useful when emitting an event at a level different from the event's default (e.g. demoting a verbose ChatEvent to DEBUG in production).

      Default implementation ignores overrides — concrete publishers that care about level filtering (Slf4j) override this.

      Specified by:
      publish in interface AgentEventPublisher
    • isEnabled

      public boolean isEnabled(EventLevel level)
      Description copied from interface: AgentEventPublisher
      Should this publisher emit at the given level? Used to short-circuit expensive event construction when the publisher will discard the event anyway.

      Default: always true (no level filtering).

      Specified by:
      isEnabled in interface AgentEventPublisher
    • delegates

      public List<AgentEventPublisher> delegates()
      Returns:
      the list of delegates (immutable).