-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1209 from j75689/metrics/build-info
metrics: add build info into metrics server
- Loading branch information
Showing
10 changed files
with
173 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
package metrics | ||
|
||
import "encoding/json" | ||
|
||
// Label hold an map[string]interface{} value that can be set arbitrarily. | ||
type Label interface { | ||
Value() map[string]interface{} | ||
String() string | ||
Mark(map[string]interface{}) | ||
} | ||
|
||
// NewRegisteredLabel constructs and registers a new StandardLabel. | ||
func NewRegisteredLabel(name string, r Registry) Label { | ||
c := NewStandardLabel() | ||
if nil == r { | ||
r = DefaultRegistry | ||
} | ||
r.Register(name, c) | ||
return c | ||
} | ||
|
||
// NewStandardLabel constructs a new StandardLabel. | ||
func NewStandardLabel() *StandardLabel { | ||
return &StandardLabel{} | ||
} | ||
|
||
// StandardLabel is the standard implementation of a Label. | ||
type StandardLabel struct { | ||
value map[string]interface{} | ||
jsonStr string | ||
} | ||
|
||
// Value returns label values. | ||
func (l *StandardLabel) Value() map[string]interface{} { | ||
return l.value | ||
} | ||
|
||
// Mark records the label. | ||
func (l *StandardLabel) Mark(value map[string]interface{}) { | ||
buf, _ := json.Marshal(value) | ||
l.jsonStr = string(buf) | ||
l.value = value | ||
} | ||
|
||
// String returns label by JSON format. | ||
func (l *StandardLabel) String() string { | ||
return l.jsonStr | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters