Skip to content

A continuation of HomeBox the inventory and organization system built for the Home User

Merge remote-tracking branch 'origin/main' into copilot/add-opentelemetry-integration

Matthew Kilgore3ca60a286829
diff --cc backend/app/api/app.go
index 3a4cd205,3d0bdea9..abbbcc07
--- a/backend/app/api/app.go
+++ b/backend/app/api/app.go
@@@ -11,14 -12,14 +13,15 @@@ import
)
type app struct {
- conf *config.Config
- mailer mailer.Mailer
- db *ent.Client
- repos *repo.AllRepos
- services *services.AllServices
- bus *eventbus.EventBus
+ conf *config.Config
+ mailer mailer.Mailer
+ db *ent.Client
+ repos *repo.AllRepos
+ services *services.AllServices
+ bus *eventbus.EventBus
+ authLimiter *authRateLimiter
+ notifierTestLimiter *simpleRateLimiter
+ otel *otel.Provider
- authLimiter *authRateLimiter
}
func new(conf *config.Config) *app {
diff --cc backend/app/api/main.go
index a0b6f5aa,17dc466e..50c0cc3a
--- a/backend/app/api/main.go
+++ b/backend/app/api/main.go
@@@ -14,24 -25,14 +15,27 @@@ import
"github.com/sysadminsmedia/homebox/backend/internal/data/ent"
"github.com/sysadminsmedia/homebox/backend/internal/data/migrations"
"github.com/sysadminsmedia/homebox/backend/internal/data/repo"
+ "github.com/sysadminsmedia/homebox/backend/internal/sys/analytics"
"github.com/sysadminsmedia/homebox/backend/internal/sys/config"
+ "github.com/sysadminsmedia/homebox/backend/internal/sys/otel"
"github.com/sysadminsmedia/homebox/backend/internal/web/mid"
+
+ "github.com/go-chi/chi/v5"
+ "github.com/go-chi/chi/v5/middleware"
+ "github.com/hay-kot/httpkit/errchain"
+ "github.com/hay-kot/httpkit/graceful"
+ "github.com/pressly/goose/v3"
+ "github.com/riandyrn/otelchi"
+ otelchimetric "github.com/riandyrn/otelchi/metric"
+ "github.com/rs/zerolog"
+ "github.com/rs/zerolog/log"
+ "github.com/rs/zerolog/pkgerrors"
"go.balki.me/anyhttp"
- _ "github.com/lib/pq"
+ "entgo.io/ent/dialect"
+ entsql "entgo.io/ent/dialect/sql"
+
+ _ "github.com/jackc/pgx/v5/stdlib"
_ "github.com/sysadminsmedia/homebox/backend/internal/data/migrations/postgres"
_ "github.com/sysadminsmedia/homebox/backend/internal/data/migrations/sqlite3"
_ "github.com/sysadminsmedia/homebox/backend/pkgs/cgofreesqlite"
@@@ -215,7 -201,8 +216,8 @@@ func run(cfg *config.Config) error
app.services = services.New(
app.repos,
services.WithAutoIncrementAssetID(cfg.Options.AutoIncrementAssetID),
- services.WithCurrencies(currencies),
+ services.WithCurrencies(currencyData),
+ services.WithNotifierConfig(&cfg.Notifier),
)
// =========================================================================
@@@ -252,23 -228,6 +254,16 @@@
runner := graceful.NewRunner()
- // Add database shutdown
- runner.AddFunc("database-shutdown", func(ctx context.Context) error {
- <-ctx.Done()
- log.Info().Msg("closing database connection")
- return c.Close()
- })
-
+ // Add OpenTelemetry shutdown
+ if otelProvider.IsEnabled() {
+ runner.AddFunc("otel-shutdown", func(ctx context.Context) error {
+ <-ctx.Done()
+ shutdownCtx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
+ defer cancel()
+ return otelProvider.Shutdown(shutdownCtx)
+ })
+ }
+
runner.AddFunc("server", func(ctx context.Context) error {
httpserver := http.Server{
Addr: fmt.Sprintf("%s:%s", cfg.Web.Host, cfg.Web.Port),
diff --cc backend/internal/sys/config/conf.go
index bf1d2644,a498e2f0..afe50623
--- a/backend/internal/sys/config/conf.go
+++ b/backend/internal/sys/config/conf.go
@@@ -31,9 -31,8 +31,9 @@@ type Config struct
LabelMaker LabelMakerConf `yaml:"labelmaker"`
Thumbnail Thumbnail `yaml:"thumbnail"`
Barcode BarcodeAPIConf `yaml:"barcode"`
+ Otel OTelConfig `yaml:"otel"`
Auth AuthConfig `yaml:"auth"`
-
+ Notifier NotifierConf `yaml:"notifier"`
}
type Options struct {
diff --cc frontend/package.json
index 43571f9e,305aa2eb..0ade00e8
--- a/frontend/package.json
+++ b/frontend/package.json
@@@ -44,18 -44,9 +44,18 @@@
"vue-tsc": "3.0.6"
},
"dependencies": {
- "@mdit/plugin-img-size": "^0.22.4",
+ "@mdit/plugin-img-size": "^0.22.5",
"@nuxtjs/color-mode": "^3.5.2",
"@nuxtjs/tailwindcss": "^6.14.0",
+ "@opentelemetry/api": "^1.9.0",
+ "@opentelemetry/context-zone": "^2.5.0",
+ "@opentelemetry/core": "^2.5.0",
+ "@opentelemetry/exporter-trace-otlp-http": "^0.210.0",
+ "@opentelemetry/instrumentation": "^0.210.0",
+ "@opentelemetry/instrumentation-fetch": "^0.210.0",
+ "@opentelemetry/resources": "^2.5.0",
+ "@opentelemetry/sdk-trace-web": "^2.5.0",
+ "@opentelemetry/semantic-conventions": "^1.39.0",
"@pinia/nuxt": "^0.11.3",
"@tailwindcss/aspect-ratio": "^0.4.2",
"@tailwindcss/forms": "^0.5.11",