This repository has been archived by the owner on Apr 19, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 99
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 #106 from mailgun/thrawn/develop
Added optional os and golang internal metrics collectors
- Loading branch information
Showing
10 changed files
with
81 additions
and
10 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
# Build image | ||
FROM golang:1.15.4 as build | ||
FROM golang:1.17 as build | ||
|
||
WORKDIR /go/src | ||
|
||
|
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 |
---|---|---|
|
@@ -29,6 +29,13 @@ GUBER_ADVERTISE_ADDRESS=localhost:9990 | |
# If value is zero (default) time is infinity | ||
# GUBER_GRPC_MAX_CONN_AGE_SEC=30 | ||
|
||
# A list of optional prometheus metric collection | ||
# os - collect process metrics | ||
# See https://pkg.go.dev/github.com/prometheus/[email protected]/prometheus/collectors#NewProcessCollector | ||
# golang - collect golang internal metrics | ||
# See https://pkg.go.dev/github.com/prometheus/[email protected]/prometheus/collectors#NewGoCollector | ||
# GUBER_METRIC_FLAGS=os,golang | ||
|
||
|
||
############################ | ||
# Behavior Config | ||
|
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,43 @@ | ||
package gubernator | ||
|
||
import "github.com/sirupsen/logrus" | ||
|
||
const ( | ||
FlagOSMetrics MetricFlags = 1 << iota | ||
FlagGolangMetrics | ||
) | ||
|
||
type MetricFlags int64 | ||
|
||
func (f *MetricFlags) Set(flag MetricFlags, set bool) { | ||
if set { | ||
*f = *f | flag | ||
} else { | ||
mask := *f ^ flag | ||
*f &= mask | ||
} | ||
} | ||
|
||
func (f *MetricFlags) Has(flag MetricFlags) bool { | ||
return *f&flag != 0 | ||
} | ||
|
||
func getEnvMetricFlags(log logrus.FieldLogger, name string) MetricFlags { | ||
flags := getEnvSlice(name) | ||
if len(flags) == 0 { | ||
return 0 | ||
} | ||
var result MetricFlags | ||
|
||
for _, f := range flags { | ||
switch f { | ||
case "os": | ||
result.Set(FlagOSMetrics, true) | ||
case "golang": | ||
result.Set(FlagGolangMetrics, true) | ||
default: | ||
log.Errorf("invalid flag '%s' for '%s' valid options are ['os', 'golang']", f, name) | ||
} | ||
} | ||
return result | ||
} |
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 |
---|---|---|
@@ -1 +1 @@ | ||
1.0.0-rc.8 | ||
2.0.0-rc.7 |