mirror of
https://github.com/zitadel/zitadel.git
synced 2025-08-11 21:47:32 +00:00
fix: Make service name configurable for Metrics and Tracing (#9563)
# Which Problems Are Solved
The service name is hardcoded in the metrics code. Making the service
name to be configurable helps when running multiple instances of
Zitadel.
The defaults remain unchanged, the service name will be defaulted to
ZITADEL.
# How the Problems Are Solved
Add a config option to override the name in defaults.yaml and pass it
down to the corresponding metrics or tracing module (google or otel)
# Additional Changes
NA
# Additional Context
NA
(cherry picked from commit dc64e35128
)
This commit is contained in:

committed by
Livio Spring

parent
3f329e8459
commit
113a4ed817
@@ -9,13 +9,15 @@ import (
|
||||
)
|
||||
|
||||
type Config struct {
|
||||
ProjectID string
|
||||
Fraction float64
|
||||
ProjectID string
|
||||
Fraction float64
|
||||
ServiceName string
|
||||
}
|
||||
|
||||
func NewTracer(rawConfig map[string]interface{}) (err error) {
|
||||
c := new(Config)
|
||||
c.ProjectID, _ = rawConfig["projectid"].(string)
|
||||
c.ServiceName, _ = rawConfig["servicename"].(string)
|
||||
c.Fraction, err = otel.FractionFromConfig(rawConfig["fraction"])
|
||||
if err != nil {
|
||||
return err
|
||||
@@ -34,6 +36,6 @@ func (c *Config) NewTracer() error {
|
||||
return err
|
||||
}
|
||||
|
||||
tracing.T, err = otel.NewTracer(sampler, exporter)
|
||||
tracing.T, err = otel.NewTracer(sampler, exporter, c.ServiceName)
|
||||
return err
|
||||
}
|
||||
|
@@ -9,12 +9,14 @@ import (
|
||||
)
|
||||
|
||||
type Config struct {
|
||||
Fraction float64
|
||||
Fraction float64
|
||||
ServiceName string
|
||||
}
|
||||
|
||||
func NewTracer(rawConfig map[string]interface{}) (err error) {
|
||||
c := new(Config)
|
||||
c.Fraction, err = otel.FractionFromConfig(rawConfig["fraction"])
|
||||
c.ServiceName, _ = rawConfig["servicename"].(string)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -32,6 +34,6 @@ func (c *Config) NewTracer() error {
|
||||
return err
|
||||
}
|
||||
|
||||
tracing.T, err = otel.NewTracer(sampler, exporter)
|
||||
tracing.T, err = otel.NewTracer(sampler, exporter, c.ServiceName)
|
||||
return err
|
||||
}
|
||||
|
@@ -13,13 +13,15 @@ import (
|
||||
)
|
||||
|
||||
type Config struct {
|
||||
Fraction float64
|
||||
Endpoint string
|
||||
Fraction float64
|
||||
Endpoint string
|
||||
ServiceName string
|
||||
}
|
||||
|
||||
func NewTracerFromConfig(rawConfig map[string]interface{}) (err error) {
|
||||
c := new(Config)
|
||||
c.Endpoint, _ = rawConfig["endpoint"].(string)
|
||||
c.ServiceName, _ = rawConfig["servicename"].(string)
|
||||
c.Fraction, err = FractionFromConfig(rawConfig["fraction"])
|
||||
if err != nil {
|
||||
return err
|
||||
@@ -54,7 +56,7 @@ func (c *Config) NewTracer() error {
|
||||
return err
|
||||
}
|
||||
|
||||
tracing.T, err = NewTracer(sampler, exporter)
|
||||
tracing.T, err = NewTracer(sampler, exporter, c.ServiceName)
|
||||
return err
|
||||
}
|
||||
|
||||
|
@@ -18,8 +18,8 @@ type Tracer struct {
|
||||
sampler sdk_trace.Sampler
|
||||
}
|
||||
|
||||
func NewTracer(sampler sdk_trace.Sampler, exporter sdk_trace.SpanExporter) (*Tracer, error) {
|
||||
resource, err := otel_resource.ResourceWithService()
|
||||
func NewTracer(sampler sdk_trace.Sampler, exporter sdk_trace.SpanExporter, serviceName string) (*Tracer, error) {
|
||||
resource, err := otel_resource.ResourceWithService(serviceName)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
Reference in New Issue
Block a user