Skip to content
This repository was archived by the owner on Jun 4, 2026. It is now read-only.

Commit 57ea8f5

Browse files
committed
meta: setup telemetry
1 parent 850365f commit 57ea8f5

3 files changed

Lines changed: 20 additions & 0 deletions

File tree

configs/config.default.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,5 @@ RailMsgSQL:
66
Admin:
77
Bind:
88
Address: ":9696"
9+
Telemetry:
10+
ServiceName: "rail-msg-sql"

pkg/service/environment.go

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,13 @@
33
package service
44

55
import (
6+
"context"
7+
"fmt"
8+
69
"github.com/moov-io/base/log"
710
"github.com/moov-io/base/stime"
11+
"github.com/moov-io/base/telemetry"
12+
railmsgsql "github.com/moov-io/rail-msg-sql"
813

914
"github.com/gorilla/mux"
1015
)
@@ -44,6 +49,16 @@ func NewEnvironment(env *Environment) (*Environment, error) {
4449
env.TimeService = stime.NewSystemTimeService()
4550
}
4651

52+
telemetryShutdownFunc, err := telemetry.SetupTelemetry(context.Background(), env.Config.Telemetry, railmsgsql.Version)
53+
if err != nil {
54+
return env, fmt.Errorf("setting up telemetry failed: %w", err)
55+
}
56+
prev := env.Shutdown
57+
env.Shutdown = func() {
58+
prev()
59+
telemetryShutdownFunc()
60+
}
61+
4762
// router
4863
if env.PublicRouter == nil {
4964
env.PublicRouter = mux.NewRouter()

pkg/service/model_config.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
package service
44

55
import (
6+
"github.com/moov-io/base/telemetry"
67
"github.com/moov-io/rail-msg-sql/internal/search"
78
"github.com/moov-io/rail-msg-sql/internal/storage"
89
)
@@ -13,6 +14,8 @@ type GlobalConfig struct {
1314

1415
// Config defines all the configuration for the app
1516
type Config struct {
17+
Telemetry telemetry.Config
18+
1619
Servers ServerConfig
1720

1821
Search search.Config

0 commit comments

Comments
 (0)