Add autoconfiguration for OTEL and resolve TODOs for metrics

This commit is contained in:
ErickSkrauch
2024-03-05 15:14:10 +01:00
parent 7964281f06
commit b9a38dd947
11 changed files with 180 additions and 120 deletions

View File

@@ -33,23 +33,25 @@ func startServer(modules ...string) error {
return err
}
shutdownOtel, err := otel.SetupOTelSDK(globalCtx)
defer func() {
err := shutdownOtel(context.Background())
if err != nil {
slog.Error("Unable to shutdown OpenTelemetry", slog.Any("error", err))
}
}()
if err != nil {
return err
}
var config *viper.Viper
err = container.Resolve(&config)
if err != nil {
return err
}
if !config.GetBool("otel.sdk.disabled") {
shutdownOtel, err := otel.SetupOTelSDK(globalCtx)
defer func() {
err := shutdownOtel(context.Background())
if err != nil {
slog.Error("Unable to shutdown OpenTelemetry", slog.Any("error", err))
}
}()
if err != nil {
return err
}
}
config.Set("modules", modules)
err = container.Invoke(http.StartServer)