Skip to content

Feat/buffered data metric#31

Merged
colmsnowplow merged 14 commits into
release/1.7.0from
feat/buffered-data-metric
Sep 10, 2025
Merged

Feat/buffered data metric#31
colmsnowplow merged 14 commits into
release/1.7.0from
feat/buffered-data-metric

Conversation

@colmsnowplow

Copy link
Copy Markdown

No description provided.

Comment thread statreceiver.go Outdated
Comment thread kinsumer.go Outdated
record.checkpointer.update(aws.ToString(record.record.SequenceNumber))
}
atomic.AddInt64(&k.recordsInMemoryCount, -1)
atomic.AddInt64(&k.bytesInMemoryCount, -record.payloadBytes)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Do we need an atomic process or can we just throw these values into channels that are then consumed out of the critical path? Worried this will add quite a bit of locking to what is currently a multi-threaded processing loop right?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Oh I think I follow that suggestion - yeah that's possibly better will have a go at that design

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

OK, pushed a refactor that I think resolves this, but keeps channel usage overhead to a minimum as well. LMK what you think!

Comment thread statsd/statsd.go
// RecordsInMemoryBytes implementation that writes to statsd a gauge metric about
// the current total payload bytes buffered in memory
func (s *Statsd) RecordsInMemoryBytes(bytes int64) {
_ = s.client.Gauge("kinsumer.records_in_memory_bytes", bytes, 1.0)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

If you want these exported out to cloudwatch the metrics need to be prefixed with "snowplow." - not sure how we are currently dealing with the kinsumer metrics today?

@colmsnowplow colmsnowplow Sep 4, 2025

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

We currently don't configure it, so we don't get kinsumer metrics.

I'll take a look into it, might need to add a prefix to the config, thanks for flagging. Edit: we just pass the same statsd client through to kinsumer, and we'll get the prefixed metrics :)

On this note - if I enable all of these into statsd, do they all automatically get sent through to cloudwatch etc?

Or is it a case of us having downstream control of what we funnel through to the customer infra, to manage costs?

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

They would all go through - there is no filtering in container monitor

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

If you want to be cost conscious you would need to have a code-level control to say which metrics to send out (or not)

Base automatically changed from feat/maxConcurrentShards to release/1.7.0 September 5, 2025 13:13
@colmsnowplow
colmsnowplow force-pushed the feat/buffered-data-metric branch from e2562b9 to 65d6668 Compare September 5, 2025 16:53
@colmsnowplow
colmsnowplow force-pushed the feat/buffered-data-metric branch from 65d6668 to 75e8722 Compare September 9, 2025 16:20
@colmsnowplow

colmsnowplow commented Sep 10, 2025

Copy link
Copy Markdown
Author

I've merged two PRs into this one, each reviewed individually. To tweak impementation, add a test, and add a config for filtering metrics out (and then a PR to clean up that config with a much nicer pattern).

Since everything's reviewed, and these changes shouldn't be critical to functionality, I don't think it's necessary to put people through the pain of re-reviewing this one.

It will all be reviewed again in final release PR. Assuming no CI testing issues, I'll squash and merge into release branch

@colmsnowplow
colmsnowplow merged commit 95ee9f8 into release/1.7.0 Sep 10, 2025
1 check passed
@colmsnowplow
colmsnowplow deleted the feat/buffered-data-metric branch September 10, 2025 13:02
colmsnowplow added a commit that referenced this pull request Sep 12, 2025
* Initial metrics implementation for tracking record in memory

* Buffer metrics before sending

* Fix metrics to account for pre-buffer in-memory data

* Add a metric which measures memory backlog

* Use int64 everywhere for recordsInMemory metric

* Use channel instead of atomics to avoid possible contention

* Log warnings if we drop metrics

* Combine the updates to reduce channel traffic overhead

* Reduce channel activity/overhead with a batching mechanic

* Use a smaller channel and log immediately if blocked

* Buffer metrics every second

* Add test of new metrics implementation

* Add config to filter metrics

* Make metrics config cleaner (#35)

* Make metrics config cleaner

* go fmt
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.

3 participants