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

aiokafka auto-propergation of context? #3026

Open
mzealey opened this issue Nov 19, 2024 · 0 comments
Open

aiokafka auto-propergation of context? #3026

mzealey opened this issue Nov 19, 2024 · 0 comments

Comments

@mzealey
Copy link

mzealey commented Nov 19, 2024

In

I can see that the context is propergated correctly, however it only appears in the record that aiokafka reads. Would it be an idea to do

opentelemetry.context.attach(extracted_context)

so that new spans following are created with this linked context?

I can see that in some cases this may not be the desired behaviour, but I'd have thought a very standard pattern would be:

record = get_from_kafka
with span(...):
  do stuff

and wanting that do stuff to sit within the parent trace context?

Obviously this is possible manually, I'm trying something like the below, but it would be nice to have some sort of context manager or auto-update which provided this functionality without some hackiness:

record = get_from_kafka
context = propagate.extract(record.headers, getter=_aiokafka_getter)
with tracer.start_as_current_span("process-record", context=context) as span:
  ...

As I'm not too familiar with the otel api this also would put the process-record span outside of the fetch when it would be nice to group both together - I assume there's a way to update the span context from within a span, but I'm yet to find it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant