Skip to content

feat(logger): add init_tracing() for Kubernetes OTLP deployments (v0.8.0)#21

Merged
Manuthor merged 14 commits into
developfrom
feat/k8s-init-tracing
Jun 24, 2026
Merged

feat(logger): add init_tracing() for Kubernetes OTLP deployments (v0.8.0)#21
Manuthor merged 14 commits into
developfrom
feat/k8s-init-tracing

Conversation

@p0wline

@p0wline p0wline commented Jun 23, 2026

Copy link
Copy Markdown
Contributor

Summary

Add tracing_init_from_env(default_service_name: &str) to cosmian_logger, gated behind the full feature flag.

This function auto-configures tracing from standard OpenTelemetry environment variables:

  • OTEL_SERVICE_NAME — service name reported to the collector (falls back to the argument)
  • OTEL_EXPORTER_OTLP_ENDPOINT — OTLP gRPC endpoint (e.g. http://otel-collector:4317). When set, OTLP export is enabled; when absent, only stdout logging is used.

Returns LoggingGuards that must be kept alive for the lifetime of the process.

Motivation

Needed by the Cosmian KMS Kubernetes plugin and operator (PR Cosmian/kms#999) to support native Kubernetes OTLP observability stacks without pulling in a separate crate with a higher rust-version constraint.

This same function will also be usable in Cosmian/velo (k8s-logging branch) to replace the equivalent in shared_logging.

Version

0.7.20.7.3

Add a convenience function init_tracing(default_service_name) that
auto-configures tracing from standard OpenTelemetry environment variables:
- OTEL_SERVICE_NAME: service name reported to the collector
- OTEL_EXPORTER_OTLP_ENDPOINT: OTLP gRPC endpoint (enables OTLP when set)

When OTEL_EXPORTER_OTLP_ENDPOINT is absent, only stdout logging is enabled.
Gated behind the full feature flag.

Bump version to 0.7.3.

Copilot AI 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.

Pull request overview

Adds a Kubernetes/cloud-native convenience entrypoint to cosmian_logger to initialize tracing using standard OpenTelemetry environment variables, intended to simplify OTLP enablement in k8s deployments while keeping the API gated behind the full feature.

Changes:

  • Introduce init_tracing(default_service_name: &str) (feature-gated behind full) that derives configuration from OTEL_SERVICE_NAME and OTEL_EXPORTER_OTLP_ENDPOINT.
  • Re-export init_tracing from the crate root when full is enabled.
  • Bump workspace/package version to 0.7.3 (and lockfile entries accordingly).

Reviewed changes

Copilot reviewed 3 out of 4 changed files in this pull request and generated 3 comments.

File Description
crate/logger/src/tracing.rs Adds the new init_tracing() env-driven initializer and its rustdoc.
crate/logger/src/lib.rs Re-exports init_tracing behind the full feature.
Cargo.toml Bumps workspace version from 0.7.2 to 0.7.3.
Cargo.lock Updates internal crate versions to 0.7.3.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread crate/logger/src/tracing.rs Outdated
Comment thread crate/logger/src/tracing.rs Outdated
Comment thread crate/logger/src/tracing.rs Outdated
p0wline and others added 3 commits June 23, 2026 13:49
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>

Copilot AI 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.

Pull request overview

Copilot reviewed 3 out of 4 changed files in this pull request and generated 4 comments.

Comment thread crate/logger/src/tracing.rs Outdated
Comment thread crate/logger/src/tracing.rs Outdated
Comment thread crate/logger/src/tracing.rs Outdated
Comment thread crate/logger/src/lib.rs Outdated
p0wline and others added 3 commits June 23, 2026 15:15
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>

Copilot AI 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.

Pull request overview

Copilot reviewed 3 out of 4 changed files in this pull request and generated no new comments.

@p0wline p0wline requested a review from Manuthor June 23, 2026 13:27
p0wline added a commit to Cosmian/kms that referenced this pull request Jun 23, 2026
Use cosmian_logger (already a workspace dependency) with features=["full"]
in the k8s plugin and operator, reading standard OpenTelemetry env vars:
- OTEL_EXPORTER_OTLP_ENDPOINT: enables OTLP export when set
- OTEL_SERVICE_NAME: service name reported to the collector (operator only)
- RUST_LOG / --log-level: log verbosity (plugin)

Avoids introducing a git dependency with a rust-version constraint
incompatible with the workspace toolchain (1.91.0 vs 1.94.1).

A cosmian_logger 0.7.3 release adding init_tracing() is tracked in
Cosmian/http_client_server#21.

Closes #1002
Manuthor and others added 2 commits June 23, 2026 17:58
…ld syntax

Replace single-arm format_args!() wrapper with two-arm macros:
- arm 1: target: $target, inject fn_name field right after
- arm 2: all other syntax, inject fn_name as first field

fn_name is now a structured field (visible in OTLP/JSON and console output)
instead of a text prefix. This preserves the full tracing API surface:
target:, named fields (key = %val), shorthand (?err, %val), and plain
format strings all work without modification.

Fixes compilation of codebases that use structured tracing syntax (KMS).

Copilot AI 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.

Pull request overview

Copilot reviewed 11 out of 12 changed files in this pull request and generated 11 comments.

Comment thread crate/logger/Cargo.toml
Comment thread crate/logger/src/types.rs
Comment thread crate/logger/src/lib.rs
Comment thread crate/logger/README.md Outdated
Comment thread crate/logger/README.md Outdated
Comment thread crate/logger/README.md Outdated
Comment thread crate/logger/README.md Outdated
Comment thread Cargo.toml
Comment thread crate/logger/Cargo.toml Outdated
Comment thread crate/logger/src/lib.rs Outdated
p0wline and others added 4 commits June 24, 2026 16:41
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>

Copilot AI 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.

Pull request overview

Copilot reviewed 11 out of 12 changed files in this pull request and generated 5 comments.

Comment thread crate/logger/src/lib.rs
Comment thread crate/logger/Cargo.toml
Comment thread crate/logger/Cargo.toml
Comment thread Cargo.toml
Comment on lines 5 to 8
[workspace.package]
version = "0.7.2"
version = "0.8.0"
edition = "2021"
rust-version = "1.71.0"

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.

Not applicable. The 0.8.0 bump is intentional: the new init_tracing() public API is a backward-incompatible addition to the public surface (new types TelemetryGuards, new function, new error module), which warrants a minor version bump under semver. The PR title already reflects this with (v0.8.0); only the early description draft was stale.

Comment thread crate/logger/src/macros.rs Outdated
@Manuthor Manuthor changed the title feat(logger): add init_tracing() for Kubernetes OTLP deployments (v0.7.3) feat(logger): add init_tracing() for Kubernetes OTLP deployments (v0.8.0) Jun 24, 2026
@Manuthor Manuthor merged commit 20cf1d9 into develop Jun 24, 2026
10 checks passed
@Manuthor Manuthor deleted the feat/k8s-init-tracing branch June 24, 2026 17:30
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