Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create metrics from transform builder context #90

Open
cuttingl opened this issue Jan 24, 2025 · 0 comments
Open

Create metrics from transform builder context #90

cuttingl opened this issue Jan 24, 2025 · 0 comments
Labels
A:core area: Alumet core library D:hard difficulty: hard (complex design or lengthy implementation) P:low priority: low = do this after the rest T:api-improvement type: request to improve the API of Alumet

Comments

@cuttingl
Copy link
Contributor

cuttingl commented Jan 24, 2025

In alumet's current state, creating metrics after getting them is impossible.

For example, if we have a list of n-metrics but don't have their names, we would need to get them inside the transform build context first and then create them.

alumet.add_transform_builder(move |ctx| {
            let name = ctx.transform_name("attribution_transform");

            let consumed_energy_metric = ctx
                .metric_by_name(&consumed_energy)
                .with_context(|| format!("Metric not found : {}", consumed_energy))?
                .0;

            let hardware_usage_metric = ctx
                .metric_by_name(&hardware_usage)
                .with_context(|| format!("Metric not found {}", hardware_usage))?
                .0;

            let metrics = Metrics {
                pod_attributed_energy: attribution_energy_metric,
                consumed_energy: consumed_energy_metric,
                hardware_usage: hardware_usage_metric,
            };

            let transform = Box::new(EnergyAttributionTransform::new(metrics));
            Ok(TransformRegistration { name, transform })
        });
@cuttingl cuttingl added A:app-agent area: runnable agent application D:hard difficulty: hard (complex design or lengthy implementation) P:low priority: low = do this after the rest T:ux type: Enhancement of the user experience labels Jan 24, 2025
@TheElectronWill TheElectronWill added A:core area: Alumet core library T:api-improvement type: request to improve the API of Alumet and removed T:ux type: Enhancement of the user experience A:app-agent area: runnable agent application labels Jan 24, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A:core area: Alumet core library D:hard difficulty: hard (complex design or lengthy implementation) P:low priority: low = do this after the rest T:api-improvement type: request to improve the API of Alumet
Projects
None yet
Development

No branches or pull requests

2 participants