From db3270ff3997380b6c8e62f947e7bf2b4eab6842 Mon Sep 17 00:00:00 2001 From: Severin Neumann Date: Wed, 7 Feb 2024 14:32:23 +0100 Subject: [PATCH] [IA] Auto-Update rust versions in docs from registry (#3944) Signed-off-by: svrnm Co-authored-by: Patrice Chalin --- content/en/docs/languages/rust/exporters.md | 5 +++-- content/en/docs/languages/rust/getting-started.md | 9 ++++++--- data/registry/otel-rust.yml | 4 ++++ layouts/shortcodes/version-from-registry.md | 15 +++++++++++++++ 4 files changed, 28 insertions(+), 5 deletions(-) create mode 100644 layouts/shortcodes/version-from-registry.md diff --git a/content/en/docs/languages/rust/exporters.md b/content/en/docs/languages/rust/exporters.md index 43913bf53835..bfd99dc7016c 100644 --- a/content/en/docs/languages/rust/exporters.md +++ b/content/en/docs/languages/rust/exporters.md @@ -9,11 +9,12 @@ cSpell:ignore: chrono millis ostream ## OTLP endpoint To send trace data to a OTLP endpoint (like the [collector](/docs/collector) or -Jaeger) you'll want to use an exporter crate, such as `opentelemetry_otlp`: +Jaeger) you'll want to use an exporter crate, such as +[opentelemetry-otlp](https://crates.io/crates/opentelemetry-otlp): ```toml [dependencies] -opentelemetry-otlp = { version = "0.13", features = ["default"] } +opentelemetry-otlp = { version = "{{% version-from-registry exporter-rust-otlp %}}", features = ["default"] } ``` Next, configure the exporter to point at an OTLP endpoint. For example you can diff --git a/content/en/docs/languages/rust/getting-started.md b/content/en/docs/languages/rust/getting-started.md index d27bad1ddf61..5b3b10ee21e7 100644 --- a/content/en/docs/languages/rust/getting-started.md +++ b/content/en/docs/languages/rust/getting-started.md @@ -103,11 +103,14 @@ Listening on 127.0.0.1:8080 ## Instrumentation To add OpenTelemetry to your application, update the `Cargo.toml` with the -following additional dependencies: +dependencies for the OpenTelemetry Rust SDK +[`opentelemetry`](https://crates.io/crates/opentelemetry) and the OpenTelemetry +Stdout Exporter +[`opentelemetry-stdout`](https://crates.io/crates/opentelemetry-stdout): ```toml -opentelemetry = { version = "0.20", features = ["trace"] } -opentelemetry-stdout = { version = "0.1", features = ["trace"] } +opentelemetry = { version = "{{% version-from-registry otel-rust %}}", features = ["trace"] } +opentelemetry-stdout = { version = "{{% version-from-registry exporter-rust-stdout %}}", features = ["trace"] } ``` Update the `dice_server.rs` file with code to initialize a tracer and to emit diff --git a/data/registry/otel-rust.yml b/data/registry/otel-rust.yml index ff3e644e3882..e33e0624dac3 100644 --- a/data/registry/otel-rust.yml +++ b/data/registry/otel-rust.yml @@ -10,3 +10,7 @@ authors: urls: repo: https://github.com/open-telemetry/opentelemetry-rust createdAt: 2020-02-04 +package: + registry: crates + name: opentelemetry + version: 0.21.0 diff --git a/layouts/shortcodes/version-from-registry.md b/layouts/shortcodes/version-from-registry.md new file mode 100644 index 000000000000..d597de0e3987 --- /dev/null +++ b/layouts/shortcodes/version-from-registry.md @@ -0,0 +1,15 @@ +{{ $name := (.Get 0) -}} + +{{ with $name -}} + {{ with index $.Site.Data.registry . -}} + {{ with .package.version -}} + {{ . -}} + {{ else -}} + {{ errorf "No 'package.version' in registry entry %q: %s" $name $.Position -}} + {{ end -}} + {{ else -}} + {{ errorf "Registry entry %q not found: %s" $name $.Position -}} + {{ end -}} +{{ else -}} + {{ errorf "Shortcode parameter 'name' is missing %s: " $.Position -}} +{{ end -}}