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

Span ID always null in Logs | Logs ID injection #1962

Open
lb1mg opened this issue Jan 31, 2024 · 4 comments
Open

Span ID always null in Logs | Logs ID injection #1962

lb1mg opened this issue Jan 31, 2024 · 4 comments
Labels
agent-python community Issues opened by the community triage Issues awaiting triage

Comments

@lb1mg
Copy link

lb1mg commented Jan 31, 2024

Describe the bug: I am using logging support which injects correlation ids (trace, transaction, span). However even after running with 100% sample rate I've not been able to get a single log with a Span ID!
Also "maybe" this could be the reason that I am not seeing any logs in trace waterfall

To Reproduce

  1. Install elastic apm agent version
  2. Simply allow logging integration (default)
  3. Check in your APM

Environment (please complete the following information)

  • OS: Linux and Mac
  • Python version: 3.9/10
  • Framework and version [e.g. Django 2.1]: Should not matter but Sanic v22
  • APM Server version: Proprietary Solution
  • Agent version: elastic-apm==6.7.1

Additional context
N/A

@github-actions github-actions bot added agent-python community Issues opened by the community triage Issues awaiting triage labels Jan 31, 2024
@basepi
Copy link
Contributor

basepi commented Jan 31, 2024

Would you mind trying to put together a reproduction case with a minimal sanic app? I'm wondering if something is breaking down with the contextvar propagation or something, but I haven't seen this behavior.

@lb1mg
Copy link
Author

lb1mg commented Jan 31, 2024

Thanks for such quick response!! Sure, pls allow me some time to get a simple app. I would also love to help in fixing anything broken

@lb1mg
Copy link
Author

lb1mg commented Jan 31, 2024

I have two questions:

  1. Can modifying the asyncio task factory using loop.set_task_factory() affect elastic apm agent in any way? we use this
  2. I have a complex running service, sharing it is not possible and would not be helpful how can I debug this issue or what can I share so someone here might be able to help?

Thanks!

@basepi
Copy link
Contributor

basepi commented Feb 5, 2024

Can modifying the asyncio task factory using loop.set_task_factory() affect elastic apm agent in any way?

It's possible. The most likely culprit would be changes to contextvars propagation.

You could try the following code snippet from within your app to see if you can properly fetch the current transaction and span:

from elasticapm.traces import execution_context
t = execution_context.get_transaction()
s = execution_context.get_span()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
agent-python community Issues opened by the community triage Issues awaiting triage
Projects
None yet
Development

No branches or pull requests

2 participants