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

DRAFT: metrics sharding handwritten #2304

Closed
wants to merge 9 commits into from
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
handle special case in delta-collect
fraillt committed Nov 22, 2024
commit e2b72734ab19cf154fcd3ec0ad53cef4fae9e05f
26 changes: 24 additions & 2 deletions opentelemetry-sdk/src/metrics/internal/mod.rs
Original file line number Diff line number Diff line change
@@ -220,8 +220,30 @@ where
));
}

for (attrs, tracker) in trackers.into_iter() {
let tracker = Arc::into_inner(tracker).expect("the only instance");
for (attrs, mut tracker) in trackers.into_iter() {
// Handles special case:
// measure-thread: get inserted tracker from `sorted_attribs` (holds tracker)
// collect-thread: replace sorted_attribs (clears sorted_attribs)
// collect-thread: clear all_attribs
// collect_thread: THIS-LOOP: loop until measure-thread still holds a tracker
// measure-thread: insert tracker into `all_attribs``
// collect_thread: exits this loop after clearing trackers
let tracker = loop {
match Arc::try_unwrap(tracker) {
Ok(inner) => {
break inner;
}
Err(reinserted) => {
tracker = reinserted;
for shard in 0..self.shards_count {
match self.all_attribs[shard].write() {
Ok(mut all_trackers) => all_trackers.clear(),
Err(_) => return,
};
}
}
};
};
dest.push(map_fn(attrs.into_inner_owned(), tracker));
}
}