Skip to content

test(beego): add middleware unit tests#28

Merged
muktaa merged 3 commits intomainfrom
feat/beego-with-tests
Mar 30, 2026
Merged

test(beego): add middleware unit tests#28
muktaa merged 3 commits intomainfrom
feat/beego-with-tests

Conversation

@prathamesh-sonpatki
Copy link
Copy Markdown
Member

Summary

  • Rebases Beego instrumentation onto current main
  • Adds 13 unit tests covering the Middleware() function

Tests cover

  • Span is created for each request
  • Span name format: METHOD /path
  • HTTP attributes: http.request.method, url.path, server.address
  • Response status code attribute (http.response.status_code)
  • 5xx responses mark span as Error; 4xx and 2xx do not
  • SpanKind is Server
  • Incoming W3C traceparent header creates a child span with matching trace ID
  • Requests with no incoming context produce a root span
  • Downstream next handler receives the request context containing the active span

Test plan

  • go test ./instrumentation/beego/... — all 13 tests pass
  • golangci-lint run ./instrumentation/beego/... — clean

🤖 Generated with Claude Code

karthikeyangs9 and others added 3 commits March 29, 2026 19:07
Cover span creation, naming, HTTP attributes, status code recording,
5xx/4xx error status, W3C trace context propagation, and span context
injection into the downstream request context.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- Hoist trace.WithSpanKind(Server) to construction time (removes per-request closure alloc)
- Inline opts slice directly into tracer.Start
- Replace fmt.Sprintf span name with string concat
- Remove what-comments in hot path (kept route-pattern limitation comment)
- Collapse 4 status-code tests into one table-driven test

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@muktaa muktaa self-requested a review March 30, 2026 00:31
@muktaa muktaa merged commit 32b1658 into main Mar 30, 2026
10 checks passed
@prathamesh-sonpatki prathamesh-sonpatki deleted the feat/beego-with-tests branch April 7, 2026 10:04
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.

3 participants