Skip to content

feat: implement wide events with span attributes for observability#195

Merged
cedi merged 10 commits intomainfrom
chore/clean_code
Jan 17, 2026
Merged

feat: implement wide events with span attributes for observability#195
cedi merged 10 commits intomainfrom
chore/clean_code

Conversation

@cedi
Copy link
Member

@cedi cedi commented Jan 16, 2026

Summary

This PR implements the wide events pattern across the codebase, replacing scattered log statements with single structured events that capture all relevant context. The wide event data is also added as span attributes for better tracing correlation.

Changes

  • Wide events in reconciler: KubeOperator.Reconcile now emits a single event at the end with operation details, username, success status, duration, and trace context
  • Wide events in auth middleware: Auth handler accumulates context and emits one event on rejection with reject reason and status code
  • Wide events in server shutdown: Graceful shutdown emits a single event with health/tailscale shutdown status
  • Span attributes: All wide event data is also captured as span attributes for querying in trace backends:
    • reconcile.{name,namespace,username,operation,success,duration_ms}
    • auth.{username,remote_addr,path,success,reject_reason,status_code}
    • login.{username,role,period,status,valid_until}
    • kubeconfig.{username,status,http_status,format}
    • logout.{username,role,was_provisioned,status}
    • shutdown.{health_ok,tailscale_ok}
    • tailnet.{url,dns_name,port,protocol}
  • Error recording: Errors are recorded with span.RecordError() and span.SetStatus(codes.Error, ...)
  • Documentation: Added documentation comments for exported types and functions
  • Bug fixes: Fixed humane error advice preservation in NewErrorResponse, fixed symbol consistency in error rendering

Test plan

  • All existing tests pass
  • Code compiles without errors
  • Verify span attributes appear in trace backend (Jaeger/etc)
  • Verify wide events are queryable in log aggregation

Note

Introduces structured "wide events" and rich span attributes for end-to-end observability, replacing scattered logs and improving trace correlation.

  • Add wide events with span attributes in auth middleware rejections, KubeOperator.Reconcile, and server shutdown; record errors via span.RecordError/SetStatus
  • Enhance API handlers (login, logout, kubeconfig) to set attributes, return clearer errors, and include Retry-After; preserve advice in models.ErrorResponse
  • Make CLI REST client context-aware with a shared http.Client timeout; update commands to pass context and improve user-facing error advice
  • Harden operator/k8s client flows with better wrapping/messages; add docs/comments and small CLI/pretty-print refinements
  • Add architecture/lint tooling (.arch-go.yaml, .golangci-tka.yaml, .golint-sl.yaml), Makefile tasks, and docs updates

Written by Cursor Bugbot for commit 88bf15e. This will update automatically on new commits. Configure here.

@cedi cedi changed the title chore/clean code feat: implement wide events with span attributes for observability Jan 16, 2026
@codecov
Copy link

codecov bot commented Jan 16, 2026

@github-actions github-actions bot added the documentation Improvements or additions to documentation label Jan 16, 2026
cedi added 7 commits January 16, 2026 20:22
- Add advice strings to humane.Wrap/humane.New calls for better error messages
- Add context to bare error returns with fmt.Errorf wrapping
- Add nolint comments for intentional panic() in flag binding code
- Replace panic with log.Error in o11y shutdown cleanup
- Add fmt import where needed for error wrapping

Reduces linter violations from 514 to 422 (18% improvement)
- Add more advice strings to humane.Wrap/humane.New calls
- Fix operator.go, serve.go, and related files

Further reduces linter violations.
- Add actionable advice to spinner/async operation errors
- Add advice to kubeconfig serialization errors
- Add advice to config file operations
- Add advice to shell cleanup errors

Further reduces linter violations from 366 to 351.
@cedi
Copy link
Member Author

cedi commented Jan 17, 2026

bugbot run

Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Bugbot Autofix is OFF. To automatically fix reported issues with Cloud Agents, enable Autofix in the Cursor dashboard.

This PR is being reviewed by Cursor Bugbot

Details

You are on the Bugbot Free tier. On this plan, Bugbot will review limited PRs each billing cycle.

To receive Bugbot reviews on all of your PRs, visit the Cursor dashboard to activate Pro and start your 14-day free trial.

Copy link
Member Author

cedi commented Jan 17, 2026

This stack of pull requests is managed by Graphite. Learn more about stacking.

@graphite-app
Copy link

graphite-app bot commented Jan 17, 2026

Graphite Automations

"Auto-assign PRs to author" took an action on this PR • (01/17/26)

1 assignee was added to this PR based on Cedric Specht's automation.

"Request reviewers once CI passes" took an action on this PR • (01/17/26)

1 reviewer was added to this PR based on Cedric Specht's automation.

@cedi cedi merged commit a909d6a into main Jan 17, 2026
22 checks passed
@cedi cedi deleted the chore/clean_code branch January 17, 2026 01:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant