elastic / elastic/logstash

MetricType decoration to be consumed by the web api

Open
#4,629 0 comments 0 reactions 0 assignees View on GitHub
code cleanup enhancement monitoring
Dominant language
Java
Stars
14.9k
Forks
3.5k
Avg merge
1d 4h
Merged PRs (30d)
88

Description

Hi,
in the current branch for the metrics feature, there is a mechanism to provide only the relevant data to the webapi, while delivering all the metrics fields to the store. This is archived by something like

``` ruby
def to_hash
{
"namespaces" => namespaces,
"key" => key,
"type" => type,
"value" => value
}
end

def to_json_data
value
end
```

And then using JSON serialization to provide all necessary fields for the web api. This is doing it's work, but is an obscure method to select only relevant data.

I propose we introduce a decorator that transform this class by only providing the relevant data (aka minimal data). This will allow us remove the usage of `to_json_data` method, only required by jrjackson and allow us to have a more clever code to understand in the long run.

Contributor guide

Open the contributing guide

Research direction

Start by reading the MetricType serialization methods shown in the issue, especially to_hash and to_json_data, and review how JSON serialization and jrjackson consume them. Determine the decorator's scope and how removing to_json_data would preserve the web API's minimal data while still exposing all metrics fields to the store.

Written by the indexing model from the issue text.

Assessment

Tech stack
ruby
Domain
api
Issue type
Refactor
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.