Skip to content

Enable Objective details to be loaded from environment variables #115

@emschwartz

Description

@emschwartz

A number of people have described use cases where the details of an SLO may be different for different instances of the same service. For example, a service that has specific instances for each geographical region, where each has its own SLO.

The main thing we would need to change in order to support this would be to make the Objective details use Strings instead of &'static strs and the methods would need to be non-const (this would be a breaking change). Then, you'd be able to define an objective like this:

use std::{env, cell::LazyCell};

static OBJECTIVE: LazyCell<Objective> = LazyCell::new(|| {
    Objective::new(env::var("OBJECTIVE_NAME").unwrap())
        .success_rate(env::var("OBJECTIVE_PERCENTILE").unwrap())
});

We could potentially add helper functions for loading the values from environment variables, or we could just show how to do this in the docs.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions