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

Consolidate honeycomb metrics to use single lock & fix concurrent read/write #511

Merged
merged 7 commits into from
Sep 14, 2022

Conversation

MikeGoldsmith
Copy link
Contributor

@MikeGoldsmith MikeGoldsmith commented Sep 12, 2022

Which problem is this PR solving?

Honeycomb metrics currently utilises 3 locks, one for each map of counters, gauges and histograms and is unnecessary. In addition, the locks were only used when registering each metric and collecting metrics values - they were missing the lock to retrieve an entry for updating which risks a read / write error.

This PR updates honeycomb metrics to utilise a single lock that is used to control all three types of metrics and is also used when attempting to retrieve a metric from a map.

Short description of the changes

  • Consolidate the 3 locks into a single lock
  • Use lock when attempting to retrieve an existing metric from one of the maps to prevent concurrent read / write panics

@MikeGoldsmith MikeGoldsmith added type: bug Something isn't working version: bump patch A PR with release-worthy changes and is backwards-compatible. labels Sep 12, 2022
@MikeGoldsmith MikeGoldsmith requested a review from a team September 12, 2022 14:05
@MikeGoldsmith MikeGoldsmith self-assigned this Sep 12, 2022
metrics/honeycomb.go Outdated Show resolved Hide resolved
metrics/honeycomb.go Outdated Show resolved Hide resolved
metrics/honeycomb.go Outdated Show resolved Hide resolved
Copy link
Contributor

@vreynolds vreynolds left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, one small change for the read unlock

metrics/honeycomb.go Outdated Show resolved Hide resolved
Co-authored-by: Vera Reynolds <vreynolds@users.noreply.github.com>
Copy link
Contributor

@vreynolds vreynolds left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔒 🎇

Copy link
Contributor

@JamieDanielson JamieDanielson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks great! I left a few tiny suggestions as I went through, mostly just for clarification 👍

metrics/honeycomb.go Outdated Show resolved Hide resolved
metrics/honeycomb.go Outdated Show resolved Hide resolved
metrics/honeycomb.go Outdated Show resolved Hide resolved
metrics/honeycomb.go Outdated Show resolved Hide resolved
metrics/honeycomb.go Outdated Show resolved Hide resolved
metrics/honeycomb.go Outdated Show resolved Hide resolved
MikeGoldsmith and others added 2 commits September 14, 2022 11:00
Co-authored-by: Jamie Danielson <jamieedanielson@gmail.com>
Co-authored-by: Jamie Danielson <jamieedanielson@gmail.com>
@MikeGoldsmith MikeGoldsmith merged commit 6302d37 into main Sep 14, 2022
@MikeGoldsmith MikeGoldsmith deleted the mike/metrics-locks branch September 14, 2022 10:12
ghost pushed a commit to opsramp/tracing-proxy that referenced this pull request Jul 5, 2024
…d/write (honeycombio#511)

Co-authored-by: Vera Reynolds <vreynolds@users.noreply.github.com>
Co-authored-by: Jamie Danielson <jamieedanielson@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug Something isn't working version: bump patch A PR with release-worthy changes and is backwards-compatible.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Honeycomb metrics panics with concurrent read/write error
3 participants