Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: make label names uniform #596

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions internal/checks/checks.go
Original file line number Diff line number Diff line change
Expand Up @@ -612,7 +612,7 @@ func (c *Updater) handleCheckUpdateWithLock(ctx context.Context, check model.Che

scraper, found := c.scrapers[cid]
if !found {
c.logger.Warn().Int64("check_id", check.Id).Int("region_id", check.RegionId).Msg("update request for an unknown check")
c.logger.Warn().Int64("checkId", check.Id).Int("regionId", check.RegionId).Msg("update request for an unknown check")
return c.addAndStartScraperWithLock(ctx, check)
}

Expand All @@ -638,7 +638,7 @@ func (c *Updater) handleCheckDelete(ctx context.Context, check model.Check) erro

scraper, found := c.scrapers[cid]
if !found {
c.logger.Warn().Int64("check_id", check.Id).Int("region_id", check.RegionId).Msg("delete request for an unknown check")
c.logger.Warn().Int64("checkId", check.Id).Int("regionId", check.RegionId).Msg("delete request for an unknown check")
return errors.New("check not found")
}

Expand Down Expand Up @@ -687,7 +687,7 @@ func (c *Updater) handleFirstBatch(ctx context.Context, changes *sm.Changes) {

if err := c.handleInitialChangeAddWithLock(ctx, check); err != nil {
c.metrics.changeErrorsCounter.WithLabelValues("add").Inc()
c.logger.Error().Err(err).Int64("check_id", check.Id).Int("region_id", check.RegionId).
c.logger.Error().Err(err).Int64("checkId", check.Id).Int("regionId", check.RegionId).
Msg("adding check failed, dropping check")
continue
}
Expand Down Expand Up @@ -715,8 +715,8 @@ func (c *Updater) handleFirstBatch(ctx context.Context, changes *sm.Changes) {

cid, rid := model.GetLocalAndRegionIDs(id)
c.logger.Debug().
Int64("check_id", cid).
Int("region_id", rid).
Int64("checkId", cid).
Int("regionId", rid).
Msg("stopping scraper during first batch handling")

checkType := scraper.CheckType().String()
Expand Down
10 changes: 5 additions & 5 deletions internal/pusher/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@ type Metrics struct {
}

var (
labelsWithTenantType = []string{"regionID", "tenantID", "type"}
labelsWithTenantTypeStatus = []string{"regionID", "tenantID", "type", "status"}
labelsWithTenantTypeReason = []string{"regionID", "tenantID", "type", "reason"}
labelsWithTenantType = []string{"regionId", "tenantId", "type"}
labelsWithTenantTypeStatus = []string{"regionId", "tenantId", "type", "status"}
labelsWithTenantTypeReason = []string{"regionId", "tenantId", "type", "reason"}
)

// NewMetrics returns a new set of publisher metrics registered in the given registerer.
Expand Down Expand Up @@ -132,8 +132,8 @@ func NewMetrics(promRegisterer prometheus.Registerer) (m Metrics) {
// already included.
func (m Metrics) WithTenant(localID int64, regionID int) Metrics {
labels := prometheus.Labels{
"regionID": strconv.FormatInt(int64(regionID), 10),
"tenantID": strconv.FormatInt(localID, 10),
"regionId": strconv.FormatInt(int64(regionID), 10),
"tenantId": strconv.FormatInt(localID, 10),
}
return Metrics{
PushCounter: m.PushCounter.MustCurryWith(labels),
Expand Down
2 changes: 1 addition & 1 deletion internal/pusher/v1/pusher.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ func (p *publisherImpl) publish(ctx context.Context, payload pusher.Payload) {
tenantStr = strconv.FormatInt(localID, 10)

newClient = false
logger = p.logger.With().Int("region", regionID).Int64("tenant", localID).Logger()
logger = p.logger.With().Int("regionId", regionID).Int64("tenantId", localID).Logger()
)

streams := payload.Streams()
Expand Down
2 changes: 1 addition & 1 deletion internal/pusher/v2/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ type pusherOptions struct {

func (o pusherOptions) withTenant(id model.GlobalID) pusherOptions {
localID, regionID := model.GetLocalAndRegionIDs(id)
o.logger = o.logger.With().Int("region", regionID).Int64("tenant", localID).Logger()
o.logger = o.logger.With().Int("regionId", regionID).Int64("tenantId", localID).Logger()
o.metrics = o.metrics.WithTenant(localID, regionID)
return o
}
Expand Down
6 changes: 3 additions & 3 deletions internal/pusher/v2/publisher.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,14 +62,14 @@ func (p *publisherImpl) Publish(payload pusher.Payload) {

func (p *publisherImpl) runHandler(tenantID model.GlobalID, h payloadHandler) {
tid, rid := model.GetLocalAndRegionIDs(tenantID)
p.options.logger.Info().Int64("tenant_id", tid).Int("region_id", rid).Msg("started push handler")
defer p.options.logger.Info().Int64("tenant_id", tid).Int("region_id", rid).Msg("stopped push handler")
p.options.logger.Info().Int64("tenantId", tid).Int("regionId", rid).Msg("started push handler")
defer p.options.logger.Info().Int64("tenantId", tid).Int("regionId", rid).Msg("stopped push handler")

for ok := true; ok && h != nil; {
next := h.run(p.ctx)
h, ok = p.replaceHandler(tenantID, h, next)
if !ok {
p.options.logger.Error().Int64("tenant_id", tid).Int("region_id", rid).Msg("unable to swap handler, tenant hijacked")
p.options.logger.Error().Int64("tenantId", tid).Int("regionId", rid).Msg("unable to swap handler, tenant hijacked")
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions internal/scraper/scraper.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,9 +122,9 @@ func NewWithOpts(ctx context.Context, check model.Check, opts ScraperOpts) (*Scr
checkName := check.Type().String()

logger := opts.Logger.With().
Int("region_id", check.RegionId).
Int("regionId", check.RegionId).
Int64("tenantId", check.TenantId).
Int64("check_id", check.Id).
Int64("checkId", check.Id).
Str("probe", opts.Probe.Name).
Str("target", check.Target).
Str("job", check.Job).
Expand Down
Loading