Skip to content

Commit

Permalink
Set up metrics on service start (fixes #251) (#262)
Browse files Browse the repository at this point in the history
Signed-off-by: Lazaros Tsigkakos <[email protected]>
  • Loading branch information
Lazaros-Tsigkakos authored and mantzas committed Jan 9, 2019
1 parent 07da69e commit 5ea220f
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 9 deletions.
2 changes: 1 addition & 1 deletion cmd/patron/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ var (
func main() {
name := "{{name}}"
err := patron.SetupLogging(name, version)
err := patron.Setup(name, version)
if err != nil {
fmt.Printf("failed to set up logging: %v", err)
os.Exit(1)
Expand Down
2 changes: 1 addition & 1 deletion examples/first/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ func main() {
name := "first"
version := "1.0.0"

err := patron.SetupLogging(name, version)
err := patron.Setup(name, version)
if err != nil {
fmt.Printf("failed to set up logging: %v", err)
os.Exit(1)
Expand Down
2 changes: 1 addition & 1 deletion examples/fourth/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ func main() {
name := "fourth"
version := "1.0.0"

err := patron.SetupLogging(name, version)
err := patron.Setup(name, version)
if err != nil {
fmt.Printf("failed to set up logging: %v", err)
os.Exit(1)
Expand Down
2 changes: 1 addition & 1 deletion examples/second/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ func main() {
name := "second"
version := "1.0.0"

err := patron.SetupLogging(name, version)
err := patron.Setup(name, version)
if err != nil {
fmt.Printf("failed to set up logging: %v", err)
os.Exit(1)
Expand Down
2 changes: 1 addition & 1 deletion examples/third/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ func main() {
name := "third"
version := "1.0.0"

err := patron.SetupLogging(name, version)
err := patron.Setup(name, version)
if err != nil {
fmt.Printf("failed to set up logging: %v", err)
os.Exit(1)
Expand Down
9 changes: 5 additions & 4 deletions service.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,11 @@ func New(name, version string, oo ...OptionFunc) (*Service, error) {

s := Service{cps: []Component{}, hcf: http.DefaultHealthCheck, termSig: make(chan os.Signal, 1)}

err := SetupLogging(name, version)
err := Setup(name, version)
if err != nil {
return nil, err
}

metric.Setup(name)
err = s.setupDefaultTracing(name, version)
if err != nil {
return nil, err
Expand Down Expand Up @@ -129,8 +128,10 @@ func (s *Service) Run() error {
return errors.Aggregate(ee...)
}

// SetupLogging set's up default logging.
func SetupLogging(name, version string) error {
// Setup set's up metrics and default logging.
func Setup(name, version string) error {
metric.Setup(name)

lvl, ok := os.LookupEnv("PATRON_LOG_LEVEL")
if !ok {
lvl = string(log.InfoLevel)
Expand Down

0 comments on commit 5ea220f

Please sign in to comment.