Instrumentor#

This modules contains the OtelInstrumentor class that implements Opentelemetry’s BaseInstrumentor interface and allows for automated instrumentation of Dialog Flow Framework applications, e.g. for automated logging and log export.

For detailed reference, see ~OtelInstrumentor class.

class OtelInstrumentor(logger_provider=None, tracer_provider=None, meter_provider=None)[source]#

Bases: BaseInstrumentor

Utility class for instrumenting DFF-related functions that implements the BaseInstrumentor interface. instrument() and uninstrument() methods are available to apply and revert the instrumentation effects, e.g. enable and disable logging at runtime.

dff_instrumentor = OtelInstrumentor()
dff_instrumentor.instrument()
dff_instrumentor.uninstrument()

Opentelemetry provider instances can be optionally passed to the class constructor. Otherwise, the global logger, tracer and meter providers are leveraged.

The class implements the __call__() method, so that regular functions can be decorated using the class instance.

@dff_instrumentor
async def function(context, pipeline, runtime_info):
    ...
Parameters:
  • logger_provider – Opentelemetry logger provider. Used to construct a logger instance.

  • tracer_provider – Opentelemetry tracer provider. Used to construct a tracer instance.

Parame meter_provider:

Opentelemetry meter provider. Used to construct a meter instance.

classmethod from_url(url, insecure=True, timeout=None)[source]#

Construct an instrumentor instance using only the url of the OTLP Collector. Inherently modifies the global provider instances adding an export destination for the target url.

instrumentor = OtelInstrumentor.from_url("grpc://localhost:4317")
Parameters:
  • url (str) – Url of the running Otel Collector server. Due to limited support of HTTP protocol by the Opentelemetry Python extension, GRPC protocol is preferred.

  • insecure (bool) – Whether non-SSL-protected connection is allowed. Defaults to True.

  • timeout (Optional[int]) – Connection timeout in seconds, optional.

instrumentation_dependencies()[source]#

Required libraries. Implements the Python Opentelemetry instrumentor interface.

Return type:

Collection[str]

_instrument(logger_provider=None, tracer_provider=None, meter_provider=None)[source]#

Instrument the library

_uninstrument(**kwargs)[source]#

Uninstrument the library

_configure_providers(logger_provider, tracer_provider, meter_provider)[source]#