Skip to content

SigNoz is an open-source, OpenTelemetry-native observability platform for your team and their AI agents. Get logs, metrics, and traces in one tool with features like APM, distributed tracing, log management, infra monitoring, etc. Combined with SigNoz MCP and a native AI teammate (in SigNoz Cloud) it helps you build more resilient apps.

fix: concurrent map writes to temporalityMap (#5432)

Srikanth Chekuri831de18464c9
diff --git a/pkg/query-service/app/http_handler.go b/pkg/query-service/app/http_handler.go
index d6c91558a5..42879123ec 100644
--- a/pkg/query-service/app/http_handler.go
+++ b/pkg/query-service/app/http_handler.go
@@ -83,6 +83,7 @@ type APIHandler struct {
// querying the v4 table on low cardinal temporality column
// should be fast but we can still avoid the query if we have the data in memory
temporalityMap map[string]map[v3.Temporality]bool
+ temporalityMux sync.Mutex
maxIdleConns int
maxOpenConns int
@@ -455,6 +456,9 @@ func (aH *APIHandler) getRule(w http.ResponseWriter, r *http.Request) {
// populateTemporality adds the temporality to the query if it is not present
func (aH *APIHandler) populateTemporality(ctx context.Context, qp *v3.QueryRangeParamsV3) error {
+ aH.temporalityMux.Lock()
+ defer aH.temporalityMux.Unlock()
+
missingTemporality := make([]string, 0)
metricNameToTemporality := make(map[string]map[v3.Temporality]bool)
if qp.CompositeQuery != nil && len(qp.CompositeQuery.BuilderQueries) > 0 {