"""Observability infrastructure — logging, crash reporting, tracing.

See: ``docs/reference/observability.md`` (logging + OTel + redaction),
     ``docs/reference/crash_reporting.md`` (crash reporter + sinks).

This subpackage has no consumer-project imports. Identity (app name +
version) flows in via :mod:`mgf.common._identity`, which the consumer
project bootstraps once in its entry point via :func:`mgf.common.bootstrap`.

Public surface:

- :func:`mgf.common.bootstrap` — single-call lifecycle wiring
  (logging + OTel + excepthooks, with rollback on failure). The
  legacy multi-call setup helpers (``setup_logging``, ``setup_otel``,
  ``install_excepthook``, ``install_threading_excepthook``) were
  removed pre-v1.0; bootstrap is the only supported entry point.
- :func:`operation_span` — context manager wrapping a use case in
  a span. Safe to use even when OTel is disabled.
- :func:`report_now` — build + persist + best-effort ship a crash
  report from any caught exception.
- :class:`Redactor` — sensitive-field redaction policy used by the
  formatters.
- :data:`DEFAULT_REDACTION_KEYS` — the built-in secret-bearing key
  set, exposed as a frozenset so consumers can audit / extend
  without copy-paste (closes FEEDBACK PAPER-02).
- :func:`default_log_path`, :func:`default_crash_dir`,
  :func:`default_state_dir` — on-disk locations the library writes
  to, for consumers building observability-adjacent UI (closes
  FEEDBACK PAPER-07).

See ``docs/standards/LOGGING.md`` and ``docs/standards/ERROR_HANDLING.md``
for the full design.
"""

from __future__ import annotations

from mgf.common.observability._conformance import (
    log_schema_manifest,
)
from mgf.common.observability._helpers import (
    add_event,
    get_current_span,
    get_logger,
    set_attribute,
    set_status,
)
from mgf.common.observability._introspect import (
    HandlerInfo,
    LogInfo,
    describe_logging,
)
from mgf.common.observability._otel_reexports import (
    Span,
    SpanContext,
    SpanKind,
    SpanStatus,
    StatusCode,
)
from mgf.common.observability._stats import (
    LogStats,
    LogStatsCollector,
    current_log_stats,
    disable_log_stats,
    enable_log_stats,
)
from mgf.common.observability.async_handler import AsyncJsonHandler
from mgf.common.observability.crash_reporter import (
    CrashSink,
    register_crash_sink,
    report_now,
    unregister_crash_sink,
)
from mgf.common.observability.json_formatter import JsonFormatter
from mgf.common.observability.log_filters import (
    DedupFilter,
    RateLimitFilter,
    SampleFilter,
)
from mgf.common.observability.log_record import (
    LOG_SCHEMA_VERSION,
    LogRecord,
)
from mgf.common.observability.logging_setup import (
    LogFormat,
    LogHandlerFactory,
    register_log_handler,
    unregister_log_handler,
)
from mgf.common.observability.otel_setup import (
    SpanProcessorFactory,
    operation_span,
    register_span_processor,
    unregister_span_processor,
)
from mgf.common.observability.paths import (
    default_crash_dir,
    default_log_path,
    default_state_dir,
)
from mgf.common.observability.redaction import (
    DEFAULT_REDACTION_KEYS,
    PatternGroupFactory,
    RedactionGroup,
    Redactor,
    register_redaction_pattern_group,
    unregister_redaction_pattern_group,
)

__all__ = [
    "DEFAULT_REDACTION_KEYS",
    "LOG_SCHEMA_VERSION",
    "AsyncJsonHandler",
    "CrashSink",
    "DedupFilter",
    "HandlerInfo",
    "JsonFormatter",
    "LogFormat",
    "LogHandlerFactory",
    "LogInfo",
    "LogRecord",
    "LogStats",
    "LogStatsCollector",
    "PatternGroupFactory",
    "RateLimitFilter",
    "RedactionGroup",
    "Redactor",
    "SampleFilter",
    "Span",
    "SpanContext",
    "SpanKind",
    "SpanProcessorFactory",
    "SpanStatus",
    "StatusCode",
    "add_event",
    "current_log_stats",
    "default_crash_dir",
    "default_log_path",
    "default_state_dir",
    "describe_logging",
    "disable_log_stats",
    "enable_log_stats",
    "get_current_span",
    "get_logger",
    "log_schema_manifest",
    "operation_span",
    "register_crash_sink",
    "register_log_handler",
    "register_redaction_pattern_group",
    "register_span_processor",
    "report_now",
    "set_attribute",
    "set_status",
    "unregister_crash_sink",
    "unregister_log_handler",
    "unregister_redaction_pattern_group",
    "unregister_span_processor",
]
