This repository was archived by the owner on Aug 13, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 5 files changed +32
-6
lines changed Expand file tree Collapse file tree 5 files changed +32
-6
lines changed Original file line number Diff line number Diff line change @@ -427,6 +427,24 @@ def finish_span(span):
427
427
if _GBL :
428
428
_GBL .tracer_impl .finish_span (span = span )
429
429
430
+ def marshal_trace_context ():
431
+ '''
432
+ Returns a serialized form of the current trace context (including the trace
433
+ id and the current span), encoded as a string. You can use this to propagate
434
+ trace context to other services.
435
+
436
+ Example:
437
+
438
+ ```
439
+ trace_context = beeline.marshal_trace_context()
440
+ headers = {'X-Honeycomb-Trace': trace_context}
441
+ requests.get("http://...", headers=headers)
442
+ ```
443
+ '''
444
+ if _GBL :
445
+ return _GBL .tracer_impl .marshal_trace_context ()
446
+
447
+
430
448
def new_event (data = None , trace_name = '' ):
431
449
''' DEPRECATED: Helper method that wraps `start_trace` and
432
450
`start_span`. It is better to use these methods as it provides
Original file line number Diff line number Diff line change @@ -34,11 +34,13 @@ def test_wrapper_works_no_init(self):
34
34
''' ensure that the wrapper doesn't break anything if used before
35
35
beeline.init is called
36
36
'''
37
- @awslambda .beeline_wrapper
38
- def foo (event , context ):
39
- return 1
37
+ with patch ('beeline.get_beeline' ) as p :
38
+ p .return_value = None
39
+ @awslambda .beeline_wrapper
40
+ def foo (event , context ):
41
+ return 1
40
42
41
- self .assertEqual (foo (None , None ), 1 )
43
+ self .assertEqual (foo (None , None ), 1 )
42
44
43
45
def test_basic_instrumentation (self ):
44
46
''' ensure basic event fields get instrumented '''
Original file line number Diff line number Diff line change @@ -152,3 +152,9 @@ def test_start_trace_returns_value(self):
152
152
self .m_gbl .tracer_impl .start_trace .return_value = 'wooimatrace'
153
153
val = beeline .start_trace ()
154
154
self .assertEqual (val , 'wooimatrace' )
155
+
156
+ def test_marshal_trace_context_returns_value (self ):
157
+ ''' ensure the top-level definition of marshal_trace_context returns a value '''
158
+ self .m_gbl .tracer_impl .marshal_trace_context .return_value = 'asdf'
159
+ val = beeline .marshal_trace_context ()
160
+ self .assertEqual (val , 'asdf' )
Original file line number Diff line number Diff line change 1
- VERSION = '2.0 .0'
1
+ VERSION = '2.1 .0'
Original file line number Diff line number Diff line change 4
4
setup (
5
5
python_requires = '>=2.7' ,
6
6
name = 'honeycomb-beeline' ,
7
- version = '2.0 .0' ,
7
+ version = '2.1 .0' ,
8
8
description = 'Honeycomb library for easy instrumentation' ,
9
9
url = 'https://github.com/honeycombio/beeline-python' ,
10
10
author = 'Honeycomb.io' ,
You can’t perform that action at this time.
0 commit comments