dd-trace-php icon indicating copy to clipboard operation
dd-trace-php copied to clipboard

It is not possible to have correct span ids since the functions `dd_trace_push_span_id` and `dd_trace_pop_span_id` are deprecated in 0.74.0

Open Pyrexx opened this issue 3 years ago • 2 comments

The seed for span_id is generated only on the dd-trace-php extension start and there is no possibility to re-seed it in a forked process. The processes get the same trace id and we have a mess in the datadog tracing.

Previously we used a workaround calling dd_trace_push_span_id certain amount of times in each of forked processes before creating a new span. So currently we are not able to use datadog in the jobs which do pcntl_fork().

Could you fix this by adding a function that allows to reseed the random number generator. Or restore dd_trace_push_span_id and dd_trace_pop_span_id.

But reseed is a better solution.

Pyrexx avatar Jul 04 '22 10:07 Pyrexx

Hey @Pyrexx, that's truly an edge case I didn't have on my radar :-)

Technically, as a temporary measure, to achieve the same result, you could do DDTrace\start_span() and DDTrace\close_span() repeatedly, then call dd_trace_serialize_closed_spans() (with autoflush off - use ini_set to change it at run-time if necessray) to discard these spans.

As a more persistent solution we are instead proposing #1633, resetting the seed generator automatically upon pcntl_fork. Would that work as well, or is there a different use case you have?

bwoebi avatar Jul 04 '22 13:07 bwoebi

Hi @bwoebi, thanks fro the response,

yes, #1633 should do the job, it would be nice to have it soon.

Pyrexx avatar Jul 04 '22 15:07 Pyrexx

Since #1633 is merged, I'm closing this now.

krakjoe avatar Oct 14 '22 12:10 krakjoe