Skip to content

Conversation

@reivilibre
Copy link
Contributor

@reivilibre reivilibre commented Mar 12, 2025

The logging looks a bit like:

2025-03-12T18:40:05.936000Z  INFO mas_cli::commands::syn2mas: crates/cli/src/commands/syn2mas.rs:303: migrating users: 29/~3798454 (~0.0%)
2025-03-12T18:40:35.938238Z  INFO mas_cli::commands::syn2mas: crates/cli/src/commands/syn2mas.rs:303: migrating users: 59/~3798454 (~0.0%)
2025-03-12T18:41:05.939241Z  INFO mas_cli::commands::syn2mas: crates/cli/src/commands/syn2mas.rs:303: migrating users: 89/~3798454 (~0.0%)

(artificially slowed down)

I did not try the metrics. The HTTP listeners aren't active so Prometheus metrics are no good, you'd have to push them to an OpenTelemetry thing and I didn't bother to do that yet.
That said, I'm not convinced by the value so perhaps it's better to just drop that aspect?

(edit maybe it'd be good to include the word 'progress' in the line there somewhere. Perhaps target: "syn2mas::progress" or something.... not sure what's best. Happy to hear your thoughts on that)

@reivilibre reivilibre requested a review from sandhose March 12, 2025 18:42
@cloudflare-workers-and-pages
Copy link

cloudflare-workers-and-pages bot commented Mar 12, 2025

Deploying matrix-authentication-service-docs with  Cloudflare Pages  Cloudflare Pages

Latest commit: 9228f20
Status: ✅  Deploy successful!
Preview URL: https://c5b41409.matrix-authentication-service-docs.pages.dev
Branch Preview URL: https://rei-syn2mas-progress-counter.matrix-authentication-service-docs.pages.dev

View logs

@reivilibre reivilibre force-pushed the rei/syn2mas_progress_counters branch from 5968aa8 to ebad8a7 Compare March 12, 2025 18:49
Copy link
Member

@sandhose sandhose left a comment

Choose a reason for hiding this comment

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

Generally happy with the approach for the progress logs, I would just do the OTEL meters differently

Comment on lines 318 to 325
let migrated_data_counter = METER
.u64_gauge("migrated_data")
.with_description("How many entities have been migrated so far")
.build();
let max_data_counter = METER
.u64_gauge("max_data")
.with_description("How many entities of the given type exist (approximate)")
.build();
Copy link
Member

Choose a reason for hiding this comment

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

Upping counters directly is probably performant enough? I would make those counters, static with a std::sync::LazyLock and just record every time we insert

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 didn't make them static but maybe this is OK?

Comment on lines 276 to 277
occasional_progress_logger_task.abort();
progress_telemetry_task.abort();
Copy link
Member

Choose a reason for hiding this comment

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

Ideally this would be done through a CancellationToken, I don't particularly like aborting tasks, but since we haven't set that up in the rest of the migration process, I'm happy to keep it like this for now

/// Reports migration progress as OpenTelemetry metrics
async fn progress_telemetry(progress: Progress) {
let migrated_data_counter = METER
.u64_gauge("migrated_data")
Copy link
Member

Choose a reason for hiding this comment

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

Let's use a prefix, plus a common namespace, e.g. syn2mas.data.migrated and syn2mas.data.total. Note that when translated to Prometheus, dots will be replaced by underscores. Feel free to come up something else, this is just a suggestion

Copy link
Contributor Author

Choose a reason for hiding this comment

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

syn2mas.entity... maybe. Don't like how vague these words are but something like 'migratee' is no better haha. I guess it doesn't exactly matter as long as it makes some sense.

@reivilibre reivilibre requested a review from sandhose March 13, 2025 12:29
…trics

Add metrics directly within syn2mas, no background thread
@reivilibre reivilibre force-pushed the rei/syn2mas_progress_counters branch from 6f6c20b to 9228f20 Compare March 13, 2025 14:50
@reivilibre reivilibre enabled auto-merge March 13, 2025 15:00
@reivilibre reivilibre merged commit 5fc97d1 into main Mar 13, 2025
21 checks passed
@reivilibre reivilibre deleted the rei/syn2mas_progress_counters branch March 13, 2025 15:04
@sandhose sandhose added A-Migration Related to the migration tooling T-Task Refactoring, removal, replacement, enabling or disabling functionality, other engineering tasks. labels Apr 14, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-Migration Related to the migration tooling T-Task Refactoring, removal, replacement, enabling or disabling functionality, other engineering tasks.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants