Skip to content

feat: follow opentelemetry semantic conventions#633

Merged
jeluard merged 5 commits into
mainfrom
jeluard/opentelemetry-semantic-conventions
Jan 9, 2026
Merged

feat: follow opentelemetry semantic conventions#633
jeluard merged 5 commits into
mainfrom
jeluard/opentelemetry-semantic-conventions

Conversation

@jeluard

@jeluard jeluard commented Jan 9, 2026

Copy link
Copy Markdown
Contributor

Pave the way to make sure OpenTelemetry conventions are followed. Also relies on default env variable and not custom amaru ones for OTEL.

Summary by CodeRabbit

  • Documentation

    • Updated monitoring docs to recommend standard OpenTelemetry environment variables (OTEL_SERVICE_NAME, OTEL_EXPORTER_OTLP_ENDPOINT, OTEL_EXPORTER_OTLP_METRICS_ENDPOINT).
  • Refactor

    • Simplified observability to rely on standard OTEL env vars and defaults; removed custom OTLP CLI options and related startup logging fields.
  • Chores

    • Added opentelemetry-semantic-conventions dependency.
  • Other

    • Adjusted runtime logging configuration in the Amaru startup script.

✏️ Tip: You can customize this high-level summary in your review settings.

@jeluard jeluard requested a review from KtorZ January 9, 2026 14:37
@coderabbitai

coderabbitai Bot commented Jan 9, 2026

Copy link
Copy Markdown
Contributor

Walkthrough

This PR removes CLI-provided OTLP parameters and the OpenTelemetry config struct, switches observability wiring to workspace/default OTEL values, adds the opentelemetry-semantic-conventions workspace dependency, and updates docs and startup logging to rely on standard OTEL environment variables. No runtime control-flow beyond observability wiring was added.

Changes

Cohort / File(s) Summary
Workspace dependency
Cargo.toml
Added opentelemetry-semantic-conventions = "0.31.0" under [workspace.dependencies].
Crate dependency wiring
crates/amaru/Cargo.toml
Marked opentelemetry-semantic-conventions as workspace = true in amaru crate dependencies.
CLI binaries
crates/amaru/src/bin/amaru/main.rs, crates/amaru/src/bin/ledger/main.rs
Removed CLI fields/flags for service_name, otlp_span_url, otlp_metric_url and their defaults; startup logging no longer emits those values; observability setup calls simplified to pass only boolean flags.
Observability implementation
crates/amaru/src/observability.rs
Removed OpenTelemetryConfig and DEFAULT_OTLP_SPAN_URL; setup_open_telemetry now takes only the subscriber and uses SERVICE_NAME / default constants instead of a config object; setup_observability signature updated accordingly.
Docs & config scripts
docker/start_amaru.sh, monitoring/README.md, engineering-decision-records/007-observability.md
Updated AMARU_LOG value in start script; README switched Amaru-specific OTLP env vars to standard OTEL env vars and clarified transport details; removed discussion subsection from the observability EDR.

Sequence Diagram(s)

(Skipped — changes are refactor/configuration-focused and do not introduce a new multi-component control flow requiring visualization.)

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Suggested reviewers

  • abailly
  • KtorZ

Poem

🍀 A tidy change, like a clean-cut scene,

Flags gone quiet, OTEL on the green,
Workspace gem added, defaults stood tall,
Docs sing standard vars — no custom brawl,
Ship it like a boss, mate, smooth as a mall. 🚀

🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 66.67% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main change: migrating to follow OpenTelemetry semantic conventions by replacing custom OTLP configuration with standard environment variables.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


📜 Recent review details

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between cbca19f and 266e459.

⛔ Files ignored due to path filters (1)
  • Cargo.lock is excluded by !**/*.lock
📒 Files selected for processing (1)
  • Cargo.toml
🚧 Files skipped from review as they are similar to previous changes (1)
  • Cargo.toml
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (11)
  • GitHub Check: End-to-end snapshot tests (preprod, 1, 182, 15, 60, 10.5.3)
  • GitHub Check: Build x86_64/linux
  • GitHub Check: Build riscv32
  • GitHub Check: Build aarch64/macos
  • GitHub Check: Build x86_64/windows
  • GitHub Check: Build wasm32
  • GitHub Check: Build aarch64/linux
  • GitHub Check: Test the CLI
  • GitHub Check: Test coverage
  • GitHub Check: Benches
  • GitHub Check: Analyze (rust)

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@jeluard

jeluard commented Jan 9, 2026

Copy link
Copy Markdown
Contributor Author

@nemo83 I recall you mentioned at some point that amaru could use standard env variable for some bits. This is a step in this direction.

Signed-off-by: jeluard <jeluard@users.noreply.github.com>
Signed-off-by: jeluard <jeluard@users.noreply.github.com>
Signed-off-by: jeluard <jeluard@users.noreply.github.com>
Signed-off-by: jeluard <jeluard@users.noreply.github.com>
@jeluard jeluard force-pushed the jeluard/opentelemetry-semantic-conventions branch from cbca19f to b9f6af5 Compare January 9, 2026 14:40

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
crates/amaru/src/bin/amaru/main.rs (1)

124-134: Startup info! likely gets dropped: log happens before tracing subscriber init.

Right now info!(...) (Line 124) runs before setup_observability(...) (Line 130) calls subscriber.init(), so you may lose the “Started with global arguments” line.

Proposed fix
-    info!(
-        with_open_telemetry = args.with_open_telemetry,
-        with_json_traces = args.with_json_traces,
-        "Started with global arguments"
-    );
-
     let (metrics, teardown) = setup_observability(
         args.with_open_telemetry,
         args.with_json_traces,
     );
+
+    info!(
+        with_open_telemetry = args.with_open_telemetry,
+        with_json_traces = args.with_json_traces,
+        "Started with global arguments"
+    );
🤖 Fix all issues with AI agents
In @crates/amaru/src/observability.rs:
- Around line 241-243: The metric exporter is hardcoding the endpoint via
opentelemetry_otlp::MetricExporter::builder().with_endpoint(DEFAULT_OTLP_METRIC_URL)
which overrides OTEL_EXPORTER_OTLP_METRICS_ENDPOINT; remove the explicit
.with_endpoint(...) call from the metric_exporter builder so it behaves like the
span exporter (which does not set an endpoint) and therefore respects standard
OTEL env vars, or alternatively change the code to read the OTEL env var and
only call .with_endpoint(...) when that var is absent.
🧹 Nitpick comments (3)
monitoring/README.md (1)

361-374: Documentation's on point, but polish these minor bits.

Ace work updating the docs to reflect the standard OTEL env vars! This aligns perfectly with the code changes. The explanation about using OTLP/gRPC for spans and OTLP/HTTP for metrics is solid context – like explaining why you chose the plasma rifle over the BFG in DOOM, yeah?

However, there are a few small nits to polish:

  1. Line 361: "recognizes" has a typo (extra space or wrong variant?)
  2. Line 372: The linter's right – "maximise" vs "maximize" should be consistent, and "3rd party" should be "3rd-party"
  3. Line 374: Both links say "here" which isn't very descriptive – maybe "OpenTelemetry SDK environment variables" and "OTLP exporter specification" would be more helpful?

These are cosmetic, but worth tidying up for a professional finish.

✨ Suggested polish for documentation
-Amaru recognizes standard OpenTelemetry env variable for its configuration:
+Amaru recognizes standard OpenTelemetry environment variables for its configuration:

-This helps maximize compatibility with 3rd party tools receiving those data.
+This helps maximize compatibility with 3rd-party tools receiving those data.

-One can find more available env variables [here](https://opentelemetry.io/docs/specs/otel/configuration/sdk-environment-variables/) and [here](https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/protocol/exporter.md).
+One can find more available environment variables in the [OpenTelemetry SDK documentation](https://opentelemetry.io/docs/specs/otel/configuration/sdk-environment-variables/) and [OTLP exporter specification](https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/protocol/exporter.md).
crates/amaru/src/bin/amaru/main.rs (2)

147-150: Prefer tracing::error! over eprintln! for teardown failures (unless you want it outside telemetry).

Since tracing is initialized, logging teardown failures via tracing keeps everything in one place.


104-113: Mind the env-var storytelling here, mate—OTEL doesn't quite work the way the concern frames it.

Quick clarification: OpenTelemetry's standard doesn't have a boolean "enable OTLP" toggle like AMARU_WITH_OPEN_TELEMETRY. Instead, it uses OTEL_TRACES_EXPORTER=otlp or none to flip the exporter on/off per signal. Setting OTEL_EXPORTER_OTLP_ENDPOINT alone won't magically enable export—you still need the exporter selected via OTEL_TRACES_EXPORTER.

That said, the UX friction is real: if someone's only familiar with OTEL's standard variables and sets OTEL_EXPORTER_OTLP_ENDPOINT, they'll hit a wall unless they also know about AMARU_WITH_OPEN_TELEMETRY.

If you want to lean full OTEL-standard here, consider deriving the toggles from OTEL_TRACES_EXPORTER / OTEL_METRICS_EXPORTER (or accept both old and new for backwards compatibility). Otherwise, a note in docs explaining the custom toggles layer on top of OTEL config would save future maintainers a head-scratch moment.

📜 Review details

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 8f9190c and cbca19f.

⛔ Files ignored due to path filters (2)
  • Cargo.lock is excluded by !**/*.lock
  • crates/amaru/Cargo.lock is excluded by !**/*.lock
📒 Files selected for processing (8)
  • Cargo.toml
  • crates/amaru/Cargo.toml
  • crates/amaru/src/bin/amaru/main.rs
  • crates/amaru/src/bin/ledger/main.rs
  • crates/amaru/src/observability.rs
  • docker/start_amaru.sh
  • engineering-decision-records/007-observability.md
  • monitoring/README.md
💤 Files with no reviewable changes (2)
  • engineering-decision-records/007-observability.md
  • crates/amaru/src/bin/ledger/main.rs
🧰 Additional context used
🧠 Learnings (2)
📚 Learning: 2025-08-12T12:28:24.027Z
Learnt from: etorreborre
Repo: pragma-org/amaru PR: 372
File: simulation/amaru-sim/src/simulator/mod.rs:410-412
Timestamp: 2025-08-12T12:28:24.027Z
Learning: In the Amaru project, panic statements are acceptable in simulation/test code (like amaru-sim crate) as they help identify configuration issues quickly during development, rather than needing proper error handling like production code.

Applied to files:

  • docker/start_amaru.sh
📚 Learning: 2025-12-16T21:32:37.668Z
Learnt from: rkuhn
Repo: pragma-org/amaru PR: 584
File: crates/amaru-network/src/handshake/tests.rs:40-47
Timestamp: 2025-12-16T21:32:37.668Z
Learning: In Rust, shadowing a binding with a new let does not drop the previous binding until the end of the scope. All shadowed bindings in a scope are dropped in reverse-declaration order when the scope ends. Therefore, multiple let _guard = register_*() calls will keep all guards alive until the end of the function (or the surrounding scope). When reviewing code, be mindful that resources tied to shadowed bindings persist longer than the most recent binding; to release early, constrain the lifetime in an inner block or explicitly drop guards when appropriate.

Applied to files:

  • crates/amaru/src/bin/amaru/main.rs
  • crates/amaru/src/observability.rs
🧬 Code graph analysis (1)
crates/amaru/src/bin/amaru/main.rs (1)
crates/amaru/src/observability.rs (1)
  • setup_observability (320-351)
🪛 LanguageTool
monitoring/README.md

[uncategorized] ~372-~372: Do not mix variants of the same word (‘maximize’ and ‘maximise’) within a single text.
Context: ...ans * OTLP/HTTP for metrics This helps maximize compatibility with 3rd party tools rece...

(EN_WORD_COHERENCY)


[grammar] ~372-~372: Use a hyphen to join words.
Context: ...is helps maximize compatibility with 3rd party tools receiving those data. One c...

(QB_NEW_EN_HYPHEN)

🪛 markdownlint-cli2 (0.18.1)
monitoring/README.md

374-374: Link text should be descriptive

(MD059, descriptive-link-text)


374-374: Link text should be descriptive

(MD059, descriptive-link-text)

⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: Analyze (rust)
🔇 Additional comments (6)
crates/amaru/src/observability.rs (2)

18-18: Ripper! Using semantic conventions like a pro.

Bonzer choice importing SERVICE_NAME from the semantic conventions crate. This is the way to go, mate – keeps everything aligned with the OTEL spec rather than rolling your own constants. Like choosing the Master Sword over a rusty stick in Zelda, innit?


320-351: Clean as a whistle! Simplified like a speedrun route.

Love how you've streamlined setup_observability to just take the two boolean flags. The refactor removes all that config plumbing and makes the API much more straightforward. It's like going from a convoluted Dark Souls boss fight to a clean one-shot, yeah?

Much easier for callers to reason about now.

crates/amaru/Cargo.toml (1)

43-43: Sorted! Dependency wired up properly.

Adding opentelemetry-semantic-conventions to match the workspace definition. No dramas here – standard dependency management, innit? Everything's aligned with the root Cargo.toml.

docker/start_amaru.sh (1)

28-28: Good on ya! Cleaning up the gasket remnants.

Removing the gasket=error target from the logging config – makes sense as part of the broader cleanup mentioned in the commits. Keeping things focused on amaru-specific logging. It's like tidying up after a house party, getting rid of the empty tinnies, yeah?

Cargo.toml (1)

47-47: Version is solid – 0.31.0 exists and is properly compatible with your other OTEL deps.

Mate, you've nailed it here. opentelemetry-semantic-conventions = "0.31.0" is absolutely the right call – it's confirmed live on crates.io and plays nice with opentelemetry 0.31.0. Keeping all your OTEL crates locked to the same version is the way. It's like making sure everyone in your party is on the same quest difficulty – no one's gonna get left behind wondering why their builds don't line up. Rock on!

crates/amaru/src/bin/amaru/main.rs (1)

15-15: Nice cleanup: import now matches the simplified observability API.

Comment thread crates/amaru/src/observability.rs
Signed-off-by: jeluard <jeluard@users.noreply.github.com>
Comment on lines -121 to -132

#[arg(long, value_name = "STRING", env("AMARU_OTLP_SERVICE_NAME"), default_value_t = DEFAULT_OTLP_SERVICE_NAME.to_string()
)]
otlp_service_name: String,

#[arg(long, value_name = "URL", env("AMARU_OTLP_SPAN_URL"), default_value_t = DEFAULT_OTLP_SPAN_URL.to_string()
)]
otlp_span_url: String,

#[arg(long, value_name = "URL", env("AMARU_OTLP_METRIC_URL"), default_value_t = DEFAULT_OTLP_METRIC_URL.to_string()
)]
otlp_metric_url: String,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

convention over configuration. LEt's go!

@nemo83

nemo83 commented Jan 9, 2026

Copy link
Copy Markdown
Contributor

Love it! Thank you!

@codecov

codecov Bot commented Jan 9, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 0% with 6 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
crates/amaru/src/observability.rs 0.00% 4 Missing ⚠️
crates/amaru/src/bin/amaru/main.rs 0.00% 1 Missing ⚠️
crates/amaru/src/bin/ledger/main.rs 0.00% 1 Missing ⚠️
Files with missing lines Coverage Δ
crates/amaru/src/bin/amaru/main.rs 0.00% <0.00%> (ø)
crates/amaru/src/bin/ledger/main.rs 0.00% <0.00%> (ø)
crates/amaru/src/observability.rs 0.00% <0.00%> (ø)

... and 7 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@jeluard jeluard merged commit d8fe306 into main Jan 9, 2026
22 checks passed
@jeluard jeluard deleted the jeluard/opentelemetry-semantic-conventions branch January 9, 2026 19:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants