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:fix data race bug when collecting metrics #402

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Sniper91
Copy link

@Sniper91 Sniper91 commented Aug 29, 2023

reproduce procedure

  1. run kafka exporter with race detector
go run -race ./  --kafka.server localhost:9092
  1. request kafka metrics frequently
curl http://localhost:9308

output

==================
WARNING: DATA RACE
Read at 0x00c0001ab170 by goroutine 27:
  main.(*Exporter).collectChans()
      /Users/bytedance/opensource/kafka_exporter/kafka_exporter.go:355 +0x366
  main.(*Exporter).Collect.func1()
      /Users/bytedance/opensource/kafka_exporter/kafka_exporter.go:330 +0x5b

Previous write at 0x00c0001ab170 by goroutine 28:
  main.(*Exporter).collectChans.func1()
      /Users/bytedance/opensource/kafka_exporter/kafka_exporter.go:347 +0x267

Goroutine 27 (running) created at:
  main.(*Exporter).Collect()
      /Users/bytedance/opensource/kafka_exporter/kafka_exporter.go:330 +0x517
  github.com/prometheus/client_golang/prometheus.(*Registry).Gather.func1()
      /Users/bytedance/opensource/kafka_exporter/vendor/github.com/prometheus/client_golang/prometheus/registry.go:455 +0x245

Goroutine 28 (finished) created at:
  main.(*Exporter).collectChans()
      /Users/bytedance/opensource/kafka_exporter/kafka_exporter.go:345 +0x253
  main.(*Exporter).Collect.func1()
      /Users/bytedance/opensource/kafka_exporter/kafka_exporter.go:330 +0x5b
==================

@Sniper91 Sniper91 marked this pull request as draft August 29, 2023 03:52
@Sniper91 Sniper91 marked this pull request as ready for review August 29, 2023 03:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant