Runner: Session Logs and Results not distinguishable between sessions

Hello everyone,

i recently migrated from the REST API to the Runner client.
I have an issue with the session logs. By following the example in the Runner API docs, we acquire the runner log which contains log entries for every opentap session. Additionally, we have no way to assign the entries to their respective sessions. We do not have any method for distinguishing between the logs for each session. Am I missing something here?

Any help would be highly appreciated.

Hi @yannick.njanjo !

There are a few ways of connecting log messages to their sessions.

First possibility just uses the Id in the sessionclient in a lambda function:

        sessionClient.ConnectSessionLogs((logList) =>
        {
            foreach (var log in logList.Logs)
            {
                Console.WriteLine($"{sessionClient.Id}: {log.Message}");
            }
        });

Second approach is to create an actual “collector” instance:

public class LogCollector
{
    public LogCollector(Guid sessionId)
    {
        SessionId = sessionId;
    }

    public Guid SessionId { get; set; }
    public List<LogEntry> Logs { get; set; } = new List<LogEntry>();
    
    public void Collect(LogList logList)
    {
        Logs.AddRange(logList.Logs);
    }
}

And then use it like this:

        LogCollector sessionSpecificLogCollector = new LogCollector(sessionClient.Id);
        sessionClient.ConnectSessionLogs(sessionSpecificLogCollector.Collect);

I hope this helps making the connection between sessions and their logs. Same approach can be used for Results and Events!

// Dennis

1 Like

@Dennis, thank you for your prompt response.

I apologize for not clearly articulating my initial question. I am currently developing a custom GUI for OpenTAP that communicates with OpenTAP through the NATS Runner. The GUI is designed to run multiple instances of the test sequencer in parallel, with each instance having its own dedicated display area for logs and results. In the TAP_Installation/SessionLogs directory, log entries are saved in separate files corresponding to the session they originated from. Additionally, there is a runner log that consolidates entries from all sessions.

The Runner API’s SessionClient.ConnectSessionLogs method returns the log entries from every session (similar to the runner log), regardless of the SessionClient instance used to call it.

Is there a way to filter out log entries from other sessions (same for results and events)?

Additionally, is there a method to access the session ID from an OpenTAP plugin?

Hello everyone, I have a similar problem as Yannick. Somehow there is no way in distinguishing between the different sessions when results are received. Yes, I can subscribe with each session seperately to the results, but in the end, I will get all the results from each of the different sessions, and they are not distinguishable from which session the result came. Am I missing something here?
Any help or ideas how to solve this problem are appreciated.