Class LoggedAspect
Logged.
This is a proxy-based Spring AOP aspect, not a full AspectJ weaving
aspect. As a consequence, it only intercepts calls made from outside the
proxied bean: a method calling another @Logged method on
this bypasses the proxy and is not intercepted. This is a known
limitation of Spring AOP and must be documented for library consumers.
For every intercepted call, this aspect always records an invocation
metric through MetricsRecorder, regardless of sampling or
threshold settings, so that dashboards and alerts remain accurate.
Whether a MethodInvocationEvent is additionally emitted through
InvocationEventEmitter is decided by EmissionPolicy: a
call is emitted when it failed, exceeded its configured slow threshold,
or was selected by random sampling. This ensures that failures and slow
calls are never silently dropped by a low sample rate, while still
reducing log volume for fast, high-traffic, successful calls.
This aspect maintains a call-chain position for nested @Logged
calls on the same thread through FlowContextHolder, so that log
output can be reconstructed as a call chain and a failure can be traced
back to exactly where in that chain it occurred.
A failure inside MetricsRecorder.record(java.lang.String, java.lang.String, long, boolean, java.lang.String) or
InvocationEventEmitter.emit(com.fayupable.logged.core.model.MethodInvocationEvent), whether from a bundled implementation
or a custom one supplied by the consuming application, is caught and
logged rather than allowed to propagate. Without this, a misbehaving
observability collaborator could replace the intercepted method's own
exception in a finally block, hiding the real failure behind an
unrelated one from this library's own bookkeeping.
-
Constructor Summary
ConstructorsConstructorDescriptionLoggedAspect(InvocationEventEmitter eventEmitter, MetricsRecorder metricsRecorder, IClientInfoPort clientInfoPort) -
Method Summary
Modifier and TypeMethodDescriptionlogInvocation(org.aspectj.lang.ProceedingJoinPoint pjp, Logged logged) Intercepts aLogged-annotated method call, measuring its duration and outcome, and delegating the emission decision and call-chain tracking to their respective collaborators.
-
Constructor Details
-
LoggedAspect
public LoggedAspect(InvocationEventEmitter eventEmitter, MetricsRecorder metricsRecorder, IClientInfoPort clientInfoPort)
-
-
Method Details