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

[Question] spanning across sub-processes #250

Closed
thehesiod opened this issue Apr 13, 2017 · 4 comments
Closed

[Question] spanning across sub-processes #250

thehesiod opened this issue Apr 13, 2017 · 4 comments
Labels
Milestone

Comments

@thehesiod
Copy link
Contributor

In our application we have a process pool of botocore workers. Is there a way, in general, to ensure that sub-processes can chain up to their parent process traces?

I'm guessing the right context details needs to be transferred to the sub-process to make things work.

@thehesiod
Copy link
Contributor Author

thehesiod commented Apr 13, 2017

btw for asyncio I found I could do it by serializing the parent span in the base process via:

        dd_span = tracer.get_call_context().get_current_span()
        attrs = {'name', 'service', 'resource', 'span_type', 'trace_id', 'span_id', 'parent_id', 'start'}
        dd_span_info = {n: getattr(dd_span, n) for n in attrs} if dd_span else None

then smashing it in in the child process:

try:
        if dd_span_info:
            dd_ctx = tracer.get_call_context()
            parent_span = Span(tracer, **dd_span_info, context=dd_ctx)

            dd_ctx._current_span = parent_span

            task = asyncio.Task.current_task(loop=self._loop)
            set_call_context(task, dd_ctx)
finally:
            if dd_span_info:
                set_call_context(task, None)

This works because the tracer only needs a few key pieces of information. If we could formalize a process for this it would be awesome!

@thehesiod
Copy link
Contributor Author

hmm, reading http://pypi.datadoghq.com/trace/docs/#distributed-tracing it seems like perhaps the asyncio patchers should support parent trace/span IDs

@thehesiod
Copy link
Contributor Author

thehesiod commented Apr 13, 2017

ok, I think I've implemented something acceptable in my PR: #248 It adds optional kwargs that follows the aiohttp style for distributed spans...however if there was a way to officially tell the context what the parent was it would be better I think.

@palazzem palazzem added this to the 0.9.0 milestone Apr 17, 2017
@palazzem palazzem self-assigned this Apr 17, 2017
@palazzem palazzem removed their assignment May 19, 2017
@palazzem
Copy link

palazzem commented Jul 2, 2017

Related to #247 that has been solved. Closing this one too.

@palazzem palazzem closed this as completed Jul 2, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants