Skip to content

Empty server and transport fields in Prometheus metrics #1898

@danbarr

Description

@danbarr

Bug description

Starting with v0.2.8, several fields in the Prometheus metrics scraped from the /metrics endpoint or collected via OTel are empty, which were previously populated.

An example:

toolhive_mcp_requests_total{mcp_method="tools/call",method="POST",otel_scope_name="github.com/stacklok/toolhive/pkg/telemetry",otel_scope_schema_url="",otel_scope_version="",server="",status="success",status_code="200",transport=""} 4

The server and transport properties are missing.

Steps to reproduce

Run an MCP server with the Prometheus endpoint enabled:

thv run fetch --otel-enable-prometheus-metrics-path

Perform any MCP action like listing the tools or calling a tool from a client. Then, grab the metrics:

curl http://127.0.0.1:<MCP_PORT>/metrics

Expected behavior

The server and transport fields should be populated in metrics records.

This was an example from v0.2.7:

toolhive_mcp_requests_total{mcp_method="tools/list",method="POST",otel_scope_name="github.com/stacklok/toolhive/pkg/telemetry",otel_scope_schema_url="",otel_scope_version="",server="fetch",status="success",status_code="200",transport="streamable-http"} 2

Actual behavior

But with v0.2.8 and above server and transport values are empty:

toolhive_mcp_requests_total{mcp_method="tools/list",method="POST",otel_scope_name="github.com/stacklok/toolhive/pkg/telemetry",otel_scope_schema_url="",otel_scope_version="",server="",status="success",status_code="200",transport=""} 2

Environment (if relevant)

  • ToolHive version: 0.2.8 and above (noticed with v0.3.0)

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingcliChanges that impact CLI functionality

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions