rcrowley / go-metrics

Go port of Coda Hale's Metrics library
Other
3.43k stars 493 forks source link

Make WriteJSON similar to JSON structure of dropwizard metrics #204

Closed vjsamuel closed 6 years ago

vjsamuel commented 7 years ago

Dropwizard HTTP servlet based metrics follows the structure:

{
  counters: {
    metric_name: {
       value: 10
  }
}

This PR tries to replicate the same structure.

vjsamuel commented 6 years ago

@rcrowley can you please take a look at this?

mihasya commented 6 years ago

This looks like it changes the output of MarshalJSON. There's no way we can merge something like that at this juncture - we have no idea what code is out there that relies on this. If you need an alternative representation, please see #216 - after the method name is updated and the PR is merged, you can use the GetAll method and write your own marshaller that doesn't break backwards compatibility.

vjsamuel commented 6 years ago

@mihasya: I assumed that this is a Go port of Dropwizard metrics. If it were so I would also assume that response payloads should look a like. That was what this PR was for.

mihasya commented 6 years ago

Let me know if the new Registry.GetAll method that just got merged gives you enough flexibility to write your own output/reporter that better suits your needs. I suppose it's a port more in spirit than in exact implementation :)