core.otlp ========= .. py:module:: core.otlp Classes ------- .. autoapisummary:: core.otlp._ProcessResourceDetector core.otlp._ServiceResourceDetector core.otlp._HostResourceDetector core.otlp._ClusterResourceDetector core.otlp.OtlpAPI core.otlp.OpenTelemetryLogFormatter Functions --------- .. autoapisummary:: core.otlp.get_resource Module Contents --------------- .. py:function:: get_resource(raise_on_error: bool) -> opentelemetry.sdk.resources.Resource Gather data on the currently running process to define an opentelemetry resource. :param raise_on_error: if True, will raise if an exception is encountered :returns: opentelemetry.sdk.resources.Resource .. py:class:: _ProcessResourceDetector Bases: :py:obj:`opentelemetry.sdk.resources.ResourceDetector` .. py:method:: detect() -> opentelemetry.sdk.resources.Resource Returns a Resource related to the process. .. py:class:: _ServiceResourceDetector Bases: :py:obj:`opentelemetry.sdk.resources.ResourceDetector` .. py:method:: detect() -> opentelemetry.sdk.resources.Resource Returns a Resource related to the instrumentation library itself. .. py:class:: _HostResourceDetector Bases: :py:obj:`opentelemetry.sdk.resources.ResourceDetector` .. py:method:: detect() -> opentelemetry.sdk.resources.Resource Returns a Resource related to the host machine. .. py:class:: _ClusterResourceDetector Bases: :py:obj:`opentelemetry.sdk.resources.ResourceDetector` .. py:method:: detect() -> opentelemetry.sdk.resources.Resource Returns a Resource related to the cluster job (if applicable). .. py:class:: OtlpAPI(extra_detectors: List[opentelemetry.sdk.resources.ResourceDetector] = []) OpenTelemetry API. .. py:attribute:: _instance :value: None .. py:attribute:: _initialized :value: False .. py:attribute:: _sqlalchemy_instrumented :value: False .. py:attribute:: _requests_instrumented :value: False .. py:attribute:: _log_config .. py:method:: _configure_resources(extra_detectors: List[opentelemetry.sdk.resources.ResourceDetector]) -> None .. py:method:: _configure_providers() -> None .. py:method:: _set_exporter(kwargs: Any, add_processor_func: Callable, batch_processor: Any) -> None .. py:method:: instrument_sqlalchemy() -> None :classmethod: Instrument SQLAlchemy. .. py:method:: instrument_app(app: flask.Flask) -> None :classmethod: Instrument Flask app. .. py:method:: instrument_requests() -> None :classmethod: Instrument requests. .. py:method:: get_tracer(name: str) -> opentelemetry.trace.Tracer Get a tracer. .. py:method:: get_logger_provider() -> opentelemetry.sdk._logs.LoggerProvider Get the logger provider. .. py:method:: correlate_logger(logger_name: str, level: int = logging.INFO) -> None Correlate a logger with the current span. .. py:method:: get_span_details() -> Tuple[Optional[str], Optional[str], Optional[str]] :staticmethod: Retrieve details of the current span. .. py:class:: OpenTelemetryLogFormatter(fmt=None, datefmt=None, style='%', validate=True, *, defaults=None) Bases: :py:obj:`logging.Formatter` Formatter that adds OpenTelemetry spans to log records. .. py:method:: format(record: Any) -> Any 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.