Skip to content

Consider the interplay between metrics expiration and handles. #314

Open
@tobz

Description

@tobz

Chatting with a user about the idle timeout support in metrics-exporter-prometheus made me realize that there's one particular -- maybe fatal? -- flaw with the handle-based design: orphaned metrics.

Consider a normal invocation of counter!("key", 1):

  • we acquire a handle to a counter identified by "key"
  • we update that handle

As is, with the handle-based design, that handle is wrapping an Arc<T>, but we query the handle right before modifying it. Either the metric already exists, or it doesn't -- either because it's brand-new or because it was previously expired and removed from the registry -- but we always get a valid handle as of the time of the call to the registry.

Now, consider when we take a handle to a metric via register_counter!(...). The steps to do so are nearly identical to before, specifically in that we query the registry, and the handle is either found if it exists, or is created if it doesn't... but then we never query for it again. If the metric is removed from the registry, the underlying storage may live on (Arc<T>) but it is disconnected from the registry where it originated.

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-coreComponent: core functionality such as traits, etc.C-utilComponent: utility classes and helpers.E-complexEffort: complex.T-ergonomicsType: ergonomics.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions