[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[tor-commits] [metrics-lib/master] Include previously unknown error codes in Torperf results.



commit afc57a61209f806581c3c6ca472077fbcba835ec
Author: Karsten Loesing <karsten.loesing@xxxxxxx>
Date:   Tue May 12 21:35:58 2020 +0200

    Include previously unknown error codes in Torperf results.
    
    As discussed on #34031, we should avoid keeping a map of known failure
    types in the sources and simply put together the error code in the
    format we want.
    
    This patch implements that change.
---
 CHANGELOG.md                                       |  4 ++++
 .../onionperf/OnionPerfAnalysisConverter.java      | 24 ++++++++--------------
 .../onionperf/OnionPerfAnalysisConverterTest.java  |  2 +-
 3 files changed, 13 insertions(+), 17 deletions(-)

diff --git a/CHANGELOG.md b/CHANGELOG.md
index af5a7f0..5ed2425 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,5 +1,9 @@
 # Changes in version 2.??.? - 2020-??-??
 
+ * Minor changes
+   - Include previously unknown error codes in Torperf results
+     converted from OnionPerf analysis files.
+
 
 # Changes in version 2.12.2 - 2020-04-30
 
diff --git a/src/main/java/org/torproject/descriptor/onionperf/OnionPerfAnalysisConverter.java b/src/main/java/org/torproject/descriptor/onionperf/OnionPerfAnalysisConverter.java
index 18adf8c..8ca5efd 100644
--- a/src/main/java/org/torproject/descriptor/onionperf/OnionPerfAnalysisConverter.java
+++ b/src/main/java/org/torproject/descriptor/onionperf/OnionPerfAnalysisConverter.java
@@ -127,18 +127,6 @@ public class OnionPerfAnalysisConverter {
   private StringBuilder formatTorperfResults(
       ParsedOnionPerfAnalysis parsedOnionPerfAnalysis) {
     StringBuilder formattedTorperfResults = new StringBuilder();
-    Map<String, String> errorCodes = new HashMap<>();
-    errorCodes.put("AUTH", "TGEN/AUTH");
-    errorCodes.put("READ", "TGEN/READ");
-    errorCodes.put("STALLOUT", "TGEN/STALLOUT");
-    errorCodes.put("TIMEOUT", "TGEN/TIMEOUT");
-    errorCodes.put("PROXY", "TOR");
-    errorCodes.put("PROXY_CANT_ATTACH", "TOR/CANT_ATTACH");
-    errorCodes.put("PROXY_DESTROY", "TOR/DESTROY");
-    errorCodes.put("PROXY_END_TIMEOUT", "TOR/END/TIMEOUT");
-    errorCodes.put("PROXY_END_CONNECTREFUSED", "TOR/END/CONNECTREFUSED");
-    errorCodes.put("PROXY_RESOLVEFAILED", "TOR/RESOLVEFAILED");
-    errorCodes.put("PROXY_TIMEOUT", "TOR/TIMEOUT");
     for (Map.Entry<String, ParsedOnionPerfAnalysis.MeasurementData> data
         : parsedOnionPerfAnalysis.data.entrySet()) {
       String nickname = data.getKey();
@@ -183,7 +171,12 @@ public class OnionPerfAnalysisConverter {
         List<String> errorCodeParts = null;
         if (transfer.isError) {
           errorCodeParts = new ArrayList<>();
-          errorCodeParts.add(transfer.errorCode);
+          if ("PROXY".equals(transfer.errorCode)) {
+            errorCodeParts.add("TOR");
+          } else {
+            errorCodeParts.add("TGEN");
+            errorCodeParts.add(transfer.errorCode);
+          }
         }
         String sourcePort = endpointLocalParts[2];
         if (streamsBySourcePort.containsKey(sourcePort)) {
@@ -207,9 +200,8 @@ public class OnionPerfAnalysisConverter {
           }
         }
         if (null != errorCodeParts) {
-          String errorCode = String.join("_", errorCodeParts);
-          torperfResultsBuilder.addString("ERRORCODE",
-              errorCodes.getOrDefault(errorCode, errorCode));
+          String errorCode = String.join("/", errorCodeParts);
+          torperfResultsBuilder.addString("ERRORCODE", errorCode);
         }
         formattedTorperfResults.append(torperfResultsBuilder.build());
       }
diff --git a/src/test/java/org/torproject/descriptor/onionperf/OnionPerfAnalysisConverterTest.java b/src/test/java/org/torproject/descriptor/onionperf/OnionPerfAnalysisConverterTest.java
index c921a2d..7a1a3a0 100644
--- a/src/test/java/org/torproject/descriptor/onionperf/OnionPerfAnalysisConverterTest.java
+++ b/src/test/java/org/torproject/descriptor/onionperf/OnionPerfAnalysisConverterTest.java
@@ -70,7 +70,7 @@ public class OnionPerfAnalysisConverterTest {
       + "ENDPOINTLOCAL=localhost:127.0.0.1:40948 "
       + "ENDPOINTPROXY=localhost:127.0.0.1:35900 "
       + "ENDPOINTREMOTE=37.218.245.95:37.218.245.95:443 "
-      + "ERRORCODE=PROXY_END_MISC FILESIZE=51200 HOSTNAMELOCAL=op-nl2 "
+      + "ERRORCODE=TOR/END/MISC FILESIZE=51200 HOSTNAMELOCAL=op-nl2 "
       + "HOSTNAMEREMOTE=(null) LAUNCH=1587991454.80 NEGOTIATE=1587991580.81 "
       + "PATH=$12CF6DB4DAE106206D6C6B09988E865C0509843B,"
       + "$1DC17C4A52A458B5C8B1E79157F8665696210E10,"

_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits