Skip to content

Commit 73f6b7d

Browse files
committed
chore: switch to compact greptimedb rust client
1 parent 3c2cd6f commit 73f6b7d

File tree

5 files changed

+41
-30
lines changed

5 files changed

+41
-30
lines changed

.github/actions/spelling/allow.txt

+2
Original file line numberDiff line numberDiff line change
@@ -294,6 +294,8 @@ gpg
294294
gql
295295
grafana
296296
graphiql
297+
greptime
298+
greptimedb
297299
gvisor
298300
gws
299301
hadoop

Cargo.lock

+31
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,7 @@ hex = { version = "0.4.3", default-features = false, optional = true }
229229
sha2 = { version = "0.10.6", default-features = false, optional = true }
230230

231231
# Greptime
232-
greptimedb-client = { git = "https://github.com/GreptimeTeam/greptimedb.git", rev = "b5e5f8e555065da0ba1d3f13b6b76fad59cb4017", package = "client", optional = true }
232+
greptimedb-client = { git = "https://github.com/GreptimeTeam/greptimedb-client-rust.git", rev = "2b5d575fd4aaff2955b20e59e752e1eba71c4b75", package = "greptimedb-client-rust", optional = true }
233233

234234
# VRL Lang
235235
vrl = { package = "vrl", git = "https://github.com/vectordotdev/vrl", rev = "v0.2.0" }

sample.toml

-19
This file was deleted.

src/sinks/greptimedb/client.rs

+7-10
Original file line numberDiff line numberDiff line change
@@ -122,8 +122,6 @@ impl Service<Vec<Metric>> for GreptimeDBService {
122122

123123
// Convert vector metrics into GreptimeDB format and send them in batch
124124
fn call(&mut self, items: Vec<Metric>) -> Self::Future {
125-
// TODO(sunng87): group metrics by name and send metrics with same name
126-
// in batch
127125
let requests = items.into_iter().map(metric_to_insert_request);
128126
let client = Arc::clone(&self.client);
129127

@@ -187,7 +185,7 @@ fn metric_to_insert_request(metric: Metric) -> InsertRequest {
187185
};
188186

189187
let mut columns = Vec::new();
190-
// timetamp
188+
// timestamp
191189
let timestamp = metric
192190
.timestamp()
193191
.map(|t| t.timestamp_millis())
@@ -267,7 +265,6 @@ fn encode_histogram(buckets: &[Bucket], columns: &mut Vec<Column>) {
267265
fn encode_quantiles(quantiles: &[Quantile], columns: &mut Vec<Column>) {
268266
for quantile in quantiles {
269267
let column_name = format!("p{:02}", quantile.quantile * 100f64);
270-
dbg!(&column_name);
271268
columns.push(f64_field(&column_name, quantile.value));
272269
}
273270
}
@@ -328,7 +325,7 @@ mod tests {
328325
MetricValue::Gauge { value: 1.1 },
329326
)
330327
.with_namespace(Some("ns"))
331-
.with_tags(Some([("host".to_owned(), "thinkneo".to_owned())].into()))
328+
.with_tags(Some([("host".to_owned(), "thinkpad".to_owned())].into()))
332329
.with_timestamp(Some(Utc::now()));
333330

334331
let insert = metric_to_insert_request(metric);
@@ -413,7 +410,7 @@ mod tests {
413410
#[test]
414411
fn test_histogram() {
415412
let metric = Metric::new(
416-
"cpu_seconds_totoal",
413+
"cpu_seconds_total",
417414
MetricKind::Incremental,
418415
MetricValue::AggregatedHistogram {
419416
buckets: vector_core::buckets![1.0 => 1, 2.0 => 2, 3.0 => 1],
@@ -434,7 +431,7 @@ mod tests {
434431
#[test]
435432
fn test_summary() {
436433
let metric = Metric::new(
437-
"cpu_seconds_totoal",
434+
"cpu_seconds_total",
438435
MetricKind::Incremental,
439436
MetricValue::AggregatedSummary {
440437
quantiles: vector_core::quantiles![0.01 => 1.5, 0.5 => 2.0, 0.99 => 3.0],
@@ -493,7 +490,7 @@ mod integration_tests {
493490
std::env::var("GREPTIMEDB_HTTP")
494491
.unwrap_or_else(|_| "http://localhost:4000".to_owned())
495492
))
496-
.query(&[("sql", "SELECT region, value FROM ms_mycounter")])
493+
.query(&[("sql", "SELECT region, value FROM ns_my_counter")])
497494
.send()
498495
.await
499496
.unwrap()
@@ -506,7 +503,7 @@ mod integration_tests {
506503
result
507504
.pointer("/output/0/records/rows")
508505
.and_then(|v| v.as_array())
509-
.expect("Error getting greptimedb resposne array")
506+
.expect("Error getting greptimedb response array")
510507
.len(),
511508
10
512509
)
@@ -519,7 +516,7 @@ mod integration_tests {
519516
fn create_event(i: i32) -> Event {
520517
Event::Metric(
521518
Metric::new(
522-
format!("mycounter"),
519+
format!("my_counter"),
523520
MetricKind::Incremental,
524521
MetricValue::Counter { value: i as f64 },
525522
)

0 commit comments

Comments
 (0)