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

Migrated IO metrics from Counter to ObservableCounter instrument (DB-85) #3834

Merged
merged 1 commit into from
May 11, 2023

Conversation

hunter1703
Copy link
Contributor

@hunter1703 hunter1703 commented May 9, 2023

Changed : IO metrics using Counter instrument to ObservableCounter instrument

@hunter1703 hunter1703 self-assigned this May 9, 2023
@hunter1703 hunter1703 changed the title Migrated IO metrics from Counter to ObservableCounter instrument Migrated IO metrics from Counter to ObservableCounter instrument (DB-85) May 9, 2023
@linear
Copy link

linear bot commented May 9, 2023

DB-85 Convert eventstore-io counters to use ObservableCounter

There are currently two Counters in MetricsBootstrapper that we call Add on frequently (whenever we read or write events)

		var byteMetric = coreMeter.CreateCounter<long>("eventstore-io", unit: "bytes");
		var eventMetric = coreMeter.CreateCounter<long>("eventstore-io", unit: "events");

We want these to be ObservableCounters that work similarly to StatusMetric. We will probably want a new class (CounterMetric?) that creates the ObservableCounter just like StatusMetric does.

The trackers (TFChunkTracker and IndexTracker) will write to the CounterSubMetrics as they do currently, but the CounterSubMetrics will Interlocked.Increment a value that is then Observed by the CounterMetric that they are registered with.

The purpose of the trackers (TFChunkTracker and IndexTracker) is to provide a trivial API to encapsulate the operation of the metrics away from the user of the tracker.

The purpose of the CounterSubMetric is to contain the data and the tags to be observed when the metric is observed (so that it doesn't have to be repeated in each tracker)

The purpose of the CounterMetric is to create the ObservableCounter such that it observes each submetric registered to it.

The effect here is that when we read/write events we are only making Interlocked.Increment calls which, it turns out, are ~10x cheaper than calling Add on a counter with tags. The observation is likely more expensive, but we only incur this cost once per scrape (typically once every 15s)

@hunter1703 hunter1703 force-pushed the observable-counter-for-io-metrics branch from 1b0139e to 59ec224 Compare May 9, 2023 16:09
@hunter1703 hunter1703 force-pushed the observable-counter-for-io-metrics branch from 59ec224 to 01b30d7 Compare May 10, 2023 13:25
@timothycoleman
Copy link
Contributor

looks good 👍 can be squashed

@hunter1703 hunter1703 force-pushed the observable-counter-for-io-metrics branch from 92297cc to 2a1f904 Compare May 11, 2023 02:55
Copy link
Contributor

@timothycoleman timothycoleman left a comment

Choose a reason for hiding this comment

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

👍

@timothycoleman timothycoleman merged commit d9de9f4 into master May 11, 2023
7 of 8 checks passed
@timothycoleman timothycoleman deleted the observable-counter-for-io-metrics branch May 11, 2023 06:19
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.

None yet

3 participants