core.otlp

Classes

_ProcessResourceDetector

_ServiceResourceDetector

_HostResourceDetector

_ClusterResourceDetector

OtlpAPI

OpenTelemetry API.

OpenTelemetryLogFormatter

Formatter that adds OpenTelemetry spans to log records.

Functions

get_resource(→ opentelemetry.sdk.resources.Resource)

Gather data on the currently running process to define an opentelemetry resource.

Module Contents

core.otlp.get_resource(raise_on_error: bool) opentelemetry.sdk.resources.Resource[source]

Gather data on the currently running process to define an opentelemetry resource.

Parameters:

raise_on_error – if True, will raise if an exception is encountered

Returns:

opentelemetry.sdk.resources.Resource

class core.otlp._ProcessResourceDetector[source]

Bases: opentelemetry.sdk.resources.ResourceDetector

detect() opentelemetry.sdk.resources.Resource[source]

Returns a Resource related to the process.

class core.otlp._ServiceResourceDetector[source]

Bases: opentelemetry.sdk.resources.ResourceDetector

detect() opentelemetry.sdk.resources.Resource[source]

Returns a Resource related to the instrumentation library itself.

class core.otlp._HostResourceDetector[source]

Bases: opentelemetry.sdk.resources.ResourceDetector

detect() opentelemetry.sdk.resources.Resource[source]

Returns a Resource related to the host machine.

class core.otlp._ClusterResourceDetector[source]

Bases: opentelemetry.sdk.resources.ResourceDetector

detect() opentelemetry.sdk.resources.Resource[source]

Returns a Resource related to the cluster job (if applicable).

class core.otlp.OtlpAPI(extra_detectors: List[opentelemetry.sdk.resources.ResourceDetector] = [])[source]

OpenTelemetry API.

_instance = None[source]
_initialized = False[source]
_sqlalchemy_instrumented = False[source]
_requests_instrumented = False[source]
_log_config[source]
_configure_resources(extra_detectors: List[opentelemetry.sdk.resources.ResourceDetector]) None[source]
_configure_providers() None[source]
_set_exporter(kwargs: Any, add_processor_func: Callable, batch_processor: Any) None[source]
classmethod instrument_sqlalchemy() None[source]

Instrument SQLAlchemy.

classmethod instrument_app(app: flask.Flask) None[source]

Instrument Flask app.

classmethod instrument_requests() None[source]

Instrument requests.

get_tracer(name: str) opentelemetry.trace.Tracer[source]

Get a tracer.

get_logger_provider() opentelemetry.sdk._logs.LoggerProvider[source]

Get the logger provider.

correlate_logger(logger_name: str, level: int = logging.INFO) None[source]

Correlate a logger with the current span.

static get_span_details() Tuple[str | None, str | None, str | None][source]

Retrieve details of the current span.

class core.otlp.OpenTelemetryLogFormatter(fmt=None, datefmt=None, style='%', validate=True, *, defaults=None)[source]

Bases: logging.Formatter

Formatter that adds OpenTelemetry spans to log records.

format(record: Any) Any[source]

Format the specified record as text.

The record’s attribute dictionary is used as the operand to a string formatting operation which yields the returned string. Before formatting the dictionary, a couple of preparatory steps are carried out. The message attribute of the record is computed using LogRecord.getMessage(). If the formatting string uses the time (as determined by a call to usesTime(), formatTime() is called to format the event time. If there is exception information, it is formatted using formatException() and appended to the message.