You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* refactor trace building
Instead of storing a mutable Context object in the contextvar, the
active span/context is stored instead. This removes the need to have
to clone the context which means that ddtrace will now work out of the
box with async frameworks that use contextvars.
* fix OT with the new context management
* Fix sampling
* remove deprecation for context_provider
* add current_execution_id function
* use execution id to group traces
this matches the previous functionality although we'll probably
want to change this in the near future
* Revert "use execution id to group traces"
This reverts commit 1d53a5c.
* various updates
- formatting
- added lock to _Trace
- updated tests
- docstrings
* support setting sampling_priority through context
* fix gevent tests
* fix asyncio
* enable partial flushing by default
Since multiple execution traces are no longer handled individually it
makes sense to enable partial flushing by default for long running
cross-execution traces.
* use get
* fix aiohttp tests
* store traces per tracer instance
* formatting
* test fixes
* fix futures test
* fix parenting issue for non active spans
* fix flask, asyncio and tornado tests
* clean up
- remove unrelated formatting
- remove new public apis (can be added later)
- add back context.sampling_priority
* sampling cleanup, backwards compatibility
* more cleanup
- revert unnecessary changes
* revert active() returning None
* handle trace-level tags
Trace-level tags like origin and sampling priority belong to a trace
and it's cumbersome to try to keep on the root span.
Context seems like the reasonable place for these things although
if feels a bit icky to overload context with it for a couple of
reasons:
- the context tags have to be shared between spans (could be easy
to forget)
- it overloads the context to support being a "non-local span" and
storing trace level state.
Ideally we could split this functionality into two structures...
maybe TraceContext and NonLocalSpan...?
* fix opentracing + gevent tests
* fix span.context active span
* rename methods
* get span from context if possible
* remove useless properties
* thread-safe context
* Add context test cases
* Remove backwards compatibility
This is done for several reasons:
- The existing functionality is undefined in a lot of cases so it
doesn't make sense to support.
- Backwards support is not entirely possible since we are no longer in
control of the context.
One example of this: previously the active span of a context could be
accessed from outside the execution that the span was created in via
the span.context. This is no longer possible since the execution
context is abstracted away.
- Adding backwards support for some of the features led to complexity
which is largely unnecessary with the above points in mind.
* update grpc test
sampling priority is actually unnecessary in these traces
* Clean up docs
* use lock instead of copying
* Use attr for context
* Add update tags api
* Revert context fix, fix tests
The context fix isn't required with the new definition of context
* Apply suggestions from code review
thank u jd and gab
Co-authored-by: Gabriele N. Tornetta <[email protected]>
Co-authored-by: Julien Danjou <[email protected]>
* Doc updates
* Fix typehint
* get_call_context -> current_trace_context
The old API naming no longer made sense as Context is not tied to
a call stack. I think that trace context is more clear as to what
the context is used for.
* update tests
* Reinstate get_call_context but deprecate it
* Expand on context documentation
* Implement local root as span attribute
This makes local root lookup constant time and a bit more defined
at the cost of another span attribute.
* Fix tests
* Address code review comments
- Doc fixes/updates
- Direct return
* Handle possibly None context
* Inline type hints
* delete init context attrs, fix eq, add unit tests
* Fix get_call_context and add back tests
It should always return a context
* Fix context attrs
* Move updating active span to context provider
Previously the active span updating was being done in the
tracer._on_span_finish callback which may not be called from the same
execution in which the span was created (eg. when a span is finished in
a future's callback). This could result in the wrong span being
activated (in the execution in which the span finished).
This has a disadvantage however. There is a possibility of a memory leak
when the following happens: there are executions A and B. A span is
created in A and finished in B. When this happens then a reference to
the span in kept in the contextvar for A. It will be removed/updated
when the context provider is queried for an active span or if a span is
activated. If this doesn't occur then the span (and any spans referenced
from the span) will be kept in memory so long as the contextvars context
lives.
The worst-case here is that a really large trace is created in an
execution and the spans are finished in another and no subsequent
tracing is done for the rest of the application lifecycle. Then this
trace will remain in memory for so long as the executor exists.
* Fix docs
* Add docs for cross-execution tracing
* Move self.enabled shortcut to after warning logic
* Doc cleanup
* Add comment for why the active span is replaced
* Store newly created contexts on a span
* Fixup the context documentation
Co-authored-by: Gabriele N. Tornetta <[email protected]>
Co-authored-by: Julien Danjou <[email protected]>
Co-authored-by: Brett Langdon <[email protected]>
0 commit comments