code: private void writeMetrics(final CouchbaseResponse response) {
          if (currentRequest != null && currentOpTime >= 0 && env() != null
              && env().networkLatencyMetricsCollector().isEnabled()) {
  
              try {
                  Class<? extends CouchbaseRequest> requestClass = currentRequest.getClass();
                  String simpleName = classNameCache.get(requestClass);
                  if (simpleName == null) {
                      simpleName = requestClass.getSimpleName();
                      classNameCache.put(requestClass, simpleName);
                  }
  
                  NetworkLatencyMetricsIdentifier identifier = new NetworkLatencyMetricsIdentifier(
                          remoteHostname,
                          serviceType().toString(),
                          simpleName,
                          response.status().toString()
                  );
                  env().networkLatencyMetricsCollector().record(identifier, currentOpTime);
              } catch (Throwable e) {
                  LOGGER.warn("Could not collect latency metric for request {} ({})",
                      user(currentRequest.toString()),
                      currentOpTime,
                      e
                  );
              }
          }
      }
docs: Helper method which creates the metrics for the current response and publishes them if enabled.
  
  @param response the response which is needed as context.