kabiroman/adaptive-entity-manager-opentelemetry-bridge

OpenTelemetry bridge for Adaptive Entity Manager - adds distributed tracing and observability to entity lifecycle operations

Installs: 5

Dependents: 0

Suggesters: 0

Security: 0

Stars: 0

Watchers: 0

Forks: 0

Open Issues: 0

Type:symfony-bundle

pkg:composer/kabiroman/adaptive-entity-manager-opentelemetry-bridge

dev-main 2025-12-17 21:34 UTC

This package is auto-updated.

Last update: 2025-12-17 21:42:36 UTC


README

This Symfony bundle automatically creates OpenTelemetry spans for persist, update, and remove operations from kabiroman/adaptive-entity-manager-bundle and resolves manager names based on entity namespaces.

Installation

composer require kabiroman/adaptive-entity-manager-opentelemetry-bridge

Register the bundle in config/bundles.php and make sure an OTLP exporter/SDK is configured if you plan to export traces.

Configuration

Supported configuration structure (config/packages/adaptive_entity_manager_opentelemetry_bridge.yaml):

adaptive_entity_manager_opentelemetry_bridge:
    enabled: true
    manager_namespaces:
        sales: 'App\Domain\Sales\'
        legacy: 'App\Domain\Legacy\'
  • enabled toggles tracing on or off.
  • manager_namespaces maps manager names (keys) to namespace prefixes (values), which are used to determine entity ownership.

Usage

EntityPersistenceTracingSubscriber listens to lifecycle events emitted by AdaptiveEntityManager. Thanks to autoconfiguration, it receives TracerInterface, LoggerInterface (if available), the enabled flag, and namespace mapping from the bundle configuration.

Span naming

Spans are named according to the following pattern:

aem.{operation}.{EntityShortName}

Examples:

  • aem.persist.User
  • aem.update.Order
  • aem.remove.Product

Span attributes

  • aem.operation: persist, update, or remove
  • aem.entity.class: fully qualified class name
  • aem.entity.short_class: short class name
  • aem.entity.id: result of getId() (when available)
  • aem.manager: manager name resolved from namespace or unknown
  • aem.entity.changed_fields and aem.entity.changed_fields_count for updates
  • component: adaptive-entity-manager

Events

  • aem.entity.persisted — emitted after entity persist
  • aem.entity.updated — emitted after entity update
  • aem.entity.removed — emitted after entity removal

Troubleshooting

Spans do not appear in Jaeger/Tempo

  1. Confirm that TracerInterface is registered:
    php bin/console debug:container TracerInterface
  2. Make sure the subscriber and bundle are loaded:
    php bin/console debug:container EntityPersistenceTracingSubscriber
  3. Check the configuration that Symfony loads:
    php bin/console debug:config adaptive_entity_manager_opentelemetry_bridge
  4. Enable debug logging if needed:
    monolog:
        handlers:
            main:
                level: debug

aem.manager always reads unknown

Ensure the configured namespaces match your entity namespaces:

manager_namespaces:
    sales: 'App\Domain\Sales\'  # Must match the entity namespace prefix
  • App\Domain\Sales\Entity\User
  • App\Entity\Sales\User ❌ (namespace differs)

Jaeger / Tempo / OTLP

The bundle relies on OpenTelemetry\API\Trace\TracerInterface, so actual exporting and exporter selection happens outside the bundle (for example, with OpenTelemetry\SDK and an OTLP exporter). Ensure a TracerInterface service is available in your application.

Graceful degradation

  • If no TracerInterface is registered, spans are not created.
  • When enabled is false, the subscriber is a no-op.
  • If manager_namespaces is empty, the manager name defaults to unknown.
  • The logger is optional and only used for debug output.

Examples

Minimal configuration example:

adaptive_entity_manager_opentelemetry_bridge:
    enabled: '%env(bool:OTEL_ENABLED)%'
    manager_namespaces:
        sales: 'App\Domain\Sales\'

When Jaeger/Tempo receives traces, look for spans such as aem.persist.User and aem.update.Order that include manager, entity class, and id attributes.

Roadmap

This package is actively maintained. See ROADMAP.md for planned features and future releases.

Upcoming:

  • v1.1.0 (Q1 2026): Span customization hooks, behavior tests, and edge case coverage
  • v1.2.0 (Q2 2026): Integration tests, performance benchmarks, and CI/CD

Contributing

Contributions are welcome! Please feel free to submit issues or pull requests.

License

MIT License - see LICENSE file for details.