Module opentracing¶
OpenTracing API module entrypoint
Functions¶
start_span (name, opts)¶
Start root span
Parameters:
- name: (string)
- opts: table specifying modifications to make to thenewly created span. The following parameters are supported:
trace_id
,references
,a list of referenced spans;start_time
, the time to mark when the spanbegins (in microseconds since epoch);tags
, a table of tags to add tothe created span.
Returns:
(table) span
start_span_from_context (context, name)¶
Start new child span from context
Parameters:
Returns:
(table) span
trace_with_context (name, ctx, fun, …)¶
Trace function with context by global tracer This function starts span from global tracer and finishes it after execution
Parameters:
- name: (string) span name
- ctx: (table) context
- fun: (function) wrapped function
- …: (vararg) function’s arguments
Returns:
(vararg) result
Or
(nil) nil
(string) err error message
Usage:¶
-- Process HTTP request
local ctx = opentracing.extractors.http(req.headers)
local result, err = opentracing.trace_with_context('process_data', ctx, process_data, req.body)
-- Wrap functions. In example we create root span that generates two child spans
local span = opentracing.start_span()
local result, err = opentracing.trace_with_context('format_string', span:context(), format, str)
if not result ~= nil then
print('Error: ', err)
end
opentracing.trace_with_context('print_string', span:context(), print, result)
span:finish()
trace (name, fun, …)¶
Trace function by global tracer This function starts span from global tracer and finishes it after execution
Parameters:
- name: (string) span name
- fun: (function) wrapped function
- …: (vararg) function’s arguments
Returns:
(vararg) result
Or
(nil) nil
(string) err error message
Usage:¶
local result, err = opentracing.trace_with_context('process_data', process_data, req.body)