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

dekaf: Implement capturing and appending stats #1923

Closed
wants to merge 14 commits into from

Conversation

jshearer
Copy link
Contributor

@jshearer jshearer commented Feb 4, 2025

Description:

A couple things to note:

  • I originally tried to create a single journal::Client responsible for appending both logs and stats, but I ended up realizing that /authorize/task only allows authoring a token for a single task/prefix at a time. So I took the simpler route of creating two clients, rather than teaching /authorize/task how to handle multiple tasks, which has some fairly delicate requirements.
  • As it turns out, the stats rollups assume the presence of a shard field on both logs and stats. So I ended up needing to craft a ShardRef that just contains the Dekaf materialization name, and attach it to both the logs and stats documents that get emitted.

This change is Reviewable

@jshearer
Copy link
Contributor Author

jshearer commented Feb 4, 2025

Temporarily switching base to master and marking this as non-draft so CI will run and I can get a dev build to test on dekaf-dev. This is actually ontop of #1840

@jshearer jshearer marked this pull request as ready for review February 4, 2025 21:25
@jshearer jshearer changed the base branch from jshearer/dekaf_multi_upstream_brokers to master February 4, 2025 21:25
@jshearer jshearer force-pushed the jshearer/dekaf_stats branch 4 times, most recently from 716b510 to df728d0 Compare February 6, 2025 17:34
…s using `/authorize/dekaf` and `/authorize/task`

Also add a hint for passing a collection name as a topic name, when the binding has renamed that topic
* Connector projections: emit recommended constraints for all fields -- you get everything by default, and you can modify the selection however you like
* Schema: Build a schema from the materialization's built spec's `field_selection` and the collection's projections that will match the extracted documents
* Extraction: Implement field extraction using the `extractors` crate to emit documents that match the "value schema"
@jshearer jshearer force-pushed the jshearer/dekaf_stats branch 2 times, most recently from c53899d to 4b31d7c Compare February 6, 2025 17:56
… a Session and write them to the correct ops logs journal

Also support filtering logs by the requested shard log level
Then implement some tests to validate field selection logic
Part of dekaf: Improvements to handle higher scale #1876, we want to implement broker fallback so Dekaf can connect to any of the brokers in the cluster if one doesn't respond. An improvement here would be to periodically fetch the metadata from at least one of the responding brokers and update this list of addresses so that future sessions can know about/use any newly created members of the cluster. I don't anticipate changing the topology of our cluster that frequently, and if we do then updating Dekaf's deployment configs isn't that big of a deal. I may eat my hat on this, we'll see.

In addition, we want to move people over to the new MSK cluster, so this implements routing new-style connections to a separate cluster with separate credentials.
A couple things to note:

* I originally tried to create a single `journal::Client` responsible for appending both logs and stats, but I ended up realizing that `/authorize/task` only allows authoring a token for a single task/prefix at a time. So I took the simpler route of creating two clients, rather than teaching `/authorize/task` how to handle multiple tasks, which has some fairly delicate requirements.
* As it turns out, the stats rollups assume the presence of a `shard` field on both logs and stats. So I ended up needing to craft a `ShardRef` that just contains the Dekaf materialization name, and attach it to both the logs and stats documents that get emitted.
I noticed that after roughly 1-2 hours, Dekaf would stop writing logs and stats. I tracked that down to an error appending logs, specifically:

```
Grpc(
  Status {
    code: DeadlineExceeded,
    message: "context deadline exceeded"
  }
)
```

It turns out that this is the error Gazette returns when the auth token you pass it is expired, and the appending machinery in Dekaf wasn't taking into account token expiry. So this commit refactors `GazetteWriter` to be composed of two `GazetteAppender`s, one for logs and one for stats. Each `GazetteAppender` is capable of refreshing its internal client when neccesary
@jshearer jshearer force-pushed the jshearer/dekaf_stats branch from 4b31d7c to 88e456f Compare February 7, 2025 17:32
@jshearer
Copy link
Contributor Author

jshearer commented Feb 7, 2025

Rolled into #1840 after all

@jshearer jshearer closed this Feb 7, 2025
@jshearer jshearer deleted the jshearer/dekaf_stats branch February 7, 2025 19:04
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