Documentation
¶
Index ¶
- func RoundTripper(tripper http.RoundTripper, m *ClientMetrics, clientName string) http.RoundTripper
- func ToolHandler[I, O any](toolName string, metrics *ToolMetrics, handler mcp.ToolHandlerFor[I, O]) mcp.ToolHandlerFor[I, O]
- func ToolHandlerUntyped(toolName string, metrics *ToolMetrics, handler mcp.ToolHandler) mcp.ToolHandler
- type ClientMetrics
- type Middleware
- type ToolMetrics
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func RoundTripper ¶
func RoundTripper(tripper http.RoundTripper, m *ClientMetrics, clientName string) http.RoundTripper
RoundTripper instruments the given roundtripper with metrics that are registered in the provided ClientMetrics. The clientName parameter is used to set the 'client' label on all metrics.
func ToolHandler ¶
func ToolHandler[I, O any]( toolName string, metrics *ToolMetrics, handler mcp.ToolHandlerFor[I, O], ) mcp.ToolHandlerFor[I, O]
ToolHandler wraps an MCP tool handler with metrics instrumentation. It records call counts, durations, and error details for each tool invocation.
func ToolHandlerUntyped ¶
func ToolHandlerUntyped( toolName string, metrics *ToolMetrics, handler mcp.ToolHandler, ) mcp.ToolHandler
ToolHandlerUntyped wraps an untyped MCP tool handler with metrics instrumentation. This is the equivalent of InstrumentToolHandler for handlers that use the base mcp.ToolHandler type (i.e., those registered via the api.Toolset interface) rather than the generic mcp.ToolHandlerFor[I, O].
Types ¶
type ClientMetrics ¶
type ClientMetrics struct {
// contains filtered or unexported fields
}
ClientMetrics holds a collection of metrics that can be used to instrument a http client. By setting this field in HTTPClientConfig, NewHTTPClient will create an instrumented client.
func NewClientMetrics ¶
func NewClientMetrics(reg prometheus.Registerer) *ClientMetrics
NewClientMetrics creates a new instance of ClientMetrics. It will also register the metrics with the included register. The metrics include a 'client' label to distinguish between different client types.
type Middleware ¶
type Middleware interface {
// NewHandler wraps the given HTTP handler for instrumentation.
NewHandler(handlerName string, handler http.Handler) http.HandlerFunc
}
Middleware holds necessary metrics to instrument an http.Server and provides necessary behaviors.
func NewMiddleware ¶
func NewMiddleware(reg prometheus.Registerer, buckets []float64) Middleware
NewMiddleware provides default Middleware. Passing nil as buckets uses the default buckets.
func NewNopMiddleware ¶
func NewNopMiddleware() Middleware
NewNopMiddleware provides a Middleware which does nothing.
type ToolMetrics ¶
type ToolMetrics struct {
// contains filtered or unexported fields
}
ToolMetrics holds Prometheus metrics for MCP tool invocations.
func NewToolMetrics ¶
func NewToolMetrics(reg prometheus.Registerer) *ToolMetrics
NewToolMetrics creates and registers new tool metrics with the provided registry.