Skip to content

feat(E9): add OTel metrics for CLI invocation rate/error#255

Open
KooshaPari wants to merge 5 commits into
mainfrom
feat/E9-otel-metrics
Open

feat(E9): add OTel metrics for CLI invocation rate/error#255
KooshaPari wants to merge 5 commits into
mainfrom
feat/E9-otel-metrics

Conversation

@KooshaPari

Copy link
Copy Markdown
Owner

Summary

@gemini-code-assist

Copy link
Copy Markdown

Warning

You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again!

@github-actions

Copy link
Copy Markdown

Legacy Tooling Scan Report

Severity Count
Critical 0
High 0
Medium 0
Low 0

No violations detected.

This is a WARN-mode scan. Fix before strict enforcement begins.

@socket-security

socket-security Bot commented Jun 26, 2026

Copy link
Copy Markdown

Review the following changes in direct dependencies. Learn more about Socket for GitHub.

Diff Package Supply Chain
Security
Vulnerability Quality Maintenance License
Addedcargo/​futures@​0.3.3210010093100100
Addedcargo/​rayon@​1.10.010010093100100
Addedcargo/​tempfile@​3.27.09810093100100

View full report

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: a780f51861

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".


use opentelemetry::{
KeyValue,
metrics::{Counter, Histogram, Meter, UpDownCounter, Result},

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Update OTel metric APIs for the pinned 0.28 crates

With byteport-otel pinned to opentelemetry = "0.28", this new crate is using pre-0.27 metric APIs: opentelemetry::metrics::Result was renamed and the instrument builders used throughout this file no longer expose .init() (they use .build()). As soon as the new workspace member is built, the crate fails to compile, so the CLI metrics feature cannot run until these calls are updated or the dependency is pinned to a compatible version.

Useful? React with 👍 / 👎.

Comment thread Cargo.toml
"crates/byteport-transport",
"crates/byteport-cli",
"crates/byteport-dag",
"crates/byteport-otel",

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Regenerate the lockfile for the new workspace member

This adds crates/byteport-otel to the workspace, but the committed Cargo.lock still has no byteport-otel package, no OpenTelemetry dependencies, and even the byteport-cli entry lacks the newly added byteport-otel/tracing dependencies. Any cargo build --locked/frozen build of this commit will reject the stale lockfile, so please regenerate and commit the lockfile after adding the crate and dependencies.

Useful? React with 👍 / 👎.

Err(e) => {
record_cli_error("codec", "encode_failure");
eprintln!("Encode error: {e}");
std::process::exit(1);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Return from main instead of exiting before telemetry flushes

On error paths such as an invalid codec operation, the code records the new error counter and then calls std::process::exit(1), which skips dropping _otel_guard in main. That means the just-recorded CLI error metrics and any pending spans are not flushed for exactly the failing invocations this feature is meant to count; return an exit status/result from main after the guard can shut down instead.

Useful? React with 👍 / 👎.

Comment on lines +125 to +127
TelemetryGuard {
_tracer_provider: tracer_provider,
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Shut down the meter provider on guard drop

The guard only retains the tracer provider, while the meter provider is moved into the global provider and no handle is kept for force_flush/shutdown. For short-lived CLI commands, the PeriodicReader is configured to export every 60 seconds, so successful invocations can increment byteport.cli.invocations and then exit before the meter reader ever exports them; keep the meter provider in TelemetryGuard and shut it down alongside traces.

Useful? React with 👍 / 👎.

Comment on lines +107 to +108
let _otel_guard = byteport_otel::init::init_default();
info!("byteport-cli starting");

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Keep telemetry logs off command stdout

init_default() enables the JSON fmt layer at info level, and these info! calls run for every normal CLI command, so commands like byteport-cli codec encode hello will emit JSON log records on stdout before/after the actual encoded value. That breaks scripts and tests that consume stdout as the command result; send logs to stderr or disable stdout logging by default for this CLI path.

Useful? React with 👍 / 👎.

@github-actions

Copy link
Copy Markdown

Legacy Tooling Scan Report

Severity Count
Critical 0
High 0
Medium 0
Low 0

No violations detected.

This is a WARN-mode scan. Fix before strict enforcement begins.

@sonarqubecloud

Copy link
Copy Markdown

@KooshaPari KooshaPari added area:compute-infra Phenotype compute/infra epic epic:epic_E BytePort: terminal UI, tools CLI, otel, governance type:feature New capability or significant enhancement labels Jun 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:compute-infra Phenotype compute/infra epic epic:epic_E BytePort: terminal UI, tools CLI, otel, governance type:feature New capability or significant enhancement

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant