Class Slf4jCollector
- All Implemented Interfaces:
Collector
project/module/area/system,
so the bound provider (for example Logback) decides levels and output. The one-off tags of an event also go to SLF4J
as key-value pairs, for structured output. FATAL goes to SLF4J error.
Thresholds follow the SLF4J logger configuration at the time of Collectors.refresh(). Alerts are logged only
when the state of a metric changes, to the logger of its project/module/area/system: CRITICAL to
error, WARNING to warn, SILENCE as heavy as Alert.silence(), a return to
OK to info. Health checks likewise, when the state of a check changes: CRITICAL to
error and WARNING to warn with the message and the exception, a return to OK to
info.
Events of sdk/"slf4j" came from the SLF4J provider — KubFlyAppender imports the
logs of the application — so the bridge neither logs them back nor widens their levels: each line is printed once,
and nothing loops.
Found by ServiceLoader with this module; a bridge — the first collector — only
when SLF4J is bound to a provider other than KubFly (Logback); without one (the NOP provider) it wants nothing.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidalert(long id, long begin, long end, Metric metric, Severity severity, long warnings, long criticals, long unassessed) Logs the alert state of a metric when it changes (the firstOKis not a change).voidLogs the begin of a frame atTRACE.booleanbridge()A bridge while a foreign provider is bound.booleanenabled()On only with a provider of SLF4J other than KubFly itself: without one there is nobody to print to.voidend(long id, long time, long duration, long threadId, String threadName, Frame frame, Throwable exception) Logs the end of a frame atTRACE: the duration, and the exception on a failure.voidevent(long id, long time, long threadId, String threadName, Frame frame, Event event, String message, ArgumentKind kind1, long bits1, Object ref1, ArgumentKind kind2, long bits2, Object ref2, Throwable exception) Receives one event.voidfinish(long id, long time, Environment environment) Writes the finish of the process, as anINFOline of the SLF4J loggersdk/api/environment, with the largest number given — if the SLF4J provider still writes at the shutdown of the JVM.booleanFrames are logged atTRACEwhen it is enabled for the logger of the scope.voidhealth(long id, long time, long duration, HealthCheck check, Health health) Logs a health check when its state changes, to the logger of itsproject/module/area/system.voidSLF4J has no metrics: this bridge ignores them.voidNot logged: the profiles are not events of the application.voidstart(long id, long time, Environment environment) Writes the start of the process, as anINFOline of the SLF4J loggersdk/api/environment, with the environment: where and on what the application runs belongs to ordinary logs as well.The most verbose level this collector wants from aproject/module/area/systempath (Level.INFO— info and everything more severe).voidNot logged: the links are not events of the application.voidSLF4J has no place for usage snapshots: this bridge ignores them.
-
Field Details
-
IMPORTED
The module of events imported from the SLF4J provider,sdk/slf4j/<package>/<class>(decision 90): the bridge skips them.- See Also:
-
-
Constructor Details
-
Slf4jCollector
public Slf4jCollector()Creates the bridge.
-
-
Method Details
-
enabled
-
bridge
-
frames
Frames are logged atTRACEwhen it is enabled for the logger of the scope.- Specified by:
framesin interfaceCollector- Parameters:
project- the first level of the scope pathmodule- the second path level: a module of the build of the projectarea- the third levelsystem- the fourth levelcomponent- the fifth level- Returns:
- whether
TRACEis enabled forproject/module/area/system
-
threshold
The most verbose level this collector wants from aproject/module/area/systempath (Level.INFO— info and everything more severe). Asked when aKubFlyof the path is first created and afterCollectors.refresh(). -
start
Writes the start of the process, as anINFOline of the SLF4J loggersdk/api/environment, with the environment: where and on what the application runs belongs to ordinary logs as well. -
begin
-
event
public void event(long id, long time, long threadId, String threadName, Frame frame, Event event, String message, ArgumentKind kind1, long bits1, Object ref1, ArgumentKind kind2, long bits2, Object ref2, Throwable exception) Receives one event.Called synchronously on the application thread that logs — including millions of virtual threads — only when this collector's
Collector.threshold(String, String, String, String)lets the level through: the implementation must be thread-safe, must not block and should not allocate. The message is a template, never formatted on the way here; arguments arrive as raw values without boxing — a primitive inbits, a reference inref, its kind inkind.id,timeandframeare the same for all collectors.References are valid only during the call. After it returns, the application may change the objects it passed — the data of a
Blobor anImageis not copied on the way. A collector that stores the event later (in another thread, after a buffer switch) must copy what it needs before returning.- Specified by:
eventin interfaceCollector- Parameters:
id- the event number: unique within the JVM process, the same for all collectors; it grows in call order within a thread, not dense, no order across threads within one millisecondtime- the event time (System.currentTimeMillis()), the same for all collectorsthreadId- the thread that logs (Thread.threadId()), the same for all collectorsthreadName- the name of the thread (Thread.getName();""— a thread without a name, as a virtual thread by default)frame- the frame of the runningScope(tags, call tree) ornulloutside any scopeevent- the event (project/module/area/systempath, level and its one-off tags); the identity of the call site isEvent.gate()andEvent.level()— a tagged event is a new instance per call, so a collector keys its own per-site data by them, not by this reference; a tag of the event shadows a tag of the frame with the same keymessage- the message template with up to two{}placeholderskind1- the kind of the first argument (ArgumentKind.NONE— no argument)bits1- the first argument if it is a primitive (ArgumentKind), otherwise 0ref1- the first argument if it is a reference, otherwisenullkind2- the kind of the second argumentbits2- the second argument if it is a primitive, otherwise 0ref2- the second argument if it is a reference, otherwisenullexception- the event exception ornull
-
end
public void end(long id, long time, long duration, long threadId, String threadName, Frame frame, Throwable exception) Logs the end of a frame atTRACE: the duration, and the exception on a failure.- Specified by:
endin interfaceCollector- Parameters:
id- the number of the endtime- the end timeduration- the duration in nanosecondsthreadId- the thread (Thread.threadId())threadName- the name of the thread (Thread.getName())frame- the frameexception- the exception ornull
-
usage
-
metrics
-
alert
public void alert(long id, long begin, long end, Metric metric, Severity severity, long warnings, long criticals, long unassessed) Logs the alert state of a metric when it changes (the firstOKis not a change).- Specified by:
alertin interfaceCollector- Parameters:
id- the number of the alertbegin- the beginning of the intervalend- the interval endmetric- the metricseverity- the statewarnings- the observations beyond a warning thresholdcriticals- the observations beyond a critical thresholdunassessed- the observations that could not be assessed
-
traffic
Not logged: the links are not events of the application. -
profile
-
health
Logs a health check when its state changes, to the logger of itsproject/module/area/system. -
finish
Writes the finish of the process, as anINFOline of the SLF4J loggersdk/api/environment, with the largest number given — if the SLF4J provider still writes at the shutdown of the JVM.
-