Skip to content
This repository was archived by the owner on Aug 13, 2025. It is now read-only.

Commit 2ed7523

Browse files
committed
rename 'wrap' to 'traced'
Seems more intuitive for the function decorator to be `traced`. As in, "my_fn is a traced function". Example: @Traced(name='my_fn') def my_fn(): pass
1 parent 5488b49 commit 2ed7523

File tree

2 files changed

+11
-10
lines changed

2 files changed

+11
-10
lines changed

beeline/__init__.py

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ def send_all(self):
164164
self.tracer_impl.finish_span(span)
165165
span = self.tracer_impl.get_active_span()
166166

167-
def wrap(self, name, trace_id=None, parent_id=None):
167+
def traced(self, name, trace_id=None, parent_id=None):
168168
def wrapped(fn, *args, **kwargs):
169169
def inner(*args, **kwargs):
170170
with self.tracer(name=name, trace_id=trace_id, parent_id=parent_id):
@@ -518,24 +518,25 @@ def close():
518518

519519
_GBL = None
520520

521-
def wrap(name, trace_id=None, parent_id=None):
521+
def traced(name, trace_id=None, parent_id=None):
522522
'''
523-
Function decorator to wrap an entire function in a span. If no trace
524-
is active, starts a new trace, and the wrapping span will be a root
525-
span.
523+
Function decorator to wrap an entire function in a trace span. If no trace
524+
is active in the current thread, starts a new trace, and the wrapping span
525+
will be a root span. If a trace is active, creates a child span of the
526+
existing trace.
526527
527528
Example use:
528529
529530
```
530-
@wrap(name="my_expensive_function")
531+
@traced(name="my_expensive_function")
531532
def my_func(n):
532533
recursive_fib(n)
533534
534535
my_func(100)
535536
```
536537
537538
Args:
538-
- `name`: a descriptive name for the this trace span, i.e. "function_name"
539+
- `name`: a descriptive name for the this trace span, i.e. "function_name". This is required.
539540
- `trace_id`: the trace_id to use. If None, will be automatically generated.
540541
Use this if you want to explicitly resume a trace in this application that was
541542
initiated in another application, and you have the upstream trace_id.
@@ -553,4 +554,4 @@ def inner(*args, **kwargs):
553554

554555
return wrapped
555556

556-
return _beeline.wrap(name, trace_id, parent_id)
557+
return _beeline.traced(name, trace_id, parent_id)

beeline/test_beeline.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ def test_trace_wrapper(self):
164164
m_gbl.return_value = _beeline
165165
_beeline.tracer_impl._run_hooks_and_send = Mock()
166166

167-
@beeline.wrap(name="my_sum")
167+
@beeline.traced(name="my_sum")
168168
def my_sum(a, b):
169169
return a + b
170170

@@ -183,7 +183,7 @@ def setUp(self):
183183
def test_trace_wrapper(self):
184184
''' ensure the trace wrapper doesn't break if the beeline is not initialized '''
185185
self.assertIsNone(beeline.get_beeline())
186-
@beeline.wrap(name="my_sum")
186+
@beeline.traced(name="my_sum")
187187
def my_sum(a, b):
188188
return a + b
189189

0 commit comments

Comments
 (0)