""" This module provides a SolarWinds-specific exporter.

The exporter translates OpenTelemetry spans into SolarWinds Observability events so that the instrumentation data
generated by an OpenTelemetry-based agent can be processed by the SolarWinds backend.
"""

import logging
from typing import Any

from opentelemetry.sdk.trace.export import SpanExporter

from solarwinds_apm.apm_constants import (
    INTL_SWO_SUPPORT_EMAIL,
)
from solarwinds_apm.w3c_transformer import W3CTransformer

logger = logging.getLogger(__name__)


class SolarWindsSpanExporter(SpanExporter):
    """SolarWinds custom span exporter for the SolarWinds backend.
    Initialization requires a liboboe reporter.
    """

    _INTERNAL_TRANSACTION_NAME = "TransactionName"

    def __init__(
        self,
        reporter,
        apm_txname_manager,
        agent_enabled,
        *args,
        **kw_args,
    ) -> None:
        super().__init__(*args, **kw_args)
        self.reporter = reporter
        self.apm_txname_manager = apm_txname_manager
        if agent_enabled:
            from solarwinds_apm.extension.oboe import Context, Metadata
            self.context = Context
            self.metadata = Metadata
        else:
            from solarwinds_apm.apm_noop import Context, Metadata
            self.context = Context
            self.metadata = Metadata

    def export(self, spans) -> None:
        """No-op export
        """
        return
