-
Notifications
You must be signed in to change notification settings - Fork 34
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
Add metric description to factory API #61
Conversation
Signed-off-by: Gary Brown <gary@brownuk.com>
Codecov Report
@@ Coverage Diff @@
## master #61 +/- ##
=====================================
Coverage 100% 100%
=====================================
Files 25 25
Lines 694 711 +17
=====================================
+ Hits 694 711 +17
Continue to review full report at Codecov.
|
I just mentioned in #62 - maybe we should consider using structs as arguments instead of explicit args. |
Signed-off-by: Gary Brown <gary@brownuk.com>
160a047
to
72aa500
Compare
@yurishkuro Updated. Let me know if you would prefer different struct names, and whether would prefer no embedded type. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
one other thing (unless I missed it) - the reflection-based initializer should support description
field in the struct tags, so that we can continue init-ing metrics declaratively.
metrics/factory.go
Outdated
@@ -14,22 +14,40 @@ | |||
|
|||
package metrics | |||
|
|||
// MetricScope defines the name and tags map associated with a metric | |||
type MetricScope struct { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is a bit overkill, makes calls to Counter() etc a lot uglier.
metrics/factory.go
Outdated
} | ||
|
||
// MetricInfo defines the information associated with a metric | ||
type MetricInfo struct { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd move Name/Tags here. Also can it be renamed to Options? So that the syntax doesn't stutter:
c := factory.Counter(metrics.Options{Name: .., Description: ...})
…de the Options. Signed-off-by: Gary Brown <gary@brownuk.com>
@yurishkuro Updates applied. Did you mean the reflection here? |
@objectiser one minor thing was nagging at me - maybe we should use the name |
Signed-off-by: Gary Brown <gary@brownuk.com>
@yurishkuro SGTM - updated. |
} | ||
func (nullFactory) Gauge(options Options) Gauge { | ||
return NullGauge | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why multi-line?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Autoformatting by vscode - but seems to accept manually putting it back to single line.
metrics/factory.go
Outdated
@@ -14,22 +14,41 @@ | |||
|
|||
package metrics | |||
|
|||
// Scope defines the name and tags map associated with a metric | |||
type Scope struct { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe something like NSOptions instead? Scope sounds like we’re introducing another concept
Signed-off-by: Gary Brown <gary@brownuk.com>
@yurishkuro Changes applied. |
Nice! |
Resolves #60
Signed-off-by: Gary Brown gary@brownuk.com