Skip to content

Comments

Deprecate otel plugin: route tagging is now built into the Goa muxer#242

Merged
raphael merged 1 commit intov3from
fix/deprecate-otel-plugin
Feb 16, 2026
Merged

Deprecate otel plugin: route tagging is now built into the Goa muxer#242
raphael merged 1 commit intov3from
fix/deprecate-otel-plugin

Conversation

@raphael
Copy link
Member

@raphael raphael commented Feb 16, 2026

Summary

  • The otel plugin's Generate function is now a no-op — it returns files unchanged
  • Package and function are marked Deprecated with clear migration instructions
  • Golden files and tests updated to reflect the passthrough behavior
  • README rewritten with deprecation notice and background context

Context

otelhttp.WithRouteTag was removed in otelhttp v0.65.0. The replacement is r.Pattern (Go 1.22+), which otelhttp now reads automatically.

The companion change in goadesign/goa updates the default HTTP muxer to set r.Pattern = "METHOD /path" on every dispatched request, making the plugin unnecessary. This approach:

  • Covers all handlers uniformly (including file servers, which the plugin never covered)
  • Eliminates fragile template string surgery
  • Has zero dependency on any otelhttp API

Migration

Remove the blank import from design packages and regenerate:

- import _ "goa.design/plugins/v3/otel"

Fixes #241

Test plan

  • go test ./otel/ passes — golden files match unmodified handler output
  • assert.Same verifies Generate returns the input slice unchanged

The Goa HTTP muxer now sets r.Pattern on every dispatched request
(using the Go 1.22+ convention), which otelhttp v0.65.0+ reads
automatically to tag spans and metrics with the matched route.

This makes the otel plugin unnecessary — its Generate function is now
a no-op. The package is marked Deprecated with migration instructions
to simply remove the blank import.

Fixes #241
@raphael raphael merged commit 4ad247e into v3 Feb 16, 2026
5 checks passed
@raphael raphael deleted the fix/deprecate-otel-plugin branch February 16, 2026 19:13
raphael added a commit to goadesign/goa that referenced this pull request Feb 16, 2026
The default HTTP muxer now populates r.Pattern with "METHOD /path" on
every matched request, following the Go 1.22+ convention established by
http.ServeMux. This enables observability middleware such as otelhttp
(v0.65.0+) to automatically tag spans and metrics with the matched
route without any per-handler wrapping.

The pattern is captured before chi's internal wildcard rewriting, so
r.Pattern always reflects the original Goa route (e.g. GET /users/{id},
GET /files/{*path}).

This replaces the need for the otel plugin in goa.design/plugins which
has been deprecated (goadesign/plugins#242).

Fixes #3896
raphael added a commit to goadesign/goa that referenced this pull request Feb 16, 2026
#3897)

The default HTTP muxer now populates r.Pattern with "METHOD /path" on
every matched request, following the Go 1.22+ convention established by
http.ServeMux. This enables observability middleware such as otelhttp
(v0.65.0+) to automatically tag spans and metrics with the matched
route without any per-handler wrapping.

The pattern is captured before chi's internal wildcard rewriting, so
r.Pattern always reflects the original Goa route (e.g. GET /users/{id},
GET /files/{*path}).

This replaces the need for the otel plugin in goa.design/plugins which
has been deprecated (goadesign/plugins#242).

Fixes #3896
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[otel] - otelhttp.WithRouteTag() has been removed from opentelemetry-go-contrib

1 participant