Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HystrixCodaHaleMetricsPublisher broken in 1.5.x #1581

Closed
KevinJCross opened this issue May 15, 2017 · 1 comment
Closed

HystrixCodaHaleMetricsPublisher broken in 1.5.x #1581

KevinJCross opened this issue May 15, 2017 · 1 comment

Comments

@KevinJCross
Copy link

The metrics publisher seems to be broken in 1.5.x where in 1.4.x it works perfectly.

The following test based on HystrixCodaHaleMetricsPublisherCommandTest works in 1.4.x and fails in 1.5.x

package com.netflix.hystrix.contrib.codahalemetricspublisher;

import com.codahale.metrics.Gauge;
import com.codahale.metrics.MetricRegistry;
import com.netflix.hystrix.HystrixCommand;
import com.netflix.hystrix.HystrixCommandGroupKey;
import com.netflix.hystrix.HystrixCommandKey;
import com.netflix.hystrix.strategy.HystrixPlugins;
import org.junit.Before;
import org.junit.Test;

import java.util.Map;

import static org.hamcrest.core.Is.is;
import static org.junit.Assert.assertThat;

public class HystrixCodaHaleMetricsPublisherCommandTest {
    private final MetricRegistry metricRegistry = new MetricRegistry();

    @Before
    public void setup() {
        HystrixPlugins.getInstance().registerMetricsPublisher(new HystrixCodaHaleMetricsPublisher(metricRegistry));
    }

    @Test
    public void commandMaxActiveGauge() throws InterruptedException {
        Command command = new Command();
        command.execute();

        for (Map.Entry<String, Gauge> entry : metricRegistry.getGauges().entrySet()) {
            entry.getValue().getValue();
        }


        assertThat((Long) metricRegistry.getGauges().get("test.test.countSuccess").getValue(), is(1L));

    }

    private static class Command extends HystrixCommand<Void> {
        final static HystrixCommandKey hystrixCommandKey = HystrixCommandKey.Factory.asKey("test");
        final static HystrixCommandGroupKey hystrixCommandGroupKey = HystrixCommandGroupKey.Factory.asKey("test");

        Command() {
            super(Setter.withGroupKey(hystrixCommandGroupKey).andCommandKey(hystrixCommandKey));
        }

        @Override
        protected Void run() throws Exception {
            return null;
        }
    }
}
@mattrjacobs
Copy link
Contributor

Thanks for the report, @kevlarC . Got this working in #1586

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants