Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: \DDTrace\current_context trace_id does not match \DDTrace\logs_correlation_trace_id() #2734

Open
Justinas-Jurciukonis opened this issue Jun 27, 2024 · 3 comments
Labels
🐛 bug Something isn't working

Comments

@Justinas-Jurciukonis
Copy link

Justinas-Jurciukonis commented Jun 27, 2024

Bug report

As stated inside Manual Injection documentation \DDTrace\current_context() should return trace identifiers and we always have used following code:

$context = \DDTrace\current_context();

$record->with(extra: [
    'dd' => [
        'span_id' => $context['span_id'],
        'trace_id' => $context['trace_id'],
    ],
])

and it worked fine for some time. But now (as of 0.98.1 and 1.1.0) adding this trace_id loses Traces information and even sometimes matches accross multiple requests.

I have logged following code and see that \DDTrace\current_context() and \DDTrace\logs_correlation_trace_id() returns different results:

var_dump(\DDTrace\current_context() + ['span_id2' => \dd_trace_peek_span_id(), 'trace_id2' => \DDTrace\logs_correlation_trace_id()]);

// Outputs
{
    "trace_id": "136226447259282480168556905957809988804", // <---
    "span_id": "6603237610001450838",
    "version": "1516-test",
    "env": "infra_test",
    "distributed_tracing_propagated_tags": [],
    "trace_id2": "12691714017235838148", // <---
    "span_id2": "6603237610001450838"
}

If using \DDTrace\logs_correlation_trace_id(), than Traces are matched against log records

PHP version

8.3

Tracer or profiler version

0.98.1; 1.1.0

Installed extensions

No response

Output of phpinfo()

No response

Upgrading from

No response

@Justinas-Jurciukonis Justinas-Jurciukonis added the 🐛 bug Something isn't working label Jun 27, 2024
@PROFeNoM
Copy link
Contributor

Hi @Justinas-Jurciukonis 👋

Currently, many external tracing systems (e.g., OpenTelemetry) utilize 128-bit Trace IDs, so when Datadog interoperates with them, we can end up with broken traces and logs correlation. This is why, alongside the OTel API support, 128-bit trace ID generation has been enabled by default (#2358) since 0.94.0 to match these open standards.

The behavior you are experiencing is expected. The results of these two functions are the same when DD_TRACE_128_BIT_TRACEID_GENERATION_ENABLED is disabled. \DDTrace\logs_correlation_trace_id should be used to ensure the right trace identifier format is used.

@Justinas-Jurciukonis
Copy link
Author

@PROFeNoM Maybe you can add this as warning into documentation page?

@bwoebi
Copy link
Collaborator

bwoebi commented Jun 29, 2024

@Justinas-Jurciukonis We're planning to change the default setting in the next few months, given that our backend now also supports 128 bit trace ids :-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐛 bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants