telemetry

package
v0.20.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 16, 2025 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// ServiceName is the service name for MCP Gateway telemetry
	ServiceName = "docker-mcp-gateway"

	// TracerName is the tracer name for MCP Gateway
	TracerName = "github.com/docker/mcp-gateway"

	// MeterName is the meter name for MCP Gateway
	MeterName = "github.com/docker/mcp-gateway"
)

Variables

View Source
var (

	// ToolCallCounter tracks the number of tool calls with server attribution
	ToolCallCounter metric.Int64Counter

	// ToolCallDuration tracks the duration of tool calls in milliseconds
	ToolCallDuration metric.Float64Histogram

	// ToolErrorCounter tracks tool call errors by type and server
	ToolErrorCounter metric.Int64Counter

	// GatewayStartCounter tracks gateway starts
	GatewayStartCounter metric.Int64Counter

	// InitializeCounter tracks initialize calls
	InitializeCounter metric.Int64Counter

	// ListToolsCounter tracks list tools calls
	ListToolsCounter metric.Int64Counter

	// Catalog operation metrics
	CatalogOperationsCounter metric.Int64Counter
	CatalogOperationDuration metric.Float64Histogram
	CatalogServersGauge      metric.Int64Gauge

	// Tool discovery metrics
	ToolsDiscovered metric.Int64Gauge

	// Prompt operation metrics
	PromptGetCounter   metric.Int64Counter
	PromptDuration     metric.Float64Histogram
	PromptErrorCounter metric.Int64Counter
	PromptsDiscovered  metric.Int64Gauge
	ListPromptsCounter metric.Int64Counter

	// Resource operation metrics
	ResourceReadCounter  metric.Int64Counter
	ResourceDuration     metric.Float64Histogram
	ResourceErrorCounter metric.Int64Counter
	ResourcesDiscovered  metric.Int64Gauge
	ListResourcesCounter metric.Int64Counter

	// Resource template operation metrics
	ResourceTemplateReadCounter  metric.Int64Counter
	ResourceTemplateDuration     metric.Float64Histogram
	ResourceTemplateErrorCounter metric.Int64Counter
	ResourceTemplatesDiscovered  metric.Int64Gauge
	ListResourceTemplatesCounter metric.Int64Counter
)

Functions

func Init

func Init()

Init initializes the telemetry package with global providers

func RecordCatalogOperation

func RecordCatalogOperation(ctx context.Context, operation string, catalogName string, durationMs float64, success bool)

RecordCatalogOperation records a catalog operation with duration

func RecordCatalogServers

func RecordCatalogServers(ctx context.Context, catalogName string, serverCount int64)

RecordCatalogServers records the number of servers in catalogs

func RecordGatewayStart

func RecordGatewayStart(ctx context.Context, transportMode string)

RecordGatewayStart records a gateway start event

func RecordInitialize

func RecordInitialize(ctx context.Context, params *mcp.InitializeParams)

func RecordListPrompts

func RecordListPrompts(ctx context.Context, clientName string)

RecordListPrompts records a list prompts call (similar to RecordListTools)

func RecordListResourceTemplates

func RecordListResourceTemplates(ctx context.Context, clientName string)

RecordListResourceTemplates records a list resource templates call

func RecordListResources

func RecordListResources(ctx context.Context, clientName string)

RecordListResources records a list resources call

func RecordListTools

func RecordListTools(ctx context.Context, clientName string)

RecordListTools records a list tools call

func RecordPromptDuration

func RecordPromptDuration(ctx context.Context, promptName string, serverName string, durationMs float64, clientName string)

RecordPromptDuration records the duration of a prompt operation

func RecordPromptError

func RecordPromptError(ctx context.Context, promptName string, serverName string, errorType string)

RecordPromptError records a prompt operation error

func RecordPromptGet

func RecordPromptGet(ctx context.Context, promptName string, serverName string, clientName string)

RecordPromptGet records a prompt get operation

func RecordPromptList

func RecordPromptList(ctx context.Context, serverName string, promptCount int)

RecordPromptList records the number of prompts discovered from a server

func RecordResourceDuration

func RecordResourceDuration(ctx context.Context, resourceURI string, serverName string, durationMs float64, clientName string)

RecordResourceDuration records the duration of a resource operation

func RecordResourceError

func RecordResourceError(ctx context.Context, resourceURI string, serverName string, errorType string)

RecordResourceError records a resource operation error

func RecordResourceList

func RecordResourceList(ctx context.Context, serverName string, resourceCount int)

RecordResourceList records the number of resources discovered from a server

func RecordResourceRead

func RecordResourceRead(ctx context.Context, resourceURI string, serverName string, clientName string)

RecordResourceRead records a resource read operation

func RecordResourceTemplateDuration

func RecordResourceTemplateDuration(ctx context.Context, uriTemplate string, serverName string, durationMs float64, clientName string)

RecordResourceTemplateDuration records the duration of a resource template operation

func RecordResourceTemplateError

func RecordResourceTemplateError(ctx context.Context, uriTemplate string, serverName string, errorType string)

RecordResourceTemplateError records a resource template operation error

func RecordResourceTemplateList

func RecordResourceTemplateList(ctx context.Context, serverName string, templateCount int)

RecordResourceTemplateList records the number of resource templates discovered from a server

func RecordResourceTemplateRead

func RecordResourceTemplateRead(ctx context.Context, uriTemplate string, serverName string, clientName string)

RecordResourceTemplateRead records a resource template read operation

func RecordToolError

func RecordToolError(ctx context.Context, span trace.Span, serverName, serverType, toolName string)

RecordToolError records a tool error with appropriate attributes

func RecordToolList

func RecordToolList(ctx context.Context, serverName string, toolCount int)

RecordToolList records the number of tools discovered from a server

func StartCommandSpan

func StartCommandSpan(ctx context.Context, commandPath string, attrs ...attribute.KeyValue) (context.Context, trace.Span)

StartCommandSpan starts a new span for a command execution

func StartInitializeSpan

func StartInitializeSpan(ctx context.Context, attrs ...attribute.KeyValue) (context.Context, trace.Span)

StartListSpan starts a new span for a list operation (tools, prompts, resources)

func StartInterceptorSpan

func StartInterceptorSpan(ctx context.Context, when, interceptorType string, attrs ...attribute.KeyValue) (context.Context, trace.Span)

StartInterceptorSpan starts a new span for interceptor execution

func StartListSpan

func StartListSpan(ctx context.Context, listType string, attrs ...attribute.KeyValue) (context.Context, trace.Span)

StartListSpan starts a new span for a list operation (tools, prompts, resources)

func StartPromptSpan

func StartPromptSpan(ctx context.Context, promptName string, attrs ...attribute.KeyValue) (context.Context, trace.Span)

StartPromptSpan starts a new span for a prompt operation

func StartResourceSpan

func StartResourceSpan(ctx context.Context, resourceURI string, attrs ...attribute.KeyValue) (context.Context, trace.Span)

StartResourceSpan starts a new span for a resource operation

func StartResourceTemplateSpan

func StartResourceTemplateSpan(ctx context.Context, uriTemplate string, attrs ...attribute.KeyValue) (context.Context, trace.Span)

StartResourceTemplateSpan starts a new span for a resource template operation

func StartToolCallSpan

func StartToolCallSpan(ctx context.Context, toolName string, attrs ...attribute.KeyValue) (context.Context, trace.Span)

StartToolCallSpan starts a new span for a tool call with server attribution

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL