Skip to content

P2: Shared packages — Prometheus metric leak, event listener panic risk, status code bug #689

Closed

Description

@agbishop

Summary

pkgs/lockmetrics — Metric Leak

  • Prometheus metrics never unregistered: Each RWMutex creates metrics; Close() only removes from tracking map. Long-running apps with dynamic resources leak thousands of metric instances.
  • WithLabelValues() hot-loop overhead: Hash lookup on every lock/unlock.

pkgs/handler — Status Code Bug

  • ResponseWriter: statusCode initialized to 200, making the if statusCode == 0 check in Write() dead code.

pkgs/events — Listener Panic Risk

  • No panic recovery: If a listener panics, the entire Emit() crashes.
  • Inefficient unsubscribe: removeByID uses append([:i], [i+1:]...).

Files

  • pkgs/lockmetrics/lockmetrics.go
  • pkgs/handler/response_writer.go
  • pkgs/events/emitter.go

Activity

  1. agbishop commented on Mar 15, 2026

    @agbishop
    CollaboratorAuthor

    copilot-autodev: agent task created for issue #689 (initial invoke).

  2. agbishop commented on Mar 15, 2026

    @agbishop
    CollaboratorAuthor

    copilot-autodev: Tracking PR #702 for this issue.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions