image_annotation_metrics.h 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. // Copyright 2019 The Chromium Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style license that can be
  3. // found in the LICENSE file.
  4. #ifndef SERVICES_IMAGE_ANNOTATION_IMAGE_ANNOTATION_METRICS_H_
  5. #define SERVICES_IMAGE_ANNOTATION_IMAGE_ANNOTATION_METRICS_H_
  6. #include "services/image_annotation/image_annotation_utils.h"
  7. #include "services/image_annotation/public/mojom/image_annotation.mojom.h"
  8. namespace image_annotation {
  9. // Implementation details exposed only for testing. May change without warning.
  10. namespace metrics_internal {
  11. // TODO(crbug.com/916420): separate out client / annotation types when we have
  12. // more use cases for the service.
  13. constexpr char kCacheHit[] = "ImageAnnotationService.AccessibilityV1.CacheHit";
  14. constexpr char kJsonParseSuccess[] =
  15. "ImageAnnotationService.AccessibilityV1.JsonParseSuccess";
  16. constexpr char kPixelFetchSuccess[] =
  17. "ImageAnnotationService.AccessibilityV1.PixelFetchSuccess";
  18. constexpr char kAnnotationConfidence[] =
  19. "ImageAnnotationService.AccessibilityV1.%s.Confidence";
  20. constexpr char kAnnotationEmpty[] =
  21. "ImageAnnotationService.AccessibilityV1.%s.Empty";
  22. constexpr char kAnnotationStatus[] =
  23. "ImageAnnotationService.AccessibilityV1.%s.Status";
  24. constexpr char kDescType[] = "ImageAnnotationService.AccessibilityV1.DescType";
  25. constexpr char kDescFailure[] =
  26. "ImageAnnotationService.AccessibilityV1.DescFailure";
  27. constexpr char kEngineKnown[] =
  28. "ImageAnnotationService.AccessibilityV1.EngineKnown";
  29. constexpr char kServerNetError[] =
  30. "ImageAnnotationService.AccessibilityV1.ServerNetError";
  31. constexpr char kServerHttpResponseCode[] =
  32. "ImageAnnotationService.AccessibilityV1.ServerHttpResponseCode";
  33. constexpr char kServerLatency[] =
  34. "ImageAnnotationService.AccessibilityV1.ServerLatencyMs";
  35. constexpr char kImageRequestIncludesDesc[] =
  36. "ImageAnnotationService.AccessibilityV1.ImageRequestIncludesDesc";
  37. constexpr char kImageRequestIncludesIcon[] =
  38. "ImageAnnotationService.AccessibilityV1.ImageRequestIncludesIcon";
  39. constexpr char kServerRequestSize[] =
  40. "ImageAnnotationService.AccessibilityV1.ServerRequestSizeKB";
  41. constexpr char kServerResponseSize[] =
  42. "ImageAnnotationService.AccessibilityV1.ServerResponseSizeBytes";
  43. constexpr char kSourcePixelCount[] =
  44. "ImageAnnotationService.AccessibilityV1.SourcePixelCount";
  45. constexpr char kEncodedJpegSize[] =
  46. "ImageAnnotationService.AccessibilityV1.EncodedJpegSizeKB";
  47. constexpr char kClientResult[] =
  48. "ImageAnnotationService.AccessibilityV1.ClientResult";
  49. } // namespace metrics_internal
  50. // An enum for reporting the end result of an image annotation request.
  51. //
  52. // Logged in metrics - do not reuse or reassign values.
  53. enum class ClientResult {
  54. kUnknown = 0,
  55. kSucceeded = 1,
  56. kCanceled = 2,
  57. kFailed = 3,
  58. kShutdown = 4,
  59. kMaxValue = kShutdown,
  60. };
  61. // Report whether or not annotations for an image were already stored in the
  62. // service cache.
  63. void ReportCacheHit(bool cache_hit);
  64. // Report whether or not JSON returned by the image annotation service was
  65. // successfully parsed or not.
  66. void ReportJsonParseSuccess(bool success);
  67. // Report whether or not pixel data is successfully fetched from a client.
  68. void ReportPixelFetchSuccess(bool success);
  69. // Report metadata for a successful OCR annotation.
  70. void ReportOcrAnnotation(double confidence, bool empty);
  71. // Report metadata for a successful description annotation.
  72. void ReportDescAnnotation(mojom::AnnotationType type, double score, bool empty);
  73. // Report an unsuccessful description response.
  74. void ReportDescFailure(DescFailureReason reason);
  75. // Report the net error from the image annotation server request. This will be
  76. // populated even if e.g. the server URL is incorrect.
  77. void ReportServerNetError(int code);
  78. // Report a HTTP response code from the image annotation server.
  79. void ReportServerResponseCode(int code);
  80. // Report the length of time taken for a response to be returned from the
  81. // server.
  82. void ReportServerLatency(base::TimeDelta latency);
  83. // Report whether or not a request for image annotation includes parameters for
  84. // the description engine; requests for images that violate the description
  85. // engine policy (e.g. are too small) will not.
  86. void ReportImageRequestIncludesDesc(bool includes_desc);
  87. // Report whether or not a request for image annotation includes parameters for
  88. // the icon engine; requests for images that violate the description
  89. // engine policy (e.g. are too large) will not.
  90. void ReportImageRequestIncludesIcon(bool includes_icon);
  91. // Report the size of the request sent to the image annotation server.
  92. void ReportServerRequestSizeKB(size_t size_kb);
  93. // Report the size of the response returned by the image annotation server.
  94. void ReportServerResponseSizeBytes(size_t size_bytes);
  95. // Report the status code attached to the OCR engine response.
  96. void ReportOcrStatus(int status);
  97. // Report the status code attached to the description engine response.
  98. void ReportDescStatus(int status);
  99. // Report whether or not each engine is recognised as either OCR or description.
  100. void ReportEngineKnown(bool known);
  101. // Report the number of source (i.e. pre-scaling) pixels in an image sent to the
  102. // image annotation service.
  103. void ReportSourcePixelCount(size_t pixel_count);
  104. // Report the size of a single encoded image to be sent to the image annotation
  105. // service.
  106. void ReportEncodedJpegSize(size_t size_kb);
  107. // Report the result of the image annotation request for a client.
  108. void ReportClientResult(ClientResult result);
  109. } // namespace image_annotation
  110. #endif // SERVICES_IMAGE_ANNOTATION_IMAGE_ANNOTATION_METRICS_H_