Jump to content

Connect SuperML | Leeroopedia MCP: Equip your AI agents with best practices, code verification, and debugging knowledge. Powered by Leeroo — building Organizational Superintelligence. Contact us at founders@leeroo.com.

Implementation:Risingwavelabs Risingwave TracingSlf4jAdapter

From Leeroopedia
Revision as of 16:33, 16 February 2026 by Admin (talk | contribs) (Auto-imported from implementations/Risingwavelabs_Risingwave_TracingSlf4jAdapter.md)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)


Property Value
Component Connector Node - Tracing
Language Java
Lines 85
License Apache 2.0
Ported From tracing-slf4j
Repository risingwavelabs/risingwave

Overview

TracingSlf4jAdapter is an SLF4J logger adapter that bridges Java logging calls to RisingWave's native Rust tracing infrastructure via JNI. It extends SLF4J's LegacyAbstractLogger to intercept all standard log level calls (TRACE, DEBUG, INFO, WARN, ERROR) and routes them through TracingSlf4jImpl, which in turn calls the Rust tracing system through the JNI binding layer.

Log messages are formatted using Log4j's ParameterizedMessage to support the {} placeholder syntax commonly used in SLF4J logging. When a Throwable is present, its full stack trace is extracted using ExceptionUtils.getStackTrace() and included in the trace event.

This class is part of the tracing module that enables unified observability across RisingWave's Java connector code and its Rust core engine.

Code Reference

Source Location

java/connector-node/tracing/src/main/java/com/risingwave/tracing/TracingSlf4jAdapter.java

View on GitHub

Signature

public class TracingSlf4jAdapter extends LegacyAbstractLogger

Key Methods

// Constructor accepting the logger name
public TracingSlf4jAdapter(String name)

// Level-check methods delegating to TracingSlf4jImpl.isEnabled()
@Override public boolean isTraceEnabled()
@Override public boolean isDebugEnabled()
@Override public boolean isInfoEnabled()
@Override public boolean isWarnEnabled()
@Override public boolean isErrorEnabled()

// Returns null (caller name not tracked)
@Override protected String getFullyQualifiedCallerName()

// Core logging method: formats message and delegates to TracingSlf4jImpl.event()
@Override
protected void handleNormalizedLoggingCall(
        Level level, Marker marker, String messagePattern,
        Object[] arguments, Throwable throwable)

Imports

import org.apache.commons.lang3.exception.ExceptionUtils;
import org.apache.logging.log4j.message.ParameterizedMessage;
import org.slf4j.Marker;
import org.slf4j.event.Level;
import org.slf4j.helpers.LegacyAbstractLogger;

I/O Contract

Input

  • name (String): The logger name, typically the fully qualified class name of the caller.
  • level (Level): The SLF4J log level (TRACE, DEBUG, INFO, WARN, ERROR).
  • marker (Marker): An SLF4J marker (not used in the current implementation).
  • messagePattern (String): The log message pattern with {} placeholders.
  • arguments (Object[]): Arguments to substitute into the message pattern.
  • throwable (Throwable): An optional exception associated with the log event.

Output

  • Trace event: Emitted through TracingSlf4jImpl.event(), which forwards the formatted message, logger name, level, and optional stack trace to the Rust tracing system via JNI.

Side Effects

  • JNI call: Each log event triggers a JNI call to the Rust tracing infrastructure through TracingSlf4jImpl.event().

Usage Examples

Standard SLF4J Logging (Transparent to Callers)

// The adapter is instantiated by the SLF4J service provider (TracingSlf4jServiceProvider)
Logger logger = LoggerFactory.getLogger(MyClass.class);

// These calls are transparently routed to Rust tracing
logger.info("Processing record {}", recordId);
logger.error("Failed to process record", exception);
logger.debug("Offset state: partition={}, offset={}", partition, offset);

Message Formatting

// Messages use Log4j ParameterizedMessage formatting
// "{}" placeholders are replaced with argument values
logger.info("Connected to {} on port {}", hostname, port);
// -> "Connected to db-host on port 5432"

Related Pages

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment