Sha256: d1e634722d1c09334d6235bb09e6057dd5d76432341f595141ccc8c0b8a0e123

Contents?: true

Size: 1.19 KB

Versions: 2

Compression:

Stored size: 1.19 KB

Contents

require 'hystrix_metrics_jars'

module HystrixMetrics

    class MetricServer
        import com.netflix.hystrix.contrib.metrics.eventstream.HystrixMetricsStreamServlet
        import 'io.undertow.Handlers'
        import 'io.undertow.Undertow'
        import 'io.undertow.servlet.Servlets'

        attr_reader :server

        def initialize(port, path="/metrics")
            servlet = Servlets.servlet("EventStream", HystrixMetricsStreamServlet.java_class).addMapping('/*')
            classloader = java.lang.ClassLoader.getSystemClassLoader
            builder = Servlets.deployment
            .setDeploymentName("HystrixMetricServer")
            .setClassLoader(classloader)
            .setContextPath(path)
            .addServlets(servlet)
            manager = Servlets.defaultContainer.addDeployment(builder)
            manager.deploy
            path = Handlers.path(Handlers.redirect(path)).addPrefixPath(path, manager.start)

            @server = Undertow.builder
            .addHttpListener(port, "0.0.0.0")
            .setHandler(path)
            .build
        end

        def start
            @server.start
        end

        def stop
            @server.stop
        end
    end

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
hystrix_metrics-0.2.0-java lib/hystrix_metrics/metric_server.rb
hystrix_metrics-0.0.1-java lib/hystrix_metrics/metric_server.rb