-
Notifications
You must be signed in to change notification settings - Fork 481
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
getting custom metrics on prometheus
- Loading branch information
Showing
5 changed files
with
133 additions
and
18 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
package metrics | ||
|
||
import ( | ||
"encoding/json" | ||
|
||
"github.com/topfreegames/pitaya/config" | ||
) | ||
|
||
// Summary ... | ||
type Summary struct { | ||
Subsystem string | ||
Name string | ||
Help string | ||
Objectives map[float64]float64 | ||
Labels []string | ||
} | ||
|
||
// Gauge ... | ||
type Gauge struct { | ||
Subsystem string | ||
Name string | ||
Help string | ||
Labels []string | ||
} | ||
|
||
// Counter ... | ||
type Counter struct { | ||
Subsystem string | ||
Name string | ||
Help string | ||
Labels []string | ||
} | ||
|
||
// CustomMetricsSpec ... | ||
type CustomMetricsSpec struct { | ||
Summaries []*Summary | ||
Gauges []*Gauge | ||
Counters []*Counter | ||
} | ||
|
||
// NewCustomMetricsSpec ... | ||
func NewCustomMetricsSpec(config *config.Config) (*CustomMetricsSpec, error) { | ||
bts, err := json.Marshal(config.Get("pitaya.metrics.custom")) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
var spec CustomMetricsSpec | ||
err = json.Unmarshal(bts, &spec) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
return &spec, nil | ||
} |
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