Skip to content

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

fix(test|lint): fix lint and test in go (#7346)

Vibhu Pandey71188291077a
diff --git a/ee/query-service/license/manager.go b/ee/query-service/license/manager.go
index fd9626800b..7ad62e0068 100644
--- a/ee/query-service/license/manager.go
+++ b/ee/query-service/license/manager.go
@@ -155,7 +155,7 @@ func (lm *Manager) ValidatorV3(ctx context.Context) {
tick := time.NewTicker(validationFrequency)
defer tick.Stop()
- lm.ValidateV3(ctx)
+ _ = lm.ValidateV3(ctx)
for {
select {
case <-lm.done:
@@ -165,7 +165,7 @@ func (lm *Manager) ValidatorV3(ctx context.Context) {
case <-lm.done:
return
case <-tick.C:
- lm.ValidateV3(ctx)
+ _ = lm.ValidateV3(ctx)
}
}
diff --git a/pkg/alertmanager/alertmanagerbatcher/batcher_test.go b/pkg/alertmanager/alertmanagerbatcher/batcher_test.go
index 1017505aea..517c16a1ea 100644
--- a/pkg/alertmanager/alertmanagerbatcher/batcher_test.go
+++ b/pkg/alertmanager/alertmanagerbatcher/batcher_test.go
@@ -12,7 +12,7 @@ import (
func TestBatcherWithOneAlertAndDefaultConfigs(t *testing.T) {
batcher := New(slog.New(slog.NewTextHandler(io.Discard, nil)), NewConfig())
- batcher.Start(context.Background())
+ _ = batcher.Start(context.Background())
batcher.Add(context.Background(), &alertmanagertypes.PostableAlert{Alert: alertmanagertypes.AlertModel{
Labels: map[string]string{"alertname": "test"},
@@ -26,7 +26,7 @@ func TestBatcherWithOneAlertAndDefaultConfigs(t *testing.T) {
func TestBatcherWithBatchSize(t *testing.T) {
batcher := New(slog.New(slog.NewTextHandler(io.Discard, nil)), Config{Size: 2, Capacity: 4})
- batcher.Start(context.Background())
+ _ = batcher.Start(context.Background())
var alerts alertmanagertypes.PostableAlerts
for i := 0; i < 4; i++ {
@@ -46,7 +46,7 @@ func TestBatcherWithBatchSize(t *testing.T) {
func TestBatcherWithCClosed(t *testing.T) {
batcher := New(slog.New(slog.NewTextHandler(io.Discard, nil)), Config{Size: 2, Capacity: 4})
- batcher.Start(context.Background())
+ _ = batcher.Start(context.Background())
var alerts alertmanagertypes.PostableAlerts
for i := 0; i < 4; i++ {
diff --git a/pkg/alertmanager/alertmanagerserver/server.go b/pkg/alertmanager/alertmanagerserver/server.go
index 8cecbf04f2..9bcca2a506 100644
--- a/pkg/alertmanager/alertmanagerserver/server.go
+++ b/pkg/alertmanager/alertmanagerserver/server.go
@@ -134,21 +134,21 @@ func New(ctx context.Context, logger *slog.Logger, registry prometheus.Registere
// Don't return here - we need to snapshot our state first.
}
- state, err := server.stateStore.Get(ctx, server.orgID)
+ storableSilences, err := server.stateStore.Get(ctx, server.orgID)
if err != nil && !errors.Ast(err, errors.TypeNotFound) {
return 0, err
}
- if state == nil {
- state = alertmanagertypes.NewStoreableState(server.orgID)
+ if storableSilences == nil {
+ storableSilences = alertmanagertypes.NewStoreableState(server.orgID)
}
- c, err := state.Set(alertmanagertypes.SilenceStateName, server.silences)
+ c, err := storableSilences.Set(alertmanagertypes.SilenceStateName, server.silences)
if err != nil {
return 0, err
}
- return c, server.stateStore.Set(ctx, server.orgID, state)
+ return c, server.stateStore.Set(ctx, server.orgID, storableSilences)
})
}()
@@ -163,21 +163,21 @@ func New(ctx context.Context, logger *slog.Logger, registry prometheus.Registere
// Don't return without saving the current state.
}
- state, err := server.stateStore.Get(ctx, server.orgID)
+ storableNFLog, err := server.stateStore.Get(ctx, server.orgID)
if err != nil && !errors.Ast(err, errors.TypeNotFound) {
return 0, err
}
- if state == nil {
- state = alertmanagertypes.NewStoreableState(server.orgID)
+ if storableNFLog == nil {
+ storableNFLog = alertmanagertypes.NewStoreableState(server.orgID)
}
- c, err := state.Set(alertmanagertypes.NFLogStateName, server.nflog)
+ c, err := storableNFLog.Set(alertmanagertypes.NFLogStateName, server.nflog)
if err != nil {
return 0, err
}
- return c, server.stateStore.Set(ctx, server.orgID, state)
+ return c, server.stateStore.Set(ctx, server.orgID, storableNFLog)
})
}()
diff --git a/pkg/alertmanager/alertmanagerserver/server_test.go b/pkg/alertmanager/alertmanagerserver/server_test.go
index 54f407d88a..142e49884f 100644
--- a/pkg/alertmanager/alertmanagerserver/server_test.go
+++ b/pkg/alertmanager/alertmanagerserver/server_test.go
@@ -110,7 +110,6 @@ func TestServerPutAlerts(t *testing.T) {
},
},
}))
- require.NotEmpty(t, server.alerts)
dummyRequest, err := http.NewRequest(http.MethodGet, "/alerts", nil)
require.NoError(t, err)
diff --git a/pkg/alertmanager/service.go b/pkg/alertmanager/service.go
index 235a3db92e..3ddafb5e36 100644
--- a/pkg/alertmanager/service.go
+++ b/pkg/alertmanager/service.go
@@ -138,11 +138,15 @@ func (service *Service) TestAlert(ctx context.Context, orgID string, alert *aler
}
func (service *Service) Stop(ctx context.Context) error {
+ var errs []error
for _, server := range service.servers {
- server.Stop(ctx)
+ if err := server.Stop(ctx); err != nil {
+ errs = append(errs, err)
+ service.settings.Logger().Error("failed to stop alertmanager server", "error", err)
+ }
}
- return nil
+ return errors.Join(errs...)
}
func (service *Service) newServer(ctx context.Context, orgID string) (*alertmanagerserver.Server, error) {
@@ -180,7 +184,9 @@ func (service *Service) getConfig(ctx context.Context, orgID string) (*alertmana
if err := config.SetGlobalConfig(service.config.Global); err != nil {
return nil, err
}
- config.SetRouteConfig(service.config.Route)
+ if err := config.SetRouteConfig(service.config.Route); err != nil {
+ return nil, err
+ }
return config, nil
}
diff --git a/pkg/cache/memorycache/provider.go b/pkg/cache/memorycache/provider.go
index 8b48d6fd92..ccc2bfd5be 100644
--- a/pkg/cache/memorycache/provider.go
+++ b/pkg/cache/memorycache/provider.go
@@ -75,7 +75,7 @@ func (c *provider) SetTTL(_ context.Context, cacheKey string, ttl time.Duration)
if !found {
return
}
- c.cc.Replace(cacheKey, item, ttl)
+ _ = c.cc.Replace(cacheKey, item, ttl)
}
// Remove removes the cache entry
diff --git a/pkg/cache/rediscache/provider_test.go b/pkg/cache/rediscache/provider_test.go
index acc447ae74..6de4b5e465 100644
--- a/pkg/cache/rediscache/provider_test.go
+++ b/pkg/cache/rediscache/provider_test.go
@@ -35,7 +35,7 @@ func TestStore(t *testing.T) {
}
mock.ExpectSet("key", storeCacheableEntity, 10*time.Second).RedisNil()
- cache.Store(context.Background(), "key", storeCacheableEntity, 10*time.Second)
+ _ = cache.Store(context.Background(), "key", storeCacheableEntity, 10*time.Second)
if err := mock.ExpectationsWereMet(); err != nil {
t.Errorf("there were unfulfilled expectations: %s", err)
@@ -53,7 +53,7 @@ func TestRetrieve(t *testing.T) {
retrieveCacheableEntity := new(CacheableEntity)
mock.ExpectSet("key", storeCacheableEntity, 10*time.Second).RedisNil()
- cache.Store(context.Background(), "key", storeCacheableEntity, 10*time.Second)
+ _ = cache.Store(context.Background(), "key", storeCacheableEntity, 10*time.Second)
data, err := storeCacheableEntity.MarshalBinary()
assert.NoError(t, err)
@@ -85,7 +85,7 @@ func TestSetTTL(t *testing.T) {
}
mock.ExpectSet("key", storeCacheableEntity, 10*time.Second).RedisNil()
- cache.Store(context.Background(), "key", storeCacheableEntity, 10*time.Second)
+ _ = cache.Store(context.Background(), "key", storeCacheableEntity, 10*time.Second)
mock.ExpectExpire("key", 4*time.Second).RedisNil()
cache.SetTTL(context.Background(), "key", 4*time.Second)
@@ -105,7 +105,7 @@ func TestRemove(t *testing.T) {
}
mock.ExpectSet("key", storeCacheableEntity, 10*time.Second).RedisNil()
- c.Store(context.Background(), "key", storeCacheableEntity, 10*time.Second)
+ _ = c.Store(context.Background(), "key", storeCacheableEntity, 10*time.Second)
mock.ExpectDel("key").RedisNil()
c.Remove(context.Background(), "key")
@@ -125,10 +125,10 @@ func TestBulkRemove(t *testing.T) {
}
mock.ExpectSet("key", storeCacheableEntity, 10*time.Second).RedisNil()
- c.Store(context.Background(), "key", storeCacheableEntity, 10*time.Second)
+ _ = c.Store(context.Background(), "key", storeCacheableEntity, 10*time.Second)
mock.ExpectSet("key2", storeCacheableEntity, 10*time.Second).RedisNil()
- c.Store(context.Background(), "key2", storeCacheableEntity, 10*time.Second)
+ _ = c.Store(context.Background(), "key2", storeCacheableEntity, 10*time.Second)
mock.ExpectDel("key", "key2").RedisNil()
c.BulkRemove(context.Background(), []string{"key", "key2"})
diff --git a/pkg/http/middleware/analytics.go b/pkg/http/middleware/analytics.go
index 76b20f71fd..fcdc25d6b2 100644
--- a/pkg/http/middleware/analytics.go
+++ b/pkg/http/middleware/analytics.go
@@ -82,7 +82,7 @@ func (a *Analytics) extractQueryRangeData(path string, r *http.Request) (map[str
}
r.Body.Close() // must close
r.Body = io.NopCloser(bytes.NewBuffer(bodyBytes))
- json.Unmarshal(bodyBytes, &postData)
+ _ = json.Unmarshal(bodyBytes, &postData)
} else {
return nil, false
diff --git a/pkg/query-service/agentConf/db.go b/pkg/query-service/agentConf/db.go
index 0167d34ac7..848de75780 100644
--- a/pkg/query-service/agentConf/db.go
+++ b/pkg/query-service/agentConf/db.go
@@ -166,8 +166,8 @@ func (r *Repo) insertConfig(
defer func() {
if fnerr != nil {
// remove all the damage (invalid rows from db)
- r.db.Exec("DELETE FROM agent_config_versions WHERE id = $1", c.ID)
- r.db.Exec("DELETE FROM agent_config_elements WHERE version_id=$1", c.ID)
+ _, _ = r.db.Exec("DELETE FROM agent_config_versions WHERE id = $1", c.ID)
+ _, _ = r.db.Exec("DELETE FROM agent_config_elements WHERE version_id=$1", c.ID)
}
}()
diff --git a/pkg/query-service/agentConf/manager.go b/pkg/query-service/agentConf/manager.go
index 77e5b43994..61fd70ab90 100644
--- a/pkg/query-service/agentConf/manager.go
+++ b/pkg/query-service/agentConf/manager.go
@@ -129,7 +129,7 @@ func (m *Manager) RecommendAgentConfig(currentConfYaml []byte) (
settingVersionsUsed = append(settingVersionsUsed, configId)
- m.updateDeployStatus(
+ _ = m.updateDeployStatus(
context.Background(),
featureType,
configVersion,
@@ -168,7 +168,7 @@ func (m *Manager) ReportConfigDeploymentStatus(
newStatus = string(DeployFailed)
message = fmt.Sprintf("%s: %s", agentId, err.Error())
}
- m.updateDeployStatusByHash(
+ _ = m.updateDeployStatusByHash(
context.Background(), featureConfId, newStatus, message,
)
}
@@ -247,7 +247,7 @@ func Redeploy(ctx context.Context, typ ElementTypeDef, version int) *model.ApiEr
return model.InternalError(fmt.Errorf("failed to deploy the config"))
}
- m.updateDeployStatus(ctx, ElementTypeSamplingRules, version, string(DeployInitiated), "Deployment started", configHash, configVersion.LastConf)
+ _ = m.updateDeployStatus(ctx, ElementTypeSamplingRules, version, string(DeployInitiated), "Deployment started", configHash, configVersion.LastConf)
case ElementTypeDropRules:
var filterConfig *filterprocessor.Config
if err := yaml.Unmarshal([]byte(configVersion.LastConf), &filterConfig); err != nil {
@@ -265,7 +265,7 @@ func Redeploy(ctx context.Context, typ ElementTypeDef, version int) *model.ApiEr
return err
}
- m.updateDeployStatus(ctx, ElementTypeSamplingRules, version, string(DeployInitiated), "Deployment started", configHash, configVersion.LastConf)
+ _ = m.updateDeployStatus(ctx, ElementTypeSamplingRules, version, string(DeployInitiated), "Deployment started", configHash, configVersion.LastConf)
}
return nil
@@ -296,7 +296,7 @@ func UpsertFilterProcessor(ctx context.Context, version int, config *filterproce
zap.L().Warn("unexpected error while transforming processor config to yaml", zap.Error(yamlErr))
}
- m.updateDeployStatus(ctx, ElementTypeDropRules, version, string(DeployInitiated), "Deployment started", configHash, string(processorConfYaml))
+ _ = m.updateDeployStatus(ctx, ElementTypeDropRules, version, string(DeployInitiated), "Deployment started", configHash, string(processorConfYaml))
return nil
}
@@ -320,7 +320,7 @@ func (m *Manager) OnConfigUpdate(agentId string, hash string, err error) {
message = fmt.Sprintf("%s: %s", agentId, err.Error())
}
- m.updateDeployStatusByHash(context.Background(), hash, status, message)
+ _ = m.updateDeployStatusByHash(context.Background(), hash, status, message)
}
// UpsertSamplingProcessor updates the agent config with new filter processor params
@@ -347,6 +347,6 @@ func UpsertSamplingProcessor(ctx context.Context, version int, config *tsp.Confi
zap.L().Warn("unexpected error while transforming processor config to yaml", zap.Error(yamlErr))
}
- m.updateDeployStatus(ctx, ElementTypeSamplingRules, version, string(DeployInitiated), "Deployment started", configHash, string(processorConfYaml))
+ _ = m.updateDeployStatus(ctx, ElementTypeSamplingRules, version, string(DeployInitiated), "Deployment started", configHash, string(processorConfYaml))
return nil
}
diff --git a/pkg/query-service/app/logs/v3/enrich_query.go b/pkg/query-service/app/logs/v3/enrich_query.go
index 5daa6aa6a6..f6f7c1165e 100644
--- a/pkg/query-service/app/logs/v3/enrich_query.go
+++ b/pkg/query-service/app/logs/v3/enrich_query.go
@@ -92,7 +92,7 @@ func Enrich(params *v3.QueryRangeParamsV3, fields map[string]v3.AttributeKey) {
if query.Expression != queryName && query.DataSource != v3.DataSourceLogs {
continue
}
- EnrichLogsQuery(query, fields)
+ _ = EnrichLogsQuery(query, fields)
}
}
diff --git a/pkg/query-service/app/opamp/mocks.go b/pkg/query-service/app/opamp/mocks.go
index 12e9410989..c90be74b80 100644
--- a/pkg/query-service/app/opamp/mocks.go
+++ b/pkg/query-service/app/opamp/mocks.go
@@ -80,7 +80,7 @@ func (ta *MockAgentConfigProvider) RecommendAgentConfig(baseConfYaml []byte) (
return nil, "", errors.Wrap(err, "could not unmarshal baseConf")
}
- k.Set("extensions.zpages.endpoint", ta.ZPagesEndpoint)
+ _ = k.Set("extensions.zpages.endpoint", ta.ZPagesEndpoint)
recommendedYaml, err := k.Marshal(yaml.Parser())
if err != nil {
return nil, "", errors.Wrap(err, "could not marshal recommended conf")
diff --git a/pkg/query-service/app/opamp/model/agent.go b/pkg/query-service/app/opamp/model/agent.go
index 5751bd255b..53ca64a5db 100644
--- a/pkg/query-service/app/opamp/model/agent.go
+++ b/pkg/query-service/app/opamp/model/agent.go
@@ -359,5 +359,5 @@ func (agent *Agent) SendToAgent(msg *protobufs.ServerToAgent) {
agent.connMutex.Lock()
defer agent.connMutex.Unlock()
- agent.conn.Send(context.Background(), msg)
+ _ = agent.conn.Send(context.Background(), msg)
}
diff --git a/pkg/query-service/app/opamp/model/agents.go b/pkg/query-service/app/opamp/model/agents.go
index 0b2a48e04c..2a6518f685 100644
--- a/pkg/query-service/app/opamp/model/agents.go
+++ b/pkg/query-service/app/opamp/model/agents.go
@@ -51,7 +51,7 @@ func (agents *Agents) RemoveConnection(conn types.Connection) {
agent := agents.agentsById[instanceId]
agent.CurrentStatus = AgentStatusDisconnected
agent.TerminatedAt = time.Now()
- agent.Upsert()
+ _ = agent.Upsert()
delete(agents.agentsById, instanceId)
}
delete(agents.connections, conn)
diff --git a/pkg/query-service/app/opamp/opamp_server.go b/pkg/query-service/app/opamp/opamp_server.go
index adc72ccdc1..45c70e0bff 100644
--- a/pkg/query-service/app/opamp/opamp_server.go
+++ b/pkg/query-service/app/opamp/opamp_server.go
@@ -71,7 +71,7 @@ func (srv *Server) Stop() {
defer cleanup()
}
- srv.server.Stop(context.Background())
+ _ = srv.server.Stop(context.Background())
}
func (srv *Server) onDisconnect(conn types.Connection) {
diff --git a/pkg/query-service/app/opamp/otelconfig/config_parser.go b/pkg/query-service/app/opamp/otelconfig/config_parser.go
index 5d6c8adba4..23d976e612 100644
--- a/pkg/query-service/app/opamp/otelconfig/config_parser.go
+++ b/pkg/query-service/app/opamp/otelconfig/config_parser.go
@@ -160,7 +160,7 @@ func (cp *ConfigParser) CheckProcessorInPipeline(pipelineName, name string) bool
func (cp *ConfigParser) Merge(c *confmap.Conf) {
cp.lock.Lock()
defer cp.lock.Unlock()
- cp.agentConf.Merge(c)
+ _ = cp.agentConf.Merge(c)
}
func (cp *ConfigParser) UpdateProcessors(processors map[string]interface{}) {
diff --git a/pkg/query-service/cache/inmemory/cache.go b/pkg/query-service/cache/inmemory/cache.go
index af8f200d08..6e24c1e53d 100644
--- a/pkg/query-service/cache/inmemory/cache.go
+++ b/pkg/query-service/cache/inmemory/cache.go
@@ -47,7 +47,7 @@ func (c *cache) SetTTL(cacheKey string, ttl time.Duration) {
if !found {
return
}
- c.cc.Replace(cacheKey, item, ttl)
+ _ = c.cc.Replace(cacheKey, item, ttl)
}
// Remove removes the cache entry
diff --git a/pkg/query-service/cache/redis/redis_test.go b/pkg/query-service/cache/redis/redis_test.go
index baed3416a3..7dfddc6380 100644
--- a/pkg/query-service/cache/redis/redis_test.go
+++ b/pkg/query-service/cache/redis/redis_test.go
@@ -13,7 +13,7 @@ func TestStore(t *testing.T) {
c := WithClient(db)
mock.ExpectSet("key", []byte("value"), 10*time.Second).RedisNil()
- c.Store("key", []byte("value"), 10*time.Second)
+ _ = c.Store("key", []byte("value"), 10*time.Second)
if err := mock.ExpectationsWereMet(); err != nil {
t.Errorf("there were unfulfilled expectations: %s", err)
@@ -24,7 +24,7 @@ func TestRetrieve(t *testing.T) {
db, mock := redismock.NewClientMock()
c := WithClient(db)
mock.ExpectSet("key", []byte("value"), 10*time.Second).RedisNil()
- c.Store("key", []byte("value"), 10*time.Second)
+ _ = c.Store("key", []byte("value"), 10*time.Second)
mock.ExpectGet("key").SetVal("value")
data, retrieveStatus, err := c.Retrieve("key", false)
@@ -49,7 +49,7 @@ func TestSetTTL(t *testing.T) {
db, mock := redismock.NewClientMock()
c := WithClient(db)
mock.ExpectSet("key", []byte("value"), 10*time.Second).RedisNil()
- c.Store("key", []byte("value"), 10*time.Second)
+ _ = c.Store("key", []byte("value"), 10*time.Second)
mock.ExpectExpire("key", 4*time.Second).RedisNil()
c.SetTTL("key", 4*time.Second)
@@ -63,7 +63,7 @@ func TestRemove(t *testing.T) {
db, mock := redismock.NewClientMock()
c := WithClient(db)
mock.ExpectSet("key", []byte("value"), 10*time.Second).RedisNil()
- c.Store("key", []byte("value"), 10*time.Second)
+ _ = c.Store("key", []byte("value"), 10*time.Second)
mock.ExpectDel("key").RedisNil()
c.Remove("key")
@@ -77,10 +77,10 @@ func TestBulkRemove(t *testing.T) {
db, mock := redismock.NewClientMock()
c := WithClient(db)
mock.ExpectSet("key", []byte("value"), 10*time.Second).RedisNil()
- c.Store("key", []byte("value"), 10*time.Second)
+ _ = c.Store("key", []byte("value"), 10*time.Second)
mock.ExpectSet("key2", []byte("value2"), 10*time.Second).RedisNil()
- c.Store("key2", []byte("value2"), 10*time.Second)
+ _ = c.Store("key2", []byte("value2"), 10*time.Second)
mock.ExpectDel("key", "key2").RedisNil()
c.BulkRemove([]string{"key", "key2"})
diff --git a/pkg/query-service/model/response.go b/pkg/query-service/model/response.go
index 650571dcf0..b54c85572c 100644
--- a/pkg/query-service/model/response.go
+++ b/pkg/query-service/model/response.go
@@ -354,7 +354,7 @@ func (item *SearchSpanResponseItem) GetValues() []interface{} {
references := []OtelSpanRef{}
jsonbody, _ := json.Marshal(item.References)
- json.Unmarshal(jsonbody, &references)
+ _ = json.Unmarshal(jsonbody, &references)
referencesStringArray := []string{}
for _, item := range references {
@@ -750,7 +750,7 @@ type ClusterInfo struct {
func (ci *ClusterInfo) GetMapFromStruct() map[string]interface{} {
var clusterInfoMap map[string]interface{}
data, _ := json.Marshal(*ci)
- json.Unmarshal(data, &clusterInfoMap)
+ _ = json.Unmarshal(data, &clusterInfoMap)
return clusterInfoMap
}
diff --git a/pkg/query-service/pqlEngine/engine.go b/pkg/query-service/pqlEngine/engine.go
index 7362e8f0c9..15fb901646 100644
--- a/pkg/query-service/pqlEngine/engine.go
+++ b/pkg/query-service/pqlEngine/engine.go
@@ -40,10 +40,10 @@ func FromReader(ch interfaces.Reader) (*PqlEngine, error) {
func NewPqlEngine(config *pconfig.Config) (*PqlEngine, error) {
logLevel := promlog.AllowedLevel{}
- logLevel.Set("debug")
+ _ = logLevel.Set("debug")
allowedFormat := promlog.AllowedFormat{}
- allowedFormat.Set("logfmt")
+ _ = allowedFormat.Set("logfmt")
promlogConfig := promlog.Config{
Level: &logLevel,
@@ -80,7 +80,7 @@ func NewPqlEngine(config *pconfig.Config) (*PqlEngine, error) {
)
fanoutStorage := pstorage.NewFanout(logger, remoteStorage)
- remoteStorage.ApplyConfig(config)
+ _ = remoteStorage.ApplyConfig(config)
return &PqlEngine{
engine: e,
diff --git a/pkg/query-service/telemetry/telemetry.go b/pkg/query-service/telemetry/telemetry.go
index 4a7464b2e4..e5681ccd83 100644
--- a/pkg/query-service/telemetry/telemetry.go
+++ b/pkg/query-service/telemetry/telemetry.go
@@ -515,8 +515,8 @@ func createTelemetry() {
nextHeartbeat := calculateNextRun(HEART_BEAT_DURATION, SCHEDULE_START_TIME)
nextActiveUser := calculateNextRun(ACTIVE_USER_DURATION, SCHEDULE_START_TIME)
- s.Every(HEART_BEAT_DURATION).StartAt(nextHeartbeat).Do(heartbeatFunc)
- s.Every(ACTIVE_USER_DURATION).StartAt(nextActiveUser).Do(activeUserFunc)
+ _, _ = s.Every(HEART_BEAT_DURATION).StartAt(nextHeartbeat).Do(heartbeatFunc)
+ _, _ = s.Every(ACTIVE_USER_DURATION).StartAt(nextActiveUser).Do(activeUserFunc)
}
// Schedule immediate execution and subsequent runs
@@ -559,18 +559,18 @@ func (a *Telemetry) IdentifyUser(user *types.User) {
if a.saasOperator != nil {
if role != "" {
- a.saasOperator.Enqueue(analytics.Identify{
+ _ = a.saasOperator.Enqueue(analytics.Identify{
UserId: a.userEmail,
Traits: analytics.NewTraits().SetName(user.Name).SetEmail(user.Email).Set("role", role),
})
} else {
- a.saasOperator.Enqueue(analytics.Identify{
+ _ = a.saasOperator.Enqueue(analytics.Identify{
UserId: a.userEmail,
Traits: analytics.NewTraits().SetName(user.Name).SetEmail(user.Email),
})
}
- a.saasOperator.Enqueue(analytics.Group{
+ _ = a.saasOperator.Enqueue(analytics.Group{
UserId: a.userEmail,
GroupId: a.getCompanyDomain(),
Traits: analytics.NewTraits().Set("company_domain", a.getCompanyDomain()),
@@ -578,12 +578,12 @@ func (a *Telemetry) IdentifyUser(user *types.User) {
}
if a.ossOperator != nil {
- a.ossOperator.Enqueue(analytics.Identify{
+ _ = a.ossOperator.Enqueue(analytics.Identify{
UserId: a.ipAddress,
Traits: analytics.NewTraits().SetName(user.Name).SetEmail(user.Email).Set("ip", a.ipAddress),
})
// Updating a groups properties
- a.ossOperator.Enqueue(analytics.Group{
+ _ = a.ossOperator.Enqueue(analytics.Group{
UserId: a.ipAddress,
GroupId: a.getCompanyDomain(),
Traits: analytics.NewTraits().Set("company_domain", a.getCompanyDomain()),
@@ -611,13 +611,13 @@ func (a *Telemetry) SendIdentifyEvent(data map[string]interface{}, userEmail str
traits.Set(k, v)
}
if a.saasOperator != nil {
- a.saasOperator.Enqueue(analytics.Identify{
+ _ = a.saasOperator.Enqueue(analytics.Identify{
UserId: a.GetUserEmail(),
Traits: traits,
})
}
if a.ossOperator != nil {
- a.ossOperator.Enqueue(analytics.Identify{
+ _ = a.ossOperator.Enqueue(analytics.Identify{
UserId: a.ipAddress,
Traits: traits,
})
@@ -644,14 +644,14 @@ func (a *Telemetry) SendGroupEvent(data map[string]interface{}, userEmail string
traits.Set(k, v)
}
if a.saasOperator != nil {
- a.saasOperator.Enqueue(analytics.Group{
+ _ = a.saasOperator.Enqueue(analytics.Group{
UserId: a.GetUserEmail(),
GroupId: a.getCompanyDomain(),
Traits: traits,
})
}
if a.ossOperator != nil {
- a.ossOperator.Enqueue(analytics.Group{
+ _ = a.ossOperator.Enqueue(analytics.Group{
UserId: a.ipAddress,
GroupId: a.getCompanyDomain(),
Traits: traits,
@@ -757,7 +757,7 @@ func (a *Telemetry) SendEvent(event string, data map[string]interface{}, userEma
_, isSaaSEvent := SAAS_EVENTS_LIST[event]
if a.saasOperator != nil && a.GetUserEmail() != "" && (isSaaSEvent || viaEventsAPI) {
- a.saasOperator.Enqueue(analytics.Track{
+ _ = a.saasOperator.Enqueue(analytics.Track{
Event: event,
UserId: a.GetUserEmail(),
Properties: properties,
@@ -772,7 +772,7 @@ func (a *Telemetry) SendEvent(event string, data map[string]interface{}, userEma
_, isOSSEvent := OSS_EVENTS_LIST[event]
if a.ossOperator != nil && isOSSEvent {
- a.ossOperator.Enqueue(analytics.Track{
+ _ = a.ossOperator.Enqueue(analytics.Track{
Event: event,
UserId: userId,
Properties: properties,
diff --git a/pkg/query-service/utils/testutils.go b/pkg/query-service/utils/testutils.go
index 99e90cf35e..ce9ff164b5 100644
--- a/pkg/query-service/utils/testutils.go
+++ b/pkg/query-service/utils/testutils.go
@@ -70,7 +70,7 @@ func NewQueryServiceDBForTests(t *testing.T) sqlstore.SQLStore {
if err != nil {
t.Fatalf("could not initialize dao: %v", err)
}
- dashboards.InitDB(sqlStore.BunDB())
+ _ = dashboards.InitDB(sqlStore.BunDB())
return sqlStore
}
diff --git a/pkg/sqlmigration/011_modify_datetime.go b/pkg/sqlmigration/011_modify_datetime.go
index 977b466494..386cbd0740 100644
--- a/pkg/sqlmigration/011_modify_datetime.go
+++ b/pkg/sqlmigration/011_modify_datetime.go
@@ -37,7 +37,7 @@ func (migration *modifyDatetime) Up(ctx context.Context, db *bun.DB) error {
if err != nil {
return err
}
- defer tx.Rollback()
+ defer tx.Rollback() //nolint:errcheck
tables := []string{"dashboards", "rules", "planned_maintenance", "ttl_status", "saved_views"}
columns := []string{"created_at", "updated_at"}
diff --git a/pkg/sqlmigration/012_modify_org_domain.go b/pkg/sqlmigration/012_modify_org_domain.go
index 3bf910f60e..45cdfb85b9 100644
--- a/pkg/sqlmigration/012_modify_org_domain.go
+++ b/pkg/sqlmigration/012_modify_org_domain.go
@@ -38,7 +38,7 @@ func (migration *modifyOrgDomain) Up(ctx context.Context, db *bun.DB) error {
if err != nil {
return err
}
- defer tx.Rollback()
+ defer tx.Rollback() //nolint:errcheck
// rename old column
if _, err := tx.ExecContext(ctx, `ALTER TABLE org_domains RENAME COLUMN updated_at TO updated_at_old`); err != nil {
diff --git a/pkg/sqlmigration/013_update_organization.go b/pkg/sqlmigration/013_update_organization.go
index ffa919961d..8f4731be0e 100644
--- a/pkg/sqlmigration/013_update_organization.go
+++ b/pkg/sqlmigration/013_update_organization.go
@@ -42,7 +42,7 @@ func (migration *updateOrganization) Up(ctx context.Context, db *bun.DB) error {
if err != nil {
return err
}
- defer tx.Rollback()
+ defer tx.Rollback() //nolint:errcheck
// update apdex settings table
if err := updateApdexSettings(ctx, tx); err != nil {
diff --git a/pkg/sqlmigration/015_update_dashboards_savedviews.go b/pkg/sqlmigration/015_update_dashboards_savedviews.go
index 9ca6d9da57..17ed6cd0eb 100644
--- a/pkg/sqlmigration/015_update_dashboards_savedviews.go
+++ b/pkg/sqlmigration/015_update_dashboards_savedviews.go
@@ -41,7 +41,7 @@ func (migration *updateDashboardAndSavedViews) Up(ctx context.Context, db *bun.D
if err != nil {
return err
}
- defer tx.Rollback()
+ defer tx.Rollback() //nolint:errcheck
// get all org ids
var orgIDs []string
diff --git a/pkg/sqlstore/postgressqlstore/dialect.go b/pkg/sqlstore/postgressqlstore/dialect.go
index 3f4744ddac..0eb1310f29 100644
--- a/pkg/sqlstore/postgressqlstore/dialect.go
+++ b/pkg/sqlstore/postgressqlstore/dialect.go
@@ -84,14 +84,13 @@ func (dialect *PGDialect) MigrateIntToBoolean(ctx context.Context, bun bun.IDB,
func (dialect *PGDialect) GetColumnType(ctx context.Context, bun bun.IDB, table string, column string) (string, error) {
var columnType string
- var err error
- err = bun.NewSelect().
+
+ err := bun.NewSelect().
ColumnExpr("data_type").
TableExpr("information_schema.columns").
Where("table_name = ?", table).
Where("column_name = ?", column).
Scan(ctx, &columnType)
-
if err != nil {
return "", err
}
diff --git a/pkg/sqlstore/sqlitesqlstore/dialect.go b/pkg/sqlstore/sqlitesqlstore/dialect.go
index 14ac7d1d45..8baefe4235 100644
--- a/pkg/sqlstore/sqlitesqlstore/dialect.go
+++ b/pkg/sqlstore/sqlitesqlstore/dialect.go
@@ -84,14 +84,12 @@ func (dialect *SQLiteDialect) MigrateIntToBoolean(ctx context.Context, bun bun.I
func (dialect *SQLiteDialect) GetColumnType(ctx context.Context, bun bun.IDB, table string, column string) (string, error) {
var columnType string
- var err error
- err = bun.NewSelect().
+ err := bun.NewSelect().
ColumnExpr("type").
TableExpr("pragma_table_info(?)", table).
Where("name = ?", column).
Scan(ctx, &columnType)
-
if err != nil {
return "", err
}
diff --git a/pkg/types/alertmanagertypes/alertmanagertypestest/state.go b/pkg/types/alertmanagertypes/alertmanagertypestest/state.go
index 4aa4b5bbaf..b6cef1e582 100644
--- a/pkg/types/alertmanagertypes/alertmanagertypestest/state.go
+++ b/pkg/types/alertmanagertypes/alertmanagertypestest/state.go
@@ -29,6 +29,8 @@ func (s *StateStore) Set(ctx context.Context, orgID string, storeableState *aler
}
func (s *StateStore) Get(ctx context.Context, orgID string) (*alertmanagertypes.StoreableState, error) {
+ s.mtx.RLock()
+ defer s.mtx.RUnlock()
if _, ok := s.states[orgID]; !ok {
return nil, errors.Newf(errors.TypeNotFound, alertmanagertypes.ErrCodeAlertmanagerStateNotFound, "state for orgID %q not found", orgID)
}