Riapplica la fase 5 di aKode (86e7c72e) sulla base ripulita:
- crate codex-* -> akode-*, codex-rs -> akode-rs, codex-cli -> akode-cli, binario e ausiliari akode;
- ~/.codex -> ~/.akode, CODEX_HOME -> AKODE_HOME, variabili CODEX_* -> AKODE_*, .codex/ -> .akode/ di progetto;
nessun fallback a ~/.codex o a CODEX_*;
- testi per l'utente "Codex" -> "aKode"; testi verso il modello e istruzioni di sistema invariati;
- snapshot insta rinominati (non ancora rigenerati).
I conflitti con la base ripulita sono stati risolti riapplicando la rinomina ai file senza le
funzioni di imeAI (script di mappa dei token per file).
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
71 lines
2.1 KiB
Rust
71 lines
2.1 KiB
Rust
//! Exercises global operation buffering across shutdown and replacement installations.
|
|
|
|
use akode_otel::MetricsClient;
|
|
use akode_otel::MetricsConfig;
|
|
use akode_otel::install_global_metrics;
|
|
use akode_otel::record_global_operation;
|
|
use opentelemetry_sdk::metrics::data::AggregatedMetrics;
|
|
use opentelemetry_sdk::metrics::data::MetricData;
|
|
use pretty_assertions::assert_eq;
|
|
use std::time::Duration;
|
|
|
|
fn install() -> MetricsClient {
|
|
install_global_metrics(
|
|
MetricsClient::new(
|
|
MetricsConfig::in_memory("test", "test", "1", Default::default()).with_runtime_reader(),
|
|
)
|
|
.expect("build in-memory metrics"),
|
|
)
|
|
}
|
|
|
|
fn observe() {
|
|
record_global_operation(
|
|
"test.operations",
|
|
"test.duration",
|
|
Duration::from_millis(/*millis*/ 7),
|
|
&[],
|
|
)
|
|
.expect("record an operation");
|
|
}
|
|
|
|
fn totals(metrics: &MetricsClient) -> (u64, u64, f64) {
|
|
let snapshot = metrics.snapshot().expect("collect runtime metrics");
|
|
let mut totals = (0, 0, 0.0);
|
|
for metric in snapshot
|
|
.scope_metrics()
|
|
.flat_map(opentelemetry_sdk::metrics::data::ScopeMetrics::metrics)
|
|
{
|
|
match metric.data() {
|
|
AggregatedMetrics::U64(MetricData::Sum(sum)) => {
|
|
totals.0 += sum
|
|
.data_points()
|
|
.map(opentelemetry_sdk::metrics::data::SumDataPoint::value)
|
|
.sum::<u64>();
|
|
}
|
|
AggregatedMetrics::F64(MetricData::Histogram(histogram)) => {
|
|
for point in histogram.data_points() {
|
|
totals.1 += point.count();
|
|
totals.2 += point.sum();
|
|
}
|
|
}
|
|
_ => panic!("unexpected metric"),
|
|
}
|
|
}
|
|
totals
|
|
}
|
|
|
|
#[test]
|
|
fn shutdown_buffers_until_replacement_and_preserves_newer_installations() {
|
|
let first = install();
|
|
first.shutdown().unwrap();
|
|
observe();
|
|
let second = install();
|
|
assert_eq!(totals(&second), (1, 1, 7.0));
|
|
|
|
let third = install();
|
|
second.shutdown().unwrap();
|
|
observe();
|
|
assert_eq!(totals(&third), (1, 1, 7.0));
|
|
third.shutdown().unwrap();
|
|
}
|