Closed hrodic closed 3 years ago
@Fahmy-Mohammed is working on finishing up w3c format issues, maybe he can shed some light on this issue.
Just hit the same issue. I think the problem is that startActiveSpan
always calls SpanContext::generate(true)
and this uses randomHex
instead of the IdGenerator
.
Describe your environment
PHP 7.3 Commit of dev-main version: https://github.com/open-telemetry/opentelemetry-php/commit/bb0bbafec1d48509171aa12be68182075ef8e459
Steps to reproduce Construct TracerProvider with custom generator
$tracer = (new TracerProvider(null, null, new TracingIdGenerator())) ->addSpanProcessor(new BatchSpanProcessor($exporter, Clock::get())) ->getTracer('io.opentelemetry.contrib.php', 'dev-main');
What is the expected behavior? I would expect the traceId of a new span to use the generator specified. If the new generator uses 8 bytes hex instead of 16 i would like to see it (per example to make it W3C compatible with tracing formats of trace and span ids).
$clientSpan->getContext()->getTraceId();
What is the actual behavior? 16 byte hex ids returned
Additional context I was investigating on how to make context propagation using TraceContext class of the same project after using the w3c trace format.
$parentContext = TraceContext::extract($carrier, new PropagationMap());
Fatal error: Uncaught InvalidArgumentException: SpanID must be exactly 8 bytes (16 chars) and at least one non-zero byte, got 0c365901539b66fcb52c24a5329de59f