Fix linking with newrelic.distributed_tracing_enabled=1 #3
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There are several behavioural differences with
newrelic.distributed_tracing_enabled=1
that this patch addressesnewrelic_add_custom_parameter('traceId', $value);
hack does not work. Traces do not get traceId matching $value assignednewrelic_get_trace_metadata
instead of UUIDs presents itself. However, this also does not work, because:newrelic_name_transaction
changes this ID.This bundle in sequence:
newrelic_name_transaction
newrelic_add_custom_parameter('traceId', $this->traceId->__toString());
This doesn't work, because step 3 uses ID generated at step 1, but NR changed ID in step 2, hence Logs get different
trace.id
assigned than NR Transaction has.This could be solved by custom NewrelicNativeTraceIdFactory + calling
$this->traceId->refresh()
right after$this->interactor->setApplicationName(
but I worry that this might work in this case, but there will be other cases where NR extension changes current traceId.Hence, I think solution in this commit is quite robust and will work with both states of
newrelic.distributed_tracing_enabled
out of the box. Only disadvantage is that if users havenewrelic.distributed_tracing_enabled=1
, even if they define custom traceIdFactory, "native" NR transaction ID will be used despite whatever they generate in their custom factory. However, I believe this is OK, because whatever they generate in their custom factory wouldn't be taken over by NR extension anyways, because of very first point mentioned in this commit message