mirror of
https://github.com/grafana/grafana.git
synced 2026-07-29 15:59:50 -05:00
K8s: Refactor metrics to share k8s registry (#79106)
This commit is contained in:
@@ -5,22 +5,23 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/grafana/grafana/pkg/extensions"
|
||||
"github.com/grafana/grafana/pkg/infra/metrics"
|
||||
"github.com/grafana/grafana/pkg/setting"
|
||||
)
|
||||
|
||||
func setBuildInfo(opts ServerOptions) {
|
||||
func getBuildstamp(opts ServerOptions) int64 {
|
||||
buildstampInt64, err := strconv.ParseInt(opts.BuildStamp, 10, 64)
|
||||
if err != nil || buildstampInt64 == 0 {
|
||||
buildstampInt64 = time.Now().Unix()
|
||||
}
|
||||
return buildstampInt64
|
||||
}
|
||||
|
||||
func setBuildInfo(opts ServerOptions) {
|
||||
setting.BuildVersion = opts.Version
|
||||
setting.BuildCommit = opts.Commit
|
||||
setting.EnterpriseBuildCommit = opts.EnterpriseCommit
|
||||
setting.BuildStamp = buildstampInt64
|
||||
setting.BuildStamp = getBuildstamp(opts)
|
||||
setting.BuildBranch = opts.BuildBranch
|
||||
setting.IsEnterprise = extensions.IsEnterprise
|
||||
setting.Packaging = validPackaging(Packaging)
|
||||
|
||||
metrics.SetBuildInformation(opts.Version, opts.Commit, opts.BuildBranch, buildstampInt64)
|
||||
}
|
||||
|
||||
@@ -16,6 +16,7 @@ import (
|
||||
"github.com/grafana/grafana/pkg/api"
|
||||
gcli "github.com/grafana/grafana/pkg/cmd/grafana-cli/commands"
|
||||
"github.com/grafana/grafana/pkg/infra/log"
|
||||
"github.com/grafana/grafana/pkg/infra/metrics"
|
||||
"github.com/grafana/grafana/pkg/infra/process"
|
||||
"github.com/grafana/grafana/pkg/server"
|
||||
_ "github.com/grafana/grafana/pkg/services/alerting/conditions"
|
||||
@@ -111,6 +112,8 @@ func RunServer(opts ServerOptions) error {
|
||||
return err
|
||||
}
|
||||
|
||||
metrics.SetBuildInformation(metrics.ProvideRegisterer(cfg), opts.Version, opts.Commit, opts.BuildBranch, getBuildstamp(opts))
|
||||
|
||||
s, err := server.Initialize(
|
||||
cfg,
|
||||
server.Options{
|
||||
|
||||
@@ -11,6 +11,7 @@ import (
|
||||
|
||||
"github.com/grafana/grafana/pkg/api"
|
||||
"github.com/grafana/grafana/pkg/infra/log"
|
||||
"github.com/grafana/grafana/pkg/infra/metrics"
|
||||
"github.com/grafana/grafana/pkg/server"
|
||||
"github.com/grafana/grafana/pkg/setting"
|
||||
)
|
||||
@@ -88,6 +89,8 @@ func RunTargetServer(opts ServerOptions) error {
|
||||
return err
|
||||
}
|
||||
|
||||
metrics.SetBuildInformation(metrics.ProvideRegisterer(cfg), opts.Version, opts.Commit, opts.BuildBranch, getBuildstamp(opts))
|
||||
|
||||
s, err := server.InitializeModuleServer(
|
||||
cfg,
|
||||
server.Options{
|
||||
|
||||
Reference in New Issue
Block a user