Class TracingInterceptor

java.lang.Object
com.loomcache.server.tracing.TracingInterceptor

public class TracingInterceptor extends Object
Intercepts cache protocol messages and instruments them with distributed tracing.

Responsibilities

- Create a root span for each incoming request - Extract and restore parent trace context from the message - Record span attributes: operation type, key, cache name, node role - Measure operation latency and record status - Record exceptions and errors - Automatically propagate trace context to downstream operations - Close span on response

Attributes Recorded

- http.method: operation type (GET, PUT, DELETE, etc.) - messaging.system: "loomcache" (fixed) - messaging.destination: cache name (map, queue, topic) - rpc.method: operation type - rpc.service: service name - client.address: client connection address - client.socket.address: client IP - network.peer.address: peer address - db.operation: operation type - db.cache_size: current cache size - error: true if operation failed - otel.status_code: OK, ERROR, or UNSET

Events Recorded

- operation_started: when message is received - operation_completed: when response is ready - operation_failed: when an exception occurs

Usage

TracingInterceptor interceptor = new TracingInterceptor(nodeId, instanceNumber);
Message request = Message.request(MessageType.MAP_GET)...;
Message response = interceptor.intercept(request, connectionContext);
Since:
1.0
  • Constructor Details

    • TracingInterceptor

      public TracingInterceptor(String nodeId, int instanceNumber)
      Create a new TracingInterceptor.
      Parameters:
      nodeId - the node ID
      instanceNumber - the instance number
  • Method Details

    • intercept

      public Message intercept(Message message, ConnectionContext connectionContext, TracingInterceptor.MessageHandler handler)
      Intercept an incoming message and trace it. This method should be called by MessageHandler implementations to wrap the actual message handling with tracing instrumentation.
      Parameters:
      message - the incoming message
      connectionContext - the connection context
      handler - the actual message handler to call
      Returns:
      the response message (may be null)