Search by

enthusiast / worker-template

konstantin_popov

There is no license information available for the latest version (1.2.10) of this package.

Base worker parts

Package info

github.com/gfsx0259/worker-template

pkg:composer/enthusiast/worker-template

Statistics

Installs: 517

Dependents: 1

Suggesters: 0

Stars: 0

Open Issues: 0

1.2.10 2026-10-21 14:03 UTC

README

Sharing common worker parts: instrumentation, queue logic etc.

Shared infra env

OpenBao keys (as ops inject them) are copied onto the app prefix. Call before config reads $_ENV:

(new \Enthusiast\WorkerTemplate\SharedEnv('API_'))->apply();
(new \Enthusiast\WorkerTemplate\SharedEnv('WORKER_INTEGRATION_'))->apply();
OpenBao App (API_ / WORKER_INTEGRATION_ / …)
KAFKA_BROKERS, KAFKA_SASL_USERNAME, KAFKA_SASL_PASSWORD *_KAFKA_BROKERS, *_KAFKA_SASL_*
REDIS_HOSTS, REDIS_PASSWORD *_REDIS_HOSTS, *_REDIS_PASSWORD
LM_CH_* *_CLICKHOUSE_*
LM_PG_* *_POSTGRES_*
DRAFT_PG_* *_DB_DRAFT_*
PANEL_PG_* *_PANEL_POSTGRES_*

Filled only when the app key is empty. Topics, Redis persistent ids and Svix stay app-local. The map is SharedEnv::MAP.

Kafka tracing

AbstractBufferedConsumer does not manage spans. Lifecycle is owned by open-telemetry/opentelemetry-auto-ext-rdkafka:

  1. KafkaConsumer::consume → start consumer span (+ parent from message traceparent)
  2. app processes the message (PSR-3 span-events hook writes to current span)
  3. acknowledge → commit / commitAsync → end span

Do not call Span::getCurrent()->end() in the consumer loop: it races the commit hook and leaks context scopes, so later messages inherit the same trace.

PSR-3 → span events (Jaeger-friendly)

Jaeger does not store OTLP Logs / Loki streams. This package can hook every PSR-3 logger call onto the active span as an event (Span::addEvent).

Works alongside open-telemetry/opentelemetry-auto-psr3 (inject / export).

Enable

OTEL_PHP_PSR3_SPAN_EVENTS=true
OTEL_PHP_PSR3_SPAN_EVENTS_LEVEL=info

Disable:

OTEL_PHP_DISABLED_INSTRUMENTATIONS=psr3-span-events

Requires ext-opentelemetry. Registered via Composer files autoload (_register_psr3_span_events.php) — no DI changes in apps.