@@ -79,6 +79,88 @@ Only the environment variables you specify will be included in spans, and
7979they'll appear as attributes with the ` environment. ` prefix (e.g.,
8080` environment.NODE_ENV ` ).
8181
82+ ### Add custom resource attributes
83+
84+ You can add custom metadata to all telemetry signals (traces and metrics) using
85+ custom resource attributes. These attributes are useful for adding context like
86+ team ownership, deployment region, server type, or any other metadata that helps
87+ you filter and query your telemetry data in observability platforms.
88+
89+ Custom attributes are attached globally to all telemetry signals from the MCP
90+ server, making them available for filtering, grouping, and searching in your
91+ observability backend.
92+
93+ #### Using the CLI flag
94+
95+ Use the ` --otel-custom-attributes ` flag to specify custom attributes as
96+ comma-separated key=value pairs:
97+
98+ ``` bash
99+ thv run \
100+ --otel-endpoint api.honeycomb.io \
101+ --otel-headers " x-honeycomb-team=<YOUR_API_KEY>" \
102+ --otel-custom-attributes " server_type=production,region=us-east-1,team=platform" \
103+ fetch
104+ ```
105+
106+ Attribute keys may contain letters, numbers, dots (` . ` ), underscores (` _ ` ), and
107+ hyphens (` - ` ). Spaces and most other punctuation are not allowed in keys.
108+ Attribute values can contain any UTF-8 string, including URLs. For more details,
109+ see the
110+ [ OpenTelemetry Resource Semantic Conventions] ( https://opentelemetry.io/docs/specs/semconv/resource/#attributes ) .
111+
112+ #### Using environment variables
113+
114+ You can also set custom attributes using the standard OpenTelemetry environment
115+ variable ` OTEL_RESOURCE_ATTRIBUTES ` :
116+
117+ ``` bash
118+ export OTEL_RESOURCE_ATTRIBUTES=" deployment.environment=staging,service.namespace=backend"
119+ thv run --otel-endpoint api.honeycomb.io fetch
120+ ```
121+
122+ #### Combining both methods
123+
124+ When using both the CLI flag and environment variable, attributes from both
125+ sources are combined:
126+
127+ ``` bash
128+ export OTEL_RESOURCE_ATTRIBUTES=" deployment.environment=production"
129+ thv run \
130+ --otel-endpoint api.honeycomb.io \
131+ --otel-custom-attributes " region=us-west-2,team=infrastructure" \
132+ fetch
133+ ```
134+
135+ This will add all three attributes to your telemetry data:
136+
137+ - ` deployment.environment=production ` (from environment variable)
138+ - ` region=us-west-2 ` (from CLI flag)
139+ - ` team=infrastructure ` (from CLI flag)
140+
141+ #### Common use cases
142+
143+ Custom attributes are particularly useful for:
144+
145+ - ** Critical context** : Add critical context to telemetry (e.g., service, host,
146+ or environment) so data is meaningful and traceable.
147+ - ** Fast filtering and troubleshooting** : Enable fast filtering, grouping, and
148+ correlation across distributed components during troubleshooting.
149+ - ** Consistent metadata:** Support standardized metadata via OpenTelemetry
150+ semantic conventions for reliable observability across systems.
151+ - ** Root-cause analysis:** Pinpoint which resource is responsible for
152+ performance issues.
153+ - ** Telemetry enrichment:** Enable automatic or manual enrichment using resource
154+ detectors and the OpenTelemetry Collector.
155+
156+ :::tip
157+
158+ Choose attribute names that follow OpenTelemetry semantic conventions when
159+ possible. For example, use ` service.version ` instead of ` app_version ` for better
160+ compatibility with observability tools.
161+
162+ :::
163+
82164### Enable Prometheus metrics
83165
84166You can expose Prometheus-style metrics at ` /metrics ` on the main transport port
@@ -134,6 +216,7 @@ when running an MCP server with the `thv run` command:
134216thv run [--otel-endpoint < URL> ] [--otel-service-name < NAME> ] \
135217 [--otel-metrics-enabled=< true| false> ] [--otel-tracing-enabled=< true| false> ] \
136218 [--otel-sampling-rate < RATE> ] [--otel-headers < KEY= VALUE> ] \
219+ [--otel-custom-attributes < KEY= VALUE> ] [--otel-env-vars < VAR1,VAR2> ] \
137220 [--otel-insecure] [--otel-enable-prometheus-metrics-path] \
138221 < SERVER>
139222```
@@ -146,6 +229,7 @@ thv run [--otel-endpoint <URL>] [--otel-service-name <NAME>] \
146229| ` --otel-service-name ` | Service name for telemetry | ` toolhive-mcp-proxy ` |
147230| ` --otel-sampling-rate ` | Trace sampling rate (0.0-1.0) | ` 0.1 ` (10%) |
148231| ` --otel-headers ` | Authentication headers in ` key=value ` format | None |
232+ | ` --otel-custom-attributes ` | Custom resource attributes in ` key=value ` format | None |
149233| ` --otel-env-vars ` | List of environment variables to include in telemetry spans | None |
150234| ` --otel-insecure ` | Connect using HTTP instead of HTTPS | ` false ` |
151235| ` --otel-enable-prometheus-metrics-path ` | Enable ` /metrics ` endpoint | ` false ` |
0 commit comments