# DO NOT EDIT THIS FILE!
#
# This code is generated off of PyCDP modules. If you need to make
# changes, edit the generator and regenerate all of the modules.

from __future__ import annotations
import typing

from ..context import get_connection_context, get_session_context

import cdp.tracing
from cdp.tracing import (
    BufferUsage,
    DataCollected,
    MemoryDumpConfig,
    StreamCompression,
    StreamFormat,
    TraceConfig,
    TracingComplete
)


async def end() -> None:
    '''
    Stop trace events collection.
    '''
    session = get_session_context('tracing.end')
    return await session.execute(cdp.tracing.end())


async def get_categories() -> typing.List[str]:
    '''
    Gets supported tracing categories.

    :returns: A list of supported tracing categories.
    '''
    session = get_session_context('tracing.get_categories')
    return await session.execute(cdp.tracing.get_categories())


async def record_clock_sync_marker(
        sync_id: str
    ) -> None:
    '''
    Record a clock sync marker in the trace.

    :param sync_id: The ID of this clock sync marker
    '''
    session = get_session_context('tracing.record_clock_sync_marker')
    return await session.execute(cdp.tracing.record_clock_sync_marker(sync_id))


async def request_memory_dump() -> typing.Tuple[str, bool]:
    '''
    Request a global memory dump.

    :returns: A tuple with the following items:

        0. **dumpGuid** – GUID of the resulting global memory dump.
        1. **success** – True iff the global memory dump succeeded.
    '''
    session = get_session_context('tracing.request_memory_dump')
    return await session.execute(cdp.tracing.request_memory_dump())


async def start(
        categories: typing.Optional[str] = None,
        options: typing.Optional[str] = None,
        buffer_usage_reporting_interval: typing.Optional[float] = None,
        transfer_mode: typing.Optional[str] = None,
        stream_format: typing.Optional[StreamFormat] = None,
        stream_compression: typing.Optional[StreamCompression] = None,
        trace_config: typing.Optional[TraceConfig] = None
    ) -> None:
    '''
    Start trace events collection.

    :param categories: **(DEPRECATED)** *(Optional)* Category/tag filter
    :param options: **(DEPRECATED)** *(Optional)* Tracing options
    :param buffer_usage_reporting_interval: *(Optional)* If set, the agent will issue bufferUsage events at this interval, specified in milliseconds
    :param transfer_mode: *(Optional)* Whether to report trace events as series of dataCollected events or to save trace to a stream (defaults to ```ReportEvents````).
    :param stream_format: *(Optional)* Trace data format to use. This only applies when using ````ReturnAsStream```` transfer mode (defaults to ````json````).
    :param stream_compression: *(Optional)* Compression format to use. This only applies when using ````ReturnAsStream```` transfer mode (defaults to ````none```)
    :param trace_config: *(Optional)*
    '''
    session = get_session_context('tracing.start')
    return await session.execute(cdp.tracing.start(categories, options, buffer_usage_reporting_interval, transfer_mode, stream_format, stream_compression, trace_config))
