OpenTelemetry Instrumentation Extension
Skill1.6k starsChanged 11 months agoMITView on GitHub
Extend OpenTelemetry instrumentation when new functionality is added to the MCP Gateway. Use when (1) new operations/functions are added, (2) reviewing code for missing instrumentation, (3) user requests otel/telemetry additions, or (4) working with state-changing operations. Analyzes git diff, suggests instrumentation points following project standards in docs/telemetry/README.md, implements with approval, writes tests, updates documentation, and verifies with debug logging and docker logs.
Trending
Quiet since October.about the whole repository
Who's talking about docker/mcp-gateway
- orbstack/orbstack“Docker MCP Gateway”GitHub · Jul 21, 2025 · 96 reactions
- @github-trending.bsky.social“📦 docker / mcp-gateway ⭐ 372 (+23) 🗒 Go docker mcp CLI plugin / MCP Gateway”Bluesky · Sep 14, 2025 · 12 likes
- openclaw/openclaw“Feature Request: MCP (Model Context Protocol) Client Support”GitHub · Feb 3, 2026 · 3 reactions
- A Hacker News story“Mcp-gateway, central auth and config manager for mcp servers”Hacker News · Jul 10, 2025 · 3 points
- ARUNAGIRINATHAN-K/awesome-ai-agents-2026“🔗 Broken links detected”GitHub · May 3, 2026 · 1 reactions
The biggest 5 of 19 mentions linking to the repository that our crawl found. Each line is their own headline.
See all 19
Talked about on GitHub, Hacker News and Bluesky (19 times).
On GitHub · 17
- Jul 21, 2025Docker MCP Gateway — orbstack/orbstack96 reactions · 1 comment
- Feb 3, 2026Feature Request: MCP (Model Context Protocol) Client Support — openclaw/openclaw3 reactions · 2 comments
- May 3, 2026🔗 Broken links detected — ARUNAGIRINATHAN-K/awesome-ai-agents-20261 reaction
- Jul 6, 2025MCP Tools are not getting loaded from Docker MCP tool kit — docker/for-win1 reaction · 12 comments
- Oct 3, 2026agent-skills.github.docker.mcp-gateway: 0.43.3 → 0.44.1 — sudosubin/agents.nix0 reactions
12 more on GitHub
- Sep 26, 2026agent-skills.github.docker.mcp-gateway: init at 0.43.3 — sudosubin/agents.nix0 reactions
- Aug 22, 2026[Deep Dive] MCP 开发连接的热重载与生命周期 Supervisor — Kingminghuang/OpportunityRadar0 reactions
- Aug 6, 2026research(mcp): evaluate docker/mcp-gateway against fak — anthony-chaudhary/fak0 reactions
- Jun 25, 2026x/vulndb: potential Go vuln in github.com/docker/mcp-gateway: GHSA-r2xf-7jw5-pjg6 — golang/vulndb0 reactions · 1 comment
- Jun 6, 2026content(mcp): add Docker MCP Gateway — JSONbored/awesome-claude0 reactions · 3 comments
- Apr 15, 2026chore(deps): update dependency docker/mcp-gateway to v0.41.0 — killo431/tools0 reactions
- Feb 18, 2026[Review] Remove JFS references + secrets engine injection — govambam/mcp-gateway0 reactions · 1 comment
- Feb 13, 2026build(deps): bump github.com/docker/mcp-gateway from 0.22.0 to 0.28.0 in the go_modules group across 1 directory — Takuya-Miyazaki/docker.github.io0 reactions
- Feb 12, 2026Docker MCP Toolkit support — schmitthub/clawker0 reactions
- Dec 8, 2025BUG: Telemetry middleware crashes with nil pointer dereference on all transports (stdio, SSE, streaming) — jcowhigjr/yelp_search_demo0 reactions · 97 comments
- Sep 26, 2025mcp gateway error — k33g/bob-agent0 reactions
- Jul 15, 2025Doc: Request for all parameter supported by catalog.yaml — docker/mcp-registry0 reactions
On Hacker News · 1
- Jul 10, 2025Mcp-gateway, central auth and config manager for mcp servers3 points · 2 comments
On Bluesky · 1
- Sep 14, 2025📦 docker / mcp-gateway ⭐ 372 (+23) 🗒 Go docker mcp CLI plugin / MCP Gateway — @github-trending.bsky.social12 likes and reposts
In this repositoryOne other file it gives its agents.
- CLAUDE.mdCLAUDE.md
The file
Show its rules and text
We split this skill into the rules it gives an agent
25 rules. About 0 are common, 13 are distinctive, and 12 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈13
Distinctive · estimate
This author's own choices. Worth a look.
12
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 24
Read docs/telemetry/README.md "Development Guidelines" section
- Very specific: line 25
Read pkg/telemetry/telemetry.go to understand existing patterns and metrics
- Very specific: line 48
Write tests: Add tests to pkg/telemetry/telemetry_test.go
- Very specific: line 49
Update docs: Add metrics/operations to docs/telemetry/README.md
- Very specific: line 51
Final verification: Run ./docs/telemetry/testing/test-telemetry.sh
- Very specific: line 55
Follow the project's documented guidelines from docs/telemetry/README.md:
- Very specific: line 60
Debug Support: Add logging behind DOCKER_MCP_TELEMETRY_DEBUG
- Very specific: line 61
Follow Naming Conventions: Use mcp.<domain>.<field> pattern
- Distinctive: line 62
Deferred Success Tracking: Only set success on clean completion
- Very specific: line 86
Use the simple defer pattern from cmd/docker-mcp/catalog/create.go:
- Very specific: line 113
When instrumentation is needed for a new domain (e.g., new package pkg/newdomain/):
- Very specific: line 149
After the Init() function, add recording functions:
- Distinctive: line 179
Add test cases following existing patterns:
- Distinctive: line 228
Add a new section for the domain in the appropriate location.
- Distinctive: line 246
After making changes, verify telemetry output:
- Distinctive: line 270
Verify the output matches expectations before proceeding to write tests and docs.
- Distinctive: line 274
When analyzing git diff:
- Distinctive: line 277
Create, Add, Update, Modify, Set, Configure, Register
- Distinctive: line 278
Delete, Remove, Unregister, Clear
- Distinctive: line 280
Start, Stop, Run, Execute
- Very specific: line 295
Search pkg/telemetry/telemetry.go for Record<Domain> functions
- Distinctive: line 296
If exists: use existing metrics
- Distinctive: line 297
If not: propose new domain metrics
- Distinctive: line 316
Ask for approval before implementing
- Distinctive: line 317
Verify early and often with collector logs
≈ “Common” is an estimate: at least 1 in 5 of the 213,897 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
OpenTelemetry Instrumentation Extension
Automatically extend OpenTelemetry instrumentation for new functionality in the MCP Gateway, following established patterns documented in docs/telemetry/README.md.
When to Use This Skill
Automatically apply when:
- New state-changing operations added (Create, Update, Delete, Push, Pull, Add, Remove, etc.)
- New CLI commands added to
cmd/docker-mcp/ - New packages with operations in
pkg/ - User mentions "otel", "telemetry", "instrumentation", "metrics", or "tracing"
- Code changes that modify state (database, files, containers, configuration)
- Reviewing code for telemetry coverage
Workflow
Phase 1: Analysis & Suggestion
- Read project telemetry standards:
- Read
docs/telemetry/README.md"Development Guidelines" section - Read
pkg/telemetry/telemetry.goto understand existing patterns and metrics
- Read
- Identify scope using git diff:
- Find new/changed files in
pkg/andcmd/docker-mcp/ - Identify functions performing state-changing operations
- Infer domain from package structure (e.g.,
pkg/foo/→ domain:foo)
- Find new/changed files in
- Categorize findings:
- Operations in existing domains (use existing metrics)
- Operations in new domains (need new metrics)
- Present suggestions to user:
- List each function needing instrumentation with file:line reference
- Specify operation type (create, update, delete, etc.)
- Identify domain and whether metrics exist
- Show what will be added (instrumentation code, metrics, docs, tests)
Phase 2: Implementation (After User Approval)
Execute in this order:
- Make changes: Instrument operations and add metrics to
pkg/telemetry/telemetry.go - Verify: Build, run with OTEL collector, check
docker logs otel-debugoutput - Write tests: Add tests to
pkg/telemetry/telemetry_test.go - Update docs: Add metrics/operations to
docs/telemetry/README.md - Run tests: Execute
make test - Final verification: Run
./docs/telemetry/testing/test-telemetry.sh
Key Principles
Follow the project's documented guidelines from docs/telemetry/README.md:
- Use Existing Providers: Get global tracer/meter from OTEL
- Preserve Server Lineage: Include server attribution in all telemetry
- Non-Blocking Operations: Telemetry never blocks or fails operations
- Debug Support: Add logging behind
DOCKER_MCP_TELEMETRY_DEBUG - Follow Naming Conventions: Use
mcp.<domain>.<field>pattern - Deferred Success Tracking: Only set success on clean completion
Where to Find Information
ALWAYS read these files before suggesting changes:
docs/telemetry/README.md- Source of truth for:- Development guidelines (lines 419-474)
- Existing metrics and attributes
- Testing procedures
- Naming conventions
pkg/telemetry/telemetry.go- Understand:- Existing metric instruments
- Recording function patterns
- Helper functions for spans
- Init() structure
pkg/telemetry/telemetry_test.go- See:- Testing patterns
- How to verify metrics
Instrumentation Pattern
Use the simple defer pattern from cmd/docker-mcp/catalog/create.go:
func OperationName(ctx context.Context, identifier string, ...) error {
telemetry.Init()
start := time.Now()
var success bool
defer func() {
duration := time.Since(start)
telemetry.Record<Domain>Operation(ctx, "operation_name", identifier,
float64(duration.Milliseconds()), success)
}()
// ... operation logic ...
// Optional: Record resource counts
telemetry.Record<Domain><Resources>(ctx, identifier, int64(count))
success = true
return nil
}Note: If identifier is generated during execution, the defer captures its final value.
Adding New Domains
When instrumentation is needed for a new domain (e.g., new package pkg/newdomain/):
1. Add Metric Instruments in pkg/telemetry/telemetry.go
In the Init() function, add global variables and create metric instruments:
var (
// ... existing metrics ...
// New domain metrics
newdomainOperations metric.Int64Counter
newdomainOperationDuration metric.Float64Histogram
newdomainResources metric.Int64Gauge // If managing resources
)
func Init() {
// ... existing init code ...
newdomainOperations, _ = meter.Int64Counter(
"mcp.newdomain.operations",
metric.WithDescription("New domain operations count"),
)
newdomainOperationDuration, _ = meter.Float64Histogram(
"mcp.newdomain.operation.duration",
metric.WithDescription("New domain operation duration in milliseconds"),
)
newdomainResources, _ = meter.Int64Gauge(
"mcp.newdomain.resources",
metric.WithDescription("Number of resources in new domain"),
)
}2. Add Recording Functions in pkg/telemetry/telemetry.go
After the Init() function, add recording functions:
func RecordNewdomainOperation(ctx context.Context, operation, identifier string, durationMs float64, success bool) {
if newdomainOperations == nil || newdomainOperationDuration == nil {
return
}
attrs := []attribute.KeyValue{
attribute.String("mcp.newdomain.operation", operation),
attribute.String("mcp.newdomain.id", identifier), // or .name, .ref as appropriate
attribute.Bool("mcp.newdomain.success", success),
}
newdomainOperations.Add(ctx, 1, metric.WithAttributes(attrs...))
newdomainOperationDuration.Record(ctx, durationMs, metric.WithAttributes(attrs...))
}
// Optional: Add resource counting function if applicable
func RecordNewdomainResources(ctx context.Context, identifier string, count int64) {
if newdomainResources == nil {
return
}
attrs := []attribute.KeyValue{
attribute.String("mcp.newdomain.id", identifier),
}
newdomainResources.Record(ctx, count, metric.WithAttributes(attrs...))
}3. Write Tests in pkg/telemetry/telemetry_test.go
Add test cases following existing patterns:
func TestRecordNewdomainOperation(t *testing.T) {
spanRecorder, metricReader := setupTestTelemetry(t)
Init()
ctx := context.Background()
// Test successful operation
RecordNewdomainOperation(ctx, "create", "test-id", 123.45, true)
// Collect and verify metrics
var rm metricdata.ResourceMetrics
err := metricReader.Collect(ctx, &rm)
require.NoError(t, err)
// Find and verify the counter metric
foundCounter := false
foundHistogram := false
for _, sm := range rm.ScopeMetrics {
for _, m := range sm.Metrics {
if m.Name == "mcp.newdomain.operations" {
foundCounter = true
sum := m.Data.(metricdata.Sum[int64])
require.Len(t, sum.DataPoints, 1)
assert.Equal(t, int64(1), sum.DataPoints[0].Value)
// Verify attributes
attrs := sum.DataPoints[0].Attributes
assert.Contains(t, attrs.ToSlice(), attribute.String("mcp.newdomain.operation", "create"))
assert.Contains(t, attrs.ToSlice(), attribute.String("mcp.newdomain.id", "test-id"))
assert.Contains(t, attrs.ToSlice(), attribute.Bool("mcp.newdomain.success", true))
}
if m.Name == "mcp.newdomain.operation.duration" {
foundHistogram = true
histogram := m.Data.(metricdata.Histogram[float64])
require.Len(t, histogram.DataPoints, 1)
assert.Equal(t, float64(123.45), histogram.DataPoints[0].Sum)
}
}
}
assert.True(t, foundCounter, "Counter metric not found")
assert.True(t, foundHistogram, "Histogram metric not found")
}4. Update Documentation in docs/telemetry/README.md
Add a new section for the domain in the appropriate location. Follow the existing format:
### New Domain Operations
Operations for managing [description of what this domain does]:
- **`mcp.newdomain.operations`** - New domain operations (create, update, delete, etc.)
- **`mcp.newdomain.operation.duration`** - Duration of new domain operations
- **`mcp.newdomain.resources`** - Gauge showing number of resources in new domain
#### New Domain Attributes
- **`mcp.newdomain.operation`** - Type of operation (create, update, delete, etc.)
- **`mcp.newdomain.id`** - ID of the resource
- **`mcp.newdomain.success`** - Boolean indicating operation successVerification
After making changes, verify telemetry output:
# Build
make docker-mcp
# Start OTEL collector
docker run --rm -d --name otel-debug \
-p 4317:4317 -p 4318:4318 \
-v $(pwd)/docs/telemetry/testing/otel-collector-config.yaml:/config.yaml \
otel/opentelemetry-collector:latest --config=/config.yaml
# Run with telemetry enabled
export DOCKER_MCP_TELEMETRY_DEBUG=1
export DOCKER_CLI_OTEL_EXPORTER_OTLP_ENDPOINT=http://localhost:4317
docker mcp [command]
# Check collector output
docker logs otel-debug | grep "mcp.newdomain"
# Cleanup
docker stop otel-debugVerify the output matches expectations before proceeding to write tests and docs.
Analysis Strategy
When analyzing git diff:
- Look for operation verbs in function names:
- Create, Add, Update, Modify, Set, Configure, Register
- Delete, Remove, Unregister, Clear
- Push, Pull, Export, Import, Sync
- Start, Stop, Run, Execute
- Look for state changes:
- Database operations (DAO/DB calls)
- File system operations (create, delete, write)
- Container operations (start, stop, create, delete)
- Configuration changes (save, update)
- Infer domain from file path:
pkg/workingset/→ domain:profilepkg/catalog_next/→ domain:catalog_nextcmd/docker-mcp/server/→ domain:server- Pattern: use logical grouping name
- Check if telemetry exists:
- Search
pkg/telemetry/telemetry.goforRecord<Domain>functions - If exists: use existing metrics
- If not: propose new domain metrics
- Search
Implementation Checklist
Follow this sequence:
- Read patterns from
docs/telemetry/README.md - Instrument operations with simple defer pattern
- Add new metrics to
pkg/telemetry/telemetry.go(if new domain) - Verify with
docker logs otel-debug- confirm output matches expectations - Write tests in
pkg/telemetry/telemetry_test.go - Update
docs/telemetry/README.mdwith new metrics - Run
make test- verify tests pass - Run
./docs/telemetry/testing/test-telemetry.sh- final verification
Important Notes
- Read documentation first
- Follow existing patterns
- Ask for approval before implementing
- Verify early and often with collector logs
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

