Class InMemoryLogQueryClient

java.lang.Object
codes.grow.packages.skywalking.testing.logging.InMemoryLogQueryClient
All Implemented Interfaces:
LogQueryClient

public final class InMemoryLogQueryClient extends Object implements LogQueryClient
LogQueryClient over in-memory records (usually InMemoryLogExporter.records()).

A query matches when every whitespace-separated term occurs (case-insensitively) in the body or in an attribute value; an empty query matches everything. Cursors are result offsets. The only stream is "default"; labels are the attribute names.

  • Constructor Details

    • InMemoryLogQueryClient

      public InMemoryLogQueryClient(InMemoryLogExporter exporter)
      Reads the records of an exporter.
      Parameters:
      exporter - in-memory exporter
    • InMemoryLogQueryClient

      public InMemoryLogQueryClient(Supplier<List<LogRecord>> source)
      Reads records from a supplier.
      Parameters:
      source - current records
  • Method Details

    • matches

      public static boolean matches(String query, LogRecord record)
      Whether a record matches a query.
      Parameters:
      query - query text
      record - record
      Returns:
      true when every term occurs in the body or an attribute value
    • search

      public LogSearchResult search(String query, SearchOptions options)
      Description copied from interface: LogQueryClient
      Searches records matching a service query (full text or the service's query language).
      Specified by:
      search in interface LogQueryClient
      Parameters:
      query - query text
      options - range, limit, order, cursor
      Returns:
      one page of records
    • tail

      public TailHandle tail(String query, Consumer<LogRecord> onRecord, TailOptions options)
      Description copied from interface: LogQueryClient
      Streams new matching records to onRecord until the handle is stopped.
      Specified by:
      tail in interface LogQueryClient
      Parameters:
      query - query text
      onRecord - callback per record
      options - start time, polling interval, error callback
      Returns:
      handle
    • listStreams

      public List<String> listStreams()
      Description copied from interface: LogQueryClient
      Lists the log streams (indexes, streams, data sets) of the service.
      Specified by:
      listStreams in interface LogQueryClient
      Returns:
      names
    • listLabels

      public List<String> listLabels()
      Description copied from interface: LogQueryClient
      Lists the label or field names of the service.
      Specified by:
      listLabels in interface LogQueryClient
      Returns:
      names