import os
from typing import Any

from opik import Opik

from ._http_debug import _install_http_debug_interceptor
from .auth import setup_acceldata_auth_hook


def AcceldataTracer(
    url: str,
    access_key: str,
    secret_key: str,
    *,
    debug: bool = False,
    check_tls_certificate: bool = True,
    **kwargs: Any,
) -> Opik:
    setup_acceldata_auth_hook(access_key, secret_key)
    os.environ["OPIK_CHECK_TLS_CERTIFICATE"] = "true" if check_tls_certificate else "false"
    if debug:
        _install_http_debug_interceptor(url)
    return Opik(host=url, **kwargs)
