Skip to content

Add OpenTelemetry tracing integration #10

@Tristan-Stoltz-ERC

Description

@Tristan-Stoltz-ERC

Summary

The cognitive loop emits tracing spans but doesn't export them via OpenTelemetry. Add optional OTLP export (behind a feature flag) so users can visualize cognitive cycle timing in Jaeger or Grafana Tempo.

Key spans to instrument

Span Current time % of cycle
hdc_encode ~580µs 13.6%
predict ~560µs 13.1%
consciousness_measure part of postprocess
moral_algebra ~17µs 0.4%
parallel_postprocess ~1.9ms 44%
stability_regime ~1.35ms 31.6%

Total cycle: ~4.3ms (234Hz) in release mode.

Implementation plan

  1. Add feature flag: opentelemetry (or otlp)
  2. Add dependencies: opentelemetry, opentelemetry-otlp, tracing-opentelemetry
  3. Initialize OTLP exporter in the cognitive loop constructor when feature is enabled
  4. Ensure existing tracing::instrument spans are properly propagated
  5. Add configuration for OTLP endpoint (default: http://localhost:4317)
  6. Graceful degradation when collector is unavailable

Why this matters

Visualizing the cognitive cycle as a trace flamegraph makes it much easier to identify performance regressions, understand phase ordering, and debug consciousness measurement timing. This is especially valuable as we add more subsystems to the pipeline.

Getting started

The codebase already uses the tracing crate extensively. The main integration point is src/cognitive_loop/cycle.rs where the core pipeline runs.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requesthelp wantedExtra attention is needed

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions