8000 Could the `LabelGroup` derive re-use the user-defined struct? · Issue #3 · conradludgate/measured · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
Could the LabelGroup derive re-use the user-defined struct? #3
Open
@clux

Description

@clux

This is mostly an ergonomics request more than anything.

Current

rather than creating a struct, which derives a second hidden struct:

#[derive(LabelGroup)]
#[label(set = ErrorLabelSet)]
pub struct ErrorLabels<'a> {
    #[label(dynamic_with = lasso::ThreadedRodeo, default)]
    instance: &'a str,
    #[label(dynamic_with = lasso::ThreadedRodeo, default)]
    error: &'a str,
}

and force user to refer to hidden struct ErrorLabelSet in #[metric] attrs and types ala CounterVec<ErrorLabelSet>

Proposed

is it possible to do some magic to have a hidden associated type internally so that we can just:

#[derive(LabelGroup)]
pub struct ErrorLabels<'a> {
    #[label(dynamic_with = lasso::ThreadedRodeo, default)]
    instance: &'a str,
    #[label(dynamic_with = lasso::ThreadedRodeo, default)]
    error: &'a str,
}

and refer to the user created ErrorLabels in #[metric] attributes and CounterVec<ErrorLabels>?

Hypocritical ask, because I commit the same sin myself in kube-derive, but I am painfully aware of how many people trip up on this (and it was my biggest stumbling block in measured because the errors all look so similar i start feeling dyslexic).

How

I don't know. Create the raw data type under the hood, and refer to by an associated type internally maybe?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0