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.
TypeScript apmapplication-monitoringdistributed-tracinggogood-first-issuejaegerloglogsmetricsmonitoringnextjsobservabilityopen-sourceopentelemetryprometheusreactreactjsself-hostedtracingtypescript
refactor: replace zap logger with slog across codebase (#10599)
Pandeyf8c38df2bf1a
diff --git a/cmd/root.go b/cmd/root.goindex a080b37645..9e7aee7b04 100644--- a/cmd/root.go+++ b/cmd/root.go@@ -6,7 +6,6 @@ import ("github.com/SigNoz/signoz/pkg/version""github.com/spf13/cobra"- "go.uber.org/zap" //nolint:depguard)var RootCmd = &cobra.Command{@@ -19,12 +18,6 @@ var RootCmd = &cobra.Command{}func Execute(logger *slog.Logger) {- zapLogger := newZapLogger()- zap.ReplaceGlobals(zapLogger)- defer func() {- _ = zapLogger.Sync()- }()-err := RootCmd.Execute()if err != nil {logger.ErrorContext(RootCmd.Context(), "error running command", "error", err)diff --git a/cmd/zap.go b/cmd/zap.godeleted file mode 100644index 885cb743a7..0000000000--- a/cmd/zap.go+++ /dev/null@@ -1,110 +0,0 @@-package cmd--import (- "context"- "time"-- "github.com/SigNoz/signoz/pkg/errors"- "go.uber.org/zap" //nolint:depguard- "go.uber.org/zap/zapcore" //nolint:depguard-)--// Deprecated: Use `NewLogger` from `pkg/instrumentation` instead.-func newZapLogger() *zap.Logger {- config := zap.NewProductionConfig()- config.EncoderConfig.TimeKey = "timestamp"- config.EncoderConfig.EncodeTime = zapcore.ISO8601TimeEncoder-- // Extract sampling config before building the logger.- // We need to disable sampling in the config and apply it manually later- // to ensure correct core ordering. See filteringCore documentation for details.- samplerConfig := config.Sampling- config.Sampling = nil-- logger, _ := config.Build()-- // Wrap with custom core wrapping to filter certain log entries.- // The order of wrapping is important:- // 1. First wrap with filteringCore- // 2. Then wrap with sampler- //- // This creates the call chain: sampler -> filteringCore -> ioCore- //- // During logging:- // - sampler.Check decides whether to sample the log entry- // - If sampled, filteringCore.Check is called- // - filteringCore adds itself to CheckedEntry.cores- // - All cores in CheckedEntry.cores have their Write method called- // - filteringCore.Write can now filter the entry before passing to ioCore- //- // If we didn't disable the sampler above, filteringCore would have wrapped- // sampler. By calling sampler.Check we would have allowed it to call- // ioCore.Check that adds itself to CheckedEntry.cores. Then ioCore.Write- // would have bypassed our checks, making filtering impossible.- return logger.WithOptions(zap.WrapCore(func(core zapcore.Core) zapcore.Core {- core = &filteringCore{core}- if samplerConfig != nil {- core = zapcore.NewSamplerWithOptions(- core,- time.Second,- samplerConfig.Initial,- samplerConfig.Thereafter,- )- }- return core- }))-}--// filteringCore wraps a zapcore.Core to filter out log entries based on a-// custom logic.-//-// Note: This core must be positioned before the sampler in the core chain-// to ensure Write is called. See newZapLogger for ordering details.-type filteringCore struct {- zapcore.Core-}--// filter determines whether a log entry should be written based on its fields.-// Returns false if the entry should be suppressed, true otherwise.-//-// Current filters:-// - context.Canceled: These are expected errors from cancelled operations,-// and create noise in logs.-func (c *filteringCore) filter(fields []zapcore.Field) bool {- for _, field := range fields {- if field.Type == zapcore.ErrorType {- if loggedErr, ok := field.Interface.(error); ok {- // Suppress logs containing context.Canceled errors- if errors.Is(loggedErr, context.Canceled) {- return false- }- }- }- }- return true-}--// With implements zapcore.Core.With-// It returns a new copy with the added context.-func (c *filteringCore) With(fields []zapcore.Field) zapcore.Core {- return &filteringCore{c.Core.With(fields)}-}--// Check implements zapcore.Core.Check.-// It adds this core to the CheckedEntry if the log level is enabled,-// ensuring that Write will be called for this entry.-func (c *filteringCore) Check(ent zapcore.Entry, ce *zapcore.CheckedEntry) *zapcore.CheckedEntry {- if c.Enabled(ent.Level) {- return ce.AddCore(ent, c)- }- return ce-}--// Write implements zapcore.Core.Write.-// It filters log entries based on their fields before delegating to the wrapped core.-func (c *filteringCore) Write(ent zapcore.Entry, fields []zapcore.Field) error {- if !c.filter(fields) {- return nil- }- return c.Core.Write(ent, fields)-}diff --git a/ee/query-service/anomaly/seasonal.go b/ee/query-service/anomaly/seasonal.goindex 5f33f5dedb..91a6b15d5d 100644--- a/ee/query-service/anomaly/seasonal.go+++ b/ee/query-service/anomaly/seasonal.go@@ -2,6 +2,7 @@ package anomalyimport ("context"+ "log/slog""math""time"@@ -13,7 +14,6 @@ import ("github.com/SigNoz/signoz/pkg/types/ctxtypes""github.com/SigNoz/signoz/pkg/types/instrumentationtypes""github.com/SigNoz/signoz/pkg/valuer"- "go.uber.org/zap")var (@@ -67,7 +67,7 @@ func (p *BaseSeasonalProvider) getResults(ctx context.Context, orgID valuer.UUIDinstrumentationtypes.CodeNamespace: "anomaly",instrumentationtypes.CodeFunctionName: "getResults",})- zap.L().Info("fetching results for current period", zap.Any("currentPeriodQuery", params.CurrentPeriodQuery))+ slog.InfoContext(ctx, "fetching results for current period", "current_period_query", params.CurrentPeriodQuery)currentPeriodResults, _, err := p.querierV2.QueryRange(ctx, orgID, params.CurrentPeriodQuery)if err != nil {return nil, err@@ -78,7 +78,7 @@ func (p *BaseSeasonalProvider) getResults(ctx context.Context, orgID valuer.UUIDreturn nil, err}- zap.L().Info("fetching results for past period", zap.Any("pastPeriodQuery", params.PastPeriodQuery))+ slog.InfoContext(ctx, "fetching results for past period", "past_period_query", params.PastPeriodQuery)pastPeriodResults, _, err := p.querierV2.QueryRange(ctx, orgID, params.PastPeriodQuery)if err != nil {return nil, err@@ -89,7 +89,7 @@ func (p *BaseSeasonalProvider) getResults(ctx context.Context, orgID valuer.UUIDreturn nil, err}- zap.L().Info("fetching results for current season", zap.Any("currentSeasonQuery", params.CurrentSeasonQuery))+ slog.InfoContext(ctx, "fetching results for current season", "current_season_query", params.CurrentSeasonQuery)currentSeasonResults, _, err := p.querierV2.QueryRange(ctx, orgID, params.CurrentSeasonQuery)if err != nil {return nil, err@@ -100,7 +100,7 @@ func (p *BaseSeasonalProvider) getResults(ctx context.Context, orgID valuer.UUIDreturn nil, err}- zap.L().Info("fetching results for past season", zap.Any("pastSeasonQuery", params.PastSeasonQuery))+ slog.InfoContext(ctx, "fetching results for past season", "past_season_query", params.PastSeasonQuery)pastSeasonResults, _, err := p.querierV2.QueryRange(ctx, orgID, params.PastSeasonQuery)if err != nil {return nil, err@@ -111,7 +111,7 @@ func (p *BaseSeasonalProvider) getResults(ctx context.Context, orgID valuer.UUIDreturn nil, err}- zap.L().Info("fetching results for past 2 season", zap.Any("past2SeasonQuery", params.Past2SeasonQuery))+ slog.InfoContext(ctx, "fetching results for past 2 season", "past_2_season_query", params.Past2SeasonQuery)past2SeasonResults, _, err := p.querierV2.QueryRange(ctx, orgID, params.Past2SeasonQuery)if err != nil {return nil, err@@ -122,7 +122,7 @@ func (p *BaseSeasonalProvider) getResults(ctx context.Context, orgID valuer.UUIDreturn nil, err}- zap.L().Info("fetching results for past 3 season", zap.Any("past3SeasonQuery", params.Past3SeasonQuery))+ slog.InfoContext(ctx, "fetching results for past 3 season", "past_3_season_query", params.Past3SeasonQuery)past3SeasonResults, _, err := p.querierV2.QueryRange(ctx, orgID, params.Past3SeasonQuery)if err != nil {return nil, err@@ -235,17 +235,17 @@ func (p *BaseSeasonalProvider) getPredictedSeries(if predictedValue < 0 {// this should not happen (except when the data has extreme outliers)// we will use the moving avg of the previous period series in this case- zap.L().Warn("predictedValue is less than 0", zap.Float64("predictedValue", predictedValue), zap.Any("labels", series.Labels))+ slog.Warn("predicted value is less than 0", "predicted_value", predictedValue, "labels", series.Labels)predictedValue = p.getMovingAvg(prevSeries, movingAvgWindowSize, idx)}- zap.L().Debug("predictedSeries",- zap.Float64("movingAvg", movingAvg),- zap.Float64("avg", avg),- zap.Float64("mean", mean),- zap.Any("labels", series.Labels),- zap.Float64("predictedValue", predictedValue),- zap.Float64("curr", curr.Value),+ slog.Debug("predicted series",+ "moving_avg", movingAvg,+ "avg", avg,+ "mean", mean,+ "labels", series.Labels,+ "predicted_value", predictedValue,+ "curr", curr.Value,)predictedSeries.Points = append(predictedSeries.Points, v3.Point{Timestamp: curr.Timestamp,@@ -418,7 +418,7 @@ func (p *BaseSeasonalProvider) getAnomalies(ctx context.Context, orgID valuer.UUfor _, series := range result.Series {stdDev := p.getStdDev(series)- zap.L().Info("stdDev", zap.Float64("stdDev", stdDev), zap.Any("labels", series.Labels))+ slog.InfoContext(ctx, "computed standard deviation", "std_dev", stdDev, "labels", series.Labels)pastPeriodSeries := p.getMatchingSeries(pastPeriodResult, series)currentSeasonSeries := p.getMatchingSeries(currentSeasonResult, series)@@ -431,7 +431,7 @@ func (p *BaseSeasonalProvider) getAnomalies(ctx context.Context, orgID valuer.UUpastSeasonSeriesAvg := p.getAvg(pastSeasonSeries)past2SeasonSeriesAvg := p.getAvg(past2SeasonSeries)past3SeasonSeriesAvg := p.getAvg(past3SeasonSeries)- zap.L().Info("getAvg", zap.Float64("prevSeriesAvg", prevSeriesAvg), zap.Float64("currentSeasonSeriesAvg", currentSeasonSeriesAvg), zap.Float64("pastSeasonSeriesAvg", pastSeasonSeriesAvg), zap.Float64("past2SeasonSeriesAvg", past2SeasonSeriesAvg), zap.Float64("past3SeasonSeriesAvg", past3SeasonSeriesAvg), zap.Any("labels", series.Labels))+ slog.InfoContext(ctx, "computed averages", "prev_series_avg", prevSeriesAvg, "current_season_series_avg", currentSeasonSeriesAvg, "past_season_series_avg", pastSeasonSeriesAvg, "past_2_season_series_avg", past2SeasonSeriesAvg, "past_3_season_series_avg", past3SeasonSeriesAvg, "labels", series.Labels)predictedSeries := p.getPredictedSeries(series,diff --git a/ee/query-service/app/api/cloudIntegrations.go b/ee/query-service/app/api/cloudIntegrations.goindex 209591f0e7..d773841d76 100644--- a/ee/query-service/app/api/cloudIntegrations.go+++ b/ee/query-service/app/api/cloudIntegrations.go@@ -18,7 +18,7 @@ import ("github.com/SigNoz/signoz/pkg/types/authtypes""github.com/SigNoz/signoz/pkg/valuer""github.com/gorilla/mux"- "go.uber.org/zap"+ "log/slog")type CloudIntegrationConnectionParamsResponse struct {@@ -71,7 +71,7 @@ func (ah *APIHandler) CloudIntegrationsGenerateConnectionParams(w http.ResponseW// Return the API Key (PAT) even if the rest of the params can not be deduced.// Params not returned from here will be requested from the user via form inputs.// This enables gracefully degraded but working experience even for non-cloud deployments.- zap.L().Info("ingestion params and signoz api url can not be deduced since no license was found")+ slog.InfoContext(r.Context(), "ingestion params and signoz api url can not be deduced since no license was found")ah.Respond(w, result)return}@@ -103,7 +103,7 @@ func (ah *APIHandler) CloudIntegrationsGenerateConnectionParams(w http.ResponseWresult.IngestionKey = ingestionKey} else {- zap.L().Info("ingestion key can't be deduced since no gateway url has been configured")+ slog.InfoContext(r.Context(), "ingestion key can't be deduced since no gateway url has been configured")}ah.Respond(w, result)@@ -138,9 +138,8 @@ func (ah *APIHandler) getOrCreateCloudIntegrationPAT(ctx context.Context, orgId}}- zap.L().Info(- "no PAT found for cloud integration, creating a new one",- zap.String("cloudProvider", cloudProvider),+ slog.InfoContext(ctx, "no PAT found for cloud integration, creating a new one",+ "cloud_provider", cloudProvider,)newPAT, err := types.NewStorableAPIKey(@@ -287,9 +286,8 @@ func getOrCreateCloudProviderIngestionKey(}}- zap.L().Info(- "no existing ingestion key found for cloud integration, creating a new one",- zap.String("cloudProvider", cloudProvider),+ slog.InfoContext(ctx, "no existing ingestion key found for cloud integration, creating a new one",+ "cloud_provider", cloudProvider,)createKeyResult, apiErr := requestGateway[createIngestionKeyResponse](ctx, gatewayUrl, licenseKey, "/v1/workspaces/me/keys",diff --git a/ee/query-service/app/api/featureFlags.go b/ee/query-service/app/api/featureFlags.goindex 867f8125e4..dc2118f421 100644--- a/ee/query-service/app/api/featureFlags.go+++ b/ee/query-service/app/api/featureFlags.go@@ -15,7 +15,7 @@ import ("github.com/SigNoz/signoz/pkg/types/featuretypes""github.com/SigNoz/signoz/pkg/types/licensetypes""github.com/SigNoz/signoz/pkg/valuer"- "go.uber.org/zap"+ "log/slog")func (ah *APIHandler) getFeatureFlags(w http.ResponseWriter, r *http.Request) {@@ -35,23 +35,23 @@ func (ah *APIHandler) getFeatureFlags(w http.ResponseWriter, r *http.Request) {}if constants.FetchFeatures == "true" {- zap.L().Debug("fetching license")+ slog.DebugContext(ctx, "fetching license")license, err := ah.Signoz.Licensing.GetActive(ctx, orgID)if err != nil {- zap.L().Error("failed to fetch license", zap.Error(err))+ slog.ErrorContext(ctx, "failed to fetch license", "error", err)} else if license == nil {- zap.L().Debug("no active license found")+ slog.DebugContext(ctx, "no active license found")} else {licenseKey := license.Key- zap.L().Debug("fetching zeus features")+ slog.DebugContext(ctx, "fetching zeus features")zeusFeatures, err := fetchZeusFeatures(constants.ZeusFeaturesURL, licenseKey)if err == nil {- zap.L().Debug("fetched zeus features", zap.Any("features", zeusFeatures))+ slog.DebugContext(ctx, "fetched zeus features", "features", zeusFeatures)// merge featureSet and zeusFeatures in featureSet with higher priority to zeusFeaturesfeatureSet = MergeFeatureSets(zeusFeatures, featureSet)} else {- zap.L().Error("failed to fetch zeus features", zap.Error(err))+ slog.ErrorContext(ctx, "failed to fetch zeus features", "error", err)}}}diff --git a/ee/query-service/app/api/queryrange.go b/ee/query-service/app/api/queryrange.goindex 06ba8eb405..07b951dbb0 100644--- a/ee/query-service/app/api/queryrange.go+++ b/ee/query-service/app/api/queryrange.go@@ -14,7 +14,7 @@ import (v3 "github.com/SigNoz/signoz/pkg/query-service/model/v3""github.com/SigNoz/signoz/pkg/types/authtypes""github.com/SigNoz/signoz/pkg/valuer"- "go.uber.org/zap"+ "log/slog")func (aH *APIHandler) queryRangeV4(w http.ResponseWriter, r *http.Request) {@@ -35,7 +35,7 @@ func (aH *APIHandler) queryRangeV4(w http.ResponseWriter, r *http.Request) {queryRangeParams, apiErrorObj := baseapp.ParseQueryRangeParams(r)if apiErrorObj != nil {- zap.L().Error("error parsing metric query range params", zap.Error(apiErrorObj.Err))+ slog.ErrorContext(r.Context(), "error parsing metric query range params", "error", apiErrorObj.Err)RespondError(w, apiErrorObj, nil)return}@@ -44,7 +44,7 @@ func (aH *APIHandler) queryRangeV4(w http.ResponseWriter, r *http.Request) {// add temporality for each metrictemporalityErr := aH.PopulateTemporality(r.Context(), orgID, queryRangeParams)if temporalityErr != nil {- zap.L().Error("Error while adding temporality for metrics", zap.Error(temporalityErr))+ slog.ErrorContext(r.Context(), "error while adding temporality for metrics", "error", temporalityErr)RespondError(w, &model.ApiError{Typ: model.ErrorInternal, Err: temporalityErr}, nil)return}diff --git a/ee/query-service/app/server.go b/ee/query-service/app/server.goindex 389d08d3e4..8a78932f1a 100644--- a/ee/query-service/app/server.go+++ b/ee/query-service/app/server.go@@ -47,7 +47,7 @@ import (baseint "github.com/SigNoz/signoz/pkg/query-service/interfaces"baserules "github.com/SigNoz/signoz/pkg/query-service/rules""github.com/SigNoz/signoz/pkg/query-service/utils"- "go.uber.org/zap"+ "log/slog")// Server runs HTTP, Mux and a grpc server@@ -83,6 +83,7 @@ func NewServer(config signoz.Config, signoz *signoz.SigNoz) (*Server, error) {}reader := clickhouseReader.NewReader(+ signoz.Instrumentation.Logger(),signoz.SQLStore,signoz.TelemetryStore,signoz.Prometheus,@@ -278,7 +279,7 @@ func (s *Server) initListeners() error {return err}- zap.L().Info(fmt.Sprintf("Query server started listening on %s...", s.httpHostPort))+ slog.Info(fmt.Sprintf("Query server started listening on %s...", s.httpHostPort))return nil}@@ -298,31 +299,31 @@ func (s *Server) Start(ctx context.Context) error {}go func() {- zap.L().Info("Starting HTTP server", zap.Int("port", httpPort), zap.String("addr", s.httpHostPort))+ slog.Info("Starting HTTP server", "port", httpPort, "addr", s.httpHostPort)switch err := s.httpServer.Serve(s.httpConn); err {case nil, http.ErrServerClosed, cmux.ErrListenerClosed:// normal exit, nothing to dodefault:- zap.L().Error("Could not start HTTP server", zap.Error(err))+ slog.Error("Could not start HTTP server", "error", err)}s.unavailableChannel <- healthcheck.Unavailable}()go func() {- zap.L().Info("Starting pprof server", zap.String("addr", baseconst.DebugHttpPort))+ slog.Info("Starting pprof server", "addr", baseconst.DebugHttpPort)err = http.ListenAndServe(baseconst.DebugHttpPort, nil)if err != nil {- zap.L().Error("Could not start pprof server", zap.Error(err))+ slog.Error("Could not start pprof server", "error", err)}}()go func() {- zap.L().Info("Starting OpAmp Websocket server", zap.String("addr", baseconst.OpAmpWsEndpoint))+ slog.Info("Starting OpAmp Websocket server", "addr", baseconst.OpAmpWsEndpoint)err := s.opampServer.Start(baseconst.OpAmpWsEndpoint)if err != nil {- zap.L().Error("opamp ws server failed to start", zap.Error(err))+ slog.Error("opamp ws server failed to start", "error", err)s.unavailableChannel <- healthcheck.Unavailable}}()@@ -358,10 +359,9 @@ func makeRulesManager(ch baseint.Reader, cache cache.Cache, alertmanager alertmaMetadataStore: metadataStore,Prometheus: prometheus,Context: context.Background(),- Logger: zap.L(),Reader: ch,Querier: querier,- SLogger: providerSettings.Logger,+ Logger: providerSettings.Logger,Cache: cache,EvalDelay: baseconst.GetEvalDelay(),PrepareTaskFunc: rules.PrepareTaskFunc,@@ -380,7 +380,7 @@ func makeRulesManager(ch baseint.Reader, cache cache.Cache, alertmanager alertmareturn nil, fmt.Errorf("rule manager error: %v", err)}- zap.L().Info("rules manager is ready")+ slog.Info("rules manager is ready")return manager, nil}diff --git a/ee/query-service/rules/anomaly_test.go b/ee/query-service/rules/anomaly_test.goindex f6e218a0ff..cc338af153 100644--- a/ee/query-service/rules/anomaly_test.go+++ b/ee/query-service/rules/anomaly_test.go@@ -2,6 +2,7 @@ package rulesimport ("context"+ "log/slog""testing""time"@@ -116,7 +117,7 @@ func TestAnomalyRule_NoData_AlertOnAbsent(t *testing.T) {telemetryStore := telemetrystoretest.New(telemetrystore.Config{}, nil)options := clickhouseReader.NewOptions("primaryNamespace")- reader := clickhouseReader.NewReader(nil, telemetryStore, nil, "", time.Second, nil, nil, options)+ reader := clickhouseReader.NewReader(slog.Default(), nil, telemetryStore, nil, "", time.Second, nil, nil, options)rule, err := NewAnomalyRule("test-anomaly-rule",@@ -247,7 +248,7 @@ func TestAnomalyRule_NoData_AbsentFor(t *testing.T) {telemetryStore := telemetrystoretest.New(telemetrystore.Config{}, nil)options := clickhouseReader.NewOptions("primaryNamespace")- reader := clickhouseReader.NewReader(nil, telemetryStore, nil, "", time.Second, nil, nil, options)+ reader := clickhouseReader.NewReader(slog.Default(), nil, telemetryStore, nil, "", time.Second, nil, nil, options)rule, err := NewAnomalyRule("test-anomaly-rule", valuer.GenerateUUID(), &postableRule, reader, nil, logger, nil)require.NoError(t, err)diff --git a/ee/query-service/rules/manager.go b/ee/query-service/rules/manager.goindex 0bd7f17787..1f9b19e763 100644--- a/ee/query-service/rules/manager.go+++ b/ee/query-service/rules/manager.go@@ -13,7 +13,7 @@ import ("github.com/SigNoz/signoz/pkg/types/ruletypes""github.com/SigNoz/signoz/pkg/valuer""github.com/google/uuid"- "go.uber.org/zap"+ "log/slog")func PrepareTaskFunc(opts baserules.PrepareTaskOptions) (baserules.Task, error) {@@ -34,7 +34,7 @@ func PrepareTaskFunc(opts baserules.PrepareTaskOptions) (baserules.Task, error)opts.Rule,opts.Reader,opts.Querier,- opts.SLogger,+ opts.Logger,baserules.WithEvalDelay(opts.ManagerOpts.EvalDelay),baserules.WithSQLStore(opts.SQLStore),baserules.WithQueryParser(opts.ManagerOpts.QueryParser),@@ -57,7 +57,7 @@ func PrepareTaskFunc(opts baserules.PrepareTaskOptions) (baserules.Task, error)ruleId,opts.OrgID,opts.Rule,- opts.SLogger,+ opts.Logger,opts.Reader,opts.ManagerOpts.Prometheus,baserules.WithSQLStore(opts.SQLStore),@@ -82,7 +82,7 @@ func PrepareTaskFunc(opts baserules.PrepareTaskOptions) (baserules.Task, error)opts.Rule,opts.Reader,opts.Querier,- opts.SLogger,+ opts.Logger,opts.Cache,baserules.WithEvalDelay(opts.ManagerOpts.EvalDelay),baserules.WithSQLStore(opts.SQLStore),@@ -142,7 +142,7 @@ func TestNotification(opts baserules.PrepareTestRuleOptions) (int, *basemodel.ApparsedRule,opts.Reader,opts.Querier,- opts.SLogger,+ opts.Logger,baserules.WithSendAlways(),baserules.WithSendUnmatched(),baserules.WithSQLStore(opts.SQLStore),@@ -151,7 +151,7 @@ func TestNotification(opts baserules.PrepareTestRuleOptions) (int, *basemodel.Ap)if err != nil {- zap.L().Error("failed to prepare a new threshold rule for test", zap.String("name", alertname), zap.Error(err))+ slog.Error("failed to prepare a new threshold rule for test", "name", alertname, "error", err)return 0, basemodel.BadRequest(err)}@@ -162,7 +162,7 @@ func TestNotification(opts baserules.PrepareTestRuleOptions) (int, *basemodel.Apalertname,opts.OrgID,parsedRule,- opts.SLogger,+ opts.Logger,opts.Reader,opts.ManagerOpts.Prometheus,baserules.WithSendAlways(),@@ -173,7 +173,7 @@ func TestNotification(opts baserules.PrepareTestRuleOptions) (int, *basemodel.Ap)if err != nil {- zap.L().Error("failed to prepare a new promql rule for test", zap.String("name", alertname), zap.Error(err))+ slog.Error("failed to prepare a new promql rule for test", "name", alertname, "error", err)return 0, basemodel.BadRequest(err)}} else if parsedRule.RuleType == ruletypes.RuleTypeAnomaly {@@ -184,7 +184,7 @@ func TestNotification(opts baserules.PrepareTestRuleOptions) (int, *basemodel.ApparsedRule,opts.Reader,opts.Querier,- opts.SLogger,+ opts.Logger,opts.Cache,baserules.WithSendAlways(),baserules.WithSendUnmatched(),@@ -193,7 +193,7 @@ func TestNotification(opts baserules.PrepareTestRuleOptions) (int, *basemodel.Apbaserules.WithMetadataStore(opts.ManagerOpts.MetadataStore),)if err != nil {- zap.L().Error("failed to prepare a new anomaly rule for test", zap.String("name", alertname), zap.Error(err))+ slog.Error("failed to prepare a new anomaly rule for test", "name", alertname, "error", err)return 0, basemodel.BadRequest(err)}} else {@@ -205,7 +205,7 @@ func TestNotification(opts baserules.PrepareTestRuleOptions) (int, *basemodel.ApalertsFound, err := rule.Eval(ctx, ts)if err != nil {- zap.L().Error("evaluating rule failed", zap.String("rule", rule.Name()), zap.Error(err))+ slog.Error("evaluating rule failed", "rule", rule.Name(), "error", err)return 0, basemodel.InternalError(fmt.Errorf("rule evaluation failed"))}rule.SendAlerts(ctx, ts, 0, time.Minute, opts.NotifyFunc)diff --git a/ee/query-service/usage/manager.go b/ee/query-service/usage/manager.goindex ad8c8ec4ba..ec71b84378 100644--- a/ee/query-service/usage/manager.go+++ b/ee/query-service/usage/manager.go@@ -8,12 +8,12 @@ import ("sync/atomic""time"+ "log/slog"+"github.com/ClickHouse/clickhouse-go/v2""github.com/go-co-op/gocron""github.com/google/uuid"- "go.uber.org/zap"-"github.com/SigNoz/signoz/ee/query-service/model""github.com/SigNoz/signoz/pkg/licensing""github.com/SigNoz/signoz/pkg/modules/organization"@@ -76,19 +76,19 @@ func (lm *Manager) Start(ctx context.Context) error {func (lm *Manager) UploadUsage(ctx context.Context) {organizations, err := lm.orgGetter.ListByOwnedKeyRange(ctx)if err != nil {- zap.L().Error("failed to get organizations", zap.Error(err))+ slog.ErrorContext(ctx, "failed to get organizations", "error", err)return}for _, organization := range organizations {// check if license is present or notlicense, err := lm.licenseService.GetActive(ctx, organization.ID)if err != nil {- zap.L().Error("failed to get active license", zap.Error(err))+ slog.ErrorContext(ctx, "failed to get active license", "error", err)return}if license == nil {// we will not start the usage reporting if license is not present.- zap.L().Info("no license present, skipping usage reporting")+ slog.InfoContext(ctx, "no license present, skipping usage reporting")return}@@ -115,7 +115,7 @@ func (lm *Manager) UploadUsage(ctx context.Context) {dbusages := []model.UsageDB{}err := lm.clickhouseConn.Select(ctx, &dbusages, fmt.Sprintf(query, db, db), time.Now().Add(-(24 * time.Hour)))if err != nil && !strings.Contains(err.Error(), "doesn't exist") {- zap.L().Error("failed to get usage from clickhouse: %v", zap.Error(err))+ slog.ErrorContext(ctx, "failed to get usage from clickhouse", "error", err)return}for _, u := range dbusages {@@ -125,24 +125,24 @@ func (lm *Manager) UploadUsage(ctx context.Context) {}if len(usages) <= 0 {- zap.L().Info("no snapshots to upload, skipping.")+ slog.InfoContext(ctx, "no snapshots to upload, skipping")return}- zap.L().Info("uploading usage data")+ slog.InfoContext(ctx, "uploading usage data")usagesPayload := []model.Usage{}for _, usage := range usages {usageDataBytes, err := encryption.Decrypt([]byte(usage.ExporterID[:32]), []byte(usage.Data))if err != nil {- zap.L().Error("error while decrypting usage data: %v", zap.Error(err))+ slog.ErrorContext(ctx, "error while decrypting usage data", "error", err)return}usageData := model.Usage{}err = json.Unmarshal(usageDataBytes, &usageData)if err != nil {- zap.L().Error("error while unmarshalling usage data: %v", zap.Error(err))+ slog.ErrorContext(ctx, "error while unmarshalling usage data", "error", err)return}@@ -163,13 +163,13 @@ func (lm *Manager) UploadUsage(ctx context.Context) {body, errv2 := json.Marshal(payload)if errv2 != nil {- zap.L().Error("error while marshalling usage payload: %v", zap.Error(errv2))+ slog.ErrorContext(ctx, "error while marshalling usage payload", "error", errv2)return}errv2 = lm.zeus.PutMeters(ctx, payload.LicenseKey.String(), body)if errv2 != nil {- zap.L().Error("failed to upload usage: %v", zap.Error(errv2))+ slog.ErrorContext(ctx, "failed to upload usage", "error", errv2)// not returning error here since it is captured in the failed countreturn}@@ -179,7 +179,7 @@ func (lm *Manager) UploadUsage(ctx context.Context) {func (lm *Manager) Stop(ctx context.Context) {lm.scheduler.Stop()- zap.L().Info("sending usage data before shutting down")+ slog.InfoContext(ctx, "sending usage data before shutting down")// send usage before shutting downlm.UploadUsage(ctx)atomic.StoreUint32(&locker, stateUnlocked)diff --git a/pkg/instrumentation/loghandler/filtering.go b/pkg/instrumentation/loghandler/filtering.gonew file mode 100644index 0000000000..1fcd6b2a90--- /dev/null+++ b/pkg/instrumentation/loghandler/filtering.go@@ -0,0 +1,41 @@+package loghandler++import (+ "context"+ "log/slog"++ "github.com/SigNoz/signoz/pkg/errors"+)++type filtering struct{}++func NewFiltering() *filtering {+ return &filtering{}+}++func (h *filtering) Wrap(next LogHandler) LogHandler {+ return LogHandlerFunc(func(ctx context.Context, record slog.Record) error {+ if !filterRecord(record) {+ return nil+ }++ return next.Handle(ctx, record)+ })+}++func filterRecord(record slog.Record) bool {+ suppress := false+ record.Attrs(func(a slog.Attr) bool {+ if a.Value.Kind() == slog.KindAny {+ if err, ok := a.Value.Any().(error); ok {+ if errors.Is(err, context.Canceled) {+ suppress = true+ return false+ }+ }+ }+ return true+ })++ return !suppress+}diff --git a/pkg/instrumentation/loghandler/filtering_test.go b/pkg/instrumentation/loghandler/filtering_test.gonew file mode 100644index 0000000000..d10a9c86bd--- /dev/null+++ b/pkg/instrumentation/loghandler/filtering_test.go@@ -0,0 +1,52 @@+package loghandler++import (+ "bytes"+ "context"+ "encoding/json"+ "log/slog"+ "testing"++ "github.com/SigNoz/signoz/pkg/errors"+ "github.com/stretchr/testify/assert"+ "github.com/stretchr/testify/require"+)++func TestFiltering_SuppressesContextCanceled(t *testing.T) {+ filtering := NewFiltering()++ buf := bytes.NewBuffer(nil)+ logger := slog.New(&handler{base: slog.NewJSONHandler(buf, &slog.HandlerOptions{Level: slog.LevelDebug}), wrappers: []Wrapper{filtering}})++ logger.ErrorContext(context.Background(), "operation failed", "error", context.Canceled)++ assert.Empty(t, buf.String(), "log with context.Canceled should be suppressed")+}++func TestFiltering_AllowsOtherErrors(t *testing.T) {+ filtering := NewFiltering()++ buf := bytes.NewBuffer(nil)+ logger := slog.New(&handler{base: slog.NewJSONHandler(buf, &slog.HandlerOptions{Level: slog.LevelDebug}), wrappers: []Wrapper{filtering}})++ logger.ErrorContext(context.Background(), "operation failed", "error", errors.New(errors.TypeInternal, errors.CodeInternal, "some other error"))++ m := make(map[string]any)+ err := json.Unmarshal(buf.Bytes(), &m)+ require.NoError(t, err)+ assert.Equal(t, "operation failed", m["msg"])+}++func TestFiltering_AllowsLogsWithoutErrors(t *testing.T) {+ filtering := NewFiltering()++ buf := bytes.NewBuffer(nil)+ logger := slog.New(&handler{base: slog.NewJSONHandler(buf, &slog.HandlerOptions{Level: slog.LevelDebug}), wrappers: []Wrapper{filtering}})++ logger.InfoContext(context.Background(), "normal log", "key", "value")++ m := make(map[string]any)+ err := json.Unmarshal(buf.Bytes(), &m)+ require.NoError(t, err)+ assert.Equal(t, "normal log", m["msg"])+}diff --git a/pkg/instrumentation/sdk.go b/pkg/instrumentation/sdk.goindex 96a7511da2..8d3bb3c081 100644--- a/pkg/instrumentation/sdk.go+++ b/pkg/instrumentation/sdk.go@@ -116,7 +116,7 @@ func New(ctx context.Context, cfg Config, build version.Build, serviceName strinmeterProvider: meterProvider,meterProviderShutdownFunc: meterProviderShutdownFunc,prometheusRegistry: prometheusRegistry,- logger: NewLogger(cfg, loghandler.NewCorrelation()),+ logger: NewLogger(cfg, loghandler.NewCorrelation(), loghandler.NewFiltering()),startCh: make(chan struct{}),}, nil}diff --git a/pkg/query-service/agentConf/db.go b/pkg/query-service/agentConf/db.goindex 12ce60de93..22e0774ee0 100644--- a/pkg/query-service/agentConf/db.go+++ b/pkg/query-service/agentConf/db.go@@ -7,13 +7,14 @@ import ("strings""time"+ "log/slog"+"github.com/SigNoz/signoz/pkg/errors""github.com/SigNoz/signoz/pkg/query-service/model""github.com/SigNoz/signoz/pkg/sqlstore""github.com/SigNoz/signoz/pkg/types""github.com/SigNoz/signoz/pkg/types/opamptypes""github.com/SigNoz/signoz/pkg/valuer"- "go.uber.org/zap""golang.org/x/exp/slices")@@ -121,7 +122,7 @@ func (r *Repo) insertConfig(// allowing empty elements for logs - use case is deleting all pipelinesif len(elements) == 0 && c.ElementType != opamptypes.ElementTypeLogPipelines {- zap.L().Error("insert config called with no elements ", zap.String("ElementType", c.ElementType.StringValue()))+ slog.ErrorContext(ctx, "insert config called with no elements", "element_type", c.ElementType.StringValue())return errors.NewInvalidInputf(CodeConfigElementsRequired, "config must have atleast one element")}@@ -129,13 +130,13 @@ func (r *Repo) insertConfig(// the version can not be set by the user, we want to auto-assign the versions// in a monotonically increasing order starting with 1. hence, we reject insert// requests with version anything other than 0. here, 0 indicates un-assigned- zap.L().Error("invalid version assignment while inserting agent config", zap.Int("version", c.Version), zap.String("ElementType", c.ElementType.StringValue()))+ slog.ErrorContext(ctx, "invalid version assignment while inserting agent config", "version", c.Version, "element_type", c.ElementType.StringValue())return errors.NewInvalidInputf(errors.CodeInvalidInput, "user defined versions are not supported in the agent config")}configVersion, err := r.GetLatestVersion(ctx, orgId, c.ElementType)if err != nil && !errors.Ast(err, errors.TypeNotFound) {- zap.L().Error("failed to fetch latest config version", zap.Error(err))+ slog.ErrorContext(ctx, "failed to fetch latest config version", "error", err)return err}@@ -155,11 +156,11 @@ func (r *Repo) insertConfig(// Delete elements first, then version (to respect potential foreign key constraints)_, delErr := r.store.BunDB().NewDelete().Model(new(opamptypes.AgentConfigElement)).Where("version_id = ?", c.ID).Exec(ctx)if delErr != nil {- zap.L().Error("failed to delete config elements during cleanup", zap.Error(delErr), zap.String("version_id", c.ID.String()))+ slog.ErrorContext(ctx, "failed to delete config elements during cleanup", "error", delErr, "version_id", c.ID.String())}_, delErr = r.store.BunDB().NewDelete().Model(new(opamptypes.AgentConfigVersion)).Where("id = ?", c.ID).Where("org_id = ?", orgId).Exec(ctx)if delErr != nil {- zap.L().Error("failed to delete config version during cleanup", zap.Error(delErr), zap.String("version_id", c.ID.String()))+ slog.ErrorContext(ctx, "failed to delete config version during cleanup", "error", delErr, "version_id", c.ID.String())}}}()@@ -170,7 +171,7 @@ func (r *Repo) insertConfig(Model(c).Exec(ctx)if dbErr != nil {- zap.L().Error("error in inserting config version: ", zap.Error(dbErr))+ slog.ErrorContext(ctx, "error in inserting config version", "error", dbErr)return errors.WrapInternalf(dbErr, CodeConfigVersionInsertFailed, "failed to insert config version")}@@ -221,7 +222,7 @@ func (r *Repo) updateDeployStatus(ctx context.Context,Where("org_id = ?", orgId).Exec(ctx)if err != nil {- zap.L().Error("failed to update deploy status", zap.Error(err))+ slog.ErrorContext(ctx, "failed to update deploy status", "error", err)return model.BadRequest(fmt.Errorf("failed to update deploy status"))}@@ -239,7 +240,7 @@ func (r *Repo) updateDeployStatusByHash(Where("org_id = ?", orgId).Exec(ctx)if err != nil {- zap.L().Error("failed to update deploy status", zap.Error(err))+ slog.ErrorContext(ctx, "failed to update deploy status", "error", err)return errors.WrapInternalf(err, CodeConfigDeployStatusUpdateFailed, "failed to update deploy status")}diff --git a/pkg/query-service/agentConf/manager.go b/pkg/query-service/agentConf/manager.goindex 6658f9f13c..9d5db2a8d8 100644--- a/pkg/query-service/agentConf/manager.go+++ b/pkg/query-service/agentConf/manager.go@@ -4,6 +4,7 @@ import ("context""crypto/sha256""fmt"+ "log/slog""strings""sync""sync/atomic"@@ -17,7 +18,6 @@ import ("github.com/SigNoz/signoz/pkg/types/opamptypes""github.com/SigNoz/signoz/pkg/valuer""github.com/google/uuid"- "go.uber.org/zap"yaml "gopkg.in/yaml.v3")@@ -36,7 +36,8 @@ type AgentFeatureType stringtype Manager struct {Repo// lock to make sure only one update is sent to remote agents at a time- lock uint32+ lock uint32+ logger *slog.Logger// For AgentConfigProvider implementationagentFeatures []AgentFeature@@ -67,6 +68,7 @@ func Initiate(options *ManagerOptions) (*Manager, error) {m = &Manager{Repo: Repo{options.Store},+ logger: slog.Default(),agentFeatures: options.AgentFeatures,configSubscribers: map[string]func(){},}@@ -222,19 +224,19 @@ func NotifyConfigUpdate(ctx context.Context) {func Redeploy(ctx context.Context, orgId valuer.UUID, typ opamptypes.ElementType, version int) error {configVersion, err := GetConfigVersion(ctx, orgId, typ, version)if err != nil {- zap.L().Error("failed to fetch config version during redeploy", zap.Error(err))+ slog.ErrorContext(ctx, "failed to fetch config version during redeploy", "error", err)return err}if configVersion == nil || (configVersion != nil && configVersion.Config == "") {- zap.L().Debug("config version has no conf yaml", zap.Any("configVersion", configVersion))+ slog.DebugContext(ctx, "config version has no conf yaml", "config_version", configVersion)return errors.NewInvalidInputf(CodeConfigVersionNoConfig, "the config version can not be redeployed")}switch typ {case opamptypes.ElementTypeSamplingRules:var config *tsp.Configif err := yaml.Unmarshal([]byte(configVersion.Config), &config); err != nil {- zap.L().Debug("failed to read last conf correctly", zap.Error(err))+ slog.DebugContext(ctx, "failed to read last conf correctly", "error", err)return model.BadRequest(fmt.Errorf("failed to read the stored config correctly"))}@@ -246,7 +248,7 @@ func Redeploy(ctx context.Context, orgId valuer.UUID, typ opamptypes.ElementTypeopamp.AddToTracePipelineSpec("signoz_tail_sampling")configHash, err := opamp.UpsertControlProcessors(ctx, "traces", processorConf, m.OnConfigUpdate)if err != nil {- zap.L().Error("failed to call agent config update for trace processor", zap.Error(err))+ slog.ErrorContext(ctx, "failed to call agent config update for trace processor", "error", err)return errors.WithAdditionalf(err, "failed to deploy the config")}@@ -254,7 +256,7 @@ func Redeploy(ctx context.Context, orgId valuer.UUID, typ opamptypes.ElementTypecase opamptypes.ElementTypeDropRules:var filterConfig *filterprocessor.Configif err := yaml.Unmarshal([]byte(configVersion.Config), &filterConfig); err != nil {- zap.L().Error("failed to read last conf correctly", zap.Error(err))+ slog.ErrorContext(ctx, "failed to read last conf correctly", "error", err)return model.InternalError(fmt.Errorf("failed to read the stored config correctly"))}processorConf := map[string]interface{}{@@ -264,7 +266,7 @@ func Redeploy(ctx context.Context, orgId valuer.UUID, typ opamptypes.ElementTypeopamp.AddToMetricsPipelineSpec("filter")configHash, err := opamp.UpsertControlProcessors(ctx, "metrics", processorConf, m.OnConfigUpdate)if err != nil {- zap.L().Error("failed to call agent config update for trace processor", zap.Error(err))+ slog.ErrorContext(ctx, "failed to call agent config update for trace processor", "error", err)return err}@@ -290,13 +292,13 @@ func UpsertFilterProcessor(ctx context.Context, orgId valuer.UUID, version int,opamp.AddToMetricsPipelineSpec("filter")configHash, err := opamp.UpsertControlProcessors(ctx, "metrics", processorConf, m.OnConfigUpdate)if err != nil {- zap.L().Error("failed to call agent config update for trace processor", zap.Error(err))+ slog.ErrorContext(ctx, "failed to call agent config update for trace processor", "error", err)return err}processorConfYaml, yamlErr := yaml.Marshal(config)if yamlErr != nil {- zap.L().Warn("unexpected error while transforming processor config to yaml", zap.Error(yamlErr))+ slog.WarnContext(ctx, "unexpected error while transforming processor config to yaml", "error", yamlErr)}m.updateDeployStatus(ctx, orgId, opamptypes.ElementTypeDropRules, version, opamptypes.DeployInitiated.StringValue(), "Deployment started", configHash, string(processorConfYaml))@@ -315,7 +317,7 @@ func (m *Manager) OnConfigUpdate(orgId valuer.UUID, agentId string, hash string,message := "Deployment was successful"defer func() {- zap.L().Info(status, zap.String("agentId", agentId), zap.String("agentResponse", message))+ m.logger.Info(status, "agent_id", agentId, "agent_response", message)}()if err != nil {@@ -341,13 +343,13 @@ func UpsertSamplingProcessor(ctx context.Context, orgId valuer.UUID, version intopamp.AddToTracePipelineSpec("signoz_tail_sampling")configHash, err := opamp.UpsertControlProcessors(ctx, "traces", processorConf, m.OnConfigUpdate)if err != nil {- zap.L().Error("failed to call agent config update for trace processor", zap.Error(err))+ slog.ErrorContext(ctx, "failed to call agent config update for trace processor", "error", err)return err}processorConfYaml, yamlErr := yaml.Marshal(config)if yamlErr != nil {- zap.L().Warn("unexpected error while transforming processor config to yaml", zap.Error(yamlErr))+ slog.WarnContext(ctx, "unexpected error while transforming processor config to yaml", "error", yamlErr)}m.updateDeployStatus(ctx, orgId, opamptypes.ElementTypeSamplingRules, version, opamptypes.DeployInitiated.StringValue(), "Deployment started", configHash, string(processorConfYaml))diff --git a/pkg/query-service/app/clickhouseReader/filter_suggestions.go b/pkg/query-service/app/clickhouseReader/filter_suggestions.goindex 1b49bb526c..1ad47baafd 100644--- a/pkg/query-service/app/clickhouseReader/filter_suggestions.go+++ b/pkg/query-service/app/clickhouseReader/filter_suggestions.go@@ -11,7 +11,6 @@ import ("github.com/SigNoz/signoz-otel-collector/utils/fingerprint""github.com/SigNoz/signoz/pkg/query-service/model"v3 "github.com/SigNoz/signoz/pkg/query-service/model/v3"- "go.uber.org/zap")func (r *ClickHouseReader) GetQBFilterSuggestionsForLogs(@@ -79,7 +78,7 @@ func (r *ClickHouseReader) GetQBFilterSuggestionsForLogs()if err != nil {// Do not fail the entire request if only example query generation fails- zap.L().Error("could not find attribute values for creating example query", zap.Error(err))+ r.logger.ErrorContext(ctx, "could not find attribute values for creating example query", "error", err)} else {// add example queries for as many attributes as possible.@@ -159,10 +158,7 @@ func (r *ClickHouseReader) getValuesForLogAttributes(*/if len(attributes) > 10 {- zap.L().Error(- "log attribute values requested for too many attributes. This can lead to slow and costly queries",- zap.Int("count", len(attributes)),- )+ r.logger.ErrorContext(ctx, "log attribute values requested for too many attributes. This can lead to slow and costly queries", "count", len(attributes))attributes = attributes[:10]}@@ -187,7 +183,7 @@ func (r *ClickHouseReader) getValuesForLogAttributes(rows, err := r.db.Query(ctx, query, tagKeyQueryArgs...)if err != nil {- zap.L().Error("couldn't query attrib values for suggestions", zap.Error(err))+ r.logger.ErrorContext(ctx, "couldn't query attrib values for suggestions", "error", err)return nil, model.InternalError(fmt.Errorf("couldn't query attrib values for suggestions: %w", err,))diff --git a/pkg/query-service/app/clickhouseReader/query_progress/inmemory_tracker.go b/pkg/query-service/app/clickhouseReader/query_progress/inmemory_tracker.goindex cc18850faa..8af1f96b2f 100644--- a/pkg/query-service/app/clickhouseReader/query_progress/inmemory_tracker.go+++ b/pkg/query-service/app/clickhouseReader/query_progress/inmemory_tracker.go@@ -2,17 +2,18 @@ package queryprogressimport ("fmt"+ "log/slog""sync""github.com/ClickHouse/clickhouse-go/v2""github.com/SigNoz/signoz/pkg/query-service/model""github.com/google/uuid"- "go.uber.org/zap""golang.org/x/exp/maps")// tracks progress and manages subscriptions for all queriestype inMemoryQueryProgressTracker struct {+ logger *slog.Loggerqueries map[string]*queryTrackerlock sync.RWMutex}@@ -30,7 +31,7 @@ func (tracker *inMemoryQueryProgressTracker) ReportQueryStarted())}- tracker.queries[queryId] = newQueryTracker(queryId)+ tracker.queries[queryId] = newQueryTracker(tracker.logger, queryId)return func() {tracker.onQueryFinished(queryId)@@ -93,6 +94,7 @@ func (tracker *inMemoryQueryProgressTracker) getQueryTracker(// Tracks progress and manages subscriptions for a single querytype queryTracker struct {+ logger *slog.LoggerqueryId stringisFinished bool@@ -102,8 +104,9 @@ type queryTracker struct {lock sync.Mutex}-func newQueryTracker(queryId string) *queryTracker {+func newQueryTracker(logger *slog.Logger, queryId string) *queryTracker {return &queryTracker{+ logger: logger,queryId: queryId,subscriptions: map[string]*queryProgressSubscription{},}@@ -114,10 +117,7 @@ func (qt *queryTracker) handleProgressUpdate(p *clickhouse.Progress) {defer qt.lock.Unlock()if qt.isFinished {- zap.L().Warn(- "received clickhouse progress update for finished query",- zap.String("queryId", qt.queryId), zap.Any("progress", p),- )+ qt.logger.Warn("received clickhouse progress update for finished query", "queryId", qt.queryId, "progress", p)return}@@ -146,7 +146,7 @@ func (qt *queryTracker) subscribe() (}subscriberId := uuid.NewString()- subscription := newQueryProgressSubscription()+ subscription := newQueryProgressSubscription(qt.logger)qt.subscriptions[subscriberId] = subscriptionif qt.progress != nil {@@ -163,11 +163,7 @@ func (qt *queryTracker) unsubscribe(subscriberId string) {defer qt.lock.Unlock()if qt.isFinished {- zap.L().Debug(- "received unsubscribe request after query finished",- zap.String("subscriber", subscriberId),- zap.String("queryId", qt.queryId),- )+ qt.logger.Debug("received unsubscribe request after query finished", "subscriber", subscriberId, "queryId", qt.queryId)return}@@ -183,10 +179,7 @@ func (qt *queryTracker) onFinished() {defer qt.lock.Unlock()if qt.isFinished {- zap.L().Warn(- "receiver query finish report after query finished",- zap.String("queryId", qt.queryId),- )+ qt.logger.Warn("receiver query finish report after query finished", "queryId", qt.queryId)return}@@ -199,15 +192,17 @@ func (qt *queryTracker) onFinished() {}type queryProgressSubscription struct {+ logger *slog.Loggerch chan model.QueryProgressisClosed boollock sync.Mutex}-func newQueryProgressSubscription() *queryProgressSubscription {+func newQueryProgressSubscription(logger *slog.Logger) *queryProgressSubscription {ch := make(chan model.QueryProgress, 1000)return &queryProgressSubscription{- ch: ch,+ logger: logger,+ ch: ch,}}@@ -217,10 +212,7 @@ func (ch *queryProgressSubscription) send(progress model.QueryProgress) {defer ch.lock.Unlock()if ch.isClosed {- zap.L().Error(- "can't send query progress: channel already closed.",- zap.Any("progress", progress),- )+ ch.logger.Error("can't send query progress: channel already closed.", "progress", progress)return}@@ -228,12 +220,9 @@ func (ch *queryProgressSubscription) send(progress model.QueryProgress) {// blocking while sending doesn't happen in the happy pathselect {case ch.ch <- progress:- zap.L().Debug("published query progress", zap.Any("progress", progress))+ ch.logger.Debug("published query progress", "progress", progress)default:- zap.L().Error(- "couldn't publish query progress. dropping update.",- zap.Any("progress", progress),- )+ ch.logger.Error("couldn't publish query progress. dropping update.", "progress", progress)}}diff --git a/pkg/query-service/app/clickhouseReader/query_progress/tracker.go b/pkg/query-service/app/clickhouseReader/query_progress/tracker.goindex 628fa40178..cafaaacf49 100644--- a/pkg/query-service/app/clickhouseReader/query_progress/tracker.go+++ b/pkg/query-service/app/clickhouseReader/query_progress/tracker.go@@ -1,6 +1,8 @@package queryprogressimport (+ "log/slog"+"github.com/ClickHouse/clickhouse-go/v2""github.com/SigNoz/signoz/pkg/query-service/model")@@ -21,10 +23,11 @@ type QueryProgressTracker interface {SubscribeToQueryProgress(queryId string) (ch <-chan model.QueryProgress, unsubscribe func(), apiErr *model.ApiError)}-func NewQueryProgressTracker() QueryProgressTracker {+func NewQueryProgressTracker(logger *slog.Logger) QueryProgressTracker {// InMemory tracker is useful only for single replica query service setups.// Multi replica setups must use a centralized store for tracking and subscribing to query progressreturn &inMemoryQueryProgressTracker{+ logger: logger,queries: map[string]*queryTracker{},}}diff --git a/pkg/query-service/app/clickhouseReader/query_progress/tracker_test.go b/pkg/query-service/app/clickhouseReader/query_progress/tracker_test.goindex 169151bfa7..43e580e368 100644--- a/pkg/query-service/app/clickhouseReader/query_progress/tracker_test.go+++ b/pkg/query-service/app/clickhouseReader/query_progress/tracker_test.go@@ -1,6 +1,7 @@package queryprogressimport (+ "log/slog""testing""time"@@ -12,7 +13,7 @@ import (func TestQueryProgressTracking(t *testing.T) {require := require.New(t)- tracker := NewQueryProgressTracker()+ tracker := NewQueryProgressTracker(slog.Default())testQueryId := "test-query"diff --git a/pkg/query-service/app/clickhouseReader/reader.go b/pkg/query-service/app/clickhouseReader/reader.goindex ca06ac90aa..91b97a1f42 100644--- a/pkg/query-service/app/clickhouseReader/reader.go+++ b/pkg/query-service/app/clickhouseReader/reader.go@@ -37,7 +37,7 @@ import ("github.com/ClickHouse/clickhouse-go/v2/lib/driver""github.com/SigNoz/signoz/pkg/cache"- "go.uber.org/zap"+ "log/slog"queryprogress "github.com/SigNoz/signoz/pkg/query-service/app/clickhouseReader/query_progress""github.com/SigNoz/signoz/pkg/query-service/app/resource"@@ -138,6 +138,7 @@ type ClickHouseReader struct {logsAttributeKeys stringlogsResourceKeys stringlogsTagAttributeTableV2 string+ logger *slog.LoggerqueryProgressTracker queryprogress.QueryProgressTrackerlogsTableV2 string@@ -165,6 +166,7 @@ type ClickHouseReader struct {// NewTraceReader returns a TraceReader for the databasefunc NewReader(+ logger *slog.Logger,sqlDB sqlstore.SQLStore,telemetryStore telemetrystore.TelemetryStore,prometheus prometheus.Prometheus,@@ -185,6 +187,7 @@ func NewReader(return &ClickHouseReader{db: telemetryStore.ClickhouseDB(),+ logger: logger,prometheus: prometheus,sqlDB: sqlDB,TraceDB: options.primary.TraceDB,@@ -206,7 +209,7 @@ func NewReader(logsTagAttributeTableV2: options.primary.LogsTagAttributeTableV2,liveTailRefreshSeconds: options.primary.LiveTailRefreshSeconds,cluster: cluster,- queryProgressTracker: queryprogress.NewQueryProgressTracker(),+ queryProgressTracker: queryprogress.NewQueryProgressTracker(logger),logsTableV2: options.primary.LogsTableV2,logsLocalTableV2: options.primary.LogsLocalTableV2,logsResourceTableV2: options.primary.LogsResourceTableV2,@@ -318,7 +321,7 @@ func (r *ClickHouseReader) GetTopLevelOperations(ctx context.Context, start, endrows, err := r.db.Query(ctx, query, clickhouse.Named("start", start), clickhouse.Named("services", services))if err != nil {- zap.L().Error("Error in processing sql query", zap.Error(err))+ r.logger.Error("Error in processing sql query", "error", err)return nil, &model.ApiError{Typ: model.ErrorExec, Err: fmt.Errorf("error in processing sql query")}}@@ -390,7 +393,7 @@ func (r *ClickHouseReader) buildResourceSubQuery(tags []model.TagQueryParam, svcv3.AttributeKey{},false)if err != nil {- zap.L().Error("Error in processing sql query", zap.Error(err))+ r.logger.Error("Error in processing sql query", "error", err)return "", err}return resourceSubQuery, nil@@ -470,7 +473,7 @@ func (r *ClickHouseReader) GetServices(ctx context.Context, queryParams *model.GresourceSubQuery, err := r.buildResourceSubQuery(queryParams.Tags, svc, *queryParams.Start, *queryParams.End)if err != nil {- zap.L().Error("Error in processing sql query", zap.Error(err))+ r.logger.Error("Error in processing sql query", "error", err)return}query += `@@ -495,7 +498,7 @@ func (r *ClickHouseReader) GetServices(ctx context.Context, queryParams *model.G}if err != nil {- zap.L().Error("Error in processing sql query", zap.Error(err))+ r.logger.Error("Error in processing sql query", "error", err)return}@@ -507,7 +510,7 @@ func (r *ClickHouseReader) GetServices(ctx context.Context, queryParams *model.Gerr = r.db.QueryRow(ctx, errorQuery, args...).Scan(&numErrors)if err != nil {- zap.L().Error("Error in processing sql query", zap.Error(err))+ r.logger.Error("Error in processing sql query", "error", err)return}@@ -790,7 +793,7 @@ func (r *ClickHouseReader) GetTopOperations(ctx context.Context, queryParams *moresourceSubQuery, err := r.buildResourceSubQuery(queryParams.Tags, queryParams.ServiceName, *queryParams.Start, *queryParams.End)if err != nil {- zap.L().Error("Error in processing sql query", zap.Error(err))+ r.logger.Error("Error in processing sql query", "error", err)return nil, &model.ApiError{Typ: model.ErrorExec, Err: fmt.Errorf("error in processing sql query")}}query += `@@ -807,7 +810,7 @@ func (r *ClickHouseReader) GetTopOperations(ctx context.Context, queryParams *moerr = r.db.Select(ctx, &topOperationsItems, query, namedArgs...)if err != nil {- zap.L().Error("Error in processing sql query", zap.Error(err))+ r.logger.Error("Error in processing sql query", "error", err)return nil, &model.ApiError{Typ: model.ErrorExec, Err: fmt.Errorf("error in processing sql query")}}@@ -841,10 +844,10 @@ func (r *ClickHouseReader) GetUsage(ctx context.Context, queryParams *model.GetUerr := r.db.Select(ctx, &usageItems, query, namedArgs...)- zap.L().Info(query)+ r.logger.Info(query)if err != nil {- zap.L().Error("Error in processing sql query", zap.Error(err))+ r.logger.Error("Error in processing sql query", "error", err)return nil, fmt.Errorf("error in processing sql query")}@@ -874,19 +877,19 @@ func (r *ClickHouseReader) GetSpansForTrace(ctx context.Context, traceID string,if err == sql.ErrNoRows {return []model.SpanItemV2{}, nil}- zap.L().Error("Error in processing trace summary sql query", zap.Error(err))+ r.logger.Error("Error in processing trace summary sql query", "error", err)return nil, model.ExecutionError(fmt.Errorf("error in processing trace summary sql query: %w", err))}var searchScanResponses []model.SpanItemV2queryStartTime := time.Now()err = r.db.Select(ctx, &searchScanResponses, traceDetailsQuery, traceID, strconv.FormatInt(traceSummary.Start.Unix()-1800, 10), strconv.FormatInt(traceSummary.End.Unix(), 10))- zap.L().Info(traceDetailsQuery)+ r.logger.Info(traceDetailsQuery)if err != nil {- zap.L().Error("Error in processing sql query", zap.Error(err))+ r.logger.Error("Error in processing sql query", "error", err)return nil, model.ExecutionError(fmt.Errorf("error in processing trace data sql query: %w", err))}- zap.L().Info("trace details query took: ", zap.Duration("duration", time.Since(queryStartTime)), zap.String("traceID", traceID))+ r.logger.Info("trace details query took: ", "duration", time.Since(queryStartTime), "traceID", traceID)return searchScanResponses, nil}@@ -895,16 +898,16 @@ func (r *ClickHouseReader) GetWaterfallSpansForTraceWithMetadataCache(ctx contexcachedTraceData := new(model.GetWaterfallSpansForTraceWithMetadataCache)err := r.cacheForTraceDetail.Get(ctx, orgID, strings.Join([]string{"getWaterfallSpansForTraceWithMetadata", traceID}, "-"), cachedTraceData)if err != nil {- zap.L().Debug("error in retrieving getWaterfallSpansForTraceWithMetadata cache", zap.Error(err), zap.String("traceID", traceID))+ r.logger.Debug("error in retrieving getWaterfallSpansForTraceWithMetadata cache", "error", err, "traceID", traceID)return nil, err}if time.Since(time.UnixMilli(int64(cachedTraceData.EndTime))) < r.fluxIntervalForTraceDetail {- zap.L().Info("the trace end time falls under the flux interval, skipping getWaterfallSpansForTraceWithMetadata cache", zap.String("traceID", traceID))+ r.logger.Info("the trace end time falls under the flux interval, skipping getWaterfallSpansForTraceWithMetadata cache", "traceID", traceID)return nil, errors.Errorf("the trace end time falls under the flux interval, skipping getWaterfallSpansForTraceWithMetadata cache, traceID: %s", traceID)}- zap.L().Info("cache is successfully hit, applying cache for getWaterfallSpansForTraceWithMetadata", zap.String("traceID", traceID))+ r.logger.Info("cache is successfully hit, applying cache for getWaterfallSpansForTraceWithMetadata", "traceID", traceID)return cachedTraceData, nil}@@ -931,7 +934,7 @@ func (r *ClickHouseReader) GetWaterfallSpansForTraceWithMetadata(ctx context.Con}if err != nil {- zap.L().Info("cache miss for getWaterfallSpansForTraceWithMetadata", zap.String("traceID", traceID))+ r.logger.Info("cache miss for getWaterfallSpansForTraceWithMetadata", "traceID", traceID)searchScanResponses, err := r.GetSpansForTrace(ctx, traceID, fmt.Sprintf("SELECT DISTINCT ON (span_id) timestamp, duration_nano, span_id, trace_id, has_error, kind, resource_string_service$$name, name, links as references, attributes_string, attributes_number, attributes_bool, resources_string, events, status_message, status_code_string, kind_string FROM %s.%s WHERE trace_id=$1 and ts_bucket_start>=$2 and ts_bucket_start<=$3 ORDER BY timestamp ASC, name ASC", r.TraceDB, r.traceTableName))if err != nil {@@ -946,7 +949,7 @@ func (r *ClickHouseReader) GetWaterfallSpansForTraceWithMetadata(ctx context.Conref := []model.OtelSpanRef{}err := json.Unmarshal([]byte(item.References), &ref)if err != nil {- zap.L().Error("getWaterfallSpansForTraceWithMetadata: error unmarshalling references", zap.Error(err), zap.String("traceID", traceID))+ r.logger.Error("getWaterfallSpansForTraceWithMetadata: error unmarshalling references", "error", err, "traceID", traceID)return nil, errorsV2.Newf(errorsV2.TypeInvalidInput, errorsV2.CodeInvalidInput, "getWaterfallSpansForTraceWithMetadata: error unmarshalling references %s", err.Error())}@@ -966,7 +969,7 @@ func (r *ClickHouseReader) GetWaterfallSpansForTraceWithMetadata(ctx context.Convar eventMap model.Eventerr = json.Unmarshal([]byte(event), &eventMap)if err != nil {- zap.L().Error("Error unmarshalling events", zap.Error(err))+ r.logger.Error("Error unmarshalling events", "error", err)return nil, errorsV2.Newf(errorsV2.TypeInternal, errorsV2.CodeInternal, "getWaterfallSpansForTraceWithMetadata: error in unmarshalling events %s", err.Error())}events = append(events, eventMap)@@ -1076,16 +1079,16 @@ func (r *ClickHouseReader) GetWaterfallSpansForTraceWithMetadata(ctx context.ConHasMissingSpans: hasMissingSpans,}- zap.L().Info("getWaterfallSpansForTraceWithMetadata: processing pre cache", zap.Duration("duration", time.Since(processingBeforeCache)), zap.String("traceID", traceID))+ r.logger.Info("getWaterfallSpansForTraceWithMetadata: processing pre cache", "duration", time.Since(processingBeforeCache), "traceID", traceID)cacheErr := r.cacheForTraceDetail.Set(ctx, orgID, strings.Join([]string{"getWaterfallSpansForTraceWithMetadata", traceID}, "-"), &traceCache, time.Minute*5)if cacheErr != nil {- zap.L().Debug("failed to store cache for getWaterfallSpansForTraceWithMetadata", zap.String("traceID", traceID), zap.Error(err))+ r.logger.Debug("failed to store cache for getWaterfallSpansForTraceWithMetadata", "traceID", traceID, "error", err)}}processingPostCache := time.Now()selectedSpans, uncollapsedSpans, rootServiceName, rootServiceEntryPoint := tracedetail.GetSelectedSpans(req.UncollapsedSpans, req.SelectedSpanID, traceRoots, spanIdToSpanNodeMap, req.IsSelectedSpanIDUnCollapsed)- zap.L().Info("getWaterfallSpansForTraceWithMetadata: processing post cache", zap.Duration("duration", time.Since(processingPostCache)), zap.String("traceID", traceID))+ r.logger.Info("getWaterfallSpansForTraceWithMetadata: processing post cache", "duration", time.Since(processingPostCache), "traceID", traceID)// convert start timestamp to millis because right now frontend is expecting it in millisfor _, span := range selectedSpans {@@ -1113,16 +1116,16 @@ func (r *ClickHouseReader) GetFlamegraphSpansForTraceCache(ctx context.Context,cachedTraceData := new(model.GetFlamegraphSpansForTraceCache)err := r.cacheForTraceDetail.Get(ctx, orgID, strings.Join([]string{"getFlamegraphSpansForTrace", traceID}, "-"), cachedTraceData)if err != nil {- zap.L().Debug("error in retrieving getFlamegraphSpansForTrace cache", zap.Error(err), zap.String("traceID", traceID))+ r.logger.Debug("error in retrieving getFlamegraphSpansForTrace cache", "error", err, "traceID", traceID)return nil, err}if time.Since(time.UnixMilli(int64(cachedTraceData.EndTime))) < r.fluxIntervalForTraceDetail {- zap.L().Info("the trace end time falls under the flux interval, skipping getFlamegraphSpansForTrace cache", zap.String("traceID", traceID))+ r.logger.Info("the trace end time falls under the flux interval, skipping getFlamegraphSpansForTrace cache", "traceID", traceID)return nil, errors.Errorf("the trace end time falls under the flux interval, skipping getFlamegraphSpansForTrace cache, traceID: %s", traceID)}- zap.L().Info("cache is successfully hit, applying cache for getFlamegraphSpansForTrace", zap.String("traceID", traceID))+ r.logger.Info("cache is successfully hit, applying cache for getFlamegraphSpansForTrace", "traceID", traceID)return cachedTraceData, nil}@@ -1146,7 +1149,7 @@ func (r *ClickHouseReader) GetFlamegraphSpansForTrace(ctx context.Context, orgID}if err != nil {- zap.L().Info("cache miss for getFlamegraphSpansForTrace", zap.String("traceID", traceID))+ r.logger.Info("cache miss for getFlamegraphSpansForTrace", "traceID", traceID)searchScanResponses, err := r.GetSpansForTrace(ctx, traceID, fmt.Sprintf("SELECT timestamp, duration_nano, span_id, trace_id, has_error,links as references, resource_string_service$$name, name, events FROM %s.%s WHERE trace_id=$1 and ts_bucket_start>=$2 and ts_bucket_start<=$3 ORDER BY timestamp ASC, name ASC", r.TraceDB, r.traceTableName))if err != nil {@@ -1161,7 +1164,7 @@ func (r *ClickHouseReader) GetFlamegraphSpansForTrace(ctx context.Context, orgIDref := []model.OtelSpanRef{}err := json.Unmarshal([]byte(item.References), &ref)if err != nil {- zap.L().Error("Error unmarshalling references", zap.Error(err))+ r.logger.Error("Error unmarshalling references", "error", err)return nil, errorsV2.Newf(errorsV2.TypeInternal, errorsV2.CodeInternal, "getFlamegraphSpansForTrace: error in unmarshalling references %s", err.Error())}@@ -1170,7 +1173,7 @@ func (r *ClickHouseReader) GetFlamegraphSpansForTrace(ctx context.Context, orgIDvar eventMap model.Eventerr = json.Unmarshal([]byte(event), &eventMap)if err != nil {- zap.L().Error("Error unmarshalling events", zap.Error(err))+ r.logger.Error("Error unmarshalling events", "error", err)return nil, errorsV2.Newf(errorsV2.TypeInternal, errorsV2.CodeInternal, "getFlamegraphSpansForTrace: error in unmarshalling events %s", err.Error())}events = append(events, eventMap)@@ -1246,16 +1249,16 @@ func (r *ClickHouseReader) GetFlamegraphSpansForTrace(ctx context.Context, orgIDTraceRoots: traceRoots,}- zap.L().Info("getFlamegraphSpansForTrace: processing pre cache", zap.Duration("duration", time.Since(processingBeforeCache)), zap.String("traceID", traceID))+ r.logger.Info("getFlamegraphSpansForTrace: processing pre cache", "duration", time.Since(processingBeforeCache), "traceID", traceID)cacheErr := r.cacheForTraceDetail.Set(ctx, orgID, strings.Join([]string{"getFlamegraphSpansForTrace", traceID}, "-"), &traceCache, time.Minute*5)if cacheErr != nil {- zap.L().Debug("failed to store cache for getFlamegraphSpansForTrace", zap.String("traceID", traceID), zap.Error(err))+ r.logger.Debug("failed to store cache for getFlamegraphSpansForTrace", "traceID", traceID, "error", err)}}processingPostCache := time.Now()selectedSpansForRequest := tracedetail.GetSelectedSpansForFlamegraphForRequest(req.SelectedSpanID, selectedSpans, startTime, endTime)- zap.L().Info("getFlamegraphSpansForTrace: processing post cache", zap.Duration("duration", time.Since(processingPostCache)), zap.String("traceID", traceID))+ r.logger.Info("getFlamegraphSpansForTrace: processing post cache", "duration", time.Since(processingPostCache), "traceID", traceID)trace.Spans = selectedSpansForRequesttrace.StartTimestampMillis = startTime / 1000000@@ -1304,12 +1307,12 @@ func (r *ClickHouseReader) GetDependencyGraph(ctx context.Context, queryParams *query += filterQuery + " GROUP BY src, dest;"args = append(args, filterArgs...)- zap.L().Debug("GetDependencyGraph query", zap.String("query", query), zap.Any("args", args))+ r.logger.Debug("GetDependencyGraph query", "query", query, "args", args)err := r.db.Select(ctx, &response, query, args...)if err != nil {- zap.L().Error("Error in processing sql query", zap.Error(err))+ r.logger.Error("Error in processing sql query", "error", err)return nil, fmt.Errorf("error in processing sql query %w", err)}@@ -1428,13 +1431,13 @@ func (r *ClickHouseReader) setTTLLogs(ctx context.Context, orgID string, paramsModel(&ttl).Exec(ctx)if dbErr != nil {- zap.L().Error("error in inserting to ttl_status table", zap.Error(dbErr))+ r.logger.Error("error in inserting to ttl_status table", "error", dbErr)return}err := r.setColdStorage(context.Background(), tableName, params.ColdStorageVolume)if err != nil {- zap.L().Error("error in setting cold storage", zap.Error(err))+ r.logger.Error("error in setting cold storage", "error", err)statusItem, apiErr := r.checkTTLStatusItem(ctx, orgID, tableName)if apiErr == nil {_, dbErr := r.@@ -1447,16 +1450,16 @@ func (r *ClickHouseReader) setTTLLogs(ctx context.Context, orgID string, paramsWhere("id = ?", statusItem.ID.StringValue()).Exec(ctx)if dbErr != nil {- zap.L().Error("Error in processing ttl_status update sql query", zap.Error(dbErr))+ r.logger.Error("Error in processing ttl_status update sql query", "error", dbErr)return}}return}- zap.L().Info("Executing TTL request: ", zap.String("request", query))+ r.logger.Info("Executing TTL request: ", "request", query)statusItem, _ := r.checkTTLStatusItem(ctx, orgID, tableName)if err := r.db.Exec(ctx, query); err != nil {- zap.L().Error("error while setting ttl", zap.Error(err))+ r.logger.Error("error while setting ttl", "error", err)_, dbErr := r.sqlDB.BunDB().@@ -1467,7 +1470,7 @@ func (r *ClickHouseReader) setTTLLogs(ctx context.Context, orgID string, paramsWhere("id = ?", statusItem.ID.StringValue()).Exec(ctx)if dbErr != nil {- zap.L().Error("Error in processing ttl_status update sql query", zap.Error(dbErr))+ r.logger.Error("Error in processing ttl_status update sql query", "error", dbErr)return}return@@ -1482,7 +1485,7 @@ func (r *ClickHouseReader) setTTLLogs(ctx context.Context, orgID string, paramsWhere("id = ?", statusItem.ID.StringValue()).Exec(ctx)if dbErr != nil {- zap.L().Error("Error in processing ttl_status update sql query", zap.Error(dbErr))+ r.logger.Error("Error in processing ttl_status update sql query", "error", dbErr)return}}@@ -1566,7 +1569,7 @@ func (r *ClickHouseReader) setTTLTraces(ctx context.Context, orgID string, paramModel(&ttl).Exec(ctx)if dbErr != nil {- zap.L().Error("error in inserting to ttl_status table", zap.Error(dbErr))+ r.logger.Error("error in inserting to ttl_status table", "error", dbErr)return}@@ -1584,7 +1587,7 @@ func (r *ClickHouseReader) setTTLTraces(ctx context.Context, orgID string, param}err := r.setColdStorage(context.Background(), tableName, params.ColdStorageVolume)if err != nil {- zap.L().Error("Error in setting cold storage", zap.Error(err))+ r.logger.Error("Error in setting cold storage", "error", err)statusItem, apiErr := r.checkTTLStatusItem(ctx, orgID, tableName)if apiErr == nil {_, dbErr := r.@@ -1597,17 +1600,17 @@ func (r *ClickHouseReader) setTTLTraces(ctx context.Context, orgID string, paramWhere("id = ?", statusItem.ID.StringValue()).Exec(ctx)if dbErr != nil {- zap.L().Error("Error in processing ttl_status update sql query", zap.Error(dbErr))+ r.logger.Error("Error in processing ttl_status update sql query", "error", dbErr)return}}return}req += " SETTINGS materialize_ttl_after_modify=0;"- zap.L().Error(" ExecutingTTL request: ", zap.String("request", req))+ r.logger.Error(" ExecutingTTL request: ", "request", req)statusItem, _ := r.checkTTLStatusItem(ctx, orgID, tableName)if err := r.db.Exec(ctx, req); err != nil {- zap.L().Error("Error in executing set TTL query", zap.Error(err))+ r.logger.Error("Error in executing set TTL query", "error", err)_, dbErr := r.sqlDB.BunDB().@@ -1618,7 +1621,7 @@ func (r *ClickHouseReader) setTTLTraces(ctx context.Context, orgID string, paramWhere("id = ?", statusItem.ID.StringValue()).Exec(ctx)if dbErr != nil {- zap.L().Error("Error in processing ttl_status update sql query", zap.Error(dbErr))+ r.logger.Error("Error in processing ttl_status update sql query", "error", dbErr)return}return@@ -1633,7 +1636,7 @@ func (r *ClickHouseReader) setTTLTraces(ctx context.Context, orgID string, paramWhere("id = ?", statusItem.ID.StringValue()).Exec(ctx)if dbErr != nil {- zap.L().Error("Error in processing ttl_status update sql query", zap.Error(dbErr))+ r.logger.Error("Error in processing ttl_status update sql query", "error", dbErr)return}}(distributedTableName)@@ -1656,14 +1659,14 @@ func (r *ClickHouseReader) hasCustomRetentionColumn(ctx context.Context) (bool,if err != nil {if err == sql.ErrNoRows {// Column doesn't exist- zap.L().Debug("_retention_days column not found in logs table", zap.String("table", r.logsLocalTableV2))+ r.logger.Debug("_retention_days column not found in logs table", "table", r.logsLocalTableV2)return false, nil}- zap.L().Error("Error checking for _retention_days column", zap.Error(err))+ r.logger.Error("Error checking for _retention_days column", "error", err)return false, errorsV2.Wrapf(err, errorsV2.TypeInternal, errorsV2.CodeInternal, "error checking columns")}- zap.L().Debug("Found _retention_days column in logs table", zap.String("table", r.logsLocalTableV2))+ r.logger.Debug("Found _retention_days column in logs table", "table", r.logsLocalTableV2)return true, nil}@@ -1680,8 +1683,7 @@ func (r *ClickHouseReader) SetTTLV2(ctx context.Context, orgID string, params *m}if !hasCustomRetention {- zap.L().Info("Custom retention not supported, falling back to standard TTL method",- zap.String("orgID", orgID))+ r.logger.Info("Custom retention not supported, falling back to standard TTL method", "orgID", orgID)ttlParams := &model.TTLParams{Type: params.Type,@@ -1840,23 +1842,23 @@ func (r *ClickHouseReader) SetTTLV2(ctx context.Context, orgID string, params *m// Insert TTL setting record_, dbErr := r.sqlDB.BunDB().NewInsert().Model(&customTTL).Exec(ctx)if dbErr != nil {- zap.L().Error("error in inserting to custom_retention_ttl_settings table", zap.Error(dbErr))+ r.logger.Error("error in inserting to custom_retention_ttl_settings table", "error", dbErr)return nil, errorsV2.Wrapf(dbErr, errorsV2.TypeInternal, errorsV2.CodeInternal, "error inserting TTL settings")}if len(params.ColdStorageVolume) > 0 && coldStorageDuration > 0 {err := r.setColdStorage(ctx, tableName, params.ColdStorageVolume)if err != nil {- zap.L().Error("error in setting cold storage", zap.Error(err))+ r.logger.Error("error in setting cold storage", "error", err)r.updateCustomRetentionTTLStatus(ctx, orgID, tableName, constants.StatusFailed)return nil, errorsV2.Wrapf(err.Err, errorsV2.TypeInternal, errorsV2.CodeInternal, "error setting cold storage for table %s", tableName)}}for i, query := range queries {- zap.L().Debug("Executing custom retention TTL request: ", zap.String("request", query), zap.Int("step", i+1))+ r.logger.Debug("Executing custom retention TTL request: ", "request", query, "step", i+1)if err := r.db.Exec(ctx, query); err != nil {- zap.L().Error("error while setting custom retention ttl", zap.Error(err))+ r.logger.Error("error while setting custom retention ttl", "error", err)r.updateCustomRetentionTTLStatus(ctx, orgID, tableName, constants.StatusFailed)return nil, errorsV2.Wrapf(err, errorsV2.TypeInternal, errorsV2.CodeInternal, "error setting custom retention TTL for table %s, query: %s", tableName, query)}@@ -1875,21 +1877,21 @@ func (r *ClickHouseReader) buildMultiIfExpression(ttlConditions []model.CustomRevar conditions []stringfor i, rule := range ttlConditions {- zap.L().Debug("Processing rule", zap.Int("ruleIndex", i), zap.Int("ttlDays", rule.TTLDays), zap.Int("conditionsCount", len(rule.Filters)))+ r.logger.Debug("Processing rule", "ruleIndex", i, "ttlDays", rule.TTLDays, "conditionsCount", len(rule.Filters))if len(rule.Filters) == 0 {- zap.L().Warn("Rule has no filters, skipping", zap.Int("ruleIndex", i))+ r.logger.Warn("Rule has no filters, skipping", "ruleIndex", i)continue}// Build AND conditions for this rulevar andConditions []stringfor j, condition := range rule.Filters {- zap.L().Debug("Processing condition", zap.Int("ruleIndex", i), zap.Int("conditionIndex", j), zap.String("key", condition.Key), zap.Strings("values", condition.Values))+ r.logger.Debug("Processing condition", "ruleIndex", i, "conditionIndex", j, "key", condition.Key, "values", condition.Values)// This should not happen as validation should catch itif len(condition.Values) == 0 {- zap.L().Error("Condition has no values - this should have been caught in validation", zap.Int("ruleIndex", i), zap.Int("conditionIndex", j))+ r.logger.Error("Condition has no values - this should have been caught in validation", "ruleIndex", i, "conditionIndex", j)continue}@@ -1922,14 +1924,14 @@ func (r *ClickHouseReader) buildMultiIfExpression(ttlConditions []model.CustomRe// Join all conditions with ANDfullCondition := strings.Join(andConditions, " AND ")conditionWithTTL := fmt.Sprintf("%s, %d", fullCondition, rule.TTLDays)- zap.L().Debug("Adding condition to multiIf", zap.String("condition", conditionWithTTL))+ r.logger.Debug("Adding condition to multiIf", "condition", conditionWithTTL)conditions = append(conditions, conditionWithTTL)}}// Handle case where no valid conditions were foundif len(conditions) == 0 {- zap.L().Info("No valid conditions found, returning default TTL", zap.Int("defaultTTLDays", defaultTTLDays))+ r.logger.Info("No valid conditions found, returning default TTL", "defaultTTLDays", defaultTTLDays)return fmt.Sprintf("%d", defaultTTLDays)}@@ -1939,7 +1941,7 @@ func (r *ClickHouseReader) buildMultiIfExpression(ttlConditions []model.CustomRedefaultTTLDays,)- zap.L().Debug("Final multiIf expression", zap.String("expression", result))+ r.logger.Debug("Final multiIf expression", "expression", result)return result}@@ -1948,7 +1950,7 @@ func (r *ClickHouseReader) GetCustomRetentionTTL(ctx context.Context, orgID strihasCustomRetention, err := r.hasCustomRetentionColumn(ctx)if err != nil {// If there's an error checking, assume V1 and proceed- zap.L().Warn("Error checking for custom retention column, assuming V1", zap.Error(err))+ r.logger.Warn("Error checking for custom retention column, assuming V1", "error", err)hasCustomRetention = false}@@ -1969,7 +1971,7 @@ func (r *ClickHouseReader) GetCustomRetentionTTL(ctx context.Context, orgID striScan(ctx)if err != nil && err != sql.ErrNoRows {- zap.L().Error("Error in processing sql query", zap.Error(err))+ r.logger.Error("Error in processing sql query", "error", err)return nil, errorsV2.Newf(errorsV2.TypeInternal, errorsV2.CodeInternal, "error in processing get custom ttl query")}@@ -1986,7 +1988,7 @@ func (r *ClickHouseReader) GetCustomRetentionTTL(ctx context.Context, orgID strivar ttlConditions []model.CustomRetentionRuleif customTTL.Condition != "" {if err := json.Unmarshal([]byte(customTTL.Condition), &ttlConditions); err != nil {- zap.L().Error("Error parsing TTL conditions", zap.Error(err))+ r.logger.Error("Error parsing TTL conditions", "error", err)ttlConditions = []model.CustomRetentionRule{}}}@@ -2039,7 +2041,7 @@ func (r *ClickHouseReader) checkCustomRetentionTTLStatusItem(ctx context.ContextScan(ctx)if err != nil && err != sql.ErrNoRows {- zap.L().Error("Error in processing sql query", zap.Error(err))+ r.logger.Error("Error in processing sql query", "error", err)return ttl, errorsV2.Newf(errorsV2.TypeInternal, errorsV2.CodeInternal, "error in processing custom_retention_ttl_status check sql query")}@@ -2056,7 +2058,7 @@ func (r *ClickHouseReader) updateCustomRetentionTTLStatus(ctx context.Context, oWhere("id = ?", statusItem.ID.StringValue()).Exec(ctx)if dbErr != nil {- zap.L().Error("Error in processing custom_retention_ttl_status update sql query", zap.Error(dbErr))+ r.logger.Error("Error in processing custom_retention_ttl_status update sql query", "error", dbErr)}}}@@ -2239,7 +2241,7 @@ func (r *ClickHouseReader) setTTLMetrics(ctx context.Context, orgID string, paraModel(&ttl).Exec(ctx)if dbErr != nil {- zap.L().Error("error in inserting to ttl_status table", zap.Error(dbErr))+ r.logger.Error("error in inserting to ttl_status table", "error", dbErr)return}timeColumn := "timestamp_ms"@@ -2257,7 +2259,7 @@ func (r *ClickHouseReader) setTTLMetrics(ctx context.Context, orgID string, para}err := r.setColdStorage(context.Background(), tableName, params.ColdStorageVolume)if err != nil {- zap.L().Error("Error in setting cold storage", zap.Error(err))+ r.logger.Error("Error in setting cold storage", "error", err)statusItem, apiErr := r.checkTTLStatusItem(ctx, orgID, tableName)if apiErr == nil {_, dbErr := r.@@ -2270,17 +2272,17 @@ func (r *ClickHouseReader) setTTLMetrics(ctx context.Context, orgID string, paraWhere("id = ?", statusItem.ID.StringValue()).Exec(ctx)if dbErr != nil {- zap.L().Error("Error in processing ttl_status update sql query", zap.Error(dbErr))+ r.logger.Error("Error in processing ttl_status update sql query", "error", dbErr)return}}return}req += " SETTINGS materialize_ttl_after_modify=0"- zap.L().Info("Executing TTL request: ", zap.String("request", req))+ r.logger.Info("Executing TTL request: ", "request", req)statusItem, _ := r.checkTTLStatusItem(ctx, orgID, tableName)if err := r.db.Exec(ctx, req); err != nil {- zap.L().Error("error while setting ttl.", zap.Error(err))+ r.logger.Error("error while setting ttl.", "error", err)_, dbErr := r.sqlDB.BunDB().@@ -2291,7 +2293,7 @@ func (r *ClickHouseReader) setTTLMetrics(ctx context.Context, orgID string, paraWhere("id = ?", statusItem.ID.StringValue()).Exec(ctx)if dbErr != nil {- zap.L().Error("Error in processing ttl_status update sql query", zap.Error(dbErr))+ r.logger.Error("Error in processing ttl_status update sql query", "error", dbErr)return}return@@ -2306,7 +2308,7 @@ func (r *ClickHouseReader) setTTLMetrics(ctx context.Context, orgID string, paraWhere("id = ?", statusItem.ID.StringValue()).Exec(ctx)if dbErr != nil {- zap.L().Error("Error in processing ttl_status update sql query", zap.Error(dbErr))+ r.logger.Error("Error in processing ttl_status update sql query", "error", dbErr)return}}@@ -2331,7 +2333,7 @@ func (r *ClickHouseReader) deleteTtlTransactions(ctx context.Context, orgID striScan(ctx, &limitTransactions)if err != nil {- zap.L().Error("Error in processing ttl_status delete sql query", zap.Error(err))+ r.logger.Error("Error in processing ttl_status delete sql query", "error", err)}_, err = r.@@ -2342,13 +2344,13 @@ func (r *ClickHouseReader) deleteTtlTransactions(ctx context.Context, orgID striWhere("transaction_id NOT IN (?)", bun.In(limitTransactions)).Exec(ctx)if err != nil {- zap.L().Error("Error in processing ttl_status delete sql query", zap.Error(err))+ r.logger.Error("Error in processing ttl_status delete sql query", "error", err)}}// checkTTLStatusItem checks if ttl_status table has an entry for the given table namefunc (r *ClickHouseReader) checkTTLStatusItem(ctx context.Context, orgID string, tableName string) (*types.TTLSetting, *model.ApiError) {- zap.L().Info("checkTTLStatusItem query", zap.String("tableName", tableName))+ r.logger.Info("checkTTLStatusItem query", "tableName", tableName)ttl := new(types.TTLSetting)err := r.sqlDB.@@ -2361,7 +2363,7 @@ func (r *ClickHouseReader) checkTTLStatusItem(ctx context.Context, orgID string,Limit(1).Scan(ctx)if err != nil && err != sql.ErrNoRows {- zap.L().Error("Error in processing sql query", zap.Error(err))+ r.logger.Error("Error in processing sql query", "error", err)return ttl, &model.ApiError{Typ: model.ErrorExec, Err: fmt.Errorf("error in processing ttl_status check sql query")}}return ttl, nil@@ -2406,9 +2408,9 @@ func (r *ClickHouseReader) setColdStorage(ctx context.Context, tableName string,if len(coldStorageVolume) > 0 {policyReq := fmt.Sprintf("ALTER TABLE %s ON CLUSTER %s MODIFY SETTING storage_policy='tiered'", tableName, r.cluster)- zap.L().Info("Executing Storage policy request: ", zap.String("request", policyReq))+ r.logger.Info("Executing Storage policy request: ", "request", policyReq)if err := r.db.Exec(ctx, policyReq); err != nil {- zap.L().Error("error while setting storage policy", zap.Error(err))+ r.logger.Error("error while setting storage policy", "error", err)return &model.ApiError{Typ: model.ErrorExec, Err: fmt.Errorf("error while setting storage policy. Err=%v", err)}}}@@ -2425,7 +2427,7 @@ func (r *ClickHouseReader) GetDisks(ctx context.Context) (*[]model.DiskItem, *moquery := "SELECT name,type FROM system.disks"if err := r.db.Select(ctx, &diskItems, query); err != nil {- zap.L().Error("Error in processing sql query", zap.Error(err))+ r.logger.Error("Error in processing sql query", "error", err)return nil, &model.ApiError{Typ: model.ErrorExec, Err: fmt.Errorf("error while getting disks. Err=%v", err)}}@@ -2450,7 +2452,7 @@ func (r *ClickHouseReader) GetTTL(ctx context.Context, orgID string, ttlParams *})parseTTL := func(queryResp string) (int, int) {- zap.L().Info("Parsing TTL from: ", zap.String("queryResp", queryResp))+ r.logger.Info("Parsing TTL from: ", "queryResp", queryResp)deleteTTLExp := regexp.MustCompile(`toIntervalSecond\(([0-9]*)\)`)moveTTLExp := regexp.MustCompile(`toIntervalSecond\(([0-9]*)\) TO VOLUME`)@@ -2485,7 +2487,7 @@ func (r *ClickHouseReader) GetTTL(ctx context.Context, orgID string, ttlParams *err := r.db.Select(ctx, &dbResp, query)if err != nil {- zap.L().Error("error while getting ttl", zap.Error(err))+ r.logger.Error("error while getting ttl", "error", err)return nil, &model.ApiError{Typ: model.ErrorExec, Err: fmt.Errorf("error while getting ttl. Err=%v", err)}}if len(dbResp) == 0 {@@ -2503,7 +2505,7 @@ func (r *ClickHouseReader) GetTTL(ctx context.Context, orgID string, ttlParams *err := r.db.Select(ctx, &dbResp, query)if err != nil {- zap.L().Error("error while getting ttl", zap.Error(err))+ r.logger.Error("error while getting ttl", "error", err)return nil, &model.ApiError{Typ: model.ErrorExec, Err: fmt.Errorf("error while getting ttl. Err=%v", err)}}if len(dbResp) == 0 {@@ -2521,7 +2523,7 @@ func (r *ClickHouseReader) GetTTL(ctx context.Context, orgID string, ttlParams *err := r.db.Select(ctx, &dbResp, query)if err != nil {- zap.L().Error("error while getting ttl", zap.Error(err))+ r.logger.Error("error while getting ttl", "error", err)return nil, &model.ApiError{Typ: model.ErrorExec, Err: fmt.Errorf("error while getting ttl. Err=%v", err)}}if len(dbResp) == 0 {@@ -2654,7 +2656,7 @@ func (r *ClickHouseReader) ListErrors(ctx context.Context, queryParams *model.Liargs = append(args, argsSubQuery...)if errStatus != nil {- zap.L().Error("Error in processing tags", zap.Error(errStatus))+ r.logger.Error("Error in processing tags", "error", errStatus)return nil, errStatus}query = query + " GROUP BY groupID"@@ -2682,10 +2684,10 @@ func (r *ClickHouseReader) ListErrors(ctx context.Context, queryParams *model.Li}err := r.db.Select(ctx, &getErrorResponses, query, args...)- zap.L().Info(query)+ r.logger.Info(query)if err != nil {- zap.L().Error("Error in processing sql query", zap.Error(err))+ r.logger.Error("Error in processing sql query", "error", err)return nil, &model.ApiError{Typ: model.ErrorExec, Err: fmt.Errorf("error in processing sql query")}}@@ -2720,15 +2722,15 @@ func (r *ClickHouseReader) CountErrors(ctx context.Context, queryParams *model.Cargs = append(args, argsSubQuery...)if errStatus != nil {- zap.L().Error("Error in processing tags", zap.Error(errStatus))+ r.logger.Error("Error in processing tags", "error", errStatus)return 0, errStatus}err := r.db.QueryRow(ctx, query, args...).Scan(&errorCount)- zap.L().Info(query)+ r.logger.Info(query)if err != nil {- zap.L().Error("Error in processing sql query", zap.Error(err))+ r.logger.Error("Error in processing sql query", "error", err)return 0, &model.ApiError{Typ: model.ErrorExec, Err: fmt.Errorf("error in processing sql query")}}@@ -2743,7 +2745,7 @@ func (r *ClickHouseReader) GetErrorFromErrorID(ctx context.Context, queryParamsinstrumentationtypes.CodeFunctionName: "GetErrorFromErrorID",})if queryParams.ErrorID == "" {- zap.L().Error("errorId missing from params")+ r.logger.Error("errorId missing from params")return nil, &model.ApiError{Typ: model.ErrorBadData, Err: fmt.Errorf("ErrorID missing from params")}}var getErrorWithSpanReponse []model.ErrorWithSpan@@ -2752,10 +2754,10 @@ func (r *ClickHouseReader) GetErrorFromErrorID(ctx context.Context, queryParamsargs := []interface{}{clickhouse.Named("errorID", queryParams.ErrorID), clickhouse.Named("groupID", queryParams.GroupID), clickhouse.Named("timestamp", strconv.FormatInt(queryParams.Timestamp.UnixNano(), 10))}err := r.db.Select(ctx, &getErrorWithSpanReponse, query, args...)- zap.L().Info(query)+ r.logger.Info(query)if err != nil {- zap.L().Error("Error in processing sql query", zap.Error(err))+ r.logger.Error("Error in processing sql query", "error", err)return nil, &model.ApiError{Typ: model.ErrorExec, Err: fmt.Errorf("error in processing sql query")}}@@ -2781,10 +2783,10 @@ func (r *ClickHouseReader) GetErrorFromGroupID(ctx context.Context, queryParamserr := r.db.Select(ctx, &getErrorWithSpanReponse, query, args...)- zap.L().Info(query)+ r.logger.Info(query)if err != nil {- zap.L().Error("Error in processing sql query", zap.Error(err))+ r.logger.Error("Error in processing sql query", "error", err)return nil, &model.ApiError{Typ: model.ErrorExec, Err: fmt.Errorf("error in processing sql query")}}@@ -2799,7 +2801,7 @@ func (r *ClickHouseReader) GetErrorFromGroupID(ctx context.Context, queryParamsfunc (r *ClickHouseReader) GetNextPrevErrorIDs(ctx context.Context, queryParams *model.GetErrorParams) (*model.NextPrevErrorIDs, *model.ApiError) {if queryParams.ErrorID == "" {- zap.L().Error("errorId missing from params")+ r.logger.Error("errorId missing from params")return nil, &model.ApiError{Typ: model.ErrorBadData, Err: fmt.Errorf("ErrorID missing from params")}}var apiErr *model.ApiError@@ -2808,12 +2810,12 @@ func (r *ClickHouseReader) GetNextPrevErrorIDs(ctx context.Context, queryParams}getNextPrevErrorIDsResponse.NextErrorID, getNextPrevErrorIDsResponse.NextTimestamp, apiErr = r.getNextErrorID(ctx, queryParams)if apiErr != nil {- zap.L().Error("Unable to get next error ID due to err: ", zap.Error(apiErr))+ r.logger.Error("Unable to get next error ID due to err: ", "error", apiErr)return nil, apiErr}getNextPrevErrorIDsResponse.PrevErrorID, getNextPrevErrorIDsResponse.PrevTimestamp, apiErr = r.getPrevErrorID(ctx, queryParams)if apiErr != nil {- zap.L().Error("Unable to get prev error ID due to err: ", zap.Error(apiErr))+ r.logger.Error("Unable to get prev error ID due to err: ", "error", apiErr)return nil, apiErr}return &getNextPrevErrorIDsResponse, nil@@ -2834,17 +2836,17 @@ func (r *ClickHouseReader) getNextErrorID(ctx context.Context, queryParams *modeerr := r.db.Select(ctx, &getNextErrorIDReponse, query, args...)- zap.L().Info(query)+ r.logger.Info(query)if err != nil {- zap.L().Error("Error in processing sql query", zap.Error(err))+ r.logger.Error("Error in processing sql query", "error", err)return "", time.Time{}, &model.ApiError{Typ: model.ErrorExec, Err: fmt.Errorf("error in processing sql query")}}if len(getNextErrorIDReponse) == 0 {- zap.L().Info("NextErrorID not found")+ r.logger.Info("NextErrorID not found")return "", time.Time{}, nil} else if len(getNextErrorIDReponse) == 1 {- zap.L().Info("NextErrorID found")+ r.logger.Info("NextErrorID found")return getNextErrorIDReponse[0].NextErrorID, getNextErrorIDReponse[0].NextTimestamp, nil} else {if getNextErrorIDReponse[0].Timestamp.UnixNano() == getNextErrorIDReponse[1].Timestamp.UnixNano() {@@ -2855,10 +2857,10 @@ func (r *ClickHouseReader) getNextErrorID(ctx context.Context, queryParams *modeerr := r.db.Select(ctx, &getNextErrorIDReponse, query, args...)- zap.L().Info(query)+ r.logger.Info(query)if err != nil {- zap.L().Error("Error in processing sql query", zap.Error(err))+ r.logger.Error("Error in processing sql query", "error", err)return "", time.Time{}, &model.ApiError{Typ: model.ErrorExec, Err: fmt.Errorf("error in processing sql query")}}if len(getNextErrorIDReponse) == 0 {@@ -2869,26 +2871,26 @@ func (r *ClickHouseReader) getNextErrorID(ctx context.Context, queryParams *modeerr := r.db.Select(ctx, &getNextErrorIDReponse, query, args...)- zap.L().Info(query)+ r.logger.Info(query)if err != nil {- zap.L().Error("Error in processing sql query", zap.Error(err))+ r.logger.Error("Error in processing sql query", "error", err)return "", time.Time{}, &model.ApiError{Typ: model.ErrorExec, Err: fmt.Errorf("error in processing sql query")}}if len(getNextErrorIDReponse) == 0 {- zap.L().Info("NextErrorID not found")+ r.logger.Info("NextErrorID not found")return "", time.Time{}, nil} else {- zap.L().Info("NextErrorID found")+ r.logger.Info("NextErrorID found")return getNextErrorIDReponse[0].NextErrorID, getNextErrorIDReponse[0].NextTimestamp, nil}} else {- zap.L().Info("NextErrorID found")+ r.logger.Info("NextErrorID found")return getNextErrorIDReponse[0].NextErrorID, getNextErrorIDReponse[0].NextTimestamp, nil}} else {- zap.L().Info("NextErrorID found")+ r.logger.Info("NextErrorID found")return getNextErrorIDReponse[0].NextErrorID, getNextErrorIDReponse[0].NextTimestamp, nil}}@@ -2908,17 +2910,17 @@ func (r *ClickHouseReader) getPrevErrorID(ctx context.Context, queryParams *modeerr := r.db.Select(ctx, &getPrevErrorIDReponse, query, args...)- zap.L().Info(query)+ r.logger.Info(query)if err != nil {- zap.L().Error("Error in processing sql query", zap.Error(err))+ r.logger.Error("Error in processing sql query", "error", err)return "", time.Time{}, &model.ApiError{Typ: model.ErrorExec, Err: fmt.Errorf("error in processing sql query")}}if len(getPrevErrorIDReponse) == 0 {- zap.L().Info("PrevErrorID not found")+ r.logger.Info("PrevErrorID not found")return "", time.Time{}, nil} else if len(getPrevErrorIDReponse) == 1 {- zap.L().Info("PrevErrorID found")+ r.logger.Info("PrevErrorID found")return getPrevErrorIDReponse[0].PrevErrorID, getPrevErrorIDReponse[0].PrevTimestamp, nil} else {if getPrevErrorIDReponse[0].Timestamp.UnixNano() == getPrevErrorIDReponse[1].Timestamp.UnixNano() {@@ -2929,10 +2931,10 @@ func (r *ClickHouseReader) getPrevErrorID(ctx context.Context, queryParams *modeerr := r.db.Select(ctx, &getPrevErrorIDReponse, query, args...)- zap.L().Info(query)+ r.logger.Info(query)if err != nil {- zap.L().Error("Error in processing sql query", zap.Error(err))+ r.logger.Error("Error in processing sql query", "error", err)return "", time.Time{}, &model.ApiError{Typ: model.ErrorExec, Err: fmt.Errorf("error in processing sql query")}}if len(getPrevErrorIDReponse) == 0 {@@ -2943,26 +2945,26 @@ func (r *ClickHouseReader) getPrevErrorID(ctx context.Context, queryParams *modeerr := r.db.Select(ctx, &getPrevErrorIDReponse, query, args...)- zap.L().Info(query)+ r.logger.Info(query)if err != nil {- zap.L().Error("Error in processing sql query", zap.Error(err))+ r.logger.Error("Error in processing sql query", "error", err)return "", time.Time{}, &model.ApiError{Typ: model.ErrorExec, Err: fmt.Errorf("error in processing sql query")}}if len(getPrevErrorIDReponse) == 0 {- zap.L().Info("PrevErrorID not found")+ r.logger.Info("PrevErrorID not found")return "", time.Time{}, nil} else {- zap.L().Info("PrevErrorID found")+ r.logger.Info("PrevErrorID found")return getPrevErrorIDReponse[0].PrevErrorID, getPrevErrorIDReponse[0].PrevTimestamp, nil}} else {- zap.L().Info("PrevErrorID found")+ r.logger.Info("PrevErrorID found")return getPrevErrorIDReponse[0].PrevErrorID, getPrevErrorIDReponse[0].PrevTimestamp, nil}} else {- zap.L().Info("PrevErrorID found")+ r.logger.Info("PrevErrorID found")return getPrevErrorIDReponse[0].PrevErrorID, getPrevErrorIDReponse[0].PrevTimestamp, nil}}@@ -2974,7 +2976,7 @@ func (r *ClickHouseReader) FetchTemporality(ctx context.Context, orgID valuer.UU// Batch fetch all metadata at oncemetadataMap, apiErr := r.GetUpdatedMetricsMetadata(ctx, orgID, metricNames...)if apiErr != nil {- zap.L().Warn("Failed to fetch updated metrics metadata", zap.Error(apiErr))+ r.logger.Warn("Failed to fetch updated metrics metadata", "error", apiErr)return nil, apiErr}@@ -3320,10 +3322,10 @@ func (r *ClickHouseReader) QueryDashboardVars(ctx context.Context, query string)var result = model.DashboardVar{VariableValues: make([]interface{}, 0)}rows, err := r.db.Query(ctx, query)- zap.L().Info(query)+ r.logger.Info(query)if err != nil {- zap.L().Error("Error in processing sql query", zap.Error(err))+ r.logger.Error("Error in processing sql query", "error", err)return nil, err}@@ -3377,7 +3379,7 @@ func (r *ClickHouseReader) GetMetricAggregateAttributes(ctx context.Context, orgrows, err := r.db.Query(ctx, query, fmt.Sprintf("%%%s%%", req.SearchText), normalized)if err != nil {- zap.L().Error("Error while querying metric names", zap.Error(err))+ r.logger.Error("Error while querying metric names", "error", err)return nil, fmt.Errorf("error while executing metric name query: %s", err.Error())}defer rows.Close()@@ -3456,7 +3458,7 @@ func (r *ClickHouseReader) GetMeterAggregateAttributes(ctx context.Context, orgIrows, err := r.db.Query(ctx, query, fmt.Sprintf("%%%s%%", req.SearchText))if err != nil {- zap.L().Error("Error while querying meter names", zap.Error(err))+ r.logger.Error("Error while querying meter names", "error", err)return nil, fmt.Errorf("error while executing meter name query: %s", err.Error())}defer rows.Close()@@ -3511,7 +3513,7 @@ func (r *ClickHouseReader) GetMetricAttributeKeys(ctx context.Context, req *v3.F}rows, err = r.db.Query(ctx, query, req.AggregateAttribute, common.PastDayRoundOff(), normalized, fmt.Sprintf("%%%s%%", req.SearchText))if err != nil {- zap.L().Error("Error while executing query", zap.Error(err))+ r.logger.Error("Error while executing query", "error", err)return nil, fmt.Errorf("error while executing query: %s", err.Error())}defer rows.Close()@@ -3551,7 +3553,7 @@ func (r *ClickHouseReader) GetMeterAttributeKeys(ctx context.Context, req *v3.Fi}rows, err = r.db.Query(ctx, query, req.AggregateAttribute, fmt.Sprintf("%%%s%%", req.SearchText))if err != nil {- zap.L().Error("Error while executing query", zap.Error(err))+ r.logger.Error("Error while executing query", "error", err)return nil, fmt.Errorf("error while executing query: %s", err.Error())}defer rows.Close()@@ -3600,7 +3602,7 @@ func (r *ClickHouseReader) GetMetricAttributeValues(ctx context.Context, req *v3rows, err = r.db.Query(ctx, query, req.FilterAttributeKey, names, req.FilterAttributeKey, fmt.Sprintf("%%%s%%", req.SearchText), common.PastDayRoundOff(), normalized)if err != nil {- zap.L().Error("Error while executing query", zap.Error(err))+ r.logger.Error("Error while executing query", "error", err)return nil, fmt.Errorf("error while executing query: %s", err.Error())}defer rows.Close()@@ -3630,7 +3632,7 @@ func (r *ClickHouseReader) GetMetricMetadata(ctx context.Context, orgID valuer.U// 1. Fetch metadata from cache/db using unified functionmetadataMap, apiError := r.GetUpdatedMetricsMetadata(ctx, orgID, metricName)if apiError != nil {- zap.L().Error("Error in getting metric cached metadata", zap.Error(apiError))+ r.logger.Error("Error in getting metric cached metadata", "error", apiError)return nil, fmt.Errorf("error fetching metric metadata: %s", apiError.Err.Error())}@@ -3673,7 +3675,7 @@ func (r *ClickHouseReader) GetMetricMetadata(ctx context.Context, orgID valuer.Urows, err := r.db.Query(ctx, query, metricName, unixMilli, serviceName, serviceName)if err != nil {- zap.L().Error("Error while querying histogram buckets", zap.Error(err))+ r.logger.Error("Error while querying histogram buckets", "error", err)return nil, fmt.Errorf("error while querying histogram buckets: %s", err.Error())}defer rows.Close()@@ -3685,7 +3687,7 @@ func (r *ClickHouseReader) GetMetricMetadata(ctx context.Context, orgID valuer.U}le, err := strconv.ParseFloat(leStr, 64)if err != nil || math.IsInf(le, 0) {- zap.L().Error("Invalid 'le' bucket value", zap.String("value", leStr), zap.Error(err))+ r.logger.Error("Invalid 'le' bucket value", "value", leStr, "error", err)continue}leFloat64 = append(leFloat64, le)@@ -3898,7 +3900,7 @@ func (r *ClickHouseReader) GetLogAggregateAttributes(ctx context.Context, req *vquery = fmt.Sprintf("SELECT DISTINCT(tag_key), tag_type, tag_data_type from %s.%s WHERE %s and tag_type != 'logfield' limit $2", r.logsDB, r.logsTagAttributeTableV2, where)rows, err = r.db.Query(ctx, query, fmt.Sprintf("%%%s%%", req.SearchText), req.Limit)if err != nil {- zap.L().Error("Error while executing query", zap.Error(err))+ r.logger.Error("Error while executing query", "error", err)return nil, fmt.Errorf("error while executing query: %s", err.Error())}defer rows.Close()@@ -3962,7 +3964,7 @@ func (r *ClickHouseReader) GetLogAttributeKeys(ctx context.Context, req *v3.Filt}if err != nil {- zap.L().Error("Error while executing query", zap.Error(err))+ r.logger.Error("Error while executing query", "error", err)return nil, fmt.Errorf("error while executing query: %s", err.Error())}defer rows.Close()@@ -4081,7 +4083,7 @@ func (r *ClickHouseReader) FetchRelatedValues(ctx context.Context, req *v3.Filter.metadataTable,whereClause,)- zap.L().Debug("filterSubQuery for related values", zap.String("query", filterSubQuery))+ r.logger.Debug("filterSubQuery for related values", "query", filterSubQuery)rows, err := r.db.Query(ctx, filterSubQuery)if err != nil {@@ -4177,7 +4179,7 @@ func (r *ClickHouseReader) GetLogAttributeValues(ctx context.Context, req *v3.Fi}if err != nil {- zap.L().Error("Error while executing query", zap.Error(err))+ r.logger.Error("Error while executing query", "error", err)return nil, fmt.Errorf("error while executing query: %s", err.Error())}defer rows.Close()@@ -4247,7 +4249,7 @@ func readRow(vars []interface{}, columnNames []string, countOfNumberCols int) ([var metric map[string]stringerr := json.Unmarshal([]byte(*v), &metric)if err != nil {- zap.L().Error("unexpected error encountered", zap.Error(err))+ slog.Error("unexpected error encountered", "error", err)}for key, val := range metric {groupBy = append(groupBy, val)@@ -4353,7 +4355,7 @@ func readRow(vars []interface{}, columnNames []string, countOfNumberCols int) ([groupAttributes[colName] = fmt.Sprintf("%v", *v)default:- zap.L().Error("unsupported var type found in query builder query result", zap.Any("v", v), zap.String("colName", colName))+ slog.Error("unsupported var type found in query builder query result", "v", v, "colName", colName)}}if isValidPoint {@@ -4435,7 +4437,7 @@ func (r *ClickHouseReader) GetTimeSeriesResultV3(ctx context.Context, query striif queryId != nil {qid, ok := queryId.(string)if !ok {- zap.L().Error("GetTimeSeriesResultV3: queryId in ctx not a string as expected", zap.Any("queryId", queryId))+ r.logger.Error("GetTimeSeriesResultV3: queryId in ctx not a string as expected", "queryId", queryId)} else {ctx = clickhouse.Context(ctx, clickhouse.WithProgress(@@ -4443,10 +4445,7 @@ func (r *ClickHouseReader) GetTimeSeriesResultV3(ctx context.Context, query strigo func() {err := r.queryProgressTracker.ReportQueryProgress(qid, p)if err != nil {- zap.L().Error(- "Couldn't report query progress",- zap.String("queryId", qid), zap.Error(err),- )+ r.logger.Error("Couldn't report query progress", "queryId", qid, "error", err)}}()},@@ -4457,7 +4456,7 @@ func (r *ClickHouseReader) GetTimeSeriesResultV3(ctx context.Context, query strirows, err := r.db.Query(ctx, query)if err != nil {- zap.L().Error("error while reading time series result", zap.Error(err))+ r.logger.Error("error while reading time series result", "error", err)return nil, errors.New(err.Error())}defer rows.Close()@@ -4499,7 +4498,7 @@ func (r *ClickHouseReader) GetListResultV3(ctx context.Context, query string) ([})rows, err := r.db.Query(ctx, query)if err != nil {- zap.L().Error("error while reading time series result", zap.Error(err))+ r.logger.Error("error while reading time series result", "error", err)return nil, errors.New(err.Error())}@@ -4577,7 +4576,7 @@ func (r *ClickHouseReader) GetMetricsExistenceAndEarliestTime(ctx context.Contexvar count, minFirstReported uint64err := r.db.QueryRow(ctx, query, clickhouse.Named("metric_names", metricNames)).Scan(&count, &minFirstReported)if err != nil {- zap.L().Error("error getting host metrics existence and earliest time", zap.Error(err))+ r.logger.Error("error getting host metrics existence and earliest time", "error", err)return 0, 0, err}return count, minFirstReported, nil@@ -4587,7 +4586,7 @@ func getPersonalisedError(err error) error {if err == nil {return nil}- zap.L().Error("error while reading result", zap.Error(err))+ slog.Error("error while reading result", "error", err)if strings.Contains(err.Error(), "code: 307") {return chErrors.ErrResourceBytesLimitExceeded}@@ -4665,7 +4664,7 @@ func (r *ClickHouseReader) GetTraceAggregateAttributes(ctx context.Context, reqrows, err = r.db.Query(ctx, query, fmt.Sprintf("%%%s%%", req.SearchText))if err != nil {- zap.L().Error("Error while executing query", zap.Error(err))+ r.logger.Error("Error while executing query", "error", err)return nil, fmt.Errorf("error while executing query: %s", err.Error())}defer rows.Close()@@ -4731,7 +4730,7 @@ func (r *ClickHouseReader) GetTraceAttributeKeys(ctx context.Context, req *v3.Firows, err = r.db.Query(ctx, query, fmt.Sprintf("%%%s%%", req.SearchText), req.Limit)if err != nil {- zap.L().Error("Error while executing query", zap.Error(err))+ r.logger.Error("Error while executing query", "error", err)return nil, fmt.Errorf("error while executing query: %s", err.Error())}defer rows.Close()@@ -4847,7 +4846,7 @@ func (r *ClickHouseReader) GetTraceAttributeValues(ctx context.Context, req *v3.}if err != nil {- zap.L().Error("Error while executing query", zap.Error(err))+ r.logger.Error("Error while executing query", "error", err)return nil, fmt.Errorf("error while executing query: %s", err.Error())}defer rows.Close()@@ -4896,7 +4895,7 @@ func (r *ClickHouseReader) GetSpanAttributeKeysByNames(ctx context.Context, namerows, err = r.db.Query(ctx, query)if err != nil {- zap.L().Error("Error while executing query", zap.Error(err))+ r.logger.Error("Error while executing query", "error", err)return nil, fmt.Errorf("error while executing query: %s", err.Error())}defer rows.Close()@@ -5054,16 +5053,16 @@ func (r *ClickHouseReader) ReadRuleStateHistoryByRuleID(signozHistoryDBName, ruleStateHistoryTableName, whereClause, params.Order, params.Limit, params.Offset)history := []model.RuleStateHistory{}- zap.L().Debug("rule state history query", zap.String("query", query))+ r.logger.Debug("rule state history query", "query", query)err := r.db.Select(ctx, &history, query)if err != nil {- zap.L().Error("Error while reading rule state history", zap.Error(err))+ r.logger.Error("Error while reading rule state history", "error", err)return nil, err}var total uint64- zap.L().Debug("rule state history total query", zap.String("query", fmt.Sprintf("SELECT count(*) FROM %s.%s WHERE %s",- signozHistoryDBName, ruleStateHistoryTableName, whereClause)))+ r.logger.Debug("rule state history total query", "query", fmt.Sprintf("SELECT count(*) FROM %s.%s WHERE %s",+ signozHistoryDBName, ruleStateHistoryTableName, whereClause))err = r.db.QueryRow(ctx, fmt.Sprintf("SELECT count(*) FROM %s.%s WHERE %s",signozHistoryDBName, ruleStateHistoryTableName, whereClause)).Scan(&total)if err != nil {@@ -5121,11 +5120,11 @@ func (r *ClickHouseReader) ReadRuleStateHistoryTopContributorsByRuleID(ORDER BY count DESC`,signozHistoryDBName, ruleStateHistoryTableName, ruleID, model.StateFiring.String(), params.Start, params.End)- zap.L().Debug("rule state history top contributors query", zap.String("query", query))+ r.logger.Debug("rule state history top contributors query", "query", query)contributors := []model.RuleStateHistoryContributor{}err := r.db.Select(ctx, &contributors, query)if err != nil {- zap.L().Error("Error while reading rule state history", zap.Error(err))+ r.logger.Error("Error while reading rule state history", "error", err)return nil, err}@@ -5180,7 +5179,7 @@ ORDER BY firing_time ASC;`signozHistoryDBName, ruleStateHistoryTableName, ruleID, params.Start, params.End,signozHistoryDBName, ruleStateHistoryTableName, ruleID, params.Start, params.End)- zap.L().Debug("overall state transitions query", zap.String("query", query))+ r.logger.Debug("overall state transitions query", "query", query)transitions := []model.RuleStateTransition{}err := r.db.Select(ctx, &transitions, query)@@ -5312,7 +5311,7 @@ FROM matched_events;signozHistoryDBName, ruleStateHistoryTableName, ruleID, params.Start, params.End,signozHistoryDBName, ruleStateHistoryTableName, ruleID, params.Start, params.End)- zap.L().Debug("avg resolution time query", zap.String("query", query))+ r.logger.Debug("avg resolution time query", "query", query)var avgResolutionTime float64err := r.db.QueryRow(ctx, query).Scan(&avgResolutionTime)if err != nil {@@ -5370,7 +5369,7 @@ ORDER BY ts ASC;`signozHistoryDBName, ruleStateHistoryTableName, ruleID, params.Start, params.End,signozHistoryDBName, ruleStateHistoryTableName, ruleID, params.Start, params.End, step)- zap.L().Debug("avg resolution time by interval query", zap.String("query", query))+ r.logger.Debug("avg resolution time by interval query", "query", query)result, err := r.GetTimeSeriesResultV3(ctx, query)if err != nil || len(result) == 0 {return nil, err@@ -5422,21 +5421,21 @@ func (r *ClickHouseReader) GetMinAndMaxTimestampForTraceID(ctx context.Context,query := fmt.Sprintf("SELECT min(timestamp), max(timestamp) FROM %s.%s WHERE traceID IN ('%s')",r.TraceDB, r.SpansTable, strings.Join(traceID, "','"))- zap.L().Debug("GetMinAndMaxTimestampForTraceID", zap.String("query", query))+ r.logger.Debug("GetMinAndMaxTimestampForTraceID", "query", query)err := r.db.QueryRow(ctx, query).Scan(&minTime, &maxTime)if err != nil {- zap.L().Error("Error while executing query", zap.Error(err))+ r.logger.Error("Error while executing query", "error", err)return 0, 0, err}// return current time if traceID not foundif minTime.IsZero() || maxTime.IsZero() {- zap.L().Debug("minTime or maxTime is zero, traceID not found")+ r.logger.Debug("minTime or maxTime is zero, traceID not found")return time.Now().UnixNano(), time.Now().UnixNano(), nil}- zap.L().Debug("GetMinAndMaxTimestampForTraceID", zap.Any("minTime", minTime), zap.Any("maxTime", maxTime))+ r.logger.Debug("GetMinAndMaxTimestampForTraceID", "minTime", minTime, "maxTime", maxTime)return minTime.UnixNano(), maxTime.UnixNano(), nil}@@ -5472,7 +5471,7 @@ func (r *ClickHouseReader) GetAllMetricFilterAttributeKeys(ctx context.Context,valueCtx := context.WithValue(ctx, "clickhouse_max_threads", constants.MetricsExplorerClickhouseThreads)rows, err := r.db.Query(valueCtx, query, common.PastDayRoundOff(), normalized, fmt.Sprintf("%%%s%%", req.SearchText)) //only showing past day dataif err != nil {- zap.L().Error("Error while executing query", zap.Error(err))+ r.logger.Error("Error while executing query", "error", err)return nil, &model.ApiError{Typ: "ClickHouseError", Err: err}}@@ -5518,7 +5517,7 @@ func (r *ClickHouseReader) GetAllMetricFilterAttributeValues(ctx context.Contextrows, err = r.db.Query(valueCtx, query, req.FilterKey, req.FilterKey, fmt.Sprintf("%%%s%%", req.SearchText), common.PastDayRoundOff(), normalized) //only showing past day dataif err != nil {- zap.L().Error("Error while executing query", zap.Error(err))+ r.logger.Error("Error while executing query", "error", err)return nil, &model.ApiError{Typ: "ClickHouseError", Err: err}}defer rows.Close()@@ -5552,7 +5551,7 @@ func (r *ClickHouseReader) GetAllMetricFilterUnits(ctx context.Context, req *metvalueCtx := context.WithValue(ctx, "clickhouse_max_threads", constants.MetricsExplorerClickhouseThreads)rows, err := r.db.Query(valueCtx, query, fmt.Sprintf("%%%s%%", req.SearchText))if err != nil {- zap.L().Error("Error while executing query", zap.Error(err))+ r.logger.Error("Error while executing query", "error", err)return nil, &model.ApiError{Typ: "ClickHouseError", Err: err}}@@ -5583,7 +5582,7 @@ func (r *ClickHouseReader) GetAllMetricFilterTypes(ctx context.Context, req *metvalueCtx := context.WithValue(ctx, "clickhouse_max_threads", constants.MetricsExplorerClickhouseThreads)rows, err := r.db.Query(valueCtx, query, fmt.Sprintf("%%%s%%", req.SearchText))if err != nil {- zap.L().Error("Error while executing query", zap.Error(err))+ r.logger.Error("Error while executing query", "error", err)return nil, &model.ApiError{Typ: "ClickHouseError", Err: err}}@@ -5820,9 +5819,9 @@ func (r *ClickHouseReader) ListSummaryMetrics(ctx context.Context, orgID valuer.begin := time.Now()rows, err := r.db.Query(valueCtx, metricsQuery, args...)queryDuration := time.Since(begin)- zap.L().Info("Time taken to execute metrics query to fetch metrics with high time series", zap.String("query", metricsQuery), zap.Any("args", args), zap.Duration("duration", queryDuration))+ r.logger.Info("Time taken to execute metrics query to fetch metrics with high time series", "query", metricsQuery, "args", args, "duration", queryDuration)if err != nil {- zap.L().Error("Error executing metrics query", zap.Error(err))+ r.logger.Error("Error executing metrics query", "error", err)return &metrics_explorer.SummaryListMetricsResponse{}, &model.ApiError{Typ: "ClickHouseError", Err: err}}defer rows.Close()@@ -5833,14 +5832,14 @@ func (r *ClickHouseReader) ListSummaryMetrics(ctx context.Context, orgID valuer.for rows.Next() {var metric metrics_explorer.MetricDetailif err := rows.Scan(&metric.MetricName, &metric.Description, &metric.MetricType, &metric.MetricUnit, &metric.TimeSeries, &response.Total); err != nil {- zap.L().Error("Error scanning metric row", zap.Error(err))+ r.logger.Error("Error scanning metric row", "error", err)return &response, &model.ApiError{Typ: "ClickHouseError", Err: err}}metricNames = append(metricNames, metric.MetricName)response.Metrics = append(response.Metrics, metric)}if err := rows.Err(); err != nil {- zap.L().Error("Error iterating over metric rows", zap.Error(err))+ r.logger.Error("Error iterating over metric rows", "error", err)return &response, &model.ApiError{Typ: "ClickHouseError", Err: err}}// If no metrics were found, return early.@@ -5925,9 +5924,9 @@ func (r *ClickHouseReader) ListSummaryMetrics(ctx context.Context, orgID valuer.begin = time.Now()rows, err = r.db.Query(valueCtx, sampleQuery, args...)queryDuration = time.Since(begin)- zap.L().Info("Time taken to execute list summary query", zap.String("query", sampleQuery), zap.Any("args", args), zap.Duration("duration", queryDuration))+ r.logger.Info("Time taken to execute list summary query", "query", sampleQuery, "args", args, "duration", queryDuration)if err != nil {- zap.L().Error("Error executing samples query", zap.Error(err))+ r.logger.Error("Error executing samples query", "error", err)return &response, &model.ApiError{Typ: "ClickHouseError", Err: err}}defer rows.Close()@@ -5938,20 +5937,20 @@ func (r *ClickHouseReader) ListSummaryMetrics(ctx context.Context, orgID valuer.var samples uint64var metricName stringif err := rows.Scan(&samples, &metricName); err != nil {- zap.L().Error("Error scanning sample row", zap.Error(err))+ r.logger.Error("Error scanning sample row", "error", err)return &response, &model.ApiError{Typ: "ClickHouseError", Err: err}}samplesMap[metricName] = samples}if err := rows.Err(); err != nil {- zap.L().Error("Error iterating over sample rows", zap.Error(err))+ r.logger.Error("Error iterating over sample rows", "error", err)return &response, &model.ApiError{Typ: "ClickHouseError", Err: err}}//get updated metrics databatch, apiError := r.GetUpdatedMetricsMetadata(ctx, orgID, metricNames...)if apiError != nil {- zap.L().Error("Error in getting metrics cached metadata", zap.Error(apiError))+ r.logger.Error("Error in getting metrics cached metadata", "error", apiError)}var filteredMetrics []metrics_explorer.MetricDetail@@ -6041,9 +6040,9 @@ func (r *ClickHouseReader) GetMetricsTimeSeriesPercentage(ctx context.Context, rbegin := time.Now()rows, err := r.db.Query(valueCtx, query, args...)duration := time.Since(begin)- zap.L().Info("Time taken to execute time series percentage query", zap.String("query", query), zap.Any("args", args), zap.Duration("duration", duration))+ r.logger.Info("Time taken to execute time series percentage query", "query", query, "args", args, "duration", duration)if err != nil {- zap.L().Error("Error executing time series percentage query", zap.Error(err), zap.String("query", query))+ r.logger.Error("Error executing time series percentage query", "error", err, "query", query)return nil, &model.ApiError{Typ: "ClickHouseError", Err: err}}defer rows.Close()@@ -6052,14 +6051,14 @@ func (r *ClickHouseReader) GetMetricsTimeSeriesPercentage(ctx context.Context, rfor rows.Next() {var item metrics_explorer.TreeMapResponseItemif err := rows.Scan(&item.MetricName, &item.TotalValue, &item.Percentage); err != nil {- zap.L().Error("Error scanning row", zap.Error(err))+ r.logger.Error("Error scanning row", "error", err)return nil, &model.ApiError{Typ: "ClickHouseError", Err: err}}treemap = append(treemap, item)}if err := rows.Err(); err != nil {- zap.L().Error("Error iterating over rows", zap.Error(err))+ r.logger.Error("Error iterating over rows", "error", err)return nil, &model.ApiError{Typ: "ClickHouseError", Err: err}}@@ -6108,9 +6107,9 @@ func (r *ClickHouseReader) GetMetricsSamplesPercentage(ctx context.Context, reqbegin := time.Now()rows, err := r.db.Query(valueCtx, metricsQuery, normalized, start, end)duration := time.Since(begin)- zap.L().Info("Time taken to execute samples percentage metric name query to reduce search space", zap.String("query", metricsQuery), zap.Any("start", start), zap.Any("end", end), zap.Duration("duration", duration))+ r.logger.Info("Time taken to execute samples percentage metric name query to reduce search space", "query", metricsQuery, "start", start, "end", end, "duration", duration)if err != nil {- zap.L().Error("Error executing samples percentage query", zap.Error(err))+ r.logger.Error("Error executing samples percentage query", "error", err)return nil, &model.ApiError{Typ: "ClickHouseError", Err: err}}defer rows.Close()@@ -6121,13 +6120,13 @@ func (r *ClickHouseReader) GetMetricsSamplesPercentage(ctx context.Context, reqvar metricName stringvar timeSeries uint64if err := rows.Scan(&metricName, &timeSeries); err != nil {- zap.L().Error("Error scanning metric row", zap.Error(err))+ r.logger.Error("Error scanning metric row", "error", err)return nil, &model.ApiError{Typ: "ClickHouseError", Err: err}}metricNames = append(metricNames, metricName)}if err := rows.Err(); err != nil {- zap.L().Error("Error iterating over metric rows", zap.Error(err))+ r.logger.Error("Error iterating over metric rows", "error", err)return nil, &model.ApiError{Typ: "ClickHouseError", Err: err}}@@ -6206,9 +6205,9 @@ func (r *ClickHouseReader) GetMetricsSamplesPercentage(ctx context.Context, req// Execute the sample percentage queryrows, err = r.db.Query(valueCtx, sampleQuery, args...)duration = time.Since(begin)- zap.L().Info("Time taken to execute samples percentage query", zap.String("query", sampleQuery), zap.Any("args", args), zap.Duration("duration", duration))+ r.logger.Info("Time taken to execute samples percentage query", "query", sampleQuery, "args", args, "duration", duration)if err != nil {- zap.L().Error("Error executing samples query", zap.Error(err))+ r.logger.Error("Error executing samples query", "error", err)return nil, &model.ApiError{Typ: "ClickHouseError", Err: err}}defer rows.Close()@@ -6218,13 +6217,13 @@ func (r *ClickHouseReader) GetMetricsSamplesPercentage(ctx context.Context, reqfor rows.Next() {var item metrics_explorer.TreeMapResponseItemif err := rows.Scan(&item.TotalValue, &item.MetricName, &item.Percentage); err != nil {- zap.L().Error("Error scanning row", zap.Error(err))+ r.logger.Error("Error scanning row", "error", err)return nil, &model.ApiError{Typ: "ClickHouseError", Err: err}}treemap = append(treemap, item)}if err := rows.Err(); err != nil {- zap.L().Error("Error iterating over sample rows", zap.Error(err))+ r.logger.Error("Error iterating over sample rows", "error", err)return nil, &model.ApiError{Typ: "ClickHouseError", Err: err}}@@ -6828,7 +6827,7 @@ func (r *ClickHouseReader) GetUpdatedMetricsMetadata(ctx context.Context, orgIDcacheKey := constants.UpdatedMetricsMetadataCachePrefix + metadata.MetricNameif cacheErr := r.cache.Set(ctx, orgID, cacheKey, metadata, 0); cacheErr != nil {- zap.L().Error("Failed to store metrics metadata in cache", zap.String("metric_name", metadata.MetricName), zap.Error(cacheErr))+ r.logger.Error("Failed to store metrics metadata in cache", "metric_name", metadata.MetricName, "error", cacheErr)}cachedMetadata[metadata.MetricName] = metadatafound[metadata.MetricName] = struct{}{}@@ -6869,7 +6868,7 @@ func (r *ClickHouseReader) GetUpdatedMetricsMetadata(ctx context.Context, orgIDcacheKey := constants.UpdatedMetricsMetadataCachePrefix + metadata.MetricNameif cacheErr := r.cache.Set(ctx, orgID, cacheKey, metadata, 0); cacheErr != nil {- zap.L().Error("Failed to cache fallback metadata", zap.String("metric_name", metadata.MetricName), zap.Error(cacheErr))+ r.logger.Error("Failed to cache fallback metadata", "metric_name", metadata.MetricName, "error", cacheErr)}cachedMetadata[metadata.MetricName] = metadata}@@ -6901,12 +6900,12 @@ func (r *ClickHouseReader) SearchTraces(ctx context.Context, params *model.Searcif err == sql.ErrNoRows {return &searchSpansResult, nil}- zap.L().Error("Error in processing sql query", zap.Error(err))+ r.logger.Error("Error in processing sql query", "error", err)return nil, fmt.Errorf("error in processing sql query")}if traceSummary.NumSpans > uint64(params.MaxSpansInTrace) {- zap.L().Error("Max spans allowed in a trace limit reached", zap.Int("MaxSpansInTrace", params.MaxSpansInTrace), zap.Uint64("Count", traceSummary.NumSpans))+ r.logger.Error("Max spans allowed in a trace limit reached", "MaxSpansInTrace", params.MaxSpansInTrace, "Count", traceSummary.NumSpans)return nil, fmt.Errorf("max spans allowed in trace limit reached, please contact support for more details")}@@ -6916,7 +6915,7 @@ func (r *ClickHouseReader) SearchTraces(ctx context.Context, params *model.Searcquery := fmt.Sprintf("SELECT timestamp, duration_nano, span_id, trace_id, has_error, kind, resource_string_service$$name, name, links as references, attributes_string, attributes_number, attributes_bool, resources_string, events, status_message, status_code_string, kind_string FROM %s.%s WHERE trace_id=$1 and ts_bucket_start>=$2 and ts_bucket_start<=$3", r.TraceDB, r.traceTableName)err = r.db.Select(ctx, &searchScanResponses, query, params.TraceID, strconv.FormatInt(traceSummary.Start.Unix()-1800, 10), strconv.FormatInt(traceSummary.End.Unix(), 10))if err != nil {- zap.L().Error("Error in processing sql query", zap.Error(err))+ r.logger.Error("Error in processing sql query", "error", err)return nil, fmt.Errorf("error in processing sql query")}@@ -6928,7 +6927,7 @@ func (r *ClickHouseReader) SearchTraces(ctx context.Context, params *model.Searcref := []model.OtelSpanRef{}err := json.Unmarshal([]byte(item.References), &ref)if err != nil {- zap.L().Error("Error unmarshalling references", zap.Error(err))+ r.logger.Error("Error unmarshalling references", "error", err)return nil, err}diff --git a/pkg/query-service/app/http_handler.go b/pkg/query-service/app/http_handler.goindex b617e0c143..7f4b04a2b5 100644--- a/pkg/query-service/app/http_handler.go+++ b/pkg/query-service/app/http_handler.go@@ -13,6 +13,7 @@ import ("github.com/SigNoz/signoz/pkg/queryparser""io"+ "log/slog""math""net/http""regexp"@@ -73,8 +74,6 @@ import ("github.com/SigNoz/signoz/pkg/types/ruletypes"traceFunnels "github.com/SigNoz/signoz/pkg/types/tracefunneltypes"- "go.uber.org/zap"-"github.com/SigNoz/signoz/pkg/query-service/app/integrations/messagingQueues/kafka""github.com/SigNoz/signoz/pkg/query-service/app/logparsingpipeline""github.com/SigNoz/signoz/pkg/query-service/interfaces"@@ -97,6 +96,7 @@ func NewRouter() *mux.Router {// APIHandler implements the query service public APItype APIHandler struct {+ logger *slog.Loggerreader interfaces.ReaderruleManager *rules.Managerquerier interfaces.Querier@@ -212,6 +212,7 @@ func NewAPIHandler(opts APIHandlerOpts, config signoz.Config) (*APIHandler, erro//quickFilterModule := quickfilter.NewAPI(opts.QuickFilterModule)aH := &APIHandler{+ logger: slog.Default(),reader: opts.Reader,temporalityMap: make(map[string]map[v3.Temporality]bool),ruleManager: opts.RuleManager,@@ -251,13 +252,13 @@ func NewAPIHandler(opts APIHandlerOpts, config signoz.Config) (*APIHandler, erro// TODO(nitya): remote this in later for multitenancy.orgs, err := opts.Signoz.Modules.OrgGetter.ListByOwnedKeyRange(context.Background())if err != nil {- zap.L().Warn("unexpected error while fetching orgs while initializing base api handler", zap.Error(err))+ aH.logger.Warn("unexpected error while fetching orgs while initializing base api handler", "error", err)}// if the first org with the first user is created then the setup is complete.if len(orgs) == 1 {count, err := opts.Signoz.Modules.UserGetter.CountByOrgID(context.Background(), orgs[0].ID)if err != nil {- zap.L().Warn("unexpected error while fetch user count while initializing base api handler", zap.Error(err))+ aH.logger.Warn("unexpected error while fetching user count while initializing base api handler", "error", err)}if count > 0 {@@ -312,7 +313,7 @@ func RespondError(w http.ResponseWriter, apiErr model.BaseApiError, data interfaData: data,})if err != nil {- zap.L().Error("error marshalling json response", zap.Error(err))+ slog.Error("error marshalling json response", "error", err)http.Error(w, err.Error(), http.StatusInternalServerError)return}@@ -344,7 +345,7 @@ func RespondError(w http.ResponseWriter, apiErr model.BaseApiError, data interfaw.Header().Set("Content-Type", "application/json")w.WriteHeader(code)if n, err := w.Write(b); err != nil {- zap.L().Error("error writing response", zap.Int("bytesWritten", n), zap.Error(err))+ slog.Error("error writing response", "bytes_written", n, "error", err)}}@@ -356,7 +357,7 @@ func writeHttpResponse(w http.ResponseWriter, data interface{}) {Data: data,})if err != nil {- zap.L().Error("error marshalling json response", zap.Error(err))+ slog.Error("error marshalling json response", "error", err)http.Error(w, err.Error(), http.StatusInternalServerError)return}@@ -364,7 +365,7 @@ func writeHttpResponse(w http.ResponseWriter, data interface{}) {w.Header().Set("Content-Type", "application/json")w.WriteHeader(http.StatusOK)if n, err := w.Write(b); err != nil {- zap.L().Error("error writing response", zap.Int("bytesWritten", n), zap.Error(err))+ slog.Error("error writing response", "bytes_written", n, "error", err)}}@@ -936,14 +937,14 @@ func (aH *APIHandler) metaForLinks(ctx context.Context, rule *ruletypes.Gettable}keys = model.GetLogFieldsV3(ctx, params, logFields)} else {- zap.L().Error("failed to get log fields using empty keys; the link might not work as expected", zap.Error(apiErr))+ aH.logger.ErrorContext(ctx, "failed to get log fields using empty keys", "error", apiErr)}} else if rule.AlertType == ruletypes.AlertTypeTraces {traceFields, err := aH.reader.GetSpanAttributeKeysByNames(ctx, logsv3.GetFieldNames(rule.PostableRule.RuleCondition.CompositeQuery))if err == nil {keys = traceFields} else {- zap.L().Error("failed to get span attributes using empty keys; the link might not work as expected", zap.Error(err))+ aH.logger.ErrorContext(ctx, "failed to get span attributes using empty keys", "error", err)}}@@ -1276,14 +1277,14 @@ func (aH *APIHandler) List(rw http.ResponseWriter, r *http.Request) {installedIntegrationDashboards, apiErr := aH.IntegrationsController.GetDashboardsForInstalledIntegrations(ctx, orgID)if apiErr != nil {- zap.L().Error("failed to get dashboards for installed integrations", zap.Error(apiErr))+ aH.logger.ErrorContext(ctx, "failed to get dashboards for installed integrations", "error", apiErr)} else {dashboards = append(dashboards, installedIntegrationDashboards...)}cloudIntegrationDashboards, apiErr := aH.CloudIntegrationsController.AvailableDashboards(ctx, orgID)if apiErr != nil {- zap.L().Error("failed to get dashboards for cloud integrations", zap.Error(apiErr))+ aH.logger.ErrorContext(ctx, "failed to get dashboards for cloud integrations", "error", apiErr)} else {dashboards = append(dashboards, cloudIntegrationDashboards...)}@@ -1325,7 +1326,7 @@ func (aH *APIHandler) testRule(w http.ResponseWriter, r *http.Request) {defer r.Body.Close()body, err := io.ReadAll(r.Body)if err != nil {- zap.L().Error("Error in getting req body in test rule API", zap.Error(err))+ aH.logger.ErrorContext(r.Context(), "error reading request body for test rule", "error", err)RespondError(w, &model.ApiError{Typ: model.ErrorBadData, Err: err}, nil)return}@@ -1377,7 +1378,7 @@ func (aH *APIHandler) patchRule(w http.ResponseWriter, r *http.Request) {defer r.Body.Close()body, err := io.ReadAll(r.Body)if err != nil {- zap.L().Error("error in getting req body of patch rule API\n", zap.Error(err))+ aH.logger.ErrorContext(r.Context(), "error reading request body for patch rule", "error", err)RespondError(w, &model.ApiError{Typ: model.ErrorBadData, Err: err}, nil)return}@@ -1407,7 +1408,7 @@ func (aH *APIHandler) editRule(w http.ResponseWriter, r *http.Request) {defer r.Body.Close()body, err := io.ReadAll(r.Body)if err != nil {- zap.L().Error("error in getting req body of edit rule API", zap.Error(err))+ aH.logger.ErrorContext(r.Context(), "error reading request body for edit rule", "error", err)RespondError(w, &model.ApiError{Typ: model.ErrorBadData, Err: err}, nil)return}@@ -1432,7 +1433,7 @@ func (aH *APIHandler) createRule(w http.ResponseWriter, r *http.Request) {defer r.Body.Close()body, err := io.ReadAll(r.Body)if err != nil {- zap.L().Error("Error in getting req body for create rule API", zap.Error(err))+ aH.logger.ErrorContext(r.Context(), "error reading request body for create rule", "error", err)RespondError(w, &model.ApiError{Typ: model.ErrorBadData, Err: err}, nil)return}@@ -1456,7 +1457,7 @@ func (aH *APIHandler) queryRangeMetrics(w http.ResponseWriter, r *http.Request)return}- // zap.L().Info(query, apiError)+ // TODO: add structured logging for query and apiError if neededctx := r.Context()if to := r.FormValue("timeout"); to != "" {@@ -1478,7 +1479,7 @@ func (aH *APIHandler) queryRangeMetrics(w http.ResponseWriter, r *http.Request)}if res.Err != nil {- zap.L().Error("error in query range metrics", zap.Error(res.Err))+ aH.logger.ErrorContext(r.Context(), "error in query range metrics", "error", res.Err)}if res.Err != nil {@@ -1511,7 +1512,7 @@ func (aH *APIHandler) queryMetrics(w http.ResponseWriter, r *http.Request) {return}- // zap.L().Info(query, apiError)+ // TODO: add structured logging for query and apiError if neededctx := r.Context()if to := r.FormValue("timeout"); to != "" {@@ -1533,7 +1534,7 @@ func (aH *APIHandler) queryMetrics(w http.ResponseWriter, r *http.Request) {}if res.Err != nil {- zap.L().Error("error in query range metrics", zap.Error(res.Err))+ aH.logger.ErrorContext(r.Context(), "error in query range metrics", "error", res.Err)}if res.Err != nil {@@ -1636,7 +1637,7 @@ func (aH *APIHandler) getServicesTopLevelOps(w http.ResponseWriter, r *http.Requvar params topLevelOpsParamserr := json.NewDecoder(r.Body).Decode(¶ms)if err != nil {- zap.L().Error("Error in getting req body for get top operations API", zap.Error(err))+ aH.logger.ErrorContext(r.Context(), "error reading request body for get top operations", "error", err)}if params.Service != "" {@@ -2058,7 +2059,7 @@ func (aH *APIHandler) HandleError(w http.ResponseWriter, err error, statusCode ireturn false}if statusCode == http.StatusInternalServerError {- zap.L().Error("HTTP handler, Internal Server Error", zap.Error(err))+ aH.logger.Error("internal server error in http handler", "error", err)}structuredResp := structuredResponse{Errors: []structuredError{@@ -2152,7 +2153,7 @@ func (aH *APIHandler) onboardProducers() {messagingQueue, apiErr := ParseKafkaQueueBody(r)if apiErr != nil {- zap.L().Error(apiErr.Err.Error())+ aH.logger.ErrorContext(r.Context(), "failed to parse kafka queue body", "error", apiErr.Err)RespondError(w, apiErr, nil)return}@@ -2160,7 +2161,7 @@ func (aH *APIHandler) onboardProducers(chq, err := kafka.BuildClickHouseQuery(messagingQueue, kafka.KafkaQueue, "onboard_producers")if err != nil {- zap.L().Error(err.Error())+ aH.logger.ErrorContext(r.Context(), "failed to build clickhouse query for onboard producers", "error", err)RespondError(w, apiErr, nil)return}@@ -2254,7 +2255,7 @@ func (aH *APIHandler) onboardConsumers() {messagingQueue, apiErr := ParseKafkaQueueBody(r)if apiErr != nil {- zap.L().Error(apiErr.Err.Error())+ aH.logger.ErrorContext(r.Context(), "failed to parse kafka queue body", "error", apiErr.Err)RespondError(w, apiErr, nil)return}@@ -2262,7 +2263,7 @@ func (aH *APIHandler) onboardConsumers(chq, err := kafka.BuildClickHouseQuery(messagingQueue, kafka.KafkaQueue, "onboard_consumers")if err != nil {- zap.L().Error(err.Error())+ aH.logger.ErrorContext(r.Context(), "failed to build clickhouse query for onboard consumers", "error", err)RespondError(w, apiErr, nil)return}@@ -2401,7 +2402,7 @@ func (aH *APIHandler) onboardKafka(w http.ResponseWriter, r *http.Request) {messagingQueue, apiErr := ParseKafkaQueueBody(r)if apiErr != nil {- zap.L().Error(apiErr.Err.Error())+ aH.logger.ErrorContext(r.Context(), "failed to parse kafka queue body", "error", apiErr.Err)RespondError(w, apiErr, nil)return}@@ -2409,7 +2410,7 @@ func (aH *APIHandler) onboardKafka(w http.ResponseWriter, r *http.Request) {queryRangeParams, err := kafka.BuildBuilderQueriesKafkaOnboarding(messagingQueue)if err != nil {- zap.L().Error(err.Error())+ aH.logger.ErrorContext(r.Context(), "failed to build kafka onboarding queries", "error", err)RespondError(w, apiErr, nil)return}@@ -2511,19 +2512,19 @@ func (aH *APIHandler) getNetworkData(w http.ResponseWriter, r *http.Request) {messagingQueue, apiErr := ParseKafkaQueueBody(r)if apiErr != nil {- zap.L().Error(apiErr.Err.Error())+ aH.logger.ErrorContext(r.Context(), "failed to parse kafka queue body", "error", apiErr.Err)RespondError(w, apiErr, nil)return}queryRangeParams, err := kafka.BuildQRParamsWithCache(messagingQueue, "throughput", attributeCache)if err != nil {- zap.L().Error(err.Error())+ aH.logger.ErrorContext(r.Context(), "failed to build query range params for throughput", "error", err)RespondError(w, apiErr, nil)return}if err := validateQueryRangeParamsV3(queryRangeParams); err != nil {- zap.L().Error(err.Error())+ aH.logger.ErrorContext(r.Context(), "failed to validate query range params", "error", err)RespondError(w, apiErr, nil)return}@@ -2562,12 +2563,12 @@ func (aH *APIHandler) getNetworkData(w http.ResponseWriter, r *http.Request) {queryRangeParams, err = kafka.BuildQRParamsWithCache(messagingQueue, "fetch-latency", attributeCache)if err != nil {- zap.L().Error(err.Error())+ aH.logger.ErrorContext(r.Context(), "failed to build query range params for fetch latency", "error", err)RespondError(w, apiErr, nil)return}if err := validateQueryRangeParamsV3(queryRangeParams); err != nil {- zap.L().Error(err.Error())+ aH.logger.ErrorContext(r.Context(), "failed to validate query range params for fetch latency", "error", err)RespondError(w, apiErr, nil)return}@@ -2622,7 +2623,7 @@ func (aH *APIHandler) getProducerData(w http.ResponseWriter, r *http.Request) {messagingQueue, apiErr := ParseKafkaQueueBody(r)if apiErr != nil {- zap.L().Error(apiErr.Err.Error())+ aH.logger.ErrorContext(r.Context(), "failed to parse kafka queue body", "error", apiErr.Err)RespondError(w, apiErr, nil)return}@@ -2636,13 +2637,13 @@ func (aH *APIHandler) getProducerData(w http.ResponseWriter, r *http.Request) {queryRangeParams, err := kafka.BuildQueryRangeParams(messagingQueue, "producer", kafkaSpanEval)if err != nil {- zap.L().Error(err.Error())+ aH.logger.ErrorContext(r.Context(), "failed to build query range params for producer", "error", err)RespondError(w, apiErr, nil)return}if err := validateQueryRangeParamsV3(queryRangeParams); err != nil {- zap.L().Error(err.Error())+ aH.logger.ErrorContext(r.Context(), "failed to validate query range params for producer", "error", err)RespondError(w, apiErr, nil)return}@@ -2679,7 +2680,7 @@ func (aH *APIHandler) getConsumerData(w http.ResponseWriter, r *http.Request) {messagingQueue, apiErr := ParseKafkaQueueBody(r)if apiErr != nil {- zap.L().Error(apiErr.Err.Error())+ aH.logger.ErrorContext(r.Context(), "failed to parse kafka queue body", "error", apiErr.Err)RespondError(w, apiErr, nil)return}@@ -2689,13 +2690,13 @@ func (aH *APIHandler) getConsumerData(w http.ResponseWriter, r *http.Request) {queryRangeParams, err := kafka.BuildQueryRangeParams(messagingQueue, "consumer", kafkaSpanEval)if err != nil {- zap.L().Error(err.Error())+ aH.logger.ErrorContext(r.Context(), "failed to build query range params for consumer", "error", err)RespondError(w, apiErr, nil)return}if err := validateQueryRangeParamsV3(queryRangeParams); err != nil {- zap.L().Error(err.Error())+ aH.logger.ErrorContext(r.Context(), "failed to validate query range params for consumer", "error", err)RespondError(w, apiErr, nil)return}@@ -2737,7 +2738,7 @@ func (aH *APIHandler) getPartitionOverviewLatencyData(w http.ResponseWriter, r *messagingQueue, apiErr := ParseKafkaQueueBody(r)if apiErr != nil {- zap.L().Error(apiErr.Err.Error())+ aH.logger.ErrorContext(r.Context(), "failed to parse kafka queue body", "error", apiErr.Err)RespondError(w, apiErr, nil)return}@@ -2747,13 +2748,13 @@ func (aH *APIHandler) getPartitionOverviewLatencyData(w http.ResponseWriter, r *queryRangeParams, err := kafka.BuildQueryRangeParams(messagingQueue, "producer-topic-throughput", kafkaSpanEval)if err != nil {- zap.L().Error(err.Error())+ aH.logger.ErrorContext(r.Context(), "failed to build query range params for producer topic throughput", "error", err)RespondError(w, apiErr, nil)return}if err := validateQueryRangeParamsV3(queryRangeParams); err != nil {- zap.L().Error(err.Error())+ aH.logger.ErrorContext(r.Context(), "failed to validate query range params for producer topic throughput", "error", err)RespondError(w, apiErr, nil)return}@@ -2795,7 +2796,7 @@ func (aH *APIHandler) getConsumerPartitionLatencyData(w http.ResponseWriter, r *messagingQueue, apiErr := ParseKafkaQueueBody(r)if apiErr != nil {- zap.L().Error(apiErr.Err.Error())+ aH.logger.ErrorContext(r.Context(), "failed to parse kafka queue body", "error", apiErr.Err)RespondError(w, apiErr, nil)return}@@ -2805,13 +2806,13 @@ func (aH *APIHandler) getConsumerPartitionLatencyData(w http.ResponseWriter, r *queryRangeParams, err := kafka.BuildQueryRangeParams(messagingQueue, "consumer_partition_latency", kafkaSpanEval)if err != nil {- zap.L().Error(err.Error())+ aH.logger.ErrorContext(r.Context(), "failed to build query range params for consumer partition latency", "error", err)RespondError(w, apiErr, nil)return}if err := validateQueryRangeParamsV3(queryRangeParams); err != nil {- zap.L().Error(err.Error())+ aH.logger.ErrorContext(r.Context(), "failed to validate query range params for consumer partition latency", "error", err)RespondError(w, apiErr, nil)return}@@ -2855,7 +2856,7 @@ func (aH *APIHandler) getProducerThroughputOverview(w http.ResponseWriter, r *htmessagingQueue, apiErr := ParseKafkaQueueBody(r)if apiErr != nil {- zap.L().Error(apiErr.Err.Error())+ aH.logger.ErrorContext(r.Context(), "failed to parse kafka queue body", "error", apiErr.Err)RespondError(w, apiErr, nil)return}@@ -2866,13 +2867,13 @@ func (aH *APIHandler) getProducerThroughputOverview(w http.ResponseWriter, r *htproducerQueryRangeParams, err := kafka.BuildQRParamsWithCache(messagingQueue, "producer-throughput-overview", attributeCache)if err != nil {- zap.L().Error(err.Error())+ aH.logger.ErrorContext(r.Context(), "failed to build query range params for producer throughput overview", "error", err)RespondError(w, apiErr, nil)return}if err := validateQueryRangeParamsV3(producerQueryRangeParams); err != nil {- zap.L().Error(err.Error())+ aH.logger.ErrorContext(r.Context(), "failed to validate query range params for producer throughput overview", "error", err)RespondError(w, apiErr, nil)return}@@ -2908,12 +2909,12 @@ func (aH *APIHandler) getProducerThroughputOverview(w http.ResponseWriter, r *htqueryRangeParams, err := kafka.BuildQRParamsWithCache(messagingQueue, "producer-throughput-overview-byte-rate", attributeCache)if err != nil {- zap.L().Error(err.Error())+ aH.logger.ErrorContext(r.Context(), "failed to build query range params for producer throughput byte rate", "error", err)RespondError(w, apiErr, nil)return}if err := validateQueryRangeParamsV3(queryRangeParams); err != nil {- zap.L().Error(err.Error())+ aH.logger.ErrorContext(r.Context(), "failed to validate query range params for producer throughput byte rate", "error", err)RespondError(w, apiErr, nil)return}@@ -2971,7 +2972,7 @@ func (aH *APIHandler) getProducerThroughputDetails(w http.ResponseWriter, r *httmessagingQueue, apiErr := ParseKafkaQueueBody(r)if apiErr != nil {- zap.L().Error(apiErr.Err.Error())+ aH.logger.ErrorContext(r.Context(), "failed to parse kafka queue body", "error", apiErr.Err)RespondError(w, apiErr, nil)return}@@ -2981,13 +2982,13 @@ func (aH *APIHandler) getProducerThroughputDetails(w http.ResponseWriter, r *httqueryRangeParams, err := kafka.BuildQueryRangeParams(messagingQueue, "producer-throughput-details", kafkaSpanEval)if err != nil {- zap.L().Error(err.Error())+ aH.logger.ErrorContext(r.Context(), "failed to build query range params for producer throughput details", "error", err)RespondError(w, apiErr, nil)return}if err := validateQueryRangeParamsV3(queryRangeParams); err != nil {- zap.L().Error(err.Error())+ aH.logger.ErrorContext(r.Context(), "failed to validate query range params for producer throughput details", "error", err)RespondError(w, apiErr, nil)return}@@ -3029,7 +3030,7 @@ func (aH *APIHandler) getConsumerThroughputOverview(w http.ResponseWriter, r *htmessagingQueue, apiErr := ParseKafkaQueueBody(r)if apiErr != nil {- zap.L().Error(apiErr.Err.Error())+ aH.logger.ErrorContext(r.Context(), "failed to parse kafka queue body", "error", apiErr.Err)RespondError(w, apiErr, nil)return}@@ -3039,13 +3040,13 @@ func (aH *APIHandler) getConsumerThroughputOverview(w http.ResponseWriter, r *htqueryRangeParams, err := kafka.BuildQueryRangeParams(messagingQueue, "consumer-throughput-overview", kafkaSpanEval)if err != nil {- zap.L().Error(err.Error())+ aH.logger.ErrorContext(r.Context(), "failed to build query range params for consumer throughput overview", "error", err)RespondError(w, apiErr, nil)return}if err := validateQueryRangeParamsV3(queryRangeParams); err != nil {- zap.L().Error(err.Error())+ aH.logger.ErrorContext(r.Context(), "failed to validate query range params for consumer throughput overview", "error", err)RespondError(w, apiErr, nil)return}@@ -3087,7 +3088,7 @@ func (aH *APIHandler) getConsumerThroughputDetails(w http.ResponseWriter, r *httmessagingQueue, apiErr := ParseKafkaQueueBody(r)if apiErr != nil {- zap.L().Error(apiErr.Err.Error())+ aH.logger.ErrorContext(r.Context(), "failed to parse kafka queue body", "error", apiErr.Err)RespondError(w, apiErr, nil)return}@@ -3097,13 +3098,13 @@ func (aH *APIHandler) getConsumerThroughputDetails(w http.ResponseWriter, r *httqueryRangeParams, err := kafka.BuildQueryRangeParams(messagingQueue, "consumer-throughput-details", kafkaSpanEval)if err != nil {- zap.L().Error(err.Error())+ aH.logger.ErrorContext(r.Context(), "failed to build query range params for consumer throughput details", "error", err)RespondError(w, apiErr, nil)return}if err := validateQueryRangeParamsV3(queryRangeParams); err != nil {- zap.L().Error(err.Error())+ aH.logger.ErrorContext(r.Context(), "failed to validate query range params for consumer throughput details", "error", err)RespondError(w, apiErr, nil)return}@@ -3148,7 +3149,7 @@ func (aH *APIHandler) getProducerConsumerEval(w http.ResponseWriter, r *http.ReqmessagingQueue, apiErr := ParseKafkaQueueBody(r)if apiErr != nil {- zap.L().Error(apiErr.Err.Error())+ aH.logger.ErrorContext(r.Context(), "failed to parse kafka queue body", "error", apiErr.Err)RespondError(w, apiErr, nil)return}@@ -3158,7 +3159,7 @@ func (aH *APIHandler) getProducerConsumerEval(w http.ResponseWriter, r *http.ReqqueryRangeParams, err := kafka.BuildQueryRangeParams(messagingQueue, "producer-consumer-eval", kafkaSpanEval)if err != nil {- zap.L().Error(err.Error())+ aH.logger.ErrorContext(r.Context(), "failed to build query range params for producer consumer eval", "error", err)RespondError(w, &model.ApiError{Typ: model.ErrorBadData,Err: err,@@ -3167,7 +3168,7 @@ func (aH *APIHandler) getProducerConsumerEval(w http.ResponseWriter, r *http.Req}if err := validateQueryRangeParamsV3(queryRangeParams); err != nil {- zap.L().Error(err.Error())+ aH.logger.ErrorContext(r.Context(), "failed to validate query range params for producer consumer eval", "error", err)RespondError(w, apiErr, nil)return}@@ -4255,7 +4256,7 @@ func (aH *APIHandler) CreateLogsPipeline(w http.ResponseWriter, r *http.Request)postable []pipelinetypes.PostablePipeline,) (*logparsingpipeline.PipelinesResponse, error) {if len(postable) == 0 {- zap.L().Warn("found no pipelines in the http request, this will delete all the pipelines")+ aH.logger.WarnContext(r.Context(), "found no pipelines in the http request, this will delete all the pipelines")}err := aH.LogsParsingPipelineController.ValidatePipelines(ctx, postable)@@ -4453,7 +4454,7 @@ func (aH *APIHandler) QueryRangeV3Format(w http.ResponseWriter, r *http.Request)queryRangeParams, apiErrorObj := ParseQueryRangeParams(r)if apiErrorObj != nil {- zap.L().Error(apiErrorObj.Err.Error())+ aH.logger.ErrorContext(r.Context(), "error parsing query range params", "error", apiErrorObj.Err)RespondError(w, apiErrorObj, nil)return}@@ -4515,13 +4516,13 @@ func (aH *APIHandler) queryRangeV3(ctx context.Context, queryRangeParams *v3.Que// check if traceID is used as filter (with equal/similar operator) in traces query if yes add timestamp filter to queryRange paramsisUsed, traceIDs := tracesV3.TraceIdFilterUsedWithEqual(queryRangeParams)if isUsed && len(traceIDs) > 0 {- zap.L().Debug("traceID used as filter in traces query")+ aH.logger.DebugContext(ctx, "trace_id used as filter in traces query")// query signoz_spans table with traceID to get min and max timestampmin, max, err := aH.reader.GetMinAndMaxTimestampForTraceID(ctx, traceIDs)if err == nil {// add timestamp filter to queryRange paramstracesV3.AddTimestampFilters(min, max, queryRangeParams)- zap.L().Debug("post adding timestamp filter in traces query", zap.Any("queryRangeParams", queryRangeParams))+ aH.logger.DebugContext(ctx, "post adding timestamp filter in traces query", "query_range_params", queryRangeParams)}}}@@ -4532,9 +4533,8 @@ func (aH *APIHandler) queryRangeV3(ctx context.Context, queryRangeParams *v3.QueonQueryFinished, apiErr := aH.reader.ReportQueryStartForProgressTracking(queryIdHeader)if apiErr != nil {- zap.L().Error(- "couldn't report query start for progress tracking",- zap.String("queryId", queryIdHeader), zap.Error(apiErr),+ aH.logger.ErrorContext(ctx, "failed to report query start for progress tracking",+ "query_id", queryIdHeader, "error", apiErr,)} else {@@ -4709,7 +4709,7 @@ func (aH *APIHandler) QueryRangeV3(w http.ResponseWriter, r *http.Request) {queryRangeParams, apiErrorObj := ParseQueryRangeParams(r)if apiErrorObj != nil {- zap.L().Error("error parsing metric query range params", zap.Error(apiErrorObj.Err))+ aH.logger.ErrorContext(r.Context(), "error parsing metric query range params", "error", apiErrorObj.Err)RespondError(w, apiErrorObj, nil)return}@@ -4717,7 +4717,7 @@ func (aH *APIHandler) QueryRangeV3(w http.ResponseWriter, r *http.Request) {// add temporality for each metrictemporalityErr := aH.PopulateTemporality(r.Context(), orgID, queryRangeParams)if temporalityErr != nil {- zap.L().Error("Error while adding temporality for metrics", zap.Error(temporalityErr))+ aH.logger.ErrorContext(r.Context(), "error adding temporality for metrics", "error", temporalityErr)RespondError(w, &model.ApiError{Typ: model.ErrorInternal, Err: temporalityErr}, nil)return}@@ -4761,9 +4761,8 @@ func (aH *APIHandler) GetQueryProgressUpdates(w http.ResponseWriter, r *http.ReqprogressCh, unsubscribe, apiErr := aH.reader.SubscribeToQueryProgress(queryId)if apiErr != nil {// Shouldn't happen unless query progress requested after query finished- zap.L().Warn(- "couldn't subscribe to query progress",- zap.String("queryId", queryId), zap.Any("error", apiErr),+ aH.logger.WarnContext(r.Context(), "failed to subscribe to query progress",+ "query_id", queryId, "error", apiErr,)return}@@ -4772,25 +4771,22 @@ func (aH *APIHandler) GetQueryProgressUpdates(w http.ResponseWriter, r *http.Reqfor queryProgress := range progressCh {msg, err := json.Marshal(queryProgress)if err != nil {- zap.L().Error(- "failed to serialize progress message",- zap.String("queryId", queryId), zap.Any("progress", queryProgress), zap.Error(err),+ aH.logger.ErrorContext(r.Context(), "failed to serialize progress message",+ "query_id", queryId, "progress", queryProgress, "error", err,)continue}err = c.WriteMessage(websocket.TextMessage, msg)if err != nil {- zap.L().Error(- "failed to write progress msg to websocket",- zap.String("queryId", queryId), zap.String("msg", string(msg)), zap.Error(err),+ aH.logger.ErrorContext(r.Context(), "failed to write progress message to websocket",+ "query_id", queryId, "msg", string(msg), "error", err,)break} else {- zap.L().Debug(- "wrote progress msg to websocket",- zap.String("queryId", queryId), zap.String("msg", string(msg)), zap.Error(err),+ aH.logger.DebugContext(r.Context(), "wrote progress message to websocket",+ "query_id", queryId, "msg", string(msg),)}}@@ -4874,13 +4870,13 @@ func (aH *APIHandler) queryRangeV4(ctx context.Context, queryRangeParams *v3.Que// check if traceID is used as filter (with equal/similar operator) in traces query if yes add timestamp filter to queryRange paramsisUsed, traceIDs := tracesV3.TraceIdFilterUsedWithEqual(queryRangeParams)if isUsed && len(traceIDs) > 0 {- zap.L().Debug("traceID used as filter in traces query")+ aH.logger.DebugContext(ctx, "trace_id used as filter in traces query")// query signoz_spans table with traceID to get min and max timestampmin, max, err := aH.reader.GetMinAndMaxTimestampForTraceID(ctx, traceIDs)if err == nil {// add timestamp filter to queryRange paramstracesV3.AddTimestampFilters(min, max, queryRangeParams)- zap.L().Debug("post adding timestamp filter in traces query", zap.Any("queryRangeParams", queryRangeParams))+ aH.logger.DebugContext(ctx, "post adding timestamp filter in traces query", "query_range_params", queryRangeParams)}}}@@ -4932,7 +4928,7 @@ func (aH *APIHandler) QueryRangeV4(w http.ResponseWriter, r *http.Request) {queryRangeParams, apiErrorObj := ParseQueryRangeParams(r)if apiErrorObj != nil {- zap.L().Error("error parsing metric query range params", zap.Error(apiErrorObj.Err))+ aH.logger.ErrorContext(r.Context(), "error parsing metric query range params", "error", apiErrorObj.Err)RespondError(w, apiErrorObj, nil)return}@@ -4941,7 +4937,7 @@ func (aH *APIHandler) QueryRangeV4(w http.ResponseWriter, r *http.Request) {// add temporality for each metrictemporalityErr := aH.PopulateTemporality(r.Context(), orgID, queryRangeParams)if temporalityErr != nil {- zap.L().Error("Error while adding temporality for metrics", zap.Error(temporalityErr))+ aH.logger.ErrorContext(r.Context(), "error adding temporality for metrics", "error", temporalityErr)RespondError(w, &model.ApiError{Typ: model.ErrorInternal, Err: temporalityErr}, nil)return}@@ -4990,7 +4986,7 @@ func (aH *APIHandler) getQueueOverview(w http.ResponseWriter, r *http.Request) {queueListRequest, apiErr := ParseQueueBody(r)if apiErr != nil {- zap.L().Error(apiErr.Err.Error())+ aH.logger.ErrorContext(r.Context(), "failed to parse queue body", "error", apiErr.Err)RespondError(w, apiErr, nil)return}@@ -4998,7 +4994,7 @@ func (aH *APIHandler) getQueueOverview(w http.ResponseWriter, r *http.Request) {chq, err := queues2.BuildOverviewQuery(queueListRequest)if err != nil {- zap.L().Error(err.Error())+ aH.logger.ErrorContext(r.Context(), "failed to build queue overview query", "error", err)RespondError(w, &model.ApiError{Typ: model.ErrorInternal, Err: fmt.Errorf("error building clickhouse query: %v", err)}, nil)return}@@ -5029,7 +5025,7 @@ func (aH *APIHandler) getDomainList(w http.ResponseWriter, r *http.Request) {// Parse the request body to get third-party query parametersthirdPartyQueryRequest, apiErr := ParseRequestBody(r)if apiErr != nil {- zap.L().Error("Failed to parse request body", zap.Error(apiErr))+ aH.logger.ErrorContext(r.Context(), "failed to parse request body", "error", apiErr)render.Error(w, errorsV2.New(errorsV2.TypeInvalidInput, errorsV2.CodeInvalidInput, apiErr.Error()))return}@@ -5037,7 +5033,7 @@ func (aH *APIHandler) getDomainList(w http.ResponseWriter, r *http.Request) {// Build the v5 query range request for domain listingqueryRangeRequest, err := thirdpartyapi.BuildDomainList(thirdPartyQueryRequest)if err != nil {- zap.L().Error("Failed to build domain list query", zap.Error(err))+ aH.logger.ErrorContext(r.Context(), "failed to build domain list query", "error", err)apiErrObj := errorsV2.New(errorsV2.TypeInvalidInput, errorsV2.CodeInvalidInput, err.Error())render.Error(w, apiErrObj)return@@ -5050,7 +5046,7 @@ func (aH *APIHandler) getDomainList(w http.ResponseWriter, r *http.Request) {// Execute the query using the v5 querierresult, err := aH.Signoz.Querier.QueryRange(ctx, orgID, queryRangeRequest)if err != nil {- zap.L().Error("Query execution failed", zap.Error(err))+ aH.logger.ErrorContext(r.Context(), "query execution failed", "error", err)apiErrObj := errorsV2.New(errorsV2.TypeInvalidInput, errorsV2.CodeInvalidInput, err.Error())render.Error(w, apiErrObj)return@@ -5089,7 +5085,7 @@ func (aH *APIHandler) getDomainInfo(w http.ResponseWriter, r *http.Request) {// Parse the request body to get third-party query parametersthirdPartyQueryRequest, apiErr := ParseRequestBody(r)if apiErr != nil {- zap.L().Error("Failed to parse request body", zap.Error(apiErr))+ aH.logger.ErrorContext(r.Context(), "failed to parse request body", "error", apiErr)render.Error(w, errorsV2.New(errorsV2.TypeInvalidInput, errorsV2.CodeInvalidInput, apiErr.Error()))return}@@ -5097,7 +5093,7 @@ func (aH *APIHandler) getDomainInfo(w http.ResponseWriter, r *http.Request) {// Build the v5 query range request for domain infoqueryRangeRequest, err := thirdpartyapi.BuildDomainInfo(thirdPartyQueryRequest)if err != nil {- zap.L().Error("Failed to build domain info query", zap.Error(err))+ aH.logger.ErrorContext(r.Context(), "failed to build domain info query", "error", err)apiErrObj := errorsV2.New(errorsV2.TypeInvalidInput, errorsV2.CodeInvalidInput, err.Error())render.Error(w, apiErrObj)return@@ -5110,7 +5106,7 @@ func (aH *APIHandler) getDomainInfo(w http.ResponseWriter, r *http.Request) {// Execute the query using the v5 querierresult, err := aH.Signoz.Querier.QueryRange(ctx, orgID, queryRangeRequest)if err != nil {- zap.L().Error("Query execution failed", zap.Error(err))+ aH.logger.ErrorContext(r.Context(), "query execution failed", "error", err)apiErrObj := errorsV2.New(errorsV2.TypeInvalidInput, errorsV2.CodeInvalidInput, err.Error())render.Error(w, apiErrObj)returndiff --git a/pkg/query-service/app/inframetrics/hosts.go b/pkg/query-service/app/inframetrics/hosts.goindex 5273db76f7..18091d85da 100644--- a/pkg/query-service/app/inframetrics/hosts.go+++ b/pkg/query-service/app/inframetrics/hosts.go@@ -17,9 +17,10 @@ import (v3 "github.com/SigNoz/signoz/pkg/query-service/model/v3""github.com/SigNoz/signoz/pkg/query-service/postprocess""github.com/SigNoz/signoz/pkg/types/ctxtypes"+ "log/slog"+"github.com/SigNoz/signoz/pkg/types/instrumentationtypes""github.com/SigNoz/signoz/pkg/valuer"- "go.uber.org/zap""golang.org/x/exp/maps""golang.org/x/exp/slices")@@ -427,7 +428,7 @@ func (h *HostsRepo) GetHostList(ctx context.Context, orgID valuer.UUID, req modestep := int64(math.Max(float64(common.MinAllowedStepInterval(req.Start, req.End)), 60))if step <= 0 {- zap.L().Error("step is less than or equal to 0", zap.Int64("step", step))+ slog.ErrorContext(ctx, "step is less than or equal to 0", "step", step)return resp, errors.New("step is less than or equal to 0")}diff --git a/pkg/query-service/app/logparsingpipeline/collector_config.go b/pkg/query-service/app/logparsingpipeline/collector_config.goindex 1bbac49354..12cf563fcc 100644--- a/pkg/query-service/app/logparsingpipeline/collector_config.go+++ b/pkg/query-service/app/logparsingpipeline/collector_config.go@@ -8,10 +8,11 @@ import ("gopkg.in/yaml.v3"+ "log/slog"+"github.com/SigNoz/signoz/pkg/errors""github.com/SigNoz/signoz/pkg/query-service/constants""github.com/SigNoz/signoz/pkg/types/pipelinetypes"- "go.uber.org/zap")var lockLogsPipelineSpec sync.RWMutex@@ -154,14 +155,14 @@ func buildCollectorPipelineProcessorsList(func checkDuplicateString(pipeline []string) bool {exists := make(map[string]bool, len(pipeline))- zap.L().Debug("checking duplicate processors in the pipeline:", zap.Any("pipeline", pipeline))+ slog.Debug("checking duplicate processors in the pipeline", "pipeline", pipeline)for _, processor := range pipeline {name := processorif _, ok := exists[name]; ok {- zap.L().Error(+ slog.Error("duplicate processor name detected in generated collector config for log pipelines",- zap.String("processor", processor),- zap.Any("pipeline", pipeline),+ "processor", processor,+ "pipeline", pipeline,)return true}diff --git a/pkg/query-service/app/logparsingpipeline/controller.go b/pkg/query-service/app/logparsingpipeline/controller.goindex 19950a35aa..fe2dd1025c 100644--- a/pkg/query-service/app/logparsingpipeline/controller.go+++ b/pkg/query-service/app/logparsingpipeline/controller.go@@ -21,7 +21,7 @@ import ("github.com/SigNoz/signoz/pkg/valuer""github.com/google/uuid"- "go.uber.org/zap"+ "log/slog")var (@@ -175,7 +175,7 @@ func (ic *LogParsingPipelineController) getEffectivePipelinesByVersion(if version >= 0 {savedPipelines, err := ic.getPipelinesByVersion(ctx, orgID.String(), version)if err != nil {- zap.L().Error("failed to get pipelines for version", zap.Int("version", version), zap.Error(err))+ slog.ErrorContext(ctx, "failed to get pipelines for version", "version", version, "error", err)return nil, err}result = savedPipelines@@ -227,7 +227,7 @@ func (ic *LogParsingPipelineController) GetPipelinesByVersion() (*PipelinesResponse, error) {pipelines, err := ic.getEffectivePipelinesByVersion(ctx, orgId, version)if err != nil {- zap.L().Error("failed to get pipelines for version", zap.Int("version", version), zap.Error(err))+ slog.ErrorContext(ctx, "failed to get pipelines for version", "version", version, "error", err)return nil, err}@@ -235,7 +235,7 @@ func (ic *LogParsingPipelineController) GetPipelinesByVersion(if version >= 0 {cv, err := agentConf.GetConfigVersion(ctx, orgId, opamptypes.ElementTypeLogPipelines, version)if err != nil {- zap.L().Error("failed to get config for version", zap.Int("version", version), zap.Error(err))+ slog.ErrorContext(ctx, "failed to get config for version", "version", version, "error", err)return nil, err}configVersion = cvdiff --git a/pkg/query-service/app/logparsingpipeline/db.go b/pkg/query-service/app/logparsingpipeline/db.goindex afd3675a52..51bb926b68 100644--- a/pkg/query-service/app/logparsingpipeline/db.go+++ b/pkg/query-service/app/logparsingpipeline/db.go@@ -6,6 +6,8 @@ import ("fmt""time"+ "log/slog"+"github.com/SigNoz/signoz/pkg/errors""github.com/SigNoz/signoz/pkg/query-service/model""github.com/SigNoz/signoz/pkg/sqlstore"@@ -13,7 +15,6 @@ import ("github.com/SigNoz/signoz/pkg/types/authtypes""github.com/SigNoz/signoz/pkg/types/pipelinetypes""github.com/SigNoz/signoz/pkg/valuer"- "go.uber.org/zap")// Repo handles DDL and DML ops on ingestion pipeline@@ -80,7 +81,7 @@ func (r *Repo) insertPipeline(Model(&insertRow.StoreablePipeline).Exec(ctx)if err != nil {- zap.L().Error("error in inserting pipeline data", zap.Error(err))+ slog.ErrorContext(ctx, "error in inserting pipeline data", "error", err)return nil, errors.WrapInternalf(err, errors.CodeInternal, "failed to insert pipeline")}@@ -136,12 +137,12 @@ func (r *Repo) GetPipeline(Where("org_id = ?", orgID).Scan(ctx)if err != nil {- zap.L().Error("failed to get ingestion pipeline from db", zap.Error(err))+ slog.ErrorContext(ctx, "failed to get ingestion pipeline from db", "error", err)return nil, errors.WrapInternalf(err, errors.CodeInternal, "failed to get ingestion pipeline from db")}if len(storablePipelines) == 0 {- zap.L().Warn("No row found for ingestion pipeline id", zap.String("id", id))+ slog.WarnContext(ctx, "no row found for ingestion pipeline id", "id", id)return nil, errors.NewNotFoundf(errors.CodeNotFound, "no row found for ingestion pipeline id %v", id)}@@ -149,11 +150,11 @@ func (r *Repo) GetPipeline(gettablePipeline := pipelinetypes.GettablePipeline{}gettablePipeline.StoreablePipeline = storablePipelines[0]if err := gettablePipeline.ParseRawConfig(); err != nil {- zap.L().Error("invalid pipeline config found", zap.String("id", id), zap.Error(err))+ slog.ErrorContext(ctx, "invalid pipeline config found", "id", id, "error", err)return nil, err}if err := gettablePipeline.ParseFilter(); err != nil {- zap.L().Error("invalid pipeline filter found", zap.String("id", id), zap.Error(err))+ slog.ErrorContext(ctx, "invalid pipeline filter found", "id", id, "error", err)return nil, err}return &gettablePipeline, nildiff --git a/pkg/query-service/app/metrics/query_builder.go b/pkg/query-service/app/metrics/query_builder.goindex 69d5cfb75a..ef4103e42c 100644--- a/pkg/query-service/app/metrics/query_builder.go+++ b/pkg/query-service/app/metrics/query_builder.go@@ -2,12 +2,12 @@ package metricsimport ("fmt"+ "log/slog""reflect""strconv""strings"v3 "github.com/SigNoz/signoz/pkg/query-service/model/v3"- "go.uber.org/zap")func AddMetricValueFilter(mq *v3.BuilderQuery) *v3.MetricValueFilter {@@ -69,7 +69,7 @@ func AddMetricValueFilter(mq *v3.BuilderQuery) *v3.MetricValueFilter {case string:numericValue, err := strconv.ParseFloat(v, 64)if err != nil {- zap.L().Warn("invalid type for metric value filter, ignoring", zap.Any("type", reflect.TypeOf(v)), zap.String("value", v))+ slog.Warn("invalid type for metric value filter, ignoring", "type", reflect.TypeOf(v), "value", v)continue}metricValueFilter = &v3.MetricValueFilter{@@ -111,11 +111,11 @@ func FormattedValue(v interface{}) string {case int, float32, float64, bool:return strings.Join(strings.Fields(fmt.Sprint(x)), ",")default:- zap.L().Error("invalid type for formatted value", zap.Any("type", reflect.TypeOf(x[0])))+ slog.Error("invalid type for formatted value", "type", reflect.TypeOf(x[0]))return ""}default:- zap.L().Error("invalid type for formatted value", zap.Any("type", reflect.TypeOf(x)))+ slog.Error("invalid type for formatted value", "type", reflect.TypeOf(x))return ""}}@@ -144,11 +144,11 @@ func PromFormattedValue(v interface{}) string {}return strings.Join(str, "|")default:- zap.L().Error("invalid type for prom formatted value", zap.Any("type", reflect.TypeOf(x[0])))+ slog.Error("invalid type for prom formatted value", "type", reflect.TypeOf(x[0]))return ""}default:- zap.L().Error("invalid type for prom formatted value", zap.Any("type", reflect.TypeOf(x)))+ slog.Error("invalid type for prom formatted value", "type", reflect.TypeOf(x))return ""}}diff --git a/pkg/query-service/app/metricsexplorer/summary.go b/pkg/query-service/app/metricsexplorer/summary.goindex 6ea93b4508..582817ed4a 100644--- a/pkg/query-service/app/metricsexplorer/summary.go+++ b/pkg/query-service/app/metricsexplorer/summary.go@@ -8,7 +8,7 @@ import ("strings""time"- "go.uber.org/zap"+ "log/slog""github.com/SigNoz/signoz/pkg/modules/dashboard""github.com/SigNoz/signoz/pkg/query-service/interfaces"@@ -173,14 +173,14 @@ func (receiver *SummaryService) GetMetricsSummary(ctx context.Context, orgID valif data != nil {jsonData, err := json.Marshal(data)if err != nil {- zap.L().Error("Error marshalling data:", zap.Error(err))+ slog.Error("error marshalling data", "error", err)return &model.ApiError{Typ: "MarshallingErr", Err: err}}var dashboards map[string][]metrics_explorer.Dashboarderr = json.Unmarshal(jsonData, &dashboards)if err != nil {- zap.L().Error("Error unmarshalling data:", zap.Error(err))+ slog.Error("error unmarshalling data", "error", err)return &model.ApiError{Typ: "UnMarshallingErr", Err: err}}if _, ok := dashboards[metricName]; ok {@@ -264,7 +264,7 @@ func (receiver *SummaryService) GetRelatedMetrics(ctx context.Context, params *mif err != nil {// If we hit a deadline exceeded error, proceed with only name similarityif errors.Is(err.Err, context.DeadlineExceeded) {- zap.L().Warn("Attribute similarity calculation timed out, proceeding with name similarity only")+ slog.Warn("attribute similarity calculation timed out, proceeding with name similarity only")attrSimilarityScores = make(map[string]metrics_explorer.RelatedMetricsScore)} else {return nil, err@@ -350,12 +350,12 @@ func (receiver *SummaryService) GetRelatedMetrics(ctx context.Context, params *mif names != nil {jsonData, err := json.Marshal(names)if err != nil {- zap.L().Error("Error marshalling dashboard data", zap.Error(err))+ slog.Error("error marshalling dashboard data", "error", err)return &model.ApiError{Typ: "MarshallingErr", Err: err}}err = json.Unmarshal(jsonData, &dashboardsRelatedData)if err != nil {- zap.L().Error("Error unmarshalling dashboard data", zap.Error(err))+ slog.Error("error unmarshalling dashboard data", "error", err)return &model.ApiError{Typ: "UnMarshallingErr", Err: err}}}diff --git a/pkg/query-service/app/opamp/configure_ingestionRules.go b/pkg/query-service/app/opamp/configure_ingestionRules.goindex c3153ce984..d588ad18cf 100644--- a/pkg/query-service/app/opamp/configure_ingestionRules.go+++ b/pkg/query-service/app/opamp/configure_ingestionRules.go@@ -3,6 +3,7 @@ package opampimport ("context""crypto/sha256"+ "log/slog""github.com/SigNoz/signoz/pkg/errors"model "github.com/SigNoz/signoz/pkg/query-service/app/opamp/model"@@ -10,7 +11,6 @@ import ("github.com/knadh/koanf/parsers/yaml""github.com/open-telemetry/opamp-go/protobufs""go.opentelemetry.io/collector/confmap"- "go.uber.org/zap")var (@@ -29,10 +29,10 @@ func UpsertControlProcessors(ctx context.Context, signal string,// AddToTracePipeline() or RemoveFromTracesPipeline() prior to calling// this method- zap.L().Debug("initiating ingestion rules deployment config", zap.String("signal", signal), zap.Any("processors", processors))+ slog.Debug("initiating ingestion rules deployment config", "signal", signal, "processors", processors)if signal != string(Metrics) && signal != string(Traces) {- zap.L().Error("received invalid signal int UpsertControlProcessors", zap.String("signal", signal))+ slog.Error("received invalid signal in UpsertControlProcessors", "signal", signal)return "", errors.NewInvalidInputf(errors.CodeInvalidInput, "signal not supported in ingestion rules: %s", signal)}@@ -46,14 +46,14 @@ func UpsertControlProcessors(ctx context.Context, signal string,}if len(agents) > 1 && signal == string(Traces) {- zap.L().Debug("found multiple agents. this feature is not supported for traces pipeline (sampling rules)")+ slog.Debug("found multiple agents, this feature is not supported for traces pipeline (sampling rules)")return "", errors.NewInvalidInputf(CodeMultipleAgentsNotSupported, "multiple agents not supported in sampling rules")}hash := ""for _, agent := range agents {agenthash, err := addIngestionControlToAgent(agent, signal, processors, false)if err != nil {- zap.L().Error("failed to push ingestion rules config to agent", zap.String("agentID", agent.AgentID), zap.Error(err))+ slog.Error("failed to push ingestion rules config to agent", "agent_id", agent.AgentID, "error", err)continue}@@ -82,7 +82,7 @@ func addIngestionControlToAgent(agent *model.Agent, signal string, processors ma// add ingestion control specerr = makeIngestionControlSpec(agentConf, Signal(signal), processors)if err != nil {- zap.L().Error("failed to prepare ingestion control processors for agent", zap.String("agentID", agent.AgentID), zap.Error(err))+ slog.Error("failed to prepare ingestion control processors for agent", "agent_id", agent.AgentID, "error", err)return confHash, err}@@ -92,7 +92,7 @@ func addIngestionControlToAgent(agent *model.Agent, signal string, processors mareturn confHash, err}- zap.L().Debug("sending new config", zap.String("config", string(configR)))+ slog.Debug("sending new config", "config", string(configR))hash := sha256.New()_, err = hash.Write(configR)if err != nil {@@ -133,7 +133,7 @@ func makeIngestionControlSpec(agentConf *confmap.Conf, signal Signal, processors// merge tracesPipelinePlan with current pipelinemergedPipeline, err := buildPipeline(signal, currentPipeline)if err != nil {- zap.L().Error("failed to build pipeline", zap.String("signal", string(signal)), zap.Error(err))+ slog.Error("failed to build pipeline", "signal", string(signal), "error", err)return err}diff --git a/pkg/query-service/app/opamp/model/agent.go b/pkg/query-service/app/opamp/model/agent.goindex 5f95ed33c6..2ee705831d 100644--- a/pkg/query-service/app/opamp/model/agent.go+++ b/pkg/query-service/app/opamp/model/agent.go@@ -11,7 +11,6 @@ import ("github.com/SigNoz/signoz/pkg/sqlstore""github.com/SigNoz/signoz/pkg/types/opamptypes""github.com/SigNoz/signoz/pkg/valuer"- "go.uber.org/zap""google.golang.org/protobuf/proto""github.com/open-telemetry/opamp-go/protobufs"@@ -305,7 +304,7 @@ func (agent *Agent) processStatusUpdate(func (agent *Agent) updateRemoteConfig(configProvider AgentConfigProvider) bool {recommendedConfig, confId, err := configProvider.RecommendAgentConfig(agent.OrgID, []byte(agent.Config))if err != nil {- zap.L().Error("could not generate config recommendation for agent", zap.String("agentID", agent.AgentID), zap.Error(err))+ agent.logger.Error("could not generate config recommendation for agent", "agent_id", agent.AgentID, "error", err)return false}@@ -322,7 +321,7 @@ func (agent *Agent) updateRemoteConfig(configProvider AgentConfigProvider) boolif len(confId) < 1 {// Should never happen. Handle gracefully if it does by some chance.- zap.L().Error("config provider recommended a config with empty confId. Using content hash for configId")+ agent.logger.Error("config provider recommended a config with empty conf_id, using content hash for config_id")hash := sha256.New()for k, v := range cfg.Config.ConfigMap {diff --git a/pkg/query-service/app/opamp/model/agents.go b/pkg/query-service/app/opamp/model/agents.goindex 6950689170..d7494b5ca5 100644--- a/pkg/query-service/app/opamp/model/agents.go+++ b/pkg/query-service/app/opamp/model/agents.go@@ -14,7 +14,6 @@ import ("github.com/open-telemetry/opamp-go/protobufs""github.com/open-telemetry/opamp-go/server/types""github.com/pkg/errors"- "go.uber.org/zap")var AllAgents = Agents{@@ -135,8 +134,8 @@ func (agents *Agents) RecommendLatestConfigToAll(// Recommendation is same as current configif string(newConfig) == agent.Config {- zap.L().Info(- "Recommended config same as current effective config for agent", zap.String("agentID", agent.AgentID),+ agents.logger.Info(+ "recommended config same as current effective config for agent", "agent_id", agent.AgentID,)return nil}diff --git a/pkg/query-service/app/opamp/opamp_server.go b/pkg/query-service/app/opamp/opamp_server.goindex ceb3b4c4f2..61f53fc9d6 100644--- a/pkg/query-service/app/opamp/opamp_server.go+++ b/pkg/query-service/app/opamp/opamp_server.go@@ -2,6 +2,7 @@ package opampimport ("context"+ "log/slog""net/http""time"@@ -11,8 +12,6 @@ import ("github.com/open-telemetry/opamp-go/protobufs""github.com/open-telemetry/opamp-go/server""github.com/open-telemetry/opamp-go/server/types"-- "go.uber.org/zap")var opAmpServer *Server@@ -20,6 +19,7 @@ var opAmpServer *Servertype Server struct {server server.OpAMPServeragents *model.Agents+ logger *slog.LoggeragentConfigProvider AgentConfigProvider@@ -43,6 +43,7 @@ func InitializeServer(opAmpServer = &Server{agents: agents,agentConfigProvider: agentConfigProvider,+ logger: instrumentation.Logger(),}opAmpServer.server = server.New(wrappedLogger(instrumentation.Logger()))return opAmpServer@@ -70,8 +71,8 @@ func (srv *Server) Start(listener string) error {unsubscribe := srv.agentConfigProvider.SubscribeToConfigUpdates(func() {err := srv.agents.RecommendLatestConfigToAll(srv.agentConfigProvider)if err != nil {- zap.L().Error(- "could not roll out latest config recommendation to connected agents", zap.Error(err),+ srv.logger.Error(+ "could not roll out latest config recommendation to connected agents", "error", err,)}})@@ -114,7 +115,7 @@ func (srv *Server) OnMessage(ctx context.Context, conn types.Connection, msg *pr// agents sends the effective config when we processStatusUpdate.agent, created, err := srv.agents.FindOrCreateAgent(agentID.String(), conn, orgID)if err != nil {- zap.L().Error("Failed to find or create agent", zap.String("agentID", agentID.String()), zap.Error(err))+ srv.logger.Error("failed to find or create agent", "agent_id", agentID.String(), "error", err)// Return error response according to OpAMP protocolreturn &protobufs.ServerToAgent{@@ -134,10 +135,10 @@ func (srv *Server) OnMessage(ctx context.Context, conn types.Connection, msg *prif created {agent.CanLB = model.ExtractLbFlag(msg.AgentDescription)- zap.L().Debug(- "New agent added", zap.Bool("canLb", agent.CanLB),- zap.String("agentID", agent.AgentID),- zap.Any("status", agent.Status),+ srv.logger.Debug(+ "new agent added", "can_lb", agent.CanLB,+ "agent_id", agent.AgentID,+ "status", agent.Status,)}@@ -158,7 +159,7 @@ func Ready() bool {return false}if opAmpServer.agents.Count() == 0 {- zap.L().Warn("no agents available, all agent config requests will be rejected")+ slog.Warn("no agents available, all agent config requests will be rejected")return false}return truediff --git a/pkg/query-service/app/opamp/pipeline_builder.go b/pkg/query-service/app/opamp/pipeline_builder.goindex 7654fe8c4f..9fb1fb0664 100644--- a/pkg/query-service/app/opamp/pipeline_builder.go+++ b/pkg/query-service/app/opamp/pipeline_builder.go@@ -2,9 +2,8 @@ package opampimport ("fmt"+ "log/slog""sync"-- "go.uber.org/zap")var lockTracesPipelineSpec sync.RWMutex@@ -89,7 +88,7 @@ func RemoveFromMetricsPipelineSpec(name string) {func checkDuplicates(pipeline []interface{}) bool {exists := make(map[string]bool, len(pipeline))- zap.L().Debug("checking duplicate processors in the pipeline", zap.Any("pipeline", pipeline))+ slog.Debug("checking duplicate processors in the pipeline", "pipeline", pipeline)for _, processor := range pipeline {name := processor.(string)if _, ok := exists[name]; ok {@@ -149,7 +148,7 @@ func buildPipeline(signal Signal, current []interface{}) ([]interface{}, error)currentPos := loc + inserts// if disabled then remove from the pipelineif !m.Enabled {- zap.L().Debug("build_pipeline: found a disabled item, removing from pipeline at position", zap.Int("position", currentPos-1), zap.String("processor", m.Name))+ slog.Debug("build_pipeline: found a disabled item, removing from pipeline at position", "position", currentPos-1, "processor", m.Name)if currentPos-1 <= 0 {pipeline = pipeline[currentPos+1:]} else {@@ -170,10 +169,10 @@ func buildPipeline(signal Signal, current []interface{}) ([]interface{}, error)// right after last matched processsor (e.g. insert filters after tail_sampling for existing list of [batch, tail_sampling])if lastMatched <= 0 {- zap.L().Debug("build_pipeline: found a new item to be inserted, inserting at position 0", zap.String("processor", m.Name))+ slog.Debug("build_pipeline: found a new item to be inserted, inserting at position 0", "processor", m.Name)pipeline = append([]interface{}{m.Name}, pipeline[lastMatched+1:]...)} else {- zap.L().Debug("build_pipeline: found a new item to be inserted, inserting at position", zap.Int("position", lastMatched), zap.String("processor", m.Name))+ slog.Debug("build_pipeline: found a new item to be inserted, inserting at position", "position", lastMatched, "processor", m.Name)prior := make([]interface{}, len(pipeline[:lastMatched]))next := make([]interface{}, len(pipeline[lastMatched:]))copy(prior, pipeline[:lastMatched])diff --git a/pkg/query-service/app/parser.go b/pkg/query-service/app/parser.goindex 89fa14a35d..5f077f2b7f 100644--- a/pkg/query-service/app/parser.go+++ b/pkg/query-service/app/parser.go@@ -19,10 +19,11 @@ import ("github.com/SigNoz/govaluate""github.com/SigNoz/signoz/pkg/query-service/app/integrations/messagingQueues/kafka"queues2 "github.com/SigNoz/signoz/pkg/query-service/app/integrations/messagingQueues/queues"+ "log/slog"+"github.com/gorilla/mux"promModel "github.com/prometheus/common/model""go.uber.org/multierr"- "go.uber.org/zap"errorsV2 "github.com/SigNoz/signoz/pkg/errors""github.com/SigNoz/signoz/pkg/query-service/app/metrics"@@ -740,9 +741,9 @@ func chTransformQuery(query string, variables map[string]interface{}) {transformer := chVariables.NewQueryTransformer(query, varsForTransform)transformedQuery, err := transformer.Transform()if err != nil {- zap.L().Warn("failed to transform clickhouse query", zap.String("query", query), zap.Error(err))+ slog.Warn("failed to transform clickhouse query", "query", query, "error", err)}- zap.L().Info("transformed clickhouse query", zap.String("transformedQuery", transformedQuery), zap.String("originalQuery", query))+ slog.Info("transformed clickhouse query", "transformed_query", transformedQuery, "original_query", query)}func ParseQueryRangeParams(r *http.Request) (*v3.QueryRangeParamsV3, *model.ApiError) {diff --git a/pkg/query-service/app/querier/helper.go b/pkg/query-service/app/querier/helper.goindex 98117c956a..87fd3b6d1f 100644--- a/pkg/query-service/app/querier/helper.go+++ b/pkg/query-service/app/querier/helper.go@@ -15,7 +15,6 @@ import ("github.com/SigNoz/signoz/pkg/query-service/postprocess""github.com/SigNoz/signoz/pkg/query-service/querycache""github.com/SigNoz/signoz/pkg/valuer"- "go.uber.org/zap")func prepareLogsQuery(@@ -97,7 +96,7 @@ func (q *querier) runBuilderQuery(var query stringvar err errorif _, ok := cacheKeys[queryName]; !ok || params.NoCache {- zap.L().Info("skipping cache for logs query", zap.String("queryName", queryName), zap.Int64("start", start), zap.Int64("end", end), zap.Int64("step", builderQuery.StepInterval), zap.Bool("noCache", params.NoCache), zap.String("cacheKey", cacheKeys[queryName]))+ q.logger.InfoContext(ctx, "skipping cache for logs query", "query_name", queryName, "start", start, "end", end, "step", builderQuery.StepInterval, "no_cache", params.NoCache, "cache_key", cacheKeys[queryName])query, err = prepareLogsQuery(ctx, start, end, builderQuery, params)if err != nil {ch <- channelResult{Err: err, Name: queryName, Query: query, Series: nil}@@ -109,7 +108,7 @@ func (q *querier) runBuilderQuery(}misses := q.queryCache.FindMissingTimeRanges(orgID, start, end, builderQuery.StepInterval, cacheKeys[queryName])- zap.L().Info("cache misses for logs query", zap.Any("misses", misses))+ q.logger.InfoContext(ctx, "cache misses for logs query", "misses", misses)missedSeries := make([]querycache.CachedSeriesData, 0)filteredMissedSeries := make([]querycache.CachedSeriesData, 0)for _, miss := range misses {@@ -217,7 +216,7 @@ func (q *querier) runBuilderQuery(// We are only caching the graph panel queries. A non-existant cache key means that the query is not cached.// If the query is not cached, we execute the query and return the result without caching it.if _, ok := cacheKeys[queryName]; !ok || params.NoCache {- zap.L().Info("skipping cache for metrics query", zap.String("queryName", queryName), zap.Int64("start", start), zap.Int64("end", end), zap.Int64("step", builderQuery.StepInterval), zap.Bool("noCache", params.NoCache), zap.String("cacheKey", cacheKeys[queryName]))+ q.logger.InfoContext(ctx, "skipping cache for metrics query", "query_name", queryName, "start", start, "end", end, "step", builderQuery.StepInterval, "no_cache", params.NoCache, "cache_key", cacheKeys[queryName])query, err := metricsV3.PrepareMetricQuery(start, end, params.CompositeQuery.QueryType, params.CompositeQuery.PanelType, builderQuery, metricsV3.Options{})if err != nil {ch <- channelResult{Err: err, Name: queryName, Query: query, Series: nil}@@ -230,7 +229,7 @@ func (q *querier) runBuilderQuery(cacheKey := cacheKeys[queryName]misses := q.queryCache.FindMissingTimeRanges(orgID, start, end, builderQuery.StepInterval, cacheKey)- zap.L().Info("cache misses for metrics query", zap.Any("misses", misses))+ q.logger.InfoContext(ctx, "cache misses for metrics query", "misses", misses)missedSeries := make([]querycache.CachedSeriesData, 0)for _, miss := range misses {query, err := metricsV3.PrepareMetricQuery(@@ -297,7 +296,7 @@ func (q *querier) runBuilderExpression(}if _, ok := cacheKeys[queryName]; !ok || params.NoCache {- zap.L().Info("skipping cache for expression query", zap.String("queryName", queryName), zap.Int64("start", params.Start), zap.Int64("end", params.End), zap.Int64("step", params.Step), zap.Bool("noCache", params.NoCache), zap.String("cacheKey", cacheKeys[queryName]))+ q.logger.InfoContext(ctx, "skipping cache for expression query", "query_name", queryName, "start", params.Start, "end", params.End, "step", params.Step, "no_cache", params.NoCache, "cache_key", cacheKeys[queryName])query := queries[queryName]series, err := q.execClickHouseQuery(ctx, query)ch <- channelResult{Err: err, Name: queryName, Query: query, Series: series}@@ -307,7 +306,7 @@ func (q *querier) runBuilderExpression(cacheKey := cacheKeys[queryName]step := postprocess.StepIntervalForFunction(params, queryName)misses := q.queryCache.FindMissingTimeRanges(orgID, params.Start, params.End, step, cacheKey)- zap.L().Info("cache misses for expression query", zap.Any("misses", misses))+ q.logger.InfoContext(ctx, "cache misses for expression query", "misses", misses)missedSeries := make([]querycache.CachedSeriesData, 0)for _, miss := range misses {missQueries, _ := q.builder.PrepareQueries(&v3.QueryRangeParamsV3{diff --git a/pkg/query-service/app/querier/querier.go b/pkg/query-service/app/querier/querier.goindex 67fe8928f5..8a8fb32e7e 100644--- a/pkg/query-service/app/querier/querier.go+++ b/pkg/query-service/app/querier/querier.go@@ -18,12 +18,13 @@ import ("github.com/SigNoz/signoz/pkg/query-service/utils""github.com/SigNoz/signoz/pkg/valuer"+ "log/slog"+"github.com/SigNoz/signoz/pkg/cache""github.com/SigNoz/signoz/pkg/query-service/interfaces""github.com/SigNoz/signoz/pkg/query-service/model"v3 "github.com/SigNoz/signoz/pkg/query-service/model/v3""go.uber.org/multierr"- "go.uber.org/zap")type channelResult struct {@@ -44,6 +45,8 @@ type querier struct {builder *queryBuilder.QueryBuilder+ logger *slog.Logger+// used for testing// TODO(srikanthccv): remove this once we have a proper mocktestingMode bool@@ -85,6 +88,8 @@ func NewQuerier(opts QuerierOptions) interfaces.Querier {BuildMetricQuery: metricsV3.PrepareMetricQuery,}),+ logger: slog.Default(),+testingMode: opts.TestingMode,returnedSeries: opts.ReturnedSeries,returnedErr: opts.ReturnedErr,@@ -113,7 +118,7 @@ func (q *querier) execClickHouseQuery(ctx context.Context, query string) ([]*v3.series.Points = points}if pointsWithNegativeTimestamps > 0 {- zap.L().Error("found points with negative timestamps for query", zap.String("query", query))+ q.logger.ErrorContext(ctx, "found points with negative timestamps for query", "query", query)}return result, err}@@ -206,14 +211,14 @@ func (q *querier) runPromQueries(ctx context.Context, orgID valuer.UUID, paramscacheKey, ok := cacheKeys[queryName]if !ok || params.NoCache {- zap.L().Info("skipping cache for metrics prom query", zap.String("queryName", queryName), zap.Int64("start", params.Start), zap.Int64("end", params.End), zap.Int64("step", params.Step), zap.Bool("noCache", params.NoCache), zap.String("cacheKey", cacheKeys[queryName]))+ q.logger.InfoContext(ctx, "skipping cache for metrics prom query", "query_name", queryName, "start", params.Start, "end", params.End, "step", params.Step, "no_cache", params.NoCache, "cache_key", cacheKeys[queryName])query := metricsV3.BuildPromQuery(promQuery, params.Step, params.Start, params.End)series, err := q.execPromQuery(ctx, query)channelResults <- channelResult{Err: err, Name: queryName, Query: query.Query, Series: series}return}misses := q.queryCache.FindMissingTimeRanges(orgID, params.Start, params.End, params.Step, cacheKey)- zap.L().Info("cache misses for metrics prom query", zap.Any("misses", misses))+ q.logger.InfoContext(ctx, "cache misses for metrics prom query", "misses", misses)missedSeries := make([]querycache.CachedSeriesData, 0)for _, miss := range misses {query := metricsV3.BuildPromQuery(promQuery, params.Step, miss.Start, miss.End)diff --git a/pkg/query-service/app/querier/querier_test.go b/pkg/query-service/app/querier/querier_test.goindex dc18c1722e..9ac44f797a 100644--- a/pkg/query-service/app/querier/querier_test.go+++ b/pkg/query-service/app/querier/querier_test.go@@ -5,6 +5,7 @@ import ("fmt""math""strings"+ "log/slog""testing""time"@@ -1403,6 +1404,7 @@ func Test_querier_Traces_runWindowBasedListQueryDesc(t *testing.T) {// Create reader and querierreader := clickhouseReader.NewReader(+ slog.Default(),nil,telemetryStore,prometheustest.New(context.Background(), instrumentationtest.New().ToProviderSettings(), prometheus.Config{}, telemetryStore),@@ -1628,6 +1630,7 @@ func Test_querier_Traces_runWindowBasedListQueryAsc(t *testing.T) {// Create reader and querierreader := clickhouseReader.NewReader(+ slog.Default(),nil,telemetryStore,prometheustest.New(context.Background(), instrumentationtest.New().ToProviderSettings(), prometheus.Config{}, telemetryStore),@@ -1928,6 +1931,7 @@ func Test_querier_Logs_runWindowBasedListQueryDesc(t *testing.T) {// Create reader and querierreader := clickhouseReader.NewReader(+ slog.Default(),nil,telemetryStore,prometheustest.New(context.Background(), instrumentationtest.New().ToProviderSettings(), prometheus.Config{}, telemetryStore),@@ -2155,6 +2159,7 @@ func Test_querier_Logs_runWindowBasedListQueryAsc(t *testing.T) {// Create reader and querierreader := clickhouseReader.NewReader(+ slog.Default(),nil,telemetryStore,prometheustest.New(context.Background(), instrumentationtest.New().ToProviderSettings(), prometheus.Config{}, telemetryStore),diff --git a/pkg/query-service/app/querier/v2/helper.go b/pkg/query-service/app/querier/v2/helper.goindex b4d5d4c2cf..d8a88db941 100644--- a/pkg/query-service/app/querier/v2/helper.go+++ b/pkg/query-service/app/querier/v2/helper.go@@ -16,7 +16,6 @@ import (v3 "github.com/SigNoz/signoz/pkg/query-service/model/v3""github.com/SigNoz/signoz/pkg/query-service/querycache""github.com/SigNoz/signoz/pkg/valuer"- "go.uber.org/zap")func prepareLogsQuery(@@ -99,7 +98,7 @@ func (q *querier) runBuilderQuery(var query stringvar err errorif _, ok := cacheKeys[queryName]; !ok || params.NoCache {- zap.L().Info("skipping cache for logs query", zap.String("queryName", queryName), zap.Int64("start", params.Start), zap.Int64("end", params.End), zap.Int64("step", params.Step), zap.Bool("noCache", params.NoCache), zap.String("cacheKey", cacheKeys[queryName]))+ q.logger.InfoContext(ctx, "skipping cache for logs query", "query_name", queryName, "start", params.Start, "end", params.End, "step", params.Step, "no_cache", params.NoCache, "cache_key", cacheKeys[queryName])query, err = prepareLogsQuery(ctx, start, end, builderQuery, params)if err != nil {ch <- channelResult{Err: err, Name: queryName, Query: query, Series: nil}@@ -110,7 +109,7 @@ func (q *querier) runBuilderQuery(return}misses := q.queryCache.FindMissingTimeRangesV2(orgID, start, end, builderQuery.StepInterval, cacheKeys[queryName])- zap.L().Info("cache misses for logs query", zap.Any("misses", misses))+ q.logger.InfoContext(ctx, "cache misses for logs query", "misses", misses)missedSeries := make([]querycache.CachedSeriesData, 0)filteredMissedSeries := make([]querycache.CachedSeriesData, 0)for _, miss := range misses {@@ -219,7 +218,7 @@ func (q *querier) runBuilderQuery(// We are only caching the graph panel queries. A non-existant cache key means that the query is not cached.// If the query is not cached, we execute the query and return the result without caching it.if _, ok := cacheKeys[queryName]; !ok || params.NoCache {- zap.L().Info("skipping cache for metrics query", zap.String("queryName", queryName), zap.Int64("start", params.Start), zap.Int64("end", params.End), zap.Int64("step", params.Step), zap.Bool("noCache", params.NoCache), zap.String("cacheKey", cacheKeys[queryName]))+ q.logger.InfoContext(ctx, "skipping cache for metrics query", "query_name", queryName, "start", params.Start, "end", params.End, "step", params.Step, "no_cache", params.NoCache, "cache_key", cacheKeys[queryName])query, err := metricsV4.PrepareMetricQuery(start, end, params.CompositeQuery.QueryType, params.CompositeQuery.PanelType, builderQuery, metricsV3.Options{})if err != nil {ch <- channelResult{Err: err, Name: queryName, Query: query, Series: nil}@@ -231,7 +230,7 @@ func (q *querier) runBuilderQuery(}misses := q.queryCache.FindMissingTimeRanges(orgID, start, end, builderQuery.StepInterval, cacheKeys[queryName])- zap.L().Info("cache misses for metrics query", zap.Any("misses", misses))+ q.logger.InfoContext(ctx, "cache misses for metrics query", "misses", misses)missedSeries := make([]querycache.CachedSeriesData, 0)for _, miss := range misses {query, err := metricsV4.PrepareMetricQuery(@@ -286,7 +285,7 @@ func (q *querier) ValidateMetricNames(ctx context.Context, query *v3.CompositeQufor _, query := range query.PromQueries {expr, err := parser.ParseExpr(query.Query)if err != nil {- zap.L().Debug("error parsing promQL expression", zap.String("query", query.Query), zap.Error(err))+ q.logger.DebugContext(ctx, "error parsing promql expression", "query", query.Query, "error", err)continue}parser.Inspect(expr, func(node parser.Node, path []parser.Node) error {@@ -302,14 +301,14 @@ func (q *querier) ValidateMetricNames(ctx context.Context, query *v3.CompositeQu}metrics, err := q.reader.GetNormalizedStatus(ctx, orgID, metricNames)if err != nil {- zap.L().Debug("error getting corresponding normalized metrics", zap.Error(err))+ q.logger.DebugContext(ctx, "error getting corresponding normalized metrics", "error", err)return}for metricName, metricPresent := range metrics {if metricPresent {continue} else {- zap.L().Warn("using normalized metric name", zap.String("metrics", metricName))+ q.logger.WarnContext(ctx, "using normalized metric name", "metrics", metricName)continue}}@@ -320,14 +319,14 @@ func (q *querier) ValidateMetricNames(ctx context.Context, query *v3.CompositeQu}metrics, err := q.reader.GetNormalizedStatus(ctx, orgID, metricNames)if err != nil {- zap.L().Debug("error getting corresponding normalized metrics", zap.Error(err))+ q.logger.DebugContext(ctx, "error getting corresponding normalized metrics", "error", err)return}for metricName, metricPresent := range metrics {if metricPresent {continue} else {- zap.L().Warn("using normalized metric name", zap.String("metrics", metricName))+ q.logger.WarnContext(ctx, "using normalized metric name", "metrics", metricName)continue}}diff --git a/pkg/query-service/app/querier/v2/querier.go b/pkg/query-service/app/querier/v2/querier.goindex 19090fca06..b812567923 100644--- a/pkg/query-service/app/querier/v2/querier.go+++ b/pkg/query-service/app/querier/v2/querier.go@@ -18,12 +18,13 @@ import ("github.com/SigNoz/signoz/pkg/query-service/utils""github.com/SigNoz/signoz/pkg/valuer"+ "log/slog"+"github.com/SigNoz/signoz/pkg/cache""github.com/SigNoz/signoz/pkg/query-service/interfaces""github.com/SigNoz/signoz/pkg/query-service/model"v3 "github.com/SigNoz/signoz/pkg/query-service/model/v3""go.uber.org/multierr"- "go.uber.org/zap")type channelResult struct {@@ -44,6 +45,8 @@ type querier struct {builder *queryBuilder.QueryBuilder+ logger *slog.Logger+// used for testing// TODO(srikanthccv): remove this once we have a proper mocktestingMode bool@@ -85,6 +88,8 @@ func NewQuerier(opts QuerierOptions) interfaces.Querier {BuildMetricQuery: metricsV4.PrepareMetricQuery,}),+ logger: slog.Default(),+testingMode: opts.TestingMode,returnedSeries: opts.ReturnedSeries,returnedErr: opts.ReturnedErr,@@ -115,7 +120,7 @@ func (q *querier) execClickHouseQuery(ctx context.Context, query string) ([]*v3.series.Points = points}if pointsWithNegativeTimestamps > 0 {- zap.L().Error("found points with negative timestamps for query", zap.String("query", query))+ q.logger.ErrorContext(ctx, "found points with negative timestamps for query", "query", query)}return result, err}@@ -167,7 +172,7 @@ func (q *querier) runBuilderQueries(ctx context.Context, orgID valuer.UUID, parawg.Wait()close(ch)- zap.L().Info("time taken to run builder queries", zap.Duration("multiQueryDuration", time.Since(now)), zap.Int("num_queries", len(params.CompositeQuery.BuilderQueries)))+ q.logger.InfoContext(ctx, "time taken to run builder queries", "multi_query_duration", time.Since(now), "num_queries", len(params.CompositeQuery.BuilderQueries))results := make([]*v3.Result, 0)errQueriesByName := make(map[string]error)@@ -208,14 +213,14 @@ func (q *querier) runPromQueries(ctx context.Context, orgID valuer.UUID, paramscacheKey, ok := cacheKeys[queryName]if !ok || params.NoCache {- zap.L().Info("skipping cache for metrics prom query", zap.String("queryName", queryName), zap.Int64("start", params.Start), zap.Int64("end", params.End), zap.Int64("step", params.Step), zap.Bool("noCache", params.NoCache), zap.String("cacheKey", cacheKeys[queryName]))+ q.logger.InfoContext(ctx, "skipping cache for metrics prom query", "query_name", queryName, "start", params.Start, "end", params.End, "step", params.Step, "no_cache", params.NoCache, "cache_key", cacheKeys[queryName])query := metricsV4.BuildPromQuery(promQuery, params.Step, params.Start, params.End)series, err := q.execPromQuery(ctx, query)channelResults <- channelResult{Err: err, Name: queryName, Query: query.Query, Series: series}return}misses := q.queryCache.FindMissingTimeRanges(orgID, params.Start, params.End, params.Step, cacheKey)- zap.L().Info("cache misses for metrics prom query", zap.Any("misses", misses))+ q.logger.InfoContext(ctx, "cache misses for metrics prom query", "misses", misses)missedSeries := make([]querycache.CachedSeriesData, 0)for _, miss := range misses {query := metricsV4.BuildPromQuery(promQuery, params.Step, miss.Start, miss.End)diff --git a/pkg/query-service/app/querier/v2/querier_test.go b/pkg/query-service/app/querier/v2/querier_test.goindex 673f19e647..d942227f2f 100644--- a/pkg/query-service/app/querier/v2/querier_test.go+++ b/pkg/query-service/app/querier/v2/querier_test.go@@ -5,6 +5,7 @@ import ("fmt""math""strings"+ "log/slog""testing""time"@@ -1455,6 +1456,7 @@ func Test_querier_Traces_runWindowBasedListQueryDesc(t *testing.T) {// Create reader and querierreader := clickhouseReader.NewReader(+ slog.Default(),nil,telemetryStore,prometheustest.New(context.Background(), instrumentationtest.New().ToProviderSettings(), prometheus.Config{}, telemetryStore),@@ -1680,6 +1682,7 @@ func Test_querier_Traces_runWindowBasedListQueryAsc(t *testing.T) {// Create reader and querierreader := clickhouseReader.NewReader(+ slog.Default(),nil,telemetryStore,prometheustest.New(context.Background(), instrumentationtest.New().ToProviderSettings(), prometheus.Config{}, telemetryStore),@@ -1979,6 +1982,7 @@ func Test_querier_Logs_runWindowBasedListQueryDesc(t *testing.T) {// Create reader and querierreader := clickhouseReader.NewReader(+ slog.Default(),nil,telemetryStore,prometheustest.New(context.Background(), instrumentationtest.New().ToProviderSettings(), prometheus.Config{}, telemetryStore),@@ -2206,6 +2210,7 @@ func Test_querier_Logs_runWindowBasedListQueryAsc(t *testing.T) {// Create reader and querierreader := clickhouseReader.NewReader(+ slog.Default(),nil,telemetryStore,prometheustest.New(context.Background(), instrumentationtest.New().ToProviderSettings(), prometheus.Config{}, telemetryStore),diff --git a/pkg/query-service/app/queryBuilder/query_builder.go b/pkg/query-service/app/queryBuilder/query_builder.goindex 9f119d4945..388a858ebc 100644--- a/pkg/query-service/app/queryBuilder/query_builder.go+++ b/pkg/query-service/app/queryBuilder/query_builder.go@@ -4,12 +4,13 @@ import ("fmt""strings"+ "log/slog"+"github.com/SigNoz/govaluate""github.com/SigNoz/signoz/pkg/cache"metricsV3 "github.com/SigNoz/signoz/pkg/query-service/app/metrics/v3""github.com/SigNoz/signoz/pkg/query-service/constants"v3 "github.com/SigNoz/signoz/pkg/query-service/model/v3"- "go.uber.org/zap")var SupportedFunctions = []string{@@ -238,7 +239,7 @@ func (qb *QueryBuilder) PrepareQueries(params *v3.QueryRangeParamsV3) (map[strin}queries[queryName] = queryStringdefault:- zap.L().Error("Unknown data source", zap.String("dataSource", string(query.DataSource)))+ slog.Error("unknown data source", "data_source", string(query.DataSource))}}}diff --git a/pkg/query-service/app/server.go b/pkg/query-service/app/server.goindex 965f2080ea..d278537c78 100644--- a/pkg/query-service/app/server.go+++ b/pkg/query-service/app/server.go@@ -44,7 +44,7 @@ import ("github.com/SigNoz/signoz/pkg/query-service/utils""go.opentelemetry.io/contrib/instrumentation/github.com/gorilla/mux/otelmux""go.opentelemetry.io/otel/propagation"- "go.uber.org/zap"+ "log/slog")// Server runs HTTP, Mux and a grpc server@@ -87,6 +87,7 @@ func NewServer(config signoz.Config, signoz *signoz.SigNoz) (*Server, error) {}reader := clickhouseReader.NewReader(+ signoz.Instrumentation.Logger(),signoz.SQLStore,signoz.TelemetryStore,signoz.Prometheus,@@ -259,7 +260,7 @@ func (s *Server) initListeners() error {return err}- zap.L().Info(fmt.Sprintf("Query server started listening on %s...", s.httpHostPort))+ slog.Info(fmt.Sprintf("Query server started listening on %s...", s.httpHostPort))return nil}@@ -279,31 +280,31 @@ func (s *Server) Start(ctx context.Context) error {}go func() {- zap.L().Info("Starting HTTP server", zap.Int("port", httpPort), zap.String("addr", s.httpHostPort))+ slog.Info("Starting HTTP server", "port", httpPort, "addr", s.httpHostPort)switch err := s.httpServer.Serve(s.httpConn); err {case nil, http.ErrServerClosed, cmux.ErrListenerClosed:// normal exit, nothing to dodefault:- zap.L().Error("Could not start HTTP server", zap.Error(err))+ slog.Error("Could not start HTTP server", "error", err)}s.unavailableChannel <- healthcheck.Unavailable}()go func() {- zap.L().Info("Starting pprof server", zap.String("addr", constants.DebugHttpPort))+ slog.Info("Starting pprof server", "addr", constants.DebugHttpPort)err = http.ListenAndServe(constants.DebugHttpPort, nil)if err != nil {- zap.L().Error("Could not start pprof server", zap.Error(err))+ slog.Error("Could not start pprof server", "error", err)}}()go func() {- zap.L().Info("Starting OpAmp Websocket server", zap.String("addr", constants.OpAmpWsEndpoint))+ slog.Info("Starting OpAmp Websocket server", "addr", constants.OpAmpWsEndpoint)err := s.opampServer.Start(constants.OpAmpWsEndpoint)if err != nil {- zap.L().Info("opamp ws server failed to start", zap.Error(err))+ slog.Error("opamp ws server failed to start", "error", err)s.unavailableChannel <- healthcheck.Unavailable}}()@@ -348,10 +349,9 @@ func makeRulesManager(MetadataStore: metadataStore,Prometheus: prometheus,Context: context.Background(),- Logger: zap.L(),Reader: ch,Querier: querier,- SLogger: providerSettings.Logger,+ Logger: providerSettings.Logger,Cache: cache,EvalDelay: constants.GetEvalDelay(),OrgGetter: orgGetter,@@ -368,7 +368,7 @@ func makeRulesManager(return nil, fmt.Errorf("rule manager error: %v", err)}- zap.L().Info("rules manager is ready")+ slog.Info("rules manager is ready")return manager, nil}diff --git a/pkg/query-service/app/summary.go b/pkg/query-service/app/summary.goindex 482df2d1df..af43de54fc 100644--- a/pkg/query-service/app/summary.go+++ b/pkg/query-service/app/summary.go@@ -11,8 +11,9 @@ import ("github.com/SigNoz/signoz/pkg/valuer""github.com/gorilla/mux"+ "log/slog"+explorer "github.com/SigNoz/signoz/pkg/query-service/app/metricsexplorer"- "go.uber.org/zap")func (aH *APIHandler) FilterKeysSuggestion(w http.ResponseWriter, r *http.Request) {@@ -22,13 +23,13 @@ func (aH *APIHandler) FilterKeysSuggestion(w http.ResponseWriter, r *http.Requesr.Body = io.NopCloser(bytes.NewBuffer(bodyBytes))params, apiError := explorer.ParseFilterKeySuggestions(r)if apiError != nil {- zap.L().Error("error parsing summary filter keys request", zap.Error(apiError.Err))+ slog.ErrorContext(ctx, "error parsing summary filter keys request", "error", apiError.Err)RespondError(w, apiError, nil)return}keys, apiError := aH.SummaryService.FilterKeys(ctx, params)if apiError != nil {- zap.L().Error("error getting filter keys", zap.Error(apiError.Err))+ slog.ErrorContext(ctx, "error getting filter keys", "error", apiError.Err)RespondError(w, apiError, nil)return}@@ -52,14 +53,14 @@ func (aH *APIHandler) FilterValuesSuggestion(w http.ResponseWriter, r *http.Requr.Body = io.NopCloser(bytes.NewBuffer(bodyBytes))params, apiError := explorer.ParseFilterValueSuggestions(r)if apiError != nil {- zap.L().Error("error parsing summary filter values request", zap.Error(apiError.Err))+ slog.ErrorContext(ctx, "error parsing summary filter values request", "error", apiError.Err)RespondError(w, apiError, nil)return}values, apiError := aH.SummaryService.FilterValues(ctx, orgID, params)if apiError != nil {- zap.L().Error("error getting filter values", zap.Error(apiError.Err))+ slog.ErrorContext(ctx, "error getting filter values", "error", apiError.Err)RespondError(w, apiError, nil)return}@@ -82,7 +83,7 @@ func (aH *APIHandler) GetMetricsDetails(w http.ResponseWriter, r *http.Request)metricName := mux.Vars(r)["metric_name"]metricsDetail, apiError := aH.SummaryService.GetMetricsSummary(ctx, orgID, metricName)if apiError != nil {- zap.L().Error("error getting metrics summary error", zap.Error(apiError.Err))+ slog.ErrorContext(ctx, "error getting metrics summary", "error", apiError.Err)RespondError(w, apiError, nil)return}@@ -106,14 +107,14 @@ func (aH *APIHandler) ListMetrics(w http.ResponseWriter, r *http.Request) {r.Body = io.NopCloser(bytes.NewBuffer(bodyBytes))params, apiErr := explorer.ParseSummaryListMetricsParams(r)if apiErr != nil {- zap.L().Error("error parsing metric list metric summary api request", zap.Error(apiErr.Err))+ slog.ErrorContext(ctx, "error parsing metric list metric summary api request", "error", apiErr.Err)RespondError(w, model.BadRequest(apiErr), nil)return}slmr, apiErr := aH.SummaryService.ListMetricsWithSummary(ctx, orgID, params)if apiErr != nil {- zap.L().Error("error in getting list metrics summary", zap.Error(apiErr.Err))+ slog.ErrorContext(ctx, "error in getting list metrics summary", "error", apiErr.Err)RespondError(w, apiErr, nil)return}@@ -126,13 +127,13 @@ func (aH *APIHandler) GetTreeMap(w http.ResponseWriter, r *http.Request) {ctx := r.Context()params, apiError := explorer.ParseTreeMapMetricsParams(r)if apiError != nil {- zap.L().Error("error parsing tree map metric params", zap.Error(apiError.Err))+ slog.ErrorContext(ctx, "error parsing tree map metric params", "error", apiError.Err)RespondError(w, apiError, nil)return}result, apiError := aH.SummaryService.GetMetricsTreemap(ctx, params)if apiError != nil {- zap.L().Error("error getting tree map data", zap.Error(apiError.Err))+ slog.ErrorContext(ctx, "error getting tree map data", "error", apiError.Err)RespondError(w, apiError, nil)return}@@ -146,13 +147,13 @@ func (aH *APIHandler) GetRelatedMetrics(w http.ResponseWriter, r *http.Request)ctx := r.Context()params, apiError := explorer.ParseRelatedMetricsParams(r)if apiError != nil {- zap.L().Error("error parsing related metric params", zap.Error(apiError.Err))+ slog.ErrorContext(ctx, "error parsing related metric params", "error", apiError.Err)RespondError(w, apiError, nil)return}result, apiError := aH.SummaryService.GetRelatedMetrics(ctx, params)if apiError != nil {- zap.L().Error("error getting related metrics", zap.Error(apiError.Err))+ slog.ErrorContext(ctx, "error getting related metrics", "error", apiError.Err)RespondError(w, apiError, nil)return}@@ -166,13 +167,13 @@ func (aH *APIHandler) GetInspectMetricsData(w http.ResponseWriter, r *http.Requectx := r.Context()params, apiError := explorer.ParseInspectMetricsParams(r)if apiError != nil {- zap.L().Error("error parsing inspect metric params", zap.Error(apiError.Err))+ slog.ErrorContext(ctx, "error parsing inspect metric params", "error", apiError.Err)RespondError(w, apiError, nil)return}result, apiError := aH.SummaryService.GetInspectMetrics(ctx, params)if apiError != nil {- zap.L().Error("error getting inspect metrics data", zap.Error(apiError.Err))+ slog.ErrorContext(ctx, "error getting inspect metrics data", "error", apiError.Err)RespondError(w, apiError, nil)return}@@ -197,13 +198,13 @@ func (aH *APIHandler) UpdateMetricsMetadata(w http.ResponseWriter, r *http.Requer.Body = io.NopCloser(bytes.NewBuffer(bodyBytes))params, apiError := explorer.ParseUpdateMetricsMetadataParams(r)if apiError != nil {- zap.L().Error("error parsing update metrics metadata params", zap.Error(apiError.Err))+ slog.ErrorContext(ctx, "error parsing update metrics metadata params", "error", apiError.Err)RespondError(w, apiError, nil)return}apiError = aH.SummaryService.UpdateMetricsMetadata(ctx, orgID, params)if apiError != nil {- zap.L().Error("error updating metrics metadata", zap.Error(apiError.Err))+ slog.ErrorContext(ctx, "error updating metrics metadata", "error", apiError.Err)RespondError(w, apiError, nil)return}diff --git a/pkg/query-service/app/traces/smart/trace.go b/pkg/query-service/app/traces/smart/trace.goindex 3f38747eef..4ba0e8d95e 100644--- a/pkg/query-service/app/traces/smart/trace.go+++ b/pkg/query-service/app/traces/smart/trace.go@@ -2,10 +2,10 @@ package smartimport ("errors"+ "log/slog""strconv"basemodel "github.com/SigNoz/signoz/pkg/query-service/model"- "go.uber.org/zap")// SmartTraceAlgorithm is an algorithm to find the target span and build a tree of spans around it with the given levelUp and levelDown parameters and the given spanLimit@@ -53,7 +53,7 @@ func SmartTraceAlgorithm(payload []basemodel.SearchSpanResponseItem, targetSpanIbreak}if err != nil {- zap.L().Error("Error during BreadthFirstSearch()", zap.Error(err))+ slog.Error("error during breadth first search", "error", err)return nil, err}}@@ -191,7 +191,7 @@ func buildSpanTrees(spansPtr *[]*SpanForTraceDetails) ([]*SpanForTraceDetails, e// If the parent span is not found, add current span to list of rootsif parent == nil {- // zap.L().Debug("Parent Span not found parent_id: ", span.ParentID)+ // slog.Debug("parent span not found", "parent_id", span.ParentID)roots = append(roots, span)span.ParentID = ""continuediff --git a/pkg/query-service/app/traces/v3/utils.go b/pkg/query-service/app/traces/v3/utils.goindex 4787299216..033951fa2d 100644--- a/pkg/query-service/app/traces/v3/utils.go+++ b/pkg/query-service/app/traces/v3/utils.go@@ -1,11 +1,11 @@package v3import (+ "log/slog""strconv"v3 "github.com/SigNoz/signoz/pkg/query-service/model/v3""github.com/SigNoz/signoz/pkg/query-service/utils"- "go.uber.org/zap")var TracesListViewDefaultSelectedColumns = []v3.AttributeKey{@@ -68,7 +68,7 @@ func TraceIdFilterUsedWithEqual(params *v3.QueryRangeParamsV3) (bool, []string)val := item.Valueval, err = utils.ValidateAndCastValue(val, item.Key.DataType)if err != nil {- zap.L().Error("invalid value for key", zap.String("key", item.Key.Key), zap.Error(err))+ slog.Error("invalid value for key", "key", item.Key.Key, "error", err)return false, []string{}}if val != nil {@@ -81,7 +81,7 @@ func TraceIdFilterUsedWithEqual(params *v3.QueryRangeParamsV3) (bool, []string)}- zap.L().Debug("traceIds", zap.Any("traceIds", traceIds))+ slog.Debug("trace_ids", "trace_ids", traceIds)return traceIdFilterUsed, traceIds}diff --git a/pkg/query-service/model/v3/v3.go b/pkg/query-service/model/v3/v3.goindex 519ea56c53..2cba401ade 100644--- a/pkg/query-service/model/v3/v3.go+++ b/pkg/query-service/model/v3/v3.go@@ -9,9 +9,10 @@ import ("strings""time"+ "log/slog"+"github.com/SigNoz/signoz/pkg/valuer""github.com/pkg/errors"- "go.uber.org/zap"qbtypes "github.com/SigNoz/signoz/pkg/types/querybuildertypes/querybuildertypesv5")@@ -937,7 +938,7 @@ func (b *BuilderQuery) SetShiftByFromFunc() {} else if shift, ok := function.Args[0].(string); ok {shiftBy, err := strconv.ParseFloat(shift, 64)if err != nil {- zap.L().Error("failed to parse time shift by", zap.String("shift", shift), zap.Error(err))+ slog.Error("failed to parse time shift by", "shift", shift, "error", err)}timeShiftBy = int64(shiftBy)}diff --git a/pkg/query-service/postprocess/process.go b/pkg/query-service/postprocess/process.goindex 6c215cbfb3..1990c5d29b 100644--- a/pkg/query-service/postprocess/process.go+++ b/pkg/query-service/postprocess/process.go@@ -1,10 +1,11 @@package postprocessimport (+ "log/slog"+"github.com/SigNoz/govaluate""github.com/SigNoz/signoz/pkg/query-service/app/queryBuilder"v3 "github.com/SigNoz/signoz/pkg/query-service/model/v3"- "go.uber.org/zap")// postProcessResult applies having clause, metric limit, reduce function to the result@@ -55,12 +56,12 @@ func PostProcessResult(result []*v3.Result, queryRangeParams *v3.QueryRangeParamexpression, err := govaluate.NewEvaluableExpressionWithFunctions(query.Expression, EvalFuncs())// This shouldn't happen here, because it should have been caught earlier in validationif err != nil {- zap.L().Error("error in expression", zap.Error(err))+ slog.Error("error in expression", "error", err)return nil, err}formulaResult, err := processResults(result, expression, canDefaultZero)if err != nil {- zap.L().Error("error in expression", zap.Error(err))+ slog.Error("error in expression", "error", err)return nil, err}formulaResult.QueryName = query.QueryNamediff --git a/pkg/query-service/queryBuilderToExpr/queryBuilderToExpr.go b/pkg/query-service/queryBuilderToExpr/queryBuilderToExpr.goindex bd2b4c0241..46199ceb2b 100644--- a/pkg/query-service/queryBuilderToExpr/queryBuilderToExpr.go+++ b/pkg/query-service/queryBuilderToExpr/queryBuilderToExpr.go@@ -5,10 +5,11 @@ import ("reflect""strings"+ "log/slog"+"github.com/SigNoz/signoz/pkg/errors"v3 "github.com/SigNoz/signoz/pkg/query-service/model/v3"expr "github.com/antonmedv/expr"- "go.uber.org/zap")var (@@ -159,11 +160,11 @@ func exprFormattedValue(v interface{}) string {case uint8, uint16, uint32, uint64, int, int8, int16, int32, int64, float32, float64, bool:return strings.Join(strings.Fields(fmt.Sprint(x)), ",")default:- zap.L().Error("invalid type for formatted value", zap.Any("type", reflect.TypeOf(x[0])))+ slog.Error("invalid type for formatted value", "type", reflect.TypeOf(x[0]))return ""}default:- zap.L().Error("invalid type for formatted value", zap.Any("type", reflect.TypeOf(x)))+ slog.Error("invalid type for formatted value", "type", reflect.TypeOf(x))return ""}}diff --git a/pkg/query-service/querycache/query_range_cache.go b/pkg/query-service/querycache/query_range_cache.goindex 0a581d94d2..e130961f32 100644--- a/pkg/query-service/querycache/query_range_cache.go+++ b/pkg/query-service/querycache/query_range_cache.go@@ -10,10 +10,11 @@ import ("github.com/SigNoz/signoz/pkg/cache""github.com/SigNoz/signoz/pkg/errors"v3 "github.com/SigNoz/signoz/pkg/query-service/model/v3"+ "log/slog"+"github.com/SigNoz/signoz/pkg/query-service/utils/labels""github.com/SigNoz/signoz/pkg/types/cachetypes""github.com/SigNoz/signoz/pkg/valuer"- "go.uber.org/zap")type queryCache struct {@@ -87,7 +88,7 @@ func (q *queryCache) FindMissingTimeRangesV2(orgID valuer.UUID, start, end int64return cachedSeriesDataList[i].Start < cachedSeriesDataList[j].Start})- zap.L().Info("Number of non-overlapping cached series data", zap.Int("count", len(cachedSeriesDataList)))+ slog.Info("number of non-overlapping cached series data", "count", len(cachedSeriesDataList))// Exclude the flux interval from the cached end time@@ -180,7 +181,7 @@ func (q *queryCache) FindMissingTimeRanges(orgID valuer.UUID, start, end, step ireturn cachedSeriesDataList[i].Start < cachedSeriesDataList[j].Start})- zap.L().Info("Number of non-overlapping cached series data", zap.Int("count", len(cachedSeriesDataList)))+ slog.Info("number of non-overlapping cached series data", "count", len(cachedSeriesDataList))// Exclude the flux interval from the cached end time@@ -291,7 +292,7 @@ func (q *queryCache) storeMergedData(orgID valuer.UUID, cacheKey string, mergedDcacheableSeriesData := CacheableSeriesData{Series: mergedData}err := q.cache.Set(context.TODO(), orgID, cacheKey, &cacheableSeriesData, 0)if err != nil {- zap.L().Error("error storing merged data", zap.Error(err))+ slog.Error("error storing merged data", "error", err)}}diff --git a/pkg/query-service/rules/base_rule.go b/pkg/query-service/rules/base_rule.goindex 2fbd670fc4..fe1848f25e 100644--- a/pkg/query-service/rules/base_rule.go+++ b/pkg/query-service/rules/base_rule.go@@ -20,7 +20,6 @@ import ("github.com/SigNoz/signoz/pkg/types/ruletypes""github.com/SigNoz/signoz/pkg/types/telemetrytypes""github.com/SigNoz/signoz/pkg/valuer"- "go.uber.org/zap")// BaseRule contains common fields and methods for all rule types@@ -400,7 +399,7 @@ func (r *BaseRule) ForEachActiveAlert(f func(*ruletypes.Alert)) {}func (r *BaseRule) RecordRuleStateHistory(ctx context.Context, prevState, currentState model.AlertState, itemsToAdd []model.RuleStateHistory) error {- zap.L().Debug("recording rule state history", zap.String("ruleid", r.ID()), zap.Any("prevState", prevState), zap.Any("currentState", currentState), zap.Any("itemsToAdd", itemsToAdd))+ r.logger.DebugContext(ctx, "recording rule state history", "ruleid", r.ID(), "prevState", prevState, "currentState", currentState, "itemsToAdd", itemsToAdd)revisedItemsToAdd := map[uint64]model.RuleStateHistory{}lastSavedState, err := r.reader.GetLastSavedRuleStateHistory(ctx, r.ID())@@ -410,7 +409,7 @@ func (r *BaseRule) RecordRuleStateHistory(ctx context.Context, prevState, curren// if the query-service has been restarted, or the rule has been modified (which re-initializes the rule),// the state would reset so we need to add the corresponding state changes to previously saved statesif !r.handledRestart && len(lastSavedState) > 0 {- zap.L().Debug("handling restart", zap.String("ruleid", r.ID()), zap.Any("lastSavedState", lastSavedState))+ r.logger.DebugContext(ctx, "handling restart", "ruleid", r.ID(), "lastSavedState", lastSavedState)l := map[uint64]model.RuleStateHistory{}for _, item := range itemsToAdd {l[item.Fingerprint] = item@@ -442,7 +441,7 @@ func (r *BaseRule) RecordRuleStateHistory(ctx context.Context, prevState, curren// do not add this item to revisedItemsToAdd as it is already processedshouldSkip[item.Fingerprint] = true}- zap.L().Debug("after lastSavedState loop", zap.String("ruleid", r.ID()), zap.Any("revisedItemsToAdd", revisedItemsToAdd))+ r.logger.DebugContext(ctx, "after lastSavedState loop", "ruleid", r.ID(), "revisedItemsToAdd", revisedItemsToAdd)// if there are any new state changes that were not saved, add them to the revised itemsfor _, item := range itemsToAdd {@@ -450,7 +449,7 @@ func (r *BaseRule) RecordRuleStateHistory(ctx context.Context, prevState, currenrevisedItemsToAdd[item.Fingerprint] = item}}- zap.L().Debug("after itemsToAdd loop", zap.String("ruleid", r.ID()), zap.Any("revisedItemsToAdd", revisedItemsToAdd))+ r.logger.DebugContext(ctx, "after itemsToAdd loop", "ruleid", r.ID(), "revisedItemsToAdd", revisedItemsToAdd)newState := model.StateInactivefor _, item := range revisedItemsToAdd {@@ -459,7 +458,7 @@ func (r *BaseRule) RecordRuleStateHistory(ctx context.Context, prevState, currenbreak}}- zap.L().Debug("newState", zap.String("ruleid", r.ID()), zap.Any("newState", newState))+ r.logger.DebugContext(ctx, "newState", "ruleid", r.ID(), "newState", newState)// if there is a change in the overall state, update the overall stateif lastSavedState[0].OverallState != newState {@@ -469,7 +468,7 @@ func (r *BaseRule) RecordRuleStateHistory(ctx context.Context, prevState, currenrevisedItemsToAdd[fingerprint] = item}}- zap.L().Debug("revisedItemsToAdd after newState", zap.String("ruleid", r.ID()), zap.Any("revisedItemsToAdd", revisedItemsToAdd))+ r.logger.DebugContext(ctx, "revisedItemsToAdd after newState", "ruleid", r.ID(), "revisedItemsToAdd", revisedItemsToAdd)} else {for _, item := range itemsToAdd {@@ -478,7 +477,7 @@ func (r *BaseRule) RecordRuleStateHistory(ctx context.Context, prevState, curren}if len(revisedItemsToAdd) > 0 && r.reader != nil {- zap.L().Debug("writing rule state history", zap.String("ruleid", r.ID()), zap.Any("revisedItemsToAdd", revisedItemsToAdd))+ r.logger.DebugContext(ctx, "writing rule state history", "ruleid", r.ID(), "revisedItemsToAdd", revisedItemsToAdd)entries := make([]model.RuleStateHistory, 0, len(revisedItemsToAdd))for _, item := range revisedItemsToAdd {@@ -486,7 +485,7 @@ func (r *BaseRule) RecordRuleStateHistory(ctx context.Context, prevState, curren}err := r.reader.AddRuleStateHistory(ctx, entries)if err != nil {- zap.L().Error("error while inserting rule state history", zap.Error(err), zap.Any("itemsToAdd", itemsToAdd))+ r.logger.ErrorContext(ctx, "error while inserting rule state history", "error", err, "itemsToAdd", itemsToAdd)}}r.handledRestart = truediff --git a/pkg/query-service/rules/base_rule_test.go b/pkg/query-service/rules/base_rule_test.goindex 32472c68cc..89db6b03b3 100644--- a/pkg/query-service/rules/base_rule_test.go+++ b/pkg/query-service/rules/base_rule_test.go@@ -2,6 +2,7 @@ package rulesimport ("context"+ "log/slog""testing""time"@@ -694,6 +695,7 @@ func TestBaseRule_FilterNewSeries(t *testing.T) {options := clickhouseReader.NewOptions("", "", "archiveNamespace")reader := clickhouseReader.NewReader(+ slog.Default(),nil,telemetryStore,prometheustest.New(context.Background(), settings, prometheus.Config{}, telemetryStore),diff --git a/pkg/query-service/rules/manager.go b/pkg/query-service/rules/manager.goindex 387c04cc1e..69a7ec9f21 100644--- a/pkg/query-service/rules/manager.go+++ b/pkg/query-service/rules/manager.go@@ -13,8 +13,6 @@ import ("github.com/SigNoz/signoz/pkg/query-service/utils/labels""github.com/SigNoz/signoz/pkg/queryparser"- "go.uber.org/zap"-"github.com/go-openapi/strfmt""github.com/SigNoz/signoz/pkg/alertmanager"@@ -40,10 +38,9 @@ type PrepareTaskOptions struct {TaskName stringRuleStore ruletypes.RuleStoreMaintenanceStore ruletypes.MaintenanceStore- Logger *zap.LoggerReader interfaces.ReaderQuerier querierV5.Querier- SLogger *slog.Logger+ Logger *slog.LoggerCache cache.CacheManagerOpts *ManagerOptionsNotifyFunc NotifyFunc@@ -55,10 +52,9 @@ type PrepareTestRuleOptions struct {Rule *ruletypes.PostableRuleRuleStore ruletypes.RuleStoreMaintenanceStore ruletypes.MaintenanceStore- Logger *zap.LoggerReader interfaces.ReaderQuerier querierV5.Querier- SLogger *slog.Logger+ Logger *slog.LoggerCache cache.CacheManagerOpts *ManagerOptionsNotifyFunc NotifyFunc@@ -90,11 +86,10 @@ type ManagerOptions struct {Prometheus prometheus.PrometheusContext context.Context- Logger *zap.LoggerResendDelay time.DurationReader interfaces.ReaderQuerier querierV5.Querier- SLogger *slog.Logger+ Logger *slog.LoggerCache cache.CacheEvalDelay valuer.TextDuration@@ -120,7 +115,7 @@ type Manager struct {ruleStore ruletypes.RuleStoremaintenanceStore ruletypes.MaintenanceStore- logger *zap.Logger+ logger *slog.Loggerreader interfaces.Readercache cache.CacheprepareTaskFunc func(opts PrepareTaskOptions) (Task, error)@@ -138,7 +133,7 @@ func defaultOptions(o *ManagerOptions) *ManagerOptions {o.ResendDelay = 1 * time.Minute}if o.Logger == nil {- o.Logger = zap.L()+ o.Logger = slog.Default()}if o.PrepareTaskFunc == nil {o.PrepareTaskFunc = defaultPrepareTaskFunc@@ -169,7 +164,7 @@ func defaultPrepareTaskFunc(opts PrepareTaskOptions) (Task, error) {opts.Rule,opts.Reader,opts.Querier,- opts.SLogger,+ opts.Logger,WithEvalDelay(opts.ManagerOpts.EvalDelay),WithSQLStore(opts.SQLStore),WithQueryParser(opts.ManagerOpts.QueryParser),@@ -192,7 +187,7 @@ func defaultPrepareTaskFunc(opts PrepareTaskOptions) (Task, error) {ruleId,opts.OrgID,opts.Rule,- opts.SLogger,+ opts.Logger,opts.Reader,opts.ManagerOpts.Prometheus,WithSQLStore(opts.SQLStore),@@ -239,13 +234,13 @@ func NewManager(o *ManagerOptions) (*Manager, error) {queryParser: o.QueryParser,}- zap.L().Debug("Manager created successfully with NotificationGroup")+ m.logger.Debug("manager created successfully with notification group")return m, nil}func (m *Manager) Start(ctx context.Context) {if err := m.initiate(ctx); err != nil {- zap.L().Error("failed to initialize alerting rules manager", zap.Error(err))+ m.logger.ErrorContext(ctx, "failed to initialize alerting rules manager", "error", err)}m.run(ctx)}@@ -288,7 +283,7 @@ func (m *Manager) initiate(ctx context.Context) error {err := json.Unmarshal([]byte(rec.Data), &parsedRule)if err != nil {- zap.L().Info("failed to load rule in json format", zap.String("name", taskName))+ m.logger.InfoContext(ctx, "failed to load rule in json format", "name", taskName)loadErrors = append(loadErrors, err)continue}@@ -297,13 +292,13 @@ func (m *Manager) initiate(ctx context.Context) error {err = m.alertmanager.SetNotificationConfig(ctx, org.ID, rec.ID.StringValue(), &config)if err != nil {loadErrors = append(loadErrors, err)- zap.L().Info("failed to set rule notification config", zap.String("ruleId", rec.ID.StringValue()))+ m.logger.InfoContext(ctx, "failed to set rule notification config", "rule_id", rec.ID.StringValue())}}if !parsedRule.Disabled {err := m.addTask(ctx, org.ID, &parsedRule, taskName)if err != nil {- zap.L().Error("failed to load the rule definition", zap.String("name", taskName), zap.Error(err))+ m.logger.ErrorContext(ctx, "failed to load the rule definition", "name", taskName, "error", err)}}}@@ -327,13 +322,13 @@ func (m *Manager) Stop(_ context.Context) {m.mtx.Lock()defer m.mtx.Unlock()- zap.L().Info("Stopping rule manager...")+ m.logger.Info("stopping rule manager")for _, t := range m.tasks {t.Stop()}- zap.L().Info("Rule manager stopped")+ m.logger.Info("rule manager stopped")}// EditRule writes the rule definition to the@@ -406,17 +401,16 @@ func (m *Manager) editTask(_ context.Context, orgID valuer.UUID, rule *ruletypesm.mtx.Lock()defer m.mtx.Unlock()- zap.L().Debug("editing a rule task", zap.String("name", taskName))+ m.logger.Debug("editing a rule task", "name", taskName)newTask, err := m.prepareTaskFunc(PrepareTaskOptions{Rule: rule,TaskName: taskName,RuleStore: m.ruleStore,MaintenanceStore: m.maintenanceStore,- Logger: m.logger,Reader: m.reader,Querier: m.opts.Querier,- SLogger: m.opts.SLogger,+ Logger: m.opts.Logger,Cache: m.cache,ManagerOpts: m.opts,NotifyFunc: m.prepareNotifyFunc(),@@ -425,7 +419,7 @@ func (m *Manager) editTask(_ context.Context, orgID valuer.UUID, rule *ruletypes})if err != nil {- zap.L().Error("loading tasks failed", zap.Error(err))+ m.logger.Error("loading tasks failed", "error", err)return errors.NewInvalidInputf(errors.CodeInvalidInput, "error preparing rule with given parameters, previous rule set restored")}@@ -437,7 +431,7 @@ func (m *Manager) editTask(_ context.Context, orgID valuer.UUID, rule *ruletypes// it to finish the current iteration. Then copy it into the new group.oldTask, ok := m.tasks[taskName]if !ok {- zap.L().Warn("rule task not found, a new task will be created", zap.String("name", taskName))+ m.logger.Warn("rule task not found, a new task will be created", "name", taskName)}delete(m.tasks, taskName)@@ -461,7 +455,7 @@ func (m *Manager) editTask(_ context.Context, orgID valuer.UUID, rule *ruletypesfunc (m *Manager) DeleteRule(ctx context.Context, idStr string) error {id, err := valuer.NewUUID(idStr)if err != nil {- zap.L().Error("delete rule received an rule id in invalid format, must be a valid uuid-v7", zap.String("id", idStr), zap.Error(err))+ m.logger.Error("delete rule received a rule id in invalid format, must be a valid uuid-v7", "id", idStr, "error", err)return fmt.Errorf("delete rule received an rule id in invalid format, must be a valid uuid-v7")}@@ -521,16 +515,16 @@ func (m *Manager) DeleteRule(ctx context.Context, idStr string) error {func (m *Manager) deleteTask(taskName string) {m.mtx.Lock()defer m.mtx.Unlock()- zap.L().Debug("deleting a rule task", zap.String("name", taskName))+ m.logger.Debug("deleting a rule task", "name", taskName)oldg, ok := m.tasks[taskName]if ok {oldg.Stop()delete(m.tasks, taskName)delete(m.rules, RuleIdFromTaskName(taskName))- zap.L().Debug("rule task deleted", zap.String("name", taskName))+ m.logger.Debug("rule task deleted", "name", taskName)} else {- zap.L().Info("rule not found for deletion", zap.String("name", taskName))+ m.logger.Info("rule not found for deletion", "name", taskName)}}@@ -617,16 +611,15 @@ func (m *Manager) addTask(_ context.Context, orgID valuer.UUID, rule *ruletypes.m.mtx.Lock()defer m.mtx.Unlock()- zap.L().Debug("adding a new rule task", zap.String("name", taskName))+ m.logger.Debug("adding a new rule task", "name", taskName)newTask, err := m.prepareTaskFunc(PrepareTaskOptions{Rule: rule,TaskName: taskName,RuleStore: m.ruleStore,MaintenanceStore: m.maintenanceStore,- Logger: m.logger,Reader: m.reader,Querier: m.opts.Querier,- SLogger: m.opts.SLogger,+ Logger: m.opts.Logger,Cache: m.cache,ManagerOpts: m.opts,NotifyFunc: m.prepareNotifyFunc(),@@ -635,7 +628,7 @@ func (m *Manager) addTask(_ context.Context, orgID valuer.UUID, rule *ruletypes.})if err != nil {- zap.L().Error("creating rule task failed", zap.String("name", taskName), zap.Error(err))+ m.logger.Error("creating rule task failed", "name", taskName, "error", err)return errors.NewInvalidInputf(errors.CodeInvalidInput, "error loading rules, previous rule set restored")}@@ -791,7 +784,7 @@ func (m *Manager) prepareTestNotifyFunc() NotifyFunc {}err := m.alertmanager.TestAlert(ctx, orgID, ruleID, receiverMap)if err != nil {- zap.L().Error("failed to send test notification", zap.Error(err))+ m.logger.ErrorContext(ctx, "failed to send test notification", "error", err)return}}@@ -826,7 +819,7 @@ func (m *Manager) ListRuleStates(ctx context.Context) (*ruletypes.GettableRules,ruleResponse := ruletypes.GettableRule{}err = json.Unmarshal([]byte(s.Data), &ruleResponse)if err != nil {- zap.L().Error("failed to unmarshal rule from db", zap.String("id", s.ID.StringValue()), zap.Error(err))+ m.logger.ErrorContext(ctx, "failed to unmarshal rule from db", "id", s.ID.StringValue(), "error", err)continue}@@ -857,7 +850,7 @@ func (m *Manager) GetRule(ctx context.Context, id valuer.UUID) (*ruletypes.Gettar := ruletypes.GettableRule{}err = json.Unmarshal([]byte(s.Data), &r)if err != nil {- zap.L().Error("failed to unmarshal rule from db", zap.String("id", s.ID.StringValue()), zap.Error(err))+ m.logger.ErrorContext(ctx, "failed to unmarshal rule from db", "id", s.ID.StringValue(), "error", err)return nil, err}r.Id = id.StringValue()@@ -926,30 +919,30 @@ func (m *Manager) PatchRule(ctx context.Context, ruleStr string, id valuer.UUID)// retrieve rule from DBstoredJSON, err := m.ruleStore.GetStoredRule(ctx, id)if err != nil {- zap.L().Error("failed to get stored rule with given id", zap.String("id", id.StringValue()), zap.Error(err))+ m.logger.ErrorContext(ctx, "failed to get stored rule with given id", "id", id.StringValue(), "error", err)return nil, err}storedRule := ruletypes.PostableRule{}if err := json.Unmarshal([]byte(storedJSON.Data), &storedRule); err != nil {- zap.L().Error("failed to unmarshal rule from db", zap.String("id", id.StringValue()), zap.Error(err))+ m.logger.ErrorContext(ctx, "failed to unmarshal rule from db", "id", id.StringValue(), "error", err)return nil, err}if err := json.Unmarshal([]byte(ruleStr), &storedRule); err != nil {- zap.L().Error("failed to unmarshal patched rule with given id", zap.String("id", id.StringValue()), zap.Error(err))+ m.logger.ErrorContext(ctx, "failed to unmarshal patched rule with given id", "id", id.StringValue(), "error", err)return nil, err}// deploy or un-deploy task according to patched (new) rule stateif err := m.syncRuleStateWithTask(ctx, orgID, taskName, &storedRule); err != nil {- zap.L().Error("failed to sync stored rule state with the task", zap.String("taskName", taskName), zap.Error(err))+ m.logger.ErrorContext(ctx, "failed to sync stored rule state with the task", "task_name", taskName, "error", err)return nil, err}newStoredJson, err := json.Marshal(&storedRule)if err != nil {- zap.L().Error("failed to marshal new stored rule with given id", zap.String("id", id.StringValue()), zap.Error(err))+ m.logger.ErrorContext(ctx, "failed to marshal new stored rule with given id", "id", id.StringValue(), "error", err)return nil, err}@@ -961,7 +954,7 @@ func (m *Manager) PatchRule(ctx context.Context, ruleStr string, id valuer.UUID)err = m.ruleStore.EditRule(ctx, storedJSON, func(ctx context.Context) error { return nil })if err != nil {if err := m.syncRuleStateWithTask(ctx, orgID, taskName, &storedRule); err != nil {- zap.L().Error("failed to restore rule after patch failure", zap.String("taskName", taskName), zap.Error(err))+ m.logger.ErrorContext(ctx, "failed to restore rule after patch failure", "task_name", taskName, "error", err)}return nil, err}@@ -1007,10 +1000,9 @@ func (m *Manager) TestNotification(ctx context.Context, orgID valuer.UUID, ruleSRule: &parsedRule,RuleStore: m.ruleStore,MaintenanceStore: m.maintenanceStore,- Logger: m.logger,- SLogger: m.opts.SLogger,Reader: m.reader,Querier: m.opts.Querier,+ Logger: m.opts.Logger,Cache: m.cache,ManagerOpts: m.opts,NotifyFunc: m.prepareTestNotifyFunc(),@@ -1030,7 +1022,7 @@ func (m *Manager) GetAlertDetailsForMetricNames(ctx context.Context, metricNamesresult := make(map[string][]ruletypes.GettableRule)rules, err := m.ruleStore.GetStoredRules(ctx, claims.OrgID)if err != nil {- zap.L().Error("Error getting stored rules", zap.Error(err))+ m.logger.ErrorContext(ctx, "error getting stored rules", "error", err)return nil, &model.ApiError{Typ: model.ErrorExec, Err: err}}@@ -1040,7 +1032,7 @@ func (m *Manager) GetAlertDetailsForMetricNames(ctx context.Context, metricNamesvar rule ruletypes.GettableRuleerr = json.Unmarshal([]byte(storedRule.Data), &rule)if err != nil {- zap.L().Error("failed to unmarshal rule from db", zap.String("id", storedRule.ID.StringValue()), zap.Error(err))+ m.logger.ErrorContext(ctx, "failed to unmarshal rule from db", "id", storedRule.ID.StringValue(), "error", err)continue}diff --git a/pkg/query-service/rules/managertestfactory.go b/pkg/query-service/rules/managertestfactory.goindex 7641fb662c..d9ef640795 100644--- a/pkg/query-service/rules/managertestfactory.go+++ b/pkg/query-service/rules/managertestfactory.go@@ -22,7 +22,6 @@ import ("github.com/SigNoz/signoz/pkg/telemetrystore""github.com/SigNoz/signoz/pkg/telemetrystore/telemetrystoretest""github.com/stretchr/testify/require"- "go.uber.org/zap")type queryMatcherAny struct {@@ -102,6 +101,7 @@ func NewTestManager(t *testing.T, testOpts *TestManagerOptions) *Manager {providerSettings := instrumentationtest.New().ToProviderSettings()prometheus := prometheustest.New(context.Background(), providerSettings, prometheus.Config{}, telemetryStore)reader := clickhouseReader.NewReader(+ instrumentationtest.New().Logger(),nil,telemetryStore,prometheus,@@ -123,8 +123,7 @@ func NewTestManager(t *testing.T, testOpts *TestManagerOptions) *Manager {require.NoError(t, err)mgrOpts := &ManagerOptions{- Logger: zap.NewNop(),- SLogger: instrumentationtest.New().Logger(),+ Logger: instrumentationtest.New().Logger(),Cache: cacheObj,Alertmanager: fAlert,Querier: mockQuerier,diff --git a/pkg/query-service/rules/prom_rule_task.go b/pkg/query-service/rules/prom_rule_task.goindex b03227c8bc..95391554e6 100644--- a/pkg/query-service/rules/prom_rule_task.go+++ b/pkg/query-service/rules/prom_rule_task.go@@ -12,7 +12,7 @@ import ("github.com/SigNoz/signoz/pkg/valuer"opentracing "github.com/opentracing/opentracing-go"plabels "github.com/prometheus/prometheus/model/labels"- "go.uber.org/zap"+ "log/slog")// PromRuleTask is a promql rule executor@@ -34,7 +34,7 @@ type PromRuleTask struct {terminated chan struct{}pause bool- logger *zap.Logger+ logger *slog.Loggernotify NotifyFuncmaintenanceStore ruletypes.MaintenanceStore@@ -44,7 +44,7 @@ type PromRuleTask struct {// NewPromRuleTask holds rules that have promql condition// and evaluates the rule at a given frequencyfunc NewPromRuleTask(name, file string, frequency time.Duration, rules []Rule, opts *ManagerOptions, notify NotifyFunc, maintenanceStore ruletypes.MaintenanceStore, orgID valuer.UUID) *PromRuleTask {- zap.L().Info("Initiating a new rule group", zap.String("name", name), zap.Duration("frequency", frequency))+ opts.Logger.Info("initiating a new rule group", "name", name, "frequency", frequency)if frequency == 0 {frequency = DefaultFrequency@@ -322,14 +322,14 @@ func (g *PromRuleTask) Eval(ctx context.Context, ts time.Time) {defer func() {if r := recover(); r != nil {- zap.L().Error("panic during promql rule evaluation", zap.Any("panic", r))+ g.logger.ErrorContext(ctx, "panic during promql rule evaluation", "panic", r)}}()- zap.L().Info("promql rule task", zap.String("name", g.name), zap.Time("eval started at", ts))+ g.logger.InfoContext(ctx, "promql rule task", "name", g.name, "eval_started_at", ts)maintenance, err := g.maintenanceStore.GetAllPlannedMaintenance(ctx, g.orgID.StringValue())if err != nil {- zap.L().Error("Error in processing sql query", zap.Error(err))+ g.logger.ErrorContext(ctx, "error in processing sql query", "error", err)}for i, rule := range g.rules {@@ -339,7 +339,7 @@ func (g *PromRuleTask) Eval(ctx context.Context, ts time.Time) {shouldSkip := falsefor _, m := range maintenance {- zap.L().Info("checking if rule should be skipped", zap.String("rule", rule.ID()), zap.Any("maintenance", m))+ g.logger.InfoContext(ctx, "checking if rule should be skipped", "rule", rule.ID(), "maintenance", m)if m.ShouldSkip(rule.ID(), ts) {shouldSkip = truebreak@@ -347,7 +347,7 @@ func (g *PromRuleTask) Eval(ctx context.Context, ts time.Time) {}if shouldSkip {- zap.L().Info("rule should be skipped", zap.String("rule", rule.ID()))+ g.logger.InfoContext(ctx, "rule should be skipped", "rule", rule.ID())continue}@@ -379,7 +379,7 @@ func (g *PromRuleTask) Eval(ctx context.Context, ts time.Time) {rule.SetHealth(ruletypes.HealthBad)rule.SetLastError(err)- zap.L().Warn("Evaluating rule failed", zap.String("ruleid", rule.ID()), zap.Error(err))+ g.logger.WarnContext(ctx, "evaluating rule failed", "rule_id", rule.ID(), "error", err)// Canceled queries are intentional termination of queries. This normally// happens on shutdown and thus we skip logging of any errors here.diff --git a/pkg/query-service/rules/prom_rule_test.go b/pkg/query-service/rules/prom_rule_test.goindex cbdd8c026d..5adc82638d 100644--- a/pkg/query-service/rules/prom_rule_test.go+++ b/pkg/query-service/rules/prom_rule_test.go@@ -3,6 +3,7 @@ package rulesimport ("context""strings"+ "log/slog""testing""time"@@ -964,7 +965,7 @@ func TestPromRuleUnitCombinations(t *testing.T) {}options := clickhouseReader.NewOptions("", "", "archiveNamespace")- reader := clickhouseReader.NewReader(nil, telemetryStore, promProvider, "", time.Second, nil, nil, options)+ reader := clickhouseReader.NewReader(slog.Default(), nil, telemetryStore, promProvider, "", time.Second, nil, nil, options)rule, err := NewPromRule("69", valuer.GenerateUUID(), &postableRule, logger, reader, promProvider)if err != nil {assert.NoError(t, err)@@ -1080,7 +1081,7 @@ func _Enable_this_after_9146_issue_fix_is_merged_TestPromRuleNoData(t *testing.T}options := clickhouseReader.NewOptions("", "", "archiveNamespace")- reader := clickhouseReader.NewReader(nil, telemetryStore, promProvider, "", time.Second, nil, nil, options)+ reader := clickhouseReader.NewReader(slog.Default(), nil, telemetryStore, promProvider, "", time.Second, nil, nil, options)rule, err := NewPromRule("69", valuer.GenerateUUID(), &postableRule, logger, reader, promProvider)if err != nil {assert.NoError(t, err)@@ -1312,7 +1313,7 @@ func TestMultipleThresholdPromRule(t *testing.T) {}options := clickhouseReader.NewOptions("", "", "archiveNamespace")- reader := clickhouseReader.NewReader(nil, telemetryStore, promProvider, "", time.Second, nil, nil, options)+ reader := clickhouseReader.NewReader(slog.Default(), nil, telemetryStore, promProvider, "", time.Second, nil, nil, options)rule, err := NewPromRule("69", valuer.GenerateUUID(), &postableRule, logger, reader, promProvider)if err != nil {assert.NoError(t, err)@@ -1448,7 +1449,7 @@ func TestPromRule_NoData(t *testing.T) {}()options := clickhouseReader.NewOptions("primaryNamespace")- reader := clickhouseReader.NewReader(nil, telemetryStore, promProvider, "", time.Second, nil, nil, options)+ reader := clickhouseReader.NewReader(slog.Default(), nil, telemetryStore, promProvider, "", time.Second, nil, nil, options)rule, err := NewPromRule("some-id", valuer.GenerateUUID(), &postableRule, logger, reader, promProvider)require.NoError(t, err)@@ -1597,7 +1598,7 @@ func TestPromRule_NoData_AbsentFor(t *testing.T) {}()options := clickhouseReader.NewOptions("primaryNamespace")- reader := clickhouseReader.NewReader(nil, telemetryStore, promProvider, "", time.Second, nil, nil, options)+ reader := clickhouseReader.NewReader(slog.Default(), nil, telemetryStore, promProvider, "", time.Second, nil, nil, options)rule, err := NewPromRule("some-id", valuer.GenerateUUID(), &postableRule, logger, reader, promProvider)require.NoError(t, err)@@ -1755,7 +1756,7 @@ func TestPromRuleEval_RequireMinPoints(t *testing.T) {}()options := clickhouseReader.NewOptions("primaryNamespace")- reader := clickhouseReader.NewReader(nil, telemetryStore, promProvider, "", time.Second, nil, nil, options)+ reader := clickhouseReader.NewReader(slog.Default(), nil, telemetryStore, promProvider, "", time.Second, nil, nil, options)rule, err := NewPromRule("some-id", valuer.GenerateUUID(), &postableRule, logger, reader, promProvider)require.NoError(t, err)diff --git a/pkg/query-service/rules/rule_task.go b/pkg/query-service/rules/rule_task.goindex 584812d7dd..d6f08ca652 100644--- a/pkg/query-service/rules/rule_task.go+++ b/pkg/query-service/rules/rule_task.go@@ -7,12 +7,13 @@ import ("sync""time"+ "log/slog"+"github.com/SigNoz/signoz/pkg/query-service/utils/labels""github.com/SigNoz/signoz/pkg/types/ctxtypes"ruletypes "github.com/SigNoz/signoz/pkg/types/ruletypes""github.com/SigNoz/signoz/pkg/valuer"opentracing "github.com/opentracing/opentracing-go"- "go.uber.org/zap")// RuleTask holds a rule (with composite queries)@@ -23,6 +24,7 @@ type RuleTask struct {frequency time.Durationrules []Ruleopts *ManagerOptions+ logger *slog.Loggermtx sync.MutexevaluationDuration time.DurationevaluationTime time.Duration@@ -46,7 +48,7 @@ func NewRuleTask(name, file string, frequency time.Duration, rules []Rule, optsif frequency == 0 {frequency = DefaultFrequency}- zap.L().Info("initiating a new rule task", zap.String("name", name), zap.Duration("frequency", frequency))+ opts.Logger.Info("initiating a new rule task", "name", name, "frequency", frequency)return &RuleTask{name: name,@@ -55,6 +57,7 @@ func NewRuleTask(name, file string, frequency time.Duration, rules []Rule, optsfrequency: frequency,rules: rules,opts: opts,+ logger: opts.Logger,done: make(chan struct{}),terminated: make(chan struct{}),notify: notify,@@ -98,7 +101,7 @@ func (g *RuleTask) Run(ctx context.Context) {// Wait an initial amount to have consistently slotted intervals.evalTimestamp := g.EvalTimestamp(time.Now().UnixNano()).Add(g.frequency)- zap.L().Debug("group run to begin at", zap.Time("evalTimestamp", evalTimestamp))+ g.logger.DebugContext(ctx, "group run to begin at", "eval_timestamp", evalTimestamp)select {case <-time.After(time.Until(evalTimestamp)):case <-g.done:@@ -304,16 +307,16 @@ func (g *RuleTask) Eval(ctx context.Context, ts time.Time) {defer func() {if r := recover(); r != nil {- zap.L().Error("panic during threshold rule evaluation", zap.Any("panic", r))+ g.logger.ErrorContext(ctx, "panic during threshold rule evaluation", "panic", r)}}()- zap.L().Debug("rule task eval started", zap.String("name", g.name), zap.Time("start time", ts))+ g.logger.DebugContext(ctx, "rule task eval started", "name", g.name, "start_time", ts)maintenance, err := g.maintenanceStore.GetAllPlannedMaintenance(ctx, g.orgID.StringValue())if err != nil {- zap.L().Error("Error in processing sql query", zap.Error(err))+ g.logger.ErrorContext(ctx, "error in processing sql query", "error", err)}for i, rule := range g.rules {@@ -323,7 +326,7 @@ func (g *RuleTask) Eval(ctx context.Context, ts time.Time) {shouldSkip := falsefor _, m := range maintenance {- zap.L().Info("checking if rule should be skipped", zap.String("rule", rule.ID()), zap.Any("maintenance", m))+ g.logger.InfoContext(ctx, "checking if rule should be skipped", "rule", rule.ID(), "maintenance", m)if m.ShouldSkip(rule.ID(), ts) {shouldSkip = truebreak@@ -331,7 +334,7 @@ func (g *RuleTask) Eval(ctx context.Context, ts time.Time) {}if shouldSkip {- zap.L().Info("rule should be skipped", zap.String("rule", rule.ID()))+ g.logger.InfoContext(ctx, "rule should be skipped", "rule", rule.ID())continue}@@ -363,7 +366,7 @@ func (g *RuleTask) Eval(ctx context.Context, ts time.Time) {rule.SetHealth(ruletypes.HealthBad)rule.SetLastError(err)- zap.L().Warn("Evaluating rule failed", zap.String("ruleid", rule.ID()), zap.Error(err))+ g.logger.WarnContext(ctx, "evaluating rule failed", "rule_id", rule.ID(), "error", err)// Canceled queries are intentional termination of queries. This normally// happens on shutdown and thus we skip logging of any errors here.diff --git a/pkg/query-service/rules/test_notification.go b/pkg/query-service/rules/test_notification.goindex 2d213153a5..ee3a485bd4 100644--- a/pkg/query-service/rules/test_notification.go+++ b/pkg/query-service/rules/test_notification.go@@ -9,7 +9,7 @@ import ("github.com/SigNoz/signoz/pkg/query-service/utils/labels"ruletypes "github.com/SigNoz/signoz/pkg/types/ruletypes""github.com/google/uuid"- "go.uber.org/zap"+ "log/slog")// TestNotification prepares a dummy rule for given rule parameters and@@ -48,7 +48,7 @@ func defaultTestNotification(opts PrepareTestRuleOptions) (int, *model.ApiError)parsedRule,opts.Reader,opts.Querier,- opts.SLogger,+ opts.Logger,WithSendAlways(),WithSendUnmatched(),WithSQLStore(opts.SQLStore),@@ -57,7 +57,7 @@ func defaultTestNotification(opts PrepareTestRuleOptions) (int, *model.ApiError))if err != nil {- zap.L().Error("failed to prepare a new threshold rule for test", zap.Error(err))+ slog.Error("failed to prepare a new threshold rule for test", "error", err)return 0, model.BadRequest(err)}@@ -68,7 +68,7 @@ func defaultTestNotification(opts PrepareTestRuleOptions) (int, *model.ApiError)alertname,opts.OrgID,parsedRule,- opts.SLogger,+ opts.Logger,opts.Reader,opts.ManagerOpts.Prometheus,WithSendAlways(),@@ -79,7 +79,7 @@ func defaultTestNotification(opts PrepareTestRuleOptions) (int, *model.ApiError))if err != nil {- zap.L().Error("failed to prepare a new promql rule for test", zap.Error(err))+ slog.Error("failed to prepare a new promql rule for test", "error", err)return 0, model.BadRequest(err)}} else {@@ -91,7 +91,7 @@ func defaultTestNotification(opts PrepareTestRuleOptions) (int, *model.ApiError)alertsFound, err := rule.Eval(ctx, ts)if err != nil {- zap.L().Error("evaluating rule failed", zap.String("rule", rule.Name()), zap.Error(err))+ slog.Error("evaluating rule failed", "rule", rule.Name(), "error", err)return 0, model.InternalError(fmt.Errorf("rule evaluation failed"))}rule.SendAlerts(ctx, ts, 0, time.Duration(1*time.Minute), opts.NotifyFunc)diff --git a/pkg/query-service/rules/threshold_rule_test.go b/pkg/query-service/rules/threshold_rule_test.goindex 1da9e2af15..0af3df8f8a 100644--- a/pkg/query-service/rules/threshold_rule_test.go+++ b/pkg/query-service/rules/threshold_rule_test.go@@ -5,6 +5,7 @@ import ("fmt""math""strings"+ "log/slog""testing""time"@@ -778,7 +779,7 @@ func TestThresholdRuleUnitCombinations(t *testing.T) {},)require.NoError(t, err)- reader := clickhouseReader.NewReader(nil, telemetryStore, prometheustest.New(context.Background(), instrumentationtest.New().ToProviderSettings(), prometheus.Config{}, telemetryStore), "", time.Duration(time.Second), nil, readerCache, options)+ reader := clickhouseReader.NewReader(slog.Default(), nil, telemetryStore, prometheustest.New(context.Background(), instrumentationtest.New().ToProviderSettings(), prometheus.Config{}, telemetryStore), "", time.Duration(time.Second), nil, readerCache, options)rule, err := NewThresholdRule("69", valuer.GenerateUUID(), &postableRule, reader, nil, logger)rule.TemporalityMap = map[string]map[v3.Temporality]bool{"signoz_calls_total": {@@ -893,7 +894,7 @@ func TestThresholdRuleNoData(t *testing.T) {)assert.NoError(t, err)options := clickhouseReader.NewOptions("", "", "archiveNamespace")- reader := clickhouseReader.NewReader(nil, telemetryStore, prometheustest.New(context.Background(), instrumentationtest.New().ToProviderSettings(), prometheus.Config{}, telemetryStore), "", time.Duration(time.Second), nil, readerCache, options)+ reader := clickhouseReader.NewReader(slog.Default(), nil, telemetryStore, prometheustest.New(context.Background(), instrumentationtest.New().ToProviderSettings(), prometheus.Config{}, telemetryStore), "", time.Duration(time.Second), nil, readerCache, options)rule, err := NewThresholdRule("69", valuer.GenerateUUID(), &postableRule, reader, nil, logger)rule.TemporalityMap = map[string]map[v3.Temporality]bool{@@ -1013,7 +1014,7 @@ func TestThresholdRuleTracesLink(t *testing.T) {}options := clickhouseReader.NewOptions("", "", "archiveNamespace")- reader := clickhouseReader.NewReader(nil, telemetryStore, prometheustest.New(context.Background(), instrumentationtest.New().ToProviderSettings(), prometheus.Config{}, telemetryStore), "", time.Duration(time.Second), nil, nil, options)+ reader := clickhouseReader.NewReader(slog.Default(), nil, telemetryStore, prometheustest.New(context.Background(), instrumentationtest.New().ToProviderSettings(), prometheus.Config{}, telemetryStore), "", time.Duration(time.Second), nil, nil, options)rule, err := NewThresholdRule("69", valuer.GenerateUUID(), &postableRule, reader, nil, logger)rule.TemporalityMap = map[string]map[v3.Temporality]bool{@@ -1150,7 +1151,7 @@ func TestThresholdRuleLogsLink(t *testing.T) {}options := clickhouseReader.NewOptions("", "", "archiveNamespace")- reader := clickhouseReader.NewReader(nil, telemetryStore, prometheustest.New(context.Background(), instrumentationtest.New().ToProviderSettings(), prometheus.Config{}, telemetryStore), "", time.Duration(time.Second), nil, nil, options)+ reader := clickhouseReader.NewReader(slog.Default(), nil, telemetryStore, prometheustest.New(context.Background(), instrumentationtest.New().ToProviderSettings(), prometheus.Config{}, telemetryStore), "", time.Duration(time.Second), nil, nil, options)rule, err := NewThresholdRule("69", valuer.GenerateUUID(), &postableRule, reader, nil, logger)rule.TemporalityMap = map[string]map[v3.Temporality]bool{@@ -1417,7 +1418,7 @@ func TestMultipleThresholdRule(t *testing.T) {},)require.NoError(t, err)- reader := clickhouseReader.NewReader(nil, telemetryStore, prometheustest.New(context.Background(), instrumentationtest.New().ToProviderSettings(), prometheus.Config{}, telemetryStore), "", time.Second, nil, readerCache, options)+ reader := clickhouseReader.NewReader(slog.Default(), nil, telemetryStore, prometheustest.New(context.Background(), instrumentationtest.New().ToProviderSettings(), prometheus.Config{}, telemetryStore), "", time.Second, nil, readerCache, options)rule, err := NewThresholdRule("69", valuer.GenerateUUID(), &postableRule, reader, nil, logger)rule.TemporalityMap = map[string]map[v3.Temporality]bool{"signoz_calls_total": {@@ -2220,7 +2221,7 @@ func TestThresholdEval_RequireMinPoints(t *testing.T) {require.NoError(t, err)prometheusProvider := prometheustest.New(context.Background(), instrumentationtest.New().ToProviderSettings(), prometheus.Config{}, telemetryStore)- reader := clickhouseReader.NewReader(nil, telemetryStore, prometheusProvider, "", time.Second, nil, readerCache, options)+ reader := clickhouseReader.NewReader(slog.Default(), nil, telemetryStore, prometheusProvider, "", time.Second, nil, readerCache, options)rule, err := NewThresholdRule("some-id", valuer.GenerateUUID(), &postableRule, reader, nil, logger)t.Run(fmt.Sprintf("%d Version=%s, %s", idx, version, c.description), func(t *testing.T) {diff --git a/pkg/query-service/utils/format.go b/pkg/query-service/utils/format.goindex 2b6fbcbe76..d2e04875c2 100644--- a/pkg/query-service/utils/format.go+++ b/pkg/query-service/utils/format.go@@ -7,10 +7,11 @@ import ("strconv""strings"+ "log/slog"+"github.com/SigNoz/signoz/pkg/query-service/constants""github.com/SigNoz/signoz/pkg/query-service/metrics"v3 "github.com/SigNoz/signoz/pkg/query-service/model/v3"- "go.uber.org/zap")// ValidateAndCastValue validates and casts the value of a key to the corresponding data type of the key@@ -209,7 +210,7 @@ func ClickHouseFormattedValue(v interface{}) string {case uint8, uint16, uint32, uint64, int, int8, int16, int32, int64, float32, float64, bool:return strings.Join(strings.Fields(fmt.Sprint(x)), ",")default:- zap.L().Error("invalid type for formatted value", zap.Any("type", reflect.TypeOf(x[0])))+ slog.Error("invalid type for formatted value", "type", reflect.TypeOf(x[0]))return "[]"}case []string:@@ -226,7 +227,7 @@ func ClickHouseFormattedValue(v interface{}) string {str += "]"return strdefault:- zap.L().Error("invalid type for formatted value", zap.Any("type", reflect.TypeOf(x)))+ slog.Error("invalid type for formatted value", "type", reflect.TypeOf(x))return ""}}diff --git a/pkg/query-service/utils/time.go b/pkg/query-service/utils/time.godeleted file mode 100644index 612da4f4bc..0000000000--- a/pkg/query-service/utils/time.go+++ /dev/null@@ -1,19 +0,0 @@-package utils--import (- "time"-- "go.uber.org/zap"-)--func Elapsed(funcName string, args map[string]interface{}) func() {- start := time.Now()- return func() {- var zapFields []zap.Field- zapFields = append(zapFields, zap.String("func_name", funcName), zap.Duration("duration", time.Since(start)))- for k, v := range args {- zapFields = append(zapFields, zap.Any(k, v))- }- zap.L().Info("Elapsed time", zapFields...)- }-}