Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor/reduce marshaling complexity #12

Conversation

bernerdschaefer
Copy link
Contributor

  • Drop AsMarshallable() from the Metric interface. Use
    json.Marshaler and MarshalJSON(), and leverage JSON struct tags
    where possible.
  • Add MarshalJSON() to Registry and remove dumpToWriter, which
    makes the registry handler much simpler.
  • Some general cleanup.

In addition to simplifying some of the marshalling behavior, this also
has the nice side effect of cutting down the number of
map[string]interface{} instances.

}

type counterVector struct {
labels map[string]string
value float64
Labels map[string]string `json:"labels"`
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suppose these need to be publicized for encoding/json?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. Though, of course, they're only exposed within the package since the type is not exported.

@matttproud
Copy link
Member

👍 overall. Merge at your convenience.

* Drop `AsMarshallable()` from the Metric interface. Use
  `json.Marshaler` and `MarshalJSON()`, and leverage JSON struct tags
  where possible.

* Add `MarshalJSON()` to Registry and remove `dumpToWriter`, which
  makes the registry handler much simpler.

In addition to simplifying some of the marshalling behavior, this also
has the nice side effect of cutting down the number of
`map[string]interface{}` instances.
bernerdschaefer added a commit that referenced this pull request Apr 19, 2013
…plexity

Refactor/reduce marshaling complexity
@bernerdschaefer bernerdschaefer merged commit 04c7f7b into refactor/user-experience/standardized-directories Apr 19, 2013
@bernerdschaefer bernerdschaefer deleted the refactor/reduce-marshaling-complexity branch April 19, 2013 13:12
@matttproud
Copy link
Member

Hey @bernerdschaefer, can you quickly validate that

  1. NaN
  2. +inf
  3. -inf

are properly serialized for consumption? IIRC, that had been a motivation for self-encoding. There is—may be closed—bug against the Go JSON serialized for these.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants