Class HttpMetricsClient

  • All Implemented Interfaces:

    
    public class HttpMetricsClient
    
                        

    Simple HTTP client for sending metrics to a receiver. Uses Java's built-in HttpURLConnection for maximum compatibility with all JVM environments including MATLAB. Metrics are sent as JSON via HTTP POST.

    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
    • Field Summary

      Fields 
      Modifier and Type Field Description
    • Enum Constant Summary

      Enum Constants 
      Enum Constant Description
    • Method Summary

      Modifier and Type Method Description
      boolean sendMetrics(List<SSAMetricPoint> metrics) Send a batch of metrics to the HTTP receiver.
      boolean isConnectionFailed() Check if connection has failed.
      void shutdown() Shutdown the client.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • HttpMetricsClient

        HttpMetricsClient(String endpoint, String serviceName)
        Create a new HTTP metrics client.
        Parameters:
        endpoint - The HTTP receiver endpoint (e.g.
        serviceName - The service name to identify this simulation
      • HttpMetricsClient

        HttpMetricsClient(String endpoint, String serviceName, boolean failOnConnectionError)
        Create a new HTTP metrics client.
        Parameters:
        endpoint - The HTTP receiver endpoint (e.g.
        serviceName - The service name to identify this simulation
        failOnConnectionError - If true, throw exception on connection failure
    • Method Detail

      • sendMetrics

         boolean sendMetrics(List<SSAMetricPoint> metrics)

        Send a batch of metrics to the HTTP receiver.

        Parameters:
        metrics - List of metric points to send
        Returns:

        true if successful, false otherwise

      • isConnectionFailed

         boolean isConnectionFailed()

        Check if connection has failed.

        Returns:

        true if connection failed and client is in dry-run mode

      • shutdown

         void shutdown()

        Shutdown the client.