Class MockApmServer

java.lang.Object
org.elasticsearch.gradle.testclusters.MockApmServer

@NotThreadSafe public class MockApmServer extends Object
This is a server which just accepts lines of JSON code and if the JSON is valid and the root node is "transaction", then adds that JSON object to a transaction list which is accessible externally to the class.

The Elastic agent sends lines of JSON code, and so this mock server can be used as a basic APM server for testing.

The HTTP server used is the JDK embedded com.sun.net.httpserver

  • Constructor Details

    • MockApmServer

      public MockApmServer(String metricFilter, String transactionFilter, String transactionExcludesFilter)
  • Method Details

    • start

      public void start() throws IOException
      Start the Mock APM server. Just returns empty JSON structures for every incoming message
      Throws:
      IOException
    • getPort

      public int getPort()
    • stop

      public void stop()
      Stop the server gracefully if possible