Skip to content

Implement cache with asynchronous command execution #44

@cmeissner

Description

@cmeissner

Is your feature request related to a problem? Please describe.
If you want to create an exporter that rely on a long running command to create a metric it can happen that a scrape from prometheus runs into a timeout.

Describe the solution you'd like
A good solution can be that we use a cache for such commands. So the following will happen:

  1. prometheus will scrape a metric
  2. exporter will start the long running command (asynchronous, in background sth. else)
  3. exporter will deliver a default value until the command does not fill up the cache with a real value (e.g. a negativ value or status unknown)
  4. the command runs in background and the collected value will stored in cache once it has finished
  5. prometheus will scrape again and get the cached value
  6. the exporter check if there is already a background command running. If there is already a command running it won't start a new one. If there is no background job running it starts the command
  7. the cache will always updated if there is no command running

Describe alternatives you've considered
Trying to work with asyncio already in combination with async_lru(see #41) but this does not really work because the long running command will still block the exporter. The command will not really do stuff in background.

Additional context

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requesthelp wantedExtra attention is needed

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions