feat(logger): add init_tracing() for Kubernetes OTLP deployments (v0.8.0)#21
Conversation
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.
There was a problem hiding this comment.
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 behindfull) that derives configuration fromOTEL_SERVICE_NAMEandOTEL_EXPORTER_OTLP_ENDPOINT. - Re-export
init_tracingfrom the crate root whenfullis 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.
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>
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>
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
…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).
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>
| [workspace.package] | ||
| version = "0.7.2" | ||
| version = "0.8.0" | ||
| edition = "2021" | ||
| rust-version = "1.71.0" |
There was a problem hiding this comment.
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.
Summary
Add
tracing_init_from_env(default_service_name: &str)tocosmian_logger, gated behind thefullfeature 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
LoggingGuardsthat 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-versionconstraint.This same function will also be usable in
Cosmian/velo(k8s-logging branch) to replace the equivalent inshared_logging.Version
0.7.2→0.7.3