Skip to content

Commit

Permalink
Auto-Update rust versions in docs from registry
Browse files Browse the repository at this point in the history
Signed-off-by: svrnm <[email protected]>
  • Loading branch information
svrnm authored and chalin committed Feb 7, 2024
1 parent 03cc9c6 commit 9f1f434
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 5 deletions.
5 changes: 3 additions & 2 deletions content/en/docs/languages/rust/exporters.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
9 changes: 6 additions & 3 deletions content/en/docs/languages/rust/getting-started.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions data/registry/otel-rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
17 changes: 17 additions & 0 deletions layouts/shortcodes/version-from-registry.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{{ $name := (.Get 0) -}}

{{ with $name -}}
{{ $registryEntry := (index $.Site.Data.registry .) -}}
{{ with $registryEntry -}}
{{ $version := .package.version -}}
{{ with $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 "Missing registry entry name: %s" $.Position -}}
{{- end -}}

0 comments on commit 9f1f434

Please sign in to comment.