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

v2 metrics #167

Draft
wants to merge 8 commits into
base: v2
Choose a base branch
from
Draft

v2 metrics #167

wants to merge 8 commits into from

Conversation

lavoiesl
Copy link
Contributor

@lavoiesl lavoiesl commented Feb 7, 2023

Significant refactor of the statsd package.

Design principles / Motivation

Backends' features to add prefix, tags, and context extraction should be composable, allowing users to pick and choose what they want from the library.

New features

  1. Is it now possible to set a context-specific backend by using ContextWithBackend. If it is not specified, the default backend is still honoured.

Breaking changes

  1. NewLogBackend is replaced with NewLogrusBackend to better reflect its implementation
    2.NewLogBackend and NewDatadogBackend no longer have built-in tags extraction from Context, prefix, and default tags. Instead, users should call BackendWithDefaultWrappers or wrap them manually.
  2. The signature of the forwarding handler has changed to use a Metric struct to simplify implementations
  3. A MockBackend has replaced the mocks.Backend
  4. The statsd package was renamed to metrics, to better reflect that it is not statsd specific.
  5. The Timer metric now uses the Timing function and the redundant Timing metric has been removed.
  6. The Backend signature has changed to receive Tags maps instead of string slices. String slices are now only created when calling the underlying statsd client.

Minor changes

  1. Move goose's metric declarations to individual packages, to avoid cross-package dependencies.
  2. logError now reports an error instead of a warning when failing to emit a metric.
  3. Tags now has helper methods to merge with other tags and generate a slice of strings.

// Set counts the number of unique elements in a group.
Set(ctx context.Context, name string, value string, tags Tags, rate float64) error
// Timing sends timing information, it is an alias for TimeInMilliseconds
Timing(ctx context.Context, name string, value time.Duration, tags Tags, rate float64) error
Copy link

Choose a reason for hiding this comment

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

Are we keeping this?

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, Timing is used by the Timer metric.

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