mirror of
https://github.com/elyby/chrly.git
synced 2025-05-31 14:11:51 +05:30
Add autoconfiguration for OTEL and resolve TODOs for metrics
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user