View module source on GitHub

SessionConfig

@deprecated(
    "This class will be removed in a future version. Use {} which is TypedDict."
)

@dataclass
class SessionConfig()

Session config.

This class represents a session config.

SessionConfigDict

class SessionConfigDict(TypedDict)

Session config dict.

This class represents a session config dictionary.

get_session_config_dict

def get_session_config_dict(
        config: Union[SessionConfig, SessionConfigDict]) -> dict[str, Any]

Convert a session config to a session config dict else return the config.

Arguments:

NameDescription
configThe config to convert.

Returns:

dict[str, Any]: The session config dict.

Session

class Session(EventEmittingBaseContainer)

A session is a collection of traces.

A session is created when a new session is started.

A session is ended when the session is stopped.

__init__

def __init__(config: Union[SessionConfig, SessionConfigDict],
             writer: LogWriter)

Create a new session.

Arguments:

NameDescription
configThe configuration for the session.

trace

def trace(config: Union[TraceConfig, TraceConfigDict]) -> Trace

Create a new trace for this session.

Arguments:

NameDescription
configThe configuration for the trace.

Returns:

A new Trace instance.

trace_

@staticmethod
def trace_(writer: LogWriter, session_id: str,
           config: Union[TraceConfig, TraceConfigDict]) -> Trace

Create a new trace for this session.

Arguments:

NameDescription
writerThe LogWriter instance to use.
session_idThe ID of the session to create the trace for.
configThe configuration for the trace.

Returns:

A new Trace instance.

feedback

def feedback(feedback: Union[Feedback, FeedbackDict])

Add feedback to this session.

Arguments:

NameDescription
feedbackThe feedback to add.

add_attachment

def add_attachment(attachment: Union[FileAttachment, FileDataAttachment,
                                     UrlAttachment])

Add an attachment to this session.

Arguments:

NameDescription
attachmentThe attachment to add.

add_attachment_

@staticmethod
def add_attachment_(writer: LogWriter, session_id: str,
                    attachment: Union[FileAttachment, FileDataAttachment,
                                      UrlAttachment])

Add an attachment to this session.

Arguments:

NameDescription
writerThe LogWriter instance to use.
session_idThe ID of the session to add the attachment to.
attachmentThe attachment to add.

add_tag_

@staticmethod
def add_tag_(writer: LogWriter, session_id: str, key: str, value: str)

Add a tag to this session.

Arguments:

NameDescription
writerThe LogWriter instance to use.
session_idThe ID of the session to add the tag to.
keyThe tag key.
valueThe tag value.

end_

@staticmethod
def end_(writer: LogWriter,
         session_id: str,
         data: Optional[Dict[str, Any]] = None)

End this session.

Arguments:

NameDescription
writerThe LogWriter instance to use.
session_idThe ID of the session to end.
dataOptional data to add to the session.

event_

@staticmethod
def event_(writer: LogWriter, session_id: str, id: str, event: str,
           data: Dict[str, str])

Add an event to this session.

Arguments:

NameDescription
writerThe LogWriter instance to use.
session_idThe ID of the session to add the event to.
idThe ID of the event.
eventThe event.
dataOptional data to add to the event.