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
fix: support module-level @Runnable with continue_tracing() (#391)
## Summary
`@runnable` previously captured the trace context snapshot at decoration time, which only worked when applied **inline** during an active request. Module-level `@runnable` (the natural Python pattern) silently broke cross-thread trace linking because the snapshot was `None` at import time.
### Changes
- `@runnable` now returns a `_RunnableWrapper` object with a `continue_tracing()` method
- `continue_tracing()` captures the snapshot on the calling (parent) thread and returns a callable for use as `Thread` target — this enables module-level `@runnable`
- `__call__` preserves the original behavior: uses the decoration-time snapshot for inline `@runnable` — **no breaking changes**
### Usage
**Module-level (new, previously broken):**
```python
@Runnable(op='/post')
def post():
requests.post(...)
@app.route('/')
def hello():
thread = Thread(target=post.continue_tracing()) # snapshot captured here
thread.start()
```
**Inline (unchanged, backward compatible):**
```python
@app.route('/')
def hello():
@Runnable(op='/post') # snapshot captured at decoration time
def post():
requests.post(...)
thread = Thread(target=post)
thread.start()
```
Closesapache/skywalking#11605
0 commit comments