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

[ENH]: add metric for total # of uncompacted log records #2696

Merged
merged 7 commits into from
Aug 23, 2024

Conversation

codetheweb
Copy link
Contributor

@codetheweb codetheweb commented Aug 21, 2024

Description of changes

Adds a new metric, emitted by the log service, that describes the total number of uncompacted log records. Here's what it looks like during test_sanity.py:

Screenshot 2024-08-21 at 10 02 53 AM

In service of this, I also added several resources to the local Tilt stack: the OpenTelemetry collector, Prometheus, and Grafana. These help debug and explore metrics as Jaeger unfortunately only does traces. All the containers are fairly lightweight and add about 200MB of memory consumption. I'm open to punting adding these local observability containers, but I think they will be useful when we start sampling traces and likely adding additional metrics to make up for the lost granularity.

Alternatives:

  • Emit a span event with a numerical attribute instead of a metric. Non-standard but works with Honeycomb. Originally chose not to do this as I was trying to get the below to work.
  • Emit metric per collection_id: would have liked to do this, but requires some careful consideration to avoid emitting 1 event per collection every 10s (or whatever interval we choose). OpenTelemetry supports instruments that only transmit a delta at each collection interval, so I think this should be possible.

Test plan

How are these changes tested?

Confirmed new metric works with Grafana.

Documentation Changes

Are all docstrings for user-facing APIs updated if required? Do we need to make documentation changes in the docs repository?

n/a

Copy link

Reviewer Checklist

Please leverage this checklist to ensure your code review is thorough before approving

Testing, Bugs, Errors, Logs, Documentation

  • Can you think of any use case in which the code does not behave as intended? Have they been tested?
  • Can you think of any inputs or external events that could break the code? Is user input validated and safe? Have they been tested?
  • If appropriate, are there adequate property based tests?
  • If appropriate, are there adequate unit tests?
  • Should any logging, debugging, tracing information be added or removed?
  • Are error messages user-friendly?
  • Have all documentation changes needed been made?
  • Have all non-obvious changes been commented?

System Compatibility

  • Are there any potential impacts on other parts of the system or backward compatibility?
  • Does this change intersect with any items on our roadmap, and if so, is there a plan for fitting them together?

Quality

  • Is this code of a unexpectedly high quality (Readability, Modularity, Intuitiveness)

@@ -85,9 +79,14 @@ k8s_yaml([

# Extra stuff to make debugging and testing easier
k8s_yaml([
'k8s/test/namespace.yaml',
Copy link
Contributor Author

Choose a reason for hiding this comment

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

resources in ks_yaml(...) take global precedence over anything else defined in the Tiltfile, so I moved namespace creation here so that it's available for these resources
(creation of the new configmaps was erroring in CI, but not locally for some reason)

@codetheweb codetheweb marked this pull request as ready for review August 21, 2024 17:40
@@ -33,3 +33,6 @@ INSERT INTO collection (id, record_enumeration_offset_position, record_compactio

-- name: PurgeRecords :exec
DELETE FROM record_log r using collection c where r.collection_id = c.id and r.offset <= c.record_compaction_offset_position;

-- name: GetTotalUncompactedRecordsCount :one
SELECT SUM(record_enumeration_offset_position - record_compaction_offset_position) AS total_uncompacted_depth FROM collection;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is there any concern of this query being slow / hogging too much of the node? Maybe we could consider this to move to a read replica if so (in future), since it would be OK with data log.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think it should be ok for now, takes 5-7ms to execute. But good to keep in mind.

Copy link
Collaborator

@HammadB HammadB left a comment

Choose a reason for hiding this comment

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

Makes sense to me, I think we should just use the same leader fwiw

@codetheweb codetheweb merged commit 69d1320 into main Aug 23, 2024
67 checks passed
@codetheweb codetheweb deleted the feat-compaction-queue-depth branch August 23, 2024 00:48
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.

2 participants