elastic / elastic/logstash

Create helpers for plugin author to test their metric implementation.

Open
#5,546 0 comments 0 reactions 0 assignees View on GitHub
tests tests-infra
Dominant language
Java
Stars
14.9k
Forks
3.5k
Avg merge
19h 14m
Merged PRs (30d)
63

Description

Currently the plugin author can start recording metrics in their plugin by invoking the `plugin#metric` command with a specific action. The problem is there is no easy way to test if their metrics is correctly recorded. We should provide an easy way to test for that specific behavior without having to a complete pipeline run.
## Required assertions
- Test for key existence
- Test for keys hierarchies
- Test for metric type
- Test for value
## Things to consider and/or investigate
- Allow to use a preconfigured metric instance only for testing instead of using the `NullMetric`
- Implement rspec helpers to make assertions easier.
- I don't think we need a complete `MetricStore` to make sure if their metrics is correctly saved, this is part of an integration test that we already have, a collector spy that only implement the `#push` method might be easier to deal with for the assertions.

When I've developed the `Metric` library I've created a (simple helper)[https://github.com/elastic/logstash/blob/master/logstash-core/spec/support/matchers.rb#L5] and use a simple array for the test, I think we could improve the usage.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.