A continuation of HomeBox the inventory and organization system built for the Home User
fix: a bunch of other required fixes
Matthew Kilgore1c2b0a775cc4
diff --git a/backend/app/api/handlers/v1/controller.go b/backend/app/api/handlers/v1/controller.goindex af1a05b0..e1edfb51 100644--- a/backend/app/api/handlers/v1/controller.go+++ b/backend/app/api/handlers/v1/controller.go@@ -168,7 +168,7 @@ func (ctrl *V1Controller) HandleBase(ready ReadyFunc, build Build) errchain.HandAllowLocal: ctrl.config.Options.AllowLocalLogin,},Telemetry: TelemetryStatus{- Enabled: ctrl.config.OTel.Enabled,+ Enabled: ctrl.config.Otel.Enabled,},})}diff --git a/backend/app/api/main.go b/backend/app/api/main.goindex 229455f0..f16b9336 100644--- a/backend/app/api/main.go+++ b/backend/app/api/main.go@@ -104,7 +104,7 @@ func run(cfg *config.Config) error {// =========================================================================// Initialize OpenTelemetry- otelProvider, err := otel.NewProvider(context.Background(), &cfg.OTel, version)+ otelProvider, err := otel.NewProvider(context.Background(), &cfg.Otel, version)if err != nil {log.Error().Err(err).Msg("failed to initialize OpenTelemetry")return fmt.Errorf("failed to initialize OpenTelemetry: %w", err)@@ -210,7 +210,7 @@ func run(cfg *config.Config) error {router := chi.NewMux()// Add OpenTelemetry HTTP middleware if enabled- if otelProvider.IsEnabled() && cfg.OTel.EnableHTTPTracing {+ if otelProvider.IsEnabled() && cfg.Otel.EnableHTTPTracing {router.Use(otelProvider.HTTPMiddleware("homebox"))}diff --git a/backend/app/api/routes.go b/backend/app/api/routes.goindex 6a5c5867..6927e4cc 100644--- a/backend/app/api/routes.go+++ b/backend/app/api/routes.go@@ -210,7 +210,7 @@ func (a *app) mountRoutes(r *chi.Mux, chain *errchain.ErrChain, repos *repo.AllRr.Get("/reporting/bill-of-materials", chain.ToHandlerFunc(v1Ctrl.HandleBillOfMaterialsExport(), userMW...))// OpenTelemetry proxy endpoint for frontend telemetry (requires auth)- if a.otel != nil && a.otel.IsEnabled() && a.conf.OTel.ProxyEnabled {+ if a.otel != nil && a.otel.IsEnabled() && a.conf.Otel.ProxyEnabled {r.Post("/telemetry", a.otel.ProxyHandler())}diff --git a/backend/go.mod b/backend/go.modindex b071a839..b487d4cd 100644--- a/backend/go.mod+++ b/backend/go.mod@@ -52,7 +52,7 @@ require (golang.org/x/oauth2 v0.34.0golang.org/x/text v0.33.0google.golang.org/grpc v1.78.0- modernc.org/sqlite v1.44.2+ modernc.org/sqlite v1.44.3)require (@@ -146,7 +146,7 @@ require (github.com/googleapis/enterprise-certificate-proxy v0.3.9 // indirectgithub.com/googleapis/gax-go/v2 v2.16.0 // indirectgithub.com/gorilla/websocket v1.5.3 // indirect- github.com/grpc-ecosystem/grpc-gateway/v2 v2.27.3 // indirect+ github.com/grpc-ecosystem/grpc-gateway/v2 v2.27.4 // indirectgithub.com/hashicorp/go-uuid v1.0.3 // indirectgithub.com/hashicorp/hcl/v2 v2.18.1 // indirectgithub.com/jcmturner/aescts/v2 v2.0.0 // indirect@@ -205,8 +205,8 @@ require (golang.org/x/xerrors v0.0.0-20240903120638-7835f813f4da // indirectgoogle.golang.org/api v0.260.0 // indirectgoogle.golang.org/genproto v0.0.0-20251202230838-ff82c1b0f217 // indirect- google.golang.org/genproto/googleapis/api v0.0.0-20251202230838-ff82c1b0f217 // indirect- google.golang.org/genproto/googleapis/rpc v0.0.0-20260114163908-3f89685c29c3 // indirect+ google.golang.org/genproto/googleapis/api v0.0.0-20260120221211-b8f7ae30c516 // indirect+ google.golang.org/genproto/googleapis/rpc v0.0.0-20260120221211-b8f7ae30c516 // indirectgoogle.golang.org/protobuf v1.36.11 // indirectgopkg.in/yaml.v3 v3.0.1 // indirectmodernc.org/libc v1.67.6 // indirectdiff --git a/backend/go.sum b/backend/go.sumindex 34578502..8a642a05 100644--- a/backend/go.sum+++ b/backend/go.sum@@ -281,6 +281,8 @@ github.com/gorilla/websocket v1.5.3 h1:saDtZ6Pbx/0u+bgYQ3q96pZgCzfhKXGPqt7kZ72aNgithub.com/gorilla/websocket v1.5.3/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE=github.com/grpc-ecosystem/grpc-gateway/v2 v2.27.3 h1:NmZ1PKzSTQbuGHw9DGPFomqkkLWMC+vZCkfs+FHv1Vg=github.com/grpc-ecosystem/grpc-gateway/v2 v2.27.3/go.mod h1:zQrxl1YP88HQlA6i9c63DSVPFklWpGX4OWAc9bFuaH4=+github.com/grpc-ecosystem/grpc-gateway/v2 v2.27.4 h1:kEISI/Gx67NzH3nJxAmY/dGac80kKZgZt134u7Y/k1s=+github.com/grpc-ecosystem/grpc-gateway/v2 v2.27.4/go.mod h1:6Nz966r3vQYCqIzWsuEl9d7cf7mRhtDmm++sOxlnfxI=github.com/hashicorp/go-uuid v1.0.2/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro=github.com/hashicorp/go-uuid v1.0.3 h1:2gKiV6YVmrJ1i2CKKa9obLvRieoRGviZFL26PcT/Co8=github.com/hashicorp/go-uuid v1.0.3/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro=@@ -558,8 +560,12 @@ google.golang.org/genproto v0.0.0-20251202230838-ff82c1b0f217 h1:GvESR9BIyHUahIbgoogle.golang.org/genproto v0.0.0-20251202230838-ff82c1b0f217/go.mod h1:yJ2HH4EHEDTd3JiLmhds6NkJ17ITVYOdV3m3VKOnws0=google.golang.org/genproto/googleapis/api v0.0.0-20251202230838-ff82c1b0f217 h1:fCvbg86sFXwdrl5LgVcTEvNC+2txB5mgROGmRL5mrls=google.golang.org/genproto/googleapis/api v0.0.0-20251202230838-ff82c1b0f217/go.mod h1:+rXWjjaukWZun3mLfjmVnQi18E1AsFbDN9QdJ5YXLto=+google.golang.org/genproto/googleapis/api v0.0.0-20260120221211-b8f7ae30c516 h1:vmC/ws+pLzWjj/gzApyoZuSVrDtF1aod4u/+bbj8hgM=+google.golang.org/genproto/googleapis/api v0.0.0-20260120221211-b8f7ae30c516/go.mod h1:p3MLuOwURrGBRoEyFHBT3GjUwaCQVKeNqqWxlcISGdw=google.golang.org/genproto/googleapis/rpc v0.0.0-20260114163908-3f89685c29c3 h1:C4WAdL+FbjnGlpp2S+HMVhBeCq2Lcib4xZqfPNF6OoQ=google.golang.org/genproto/googleapis/rpc v0.0.0-20260114163908-3f89685c29c3/go.mod h1:j9x/tPzZkyxcgEFkiKEEGxfvyumM01BEtsW8xzOahRQ=+google.golang.org/genproto/googleapis/rpc v0.0.0-20260120221211-b8f7ae30c516 h1:sNrWoksmOyF5bvJUcnmbeAmQi8baNhqg5IWaI3llQqU=+google.golang.org/genproto/googleapis/rpc v0.0.0-20260120221211-b8f7ae30c516/go.mod h1:j9x/tPzZkyxcgEFkiKEEGxfvyumM01BEtsW8xzOahRQ=google.golang.org/grpc v1.78.0 h1:K1XZG/yGDJnzMdd/uZHAkVqJE+xIDOcmdSFZkBUicNc=google.golang.org/grpc v1.78.0/go.mod h1:I47qjTo4OKbMkjA/aOOwxDIiPSBofUtQUI5EfpWvW7U=google.golang.org/protobuf v1.36.11 h1:fV6ZwhNocDyBLK0dj+fg8ektcVegBBuEolpbTQyBNVE=@@ -595,6 +601,8 @@ modernc.org/sortutil v1.2.1 h1:+xyoGf15mM3NMlPDnFqrteY07klSFxLElE2PVuWIJ7w=modernc.org/sortutil v1.2.1/go.mod h1:7ZI3a3REbai7gzCLcotuw9AC4VZVpYMjDzETGsSMqJE=modernc.org/sqlite v1.44.2 h1:EdYqXeBpKFJjg8QYnw6E71MpANkoxyuYi+g68ugOL8g=modernc.org/sqlite v1.44.2/go.mod h1:CzbrU2lSB1DKUusvwGz7rqEKIq+NUd8GWuBBZDs9/nA=+modernc.org/sqlite v1.44.3 h1:+39JvV/HWMcYslAwRxHb8067w+2zowvFOUrOWIy9PjY=+modernc.org/sqlite v1.44.3/go.mod h1:CzbrU2lSB1DKUusvwGz7rqEKIq+NUd8GWuBBZDs9/nA=modernc.org/strutil v1.2.1 h1:UneZBkQA+DX2Rp35KcM69cSsNES9ly8mQWD71HKlOA0=modernc.org/strutil v1.2.1/go.mod h1:EHkiggD70koQxjVdSBM3JKM7k6L0FbGE5eymy9i3B9A=modernc.org/token v1.1.0 h1:Xl7Ap9dKaEs5kLoOQeQmPWevfnk/DM5qcLcYlA8ys6Y=diff --git a/backend/internal/sys/config/conf.go b/backend/internal/sys/config/conf.goindex 52ad5457..09c2772e 100644--- a/backend/internal/sys/config/conf.go+++ b/backend/internal/sys/config/conf.go@@ -31,7 +31,7 @@ type Config struct {LabelMaker LabelMakerConf `yaml:"labelmaker"`Thumbnail Thumbnail `yaml:"thumbnail"`Barcode BarcodeAPIConf `yaml:"barcode"`- OTel OTelConfig `yaml:"otel"`+ Otel OTelConfig `yaml:"otel"`}type Options struct {diff --git a/backend/internal/sys/config/conf_otel.go b/backend/internal/sys/config/conf_otel.goindex d6f6dad7..41e39748 100644--- a/backend/internal/sys/config/conf_otel.go+++ b/backend/internal/sys/config/conf_otel.go@@ -15,7 +15,8 @@ type OTelConfig struct {// Exporter specifies the exporter type: "otlp", "stdout", or "none"Exporter string `yaml:"exporter" conf:"default:otlp"`- // Endpoint is the OTLP exporter endpoint (e.g., "localhost:4317" for gRPC or "localhost:4318" for HTTP)+ // Endpoint is the OTLP exporter endpoint (e.g., "localhost:4317" for gRPC or "http://localhost:4318" for HTTP)+ // The full address including port should be specifiedEndpoint string `yaml:"endpoint"`// Protocol specifies the OTLP protocol: "grpc" or "http"diff --git a/backend/internal/sys/otel/otel.go b/backend/internal/sys/otel/otel.goindex 1b9350fc..3ebc0ce0 100644--- a/backend/internal/sys/otel/otel.go+++ b/backend/internal/sys/otel/otel.go@@ -79,18 +79,13 @@ func NewProvider(ctx context.Context, cfg *config.OTelConfig, buildVersion strinserviceVersion = buildVersion}- res, err := resource.Merge(- resource.Default(),- resource.NewWithAttributes(- semconv.SchemaURL,- semconv.ServiceName(cfg.ServiceName),- semconv.ServiceVersion(serviceVersion),- attribute.String("deployment.environment", getEnvironment()),- ),+ // Note: we don't merge with resource.Default() to avoid schema URL conflicts+ res := resource.NewWithAttributes(+ semconv.SchemaURL,+ semconv.ServiceName(cfg.ServiceName),+ semconv.ServiceVersion(serviceVersion),+ attribute.String("deployment.environment", getEnvironment()),)- if err != nil {- return nil, fmt.Errorf("failed to create resource: %w", err)- }// Create exporter based on configurationexporter, err := createExporter(ctx, cfg)@@ -221,8 +216,8 @@ func parseHeaders(headerStr string) map[string]string {}// getEnvironment returns the current deployment environment.+// ...existing code...func getEnvironment() string {- // This could be enhanced to read from config or environmentreturn "production"}