Module opentracing.tracer | Enterprise
Документация на русском языке
поддерживается сообществом

Module opentracing.tracer

Tracer is the entry point API between instrumentation code and the tracing implementation.

This implementation both defines the public Tracer API, and provides a default no-op behavior.

Functions

new (reporter, sampler)

Init new tracer

Parameters:

  • reporter:
    • report: (function)
  • sampler:
    • sample: (function)

Returns:

(table) tracer

start_span (self, name, opts)

Starts and returns a new Span representing a unit of work.

Example usage:

Create a root Span (a Span with no causal references):

tracer:start_span("op-name")

Create a child Span :

tracer:start_span(
        "op-name",
        {["references"] = {{"child_of", parent_span:context()}}})

Parameters:

  • self: (table)
  • name: (string) operation_name name of the operation represented by the new.. code-block:: lua Span from the perspective of the current service.
  • 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.
    • trace_id: (optional string)
    • child_of: (optional table)
    • references: (optional table)
    • tags: (optional table)
    • start_timestamp: (optional number)

Returns:

(table) span a Span instance

register_injector (self, format, injector)

Register injector for tracer

Parameters:

Returns:

(boolean) true

register_extractor (self, format, extractor)

Register extractor for tracer

Parameters:

Returns:

(boolean) true

inject (self, context, format, carrier)

Inject context into carrier with specified format. See https://opentracing.io/docs/overview/inject-extract/

Parameters:

Returns:

(table) carrier

Or

(nil)

(string) error

extract (self, format, carrier)

Extract context from carrier with specified format. See https://opentracing.io/docs/overview/inject-extract/

Parameters:

Returns:

(table) context

Or

(nil)

(string) error

http_headers_inject (self, context, carrier)

Injects span_context into carrier using a format appropriate for HTTP headers.

Parameters:

  • self: (table)
  • context: (table) the SpanContext instance to inject
  • carrier: (table)

Returns:

(table) context a table to contain the span context

Usage:

carrier = {}
tracer:http_headers_inject(span:context(), carrier)

text_map_inject (self, context, carrier)

Injects span_context into carrier .

Parameters:

  • self: (table)
  • context: (table) the SpanContext instance to inject
  • carrier: (table)

Returns:

(table) context a table to contain the span context

Usage:

carrier = {}
tracer:text_map_inject(span:context(), carrier)

http_headers_extract (self, carrier)

Returns a SpanContext instance extracted from the carrier or nil if no such SpanContext could be found. http_headers_extract expects a format appropriate for HTTP headers and uses case-sensitive comparisons for the keys.

Parameters:

  • self: (table)
  • carrier: (table) the format-specific carrier object to extract from

Returns:

(table) context

Or

(nil)

(string) error

text_map_extract (self, carrier)

Returns a SpanContext instance extracted from the carrier or nil if no such SpanContext could be found.

Parameters:

  • self: (table)
  • carrier: (table) the format-specific carrier object to extract from

Returns:

(table) context

Or

(nil)

(string) error

Нашли ответ на свой вопрос?
Обратная связь