diff --git a/k8s/metrics/jaeger/jaeger.yaml b/k8s/metrics/jaeger/jaeger.yaml index 18d93a4019..1be95339b4 100644 --- a/k8s/metrics/jaeger/jaeger.yaml +++ b/k8s/metrics/jaeger/jaeger.yaml @@ -20,7 +20,7 @@ metadata: spec: strategy: allInOne allInOne: - image: jaegertracing/all-in-one:latest + image: jaegertracing/all-in-one:1.31 options: log-level: debug # spec for jaeger-collector components. diff --git a/rust/Cargo.toml b/rust/Cargo.toml index 6121c82c41..fe06a917b1 100644 --- a/rust/Cargo.toml +++ b/rust/Cargo.toml @@ -18,6 +18,7 @@ members = [ "libs/observability", "libs/proto", "bin/meta", + "bin/test", # "bin/agent", # "libs/algorithm", # "libs/algorithms/ngt", diff --git a/rust/bin/meta/src/main.rs b/rust/bin/meta/src/main.rs index c45b471783..43efc37b0e 100644 --- a/rust/bin/meta/src/main.rs +++ b/rust/bin/meta/src/main.rs @@ -74,7 +74,7 @@ async fn main() -> Result<(), Box> { .attribute("target_node", "target_node") .attribute("exported_kubernetes_namaspace", "default") .attribute("kubernetes_name", "vald-lb-gateway") - .endpoint("127.0.0.1:4318") + .endpoint("http://127.0.0.1:4318") .tracer(Tracer::new().enabled(true)); let mut observability = ObservabilityImpl::new(observability_cfg)?; diff --git a/rust/bin/test_client/Cargo.toml b/rust/bin/test_client/Cargo.toml new file mode 100644 index 0000000000..f91baab0c6 --- /dev/null +++ b/rust/bin/test_client/Cargo.toml @@ -0,0 +1,15 @@ +[package] +name = "test" +version = "0.1.0" +edition = "2021" + +[dependencies] +kv = "0.24.0" +opentelemetry = "0.25.0" +prost-types = "0.13.2" +proto = { version = "0.1.0", path = "../../libs/proto" } +sled = "0.34.7" +tokio = { version = "1.40.0", features = ["full"] } +tonic = "0.12.2" +observability = { path = "../../libs/observability" } +defer = "0.2.1" diff --git a/rust/bin/test_client/src/main.rs b/rust/bin/test_client/src/main.rs new file mode 100644 index 0000000000..7b408b906a --- /dev/null +++ b/rust/bin/test_client/src/main.rs @@ -0,0 +1,191 @@ +use proto::meta::v1::meta_client::MetaClient; +use proto::payload::v1::meta; +use prost_types::Any; +use opentelemetry::global; +use opentelemetry::propagation::Injector; +use tonic::metadata::MetadataMap; +use tonic::Request; + +// MetadataInjector構造体を定義して、Injectorトレイトを実装する +struct MetadataInjector<'a>(&'a mut MetadataMap); + +impl<'a> Injector for MetadataInjector<'a> { + fn set(&mut self, key: &str, value: String) { + // keyを所有権を持つ文字列に変換してから、挿入する + let key_owned = key.to_owned(); // Stringに変換 + let parsed_key = key_owned.parse::>().unwrap(); + self.0.insert(parsed_key, value.parse().unwrap()); + } +} + +// ジェネリック型を用いたトレースコンテキストの挿入関数 +fn inject_trace_context(request: &mut Request) { + let metadata = request.metadata_mut(); // mutは不要 + let mut injector = MetadataInjector(metadata); // injectorをミュータブルに + + // Contextの取得 + let current_context = opentelemetry::Context::current(); + + // グローバルプロパゲータを使ってトレースコンテキストを挿入 + global::get_text_map_propagator(|propagator| { + propagator.inject_context(¤t_context, &mut injector); // injectorをミュータブルで渡す + }); +} + +#[tokio::main] +async fn main() -> Result<(), Box> { + // gRPC サーバーに接続するクライアントを作成 + let mut client = MetaClient::connect("http://[::1]:8081").await?; + + // 1. set key: aaa, value: 1 + let any_value = Any { + type_url: "".to_string(), // 型URLを設定(必要なら適切なURLに) + value: b"1".to_vec(), // Vec を prost_types::Any に変換 + }; + let mut request = tonic::Request::new(meta::KeyValue { + key: Some(meta::Key{key: "aaa".to_string()}), + value: Some(meta::Value { value: Some(any_value) }), + }); + // トレースコンテキストをリクエストに挿入 + inject_trace_context(&mut request); + client.set(request).await?; + println!("Set key: aaa, value: 1"); + + // 2. set key: bbb, value: 2 + let any_value = Any { + type_url: "".to_string(), // 型URLを設定 + value: b"2".to_vec(), + }; + let mut request = tonic::Request::new(meta::KeyValue { + key: Some(meta::Key{key: "bbb".to_string()}), + value: Some(meta::Value { value: Some(any_value) }), + }); + inject_trace_context(&mut request); // トレースコンテキストを挿入 + client.set(request).await?; + println!("Set key: bbb, value: 2"); + + // 3. get key: bbb + let mut request = tonic::Request::new(meta::Key { + key: "bbb".to_string(), + }); + inject_trace_context(&mut request); // トレースコンテキストを挿入 + let response = client.get(request).await?; + println!("Get key: bbb, RESPONSE={:?}", response.into_inner()); + + // 4. set key: bbb, value: 3 + let any_value = Any { + type_url: "".to_string(), + value: b"3".to_vec(), + }; + let mut request = tonic::Request::new(meta::KeyValue { + key: Some(meta::Key{key: "bbb".to_string()}), + value: Some(meta::Value { value: Some(any_value) }), + }); + inject_trace_context(&mut request); // トレースコンテキストを挿入 + client.set(request).await?; + println!("Set key: bbb, value: 3"); + + // 5. get key: bbb + let mut request = tonic::Request::new(meta::Key { + key: "bbb".to_string(), + }); + inject_trace_context(&mut request); // トレースコンテキストを挿入 + let response = client.get(request).await?; + println!("Get key: bbb, RESPONSE={:?}", response.into_inner()); + + // 6. delete key: aaa + let mut request = tonic::Request::new(meta::Key { + key: "aaa".to_string(), + }); + inject_trace_context(&mut request); // トレースコンテキストを挿入 + client.delete(request).await?; + println!("Deleted key: aaa"); + + // 7. get key: aaa (after deletion) + let mut request = tonic::Request::new(meta::Key { + key: "aaa".to_string(), + }); + inject_trace_context(&mut request); // トレースコンテキストを挿入 + let response = client.get(request).await; + match response { + Ok(res) => println!("Get key: aaa, RESPONSE={:?}", res.into_inner()), + Err(e) => println!("Get key: aaa failed with error: {:?}", e), + } + + Ok(()) +} + +// #[tokio::main] +// async fn main() -> Result<(), Box> { +// // gRPC サーバーに接続するクライアントを作成 +// let mut client = MetaClient::connect("http://[::1]:8081").await?; + +// // 1. set key: aaa, value: 1 +// let any_value = Any { +// type_url: "".to_string(), // 型URLを設定(必要なら適切なURLに) +// value: b"1".to_vec(), // Vec を prost_types::Any に変換 +// }; +// let request = tonic::Request::new(meta::KeyValue { +// key: Some(meta::Key{key: "aaa".to_string()}), +// value: Some(meta::Value { value: Some(any_value) }), +// }); +// client.set(request).await?; +// println!("Set key: aaa, value: 1"); + +// // 2. set key: bbb, value: 2 +// let any_value = Any { +// type_url: "".to_string(), // 型URLを設定 +// value: b"2".to_vec(), +// }; +// let request = tonic::Request::new(meta::KeyValue { +// key: Some(meta::Key{key: "bbb".to_string()}), +// value: Some(meta::Value { value: Some(any_value) }), +// }); +// client.set(request).await?; +// println!("Set key: bbb, value: 2"); + +// // 3. get key: bbb +// let request = tonic::Request::new(meta::Key { +// key: "bbb".to_string(), +// }); +// let response = client.get(request).await?; +// println!("Get key: bbb, RESPONSE={:?}", response.into_inner()); + +// // 4. set key: bbb, value: 3 +// let any_value = Any { +// type_url: "".to_string(), +// value: b"3".to_vec(), +// }; +// let request = tonic::Request::new(meta::KeyValue { +// key: Some(meta::Key{key: "bbb".to_string()}), +// value: Some(meta::Value { value: Some(any_value) }), +// }); +// client.set(request).await?; +// println!("Set key: bbb, value: 3"); + +// // 5. get key: bbb +// let request = tonic::Request::new(meta::Key { +// key: "bbb".to_string(), +// }); +// let response = client.get(request).await?; +// println!("Get key: bbb, RESPONSE={:?}", response.into_inner()); + +// // 6. delete key: aaa +// let request = tonic::Request::new(meta::Key { +// key: "aaa".to_string(), +// }); +// client.delete(request).await?; +// println!("Deleted key: aaa"); + +// // 7. get key: aaa (after deletion) +// let request = tonic::Request::new(meta::Key { +// key: "aaa".to_string(), +// }); +// let response = client.get(request).await; +// match response { +// Ok(res) => println!("Get key: aaa, RESPONSE={:?}", res.into_inner()), +// Err(e) => println!("Get key: aaa failed with error: {:?}", e), +// } + +// Ok(()) +// } \ No newline at end of file diff --git a/versions/JAEGER_OPERATOR_VERSION b/versions/JAEGER_OPERATOR_VERSION index 5f46e11eed..d66b738716 100644 --- a/versions/JAEGER_OPERATOR_VERSION +++ b/versions/JAEGER_OPERATOR_VERSION @@ -1 +1 @@ -2.56.0 +2.51.0