2015-09-01 1 views
1

J'essaie d'utiliser hystrix pour surveiller un certain appel réseau. Mais toutes les mesures que j'essaie de surveiller sont toujours vides. Qu'est-ce que je fais mal?Pourquoi n'ai-je pas de statistiques hystrix?

Je simulent un appel réseau en mettant en place un (peu) l'interface RESTful qui renvoie un calcul de pow:

GetPowerCommand gpc = new GetPowerCommand(5, 82); 
powerMetrics = gpc.getMetrics(); 

Voici comment j'appelle la commande hystrix et vous attendre à obtenir des mesures (au moins demandes: non 0)

boolean run = true; 
while (run) { 
    try { 
     Thread.sleep(1000); 
    } catch (InterruptedException e) { 
     e.printStackTrace(); 
     run = false; 
    } 
    System.out.println("GetPowerCommand.run(): " + gpc.run()); 
    System.out.println("GetPowerCommand.run(): " + gpc.run()); 
    System.out.println("getStatsStringFromMetrics(powerMetrics): " + getStatsStringFromMetrics(powerMetrics)); 
} 

Mais tout ce que je reçois est:

GetPowerCommand.run(): <p>I guess .. </p><p>2^5 = 32</p> 
GetPowerCommand.run(): <p>I guess .. </p><p>2^5 = 32</p> 
getStatsStringFromMetrics(powerMetrics): Requests: 0 Errors: 0 (0%) Mean: 0 50th: 0 75th: 0 90th: 0 99th: 0 
GetPowerCommand.run(): <p>I guess .. </p><p>2^5 = 32</p> 
GetPowerCommand.run(): <p>I guess .. </p><p>2^5 = 32</p> 
getStatsStringFromMetrics(powerMetrics): Requests: 0 Errors: 0 (0%) Mean: 0 50th: 0 75th: 0 90th: 0 99th: 0 

edit: mes paramètres Méthode de récupération:

private static String getStatsStringFromMetrics(HystrixCommandMetrics metrics) { 
    StringBuilder m = new StringBuilder(); 
    if (metrics != null) { 
     HealthCounts health = metrics.getHealthCounts(); 
     m.append("Requests: ").append(health.getTotalRequests()).append(" "); 
     m.append("Errors: ").append(health.getErrorCount()).append(" (").append(health.getErrorPercentage()) 
       .append("%) "); 
     m.append("Mean: ").append(metrics.getTotalTimeMean()).append(" "); 
     m.append("50th: ").append(metrics.getExecutionTimePercentile(50)).append(" "); 
     m.append("75th: ").append(metrics.getExecutionTimePercentile(75)).append(" "); 
     m.append("90th: ").append(metrics.getExecutionTimePercentile(90)).append(" "); 
     m.append("99th: ").append(metrics.getExecutionTimePercentile(99)).append(" "); 
    } 
    return m.toString(); 
} 
+0

Je pourrais avoir une solution ici: Je pense qu'il est faux d'appeler 'GetPowerCommand.run()'. Je devrais appeler 'GetPowerCommand.execute()' à la place. – Christian

Répondre

1

Vous avez déjà répondu à votre question: utilisez execute() au lieu de run(). Regardez aussi here