Package com.tnsai.mcp.observability
Interface McpTracer
- All Known Implementing Classes:
LoggingMcpTracer,NoopMcpTracer
public interface McpTracer
Abstraction for creating tracing spans in MCP operations.
Provides a pluggable tracing interface that decouples the MCP module from any specific tracing implementation. Users can choose:
noop()- Zero-overhead no-op tracer for production without tracinglogging()- SLF4J-based tracer that logs span lifecycle events- Custom implementation backed by OpenTelemetry, Zipkin, etc.
Example usage:
// No-op tracer (zero overhead)
McpTracer tracer = McpTracer.noop();
// Logging tracer (for development/debugging)
McpTracer tracer = McpTracer.logging();
// Use with TracingMcpClient
TracingMcpClient tracingClient = new TracingMcpClient(client, tracer);
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionstatic McpTracerlogging()Returns a logging tracer that records span events via SLF4J.static McpTracernoop()Returns a no-op tracer that performs no work and has zero overhead.Starts a new root span with the given operation name.Starts a new child span with the given operation name and parent.
-
Method Details
-
startSpan
Starts a new root span with the given operation name.- Parameters:
operationName- the name of the operation being traced- Returns:
- a new span that must be ended via
McpSpan.end()
-
startSpan
Starts a new child span with the given operation name and parent.- Parameters:
operationName- the name of the operation being tracedparent- the parent span- Returns:
- a new child span that must be ended via
McpSpan.end()
-
noop
Returns a no-op tracer that performs no work and has zero overhead.- Returns:
- the singleton no-op tracer instance
-
logging
Returns a logging tracer that records span events via SLF4J.- Returns:
- a new logging tracer instance
-