<commit_before>/*
 * Copyright 2016, Google Inc.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *     http://www.apache.org/licenses/LICENSE-2.0
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.google.instrumentation.stats;

import com.google.instrumentation.stats.MeasurementDescriptor.BasicUnit;
import com.google.instrumentation.stats.MeasurementDescriptor.MeasurementUnit;
import com.google.instrumentation.stats.ViewDescriptor.DistributionViewDescriptor;

import java.util.Arrays;
import java.util.List;

/**
 * Constants for collecting rpc stats.
 */
public final class RpcConstants {
  /**
   * Rpc tag keys.
   */
  public static final TagKey RPC_STATUS = TagKey.create("OpStatus");
  public static final TagKey RPC_CLIENT_METHOD = TagKey.create("method");
  public static final TagKey RPC_SERVER_METHOD = TagKey.create("method");

  // Constants used to define the following MeasurementDescriptors.
  private static final List<BasicUnit> bytes = Arrays.asList(BasicUnit.BYTES);
  private static final List<BasicUnit> scalar = Arrays.asList(BasicUnit.SCALAR);
  private static final List<BasicUnit> seconds = Arrays.asList(BasicUnit.SECONDS);

  /**
   * Census defined rpc client {@link MeasurementDescriptor}s.
   */
  public static final MeasurementDescriptor RPC_CLIENT_ERROR_COUNT =
      MeasurementDescriptor.create(
          "/rpc/client/error_count",
          "RPC Errors",
          MeasurementUnit.create(0, scalar));
  public static final MeasurementDescriptor RPC_CLIENT_REQUEST_BYTES =
      MeasurementDescriptor.create(
          "/rpc/client/request_bytes",
          "Request MB/s",
          MeasurementUnit.create(6, bytes, seconds));
  public static final MeasurementDescriptor RPC_CLIENT_RESPONSE_BYTES =
      MeasurementDescriptor.create(
          "/rpc/client/response_bytes",
          "Response MB/s",
          MeasurementUnit.create(6, bytes, seconds));
  // TODO(dpo): verify this encoding
  public static final MeasurementDescriptor RPC_CLIENT_ROUNDTRIP_LATENCY =
      MeasurementDescriptor.create(
          "/rpc/client/roundtrip_latency",
          "RPC roundtrip latency us",
          MeasurementUnit.create(-6, scalar));
  public static final MeasurementDescriptor RPC_CLIENT_SERVER_ELAPSED_TIME =
      MeasurementDescriptor.create(
          "/rpc/client/server_elapsed_time",
          "Server elapsed time in msecs",
          MeasurementUnit.create(-3, scalar));
  public static final MeasurementDescriptor RPC_CLIENT_UNCOMPRESSED_REQUEST_BYTES =
      MeasurementDescriptor.create(
          "/rpc/client/uncompressed_request_bytes",
          "Uncompressed Request MB/s",
          MeasurementUnit.create(6, bytes, seconds));
  public static final MeasurementDescriptor RPC_CLIENT_UNCOMPRESSED_RESPONSE_BYTES =
      MeasurementDescriptor.create(
          "/rpc/client/uncompressed_response_bytes",
          "Uncompressed Request MB/s",
          MeasurementUnit.create(6, bytes, seconds));

  /**
   * Census defined rpc server {@link MeasurementDescriptor}s.
   */
  public static final MeasurementDescriptor RPC_SERVER_ERROR_COUNT =
      MeasurementDescriptor.create(
          "/rpc/server/error_count",
          "RPC Errors",
          MeasurementUnit.create(0, scalar));
  public static final MeasurementDescriptor RPC_SERVER_REQUEST_BYTES =
      MeasurementDescriptor.create(
          "/rpc/server/request_bytes",
          "Request MB/s",
          MeasurementUnit.create(6, bytes, seconds));
  public static final MeasurementDescriptor RPC_SERVER_RESPONSE_BYTES =
      MeasurementDescriptor.create(
          "/rpc/server/response_bytes",
          "Response MB/s",
          MeasurementUnit.create(6, bytes, seconds));
  public static final MeasurementDescriptor RPC_SERVER_SERVER_ELAPSED_TIME =
      MeasurementDescriptor.create(
          "/rpc/server/server_elapsed_time",
          "Server elapsed time in msecs",
          MeasurementUnit.create(-3, scalar));
  public static final MeasurementDescriptor RPC_SERVER_SERVER_LATENCY =
      MeasurementDescriptor.create(
          "/rpc/server/server_latency",
          "Latency in msecs",
          MeasurementUnit.create(-3, scalar));
  public static final MeasurementDescriptor RPC_SERVER_UNCOMPRESSED_REQUEST_BYTES =
      MeasurementDescriptor.create(
          "/rpc/server/uncompressed_request_bytes",
          "Uncompressed Request MB/s",
          MeasurementUnit.create(6, bytes, seconds));
  public static final MeasurementDescriptor RPC_SERVER_UNCOMPRESSED_RESPONSE_BYTES =
      MeasurementDescriptor.create(
          "/rpc/server/uncompressed_response_bytes",<commit_msg>Updates time measurements w/appropriate measurement unit.<commit_after>/*
 * Copyright 2016, Google Inc.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *     http://www.apache.org/licenses/LICENSE-2.0
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.google.instrumentation.stats;

import com.google.instrumentation.stats.MeasurementDescriptor.BasicUnit;
import com.google.instrumentation.stats.MeasurementDescriptor.MeasurementUnit;
import com.google.instrumentation.stats.ViewDescriptor.DistributionViewDescriptor;

import java.util.Arrays;
import java.util.List;

/**
 * Constants for collecting rpc stats.
 */
public final class RpcConstants {
  /**
   * Rpc tag keys.
   */
  public static final TagKey RPC_STATUS = TagKey.create("OpStatus");
  public static final TagKey RPC_CLIENT_METHOD = TagKey.create("method");
  public static final TagKey RPC_SERVER_METHOD = TagKey.create("method");

  // Constants used to define the following MeasurementDescriptors.
  private static final List<BasicUnit> bytes = Arrays.asList(BasicUnit.BYTES);
  private static final List<BasicUnit> scalar = Arrays.asList(BasicUnit.SCALAR);
  private static final List<BasicUnit> seconds = Arrays.asList(BasicUnit.SECONDS);

  /**
   * Census defined rpc client {@link MeasurementDescriptor}s.
   */
  public static final MeasurementDescriptor RPC_CLIENT_ERROR_COUNT =
      MeasurementDescriptor.create(
          "/rpc/client/error_count",
          "RPC Errors",
          MeasurementUnit.create(0, scalar));
  public static final MeasurementDescriptor RPC_CLIENT_REQUEST_BYTES =
      MeasurementDescriptor.create(
          "/rpc/client/request_bytes",
          "Request MB/s",
          MeasurementUnit.create(6, bytes, seconds));
  public static final MeasurementDescriptor RPC_CLIENT_RESPONSE_BYTES =
      MeasurementDescriptor.create(
          "/rpc/client/response_bytes",
          "Response MB/s",
          MeasurementUnit.create(6, bytes, seconds));
  // TODO(dpo): verify this encoding
  public static final MeasurementDescriptor RPC_CLIENT_ROUNDTRIP_LATENCY =
      MeasurementDescriptor.create(
          "/rpc/client/roundtrip_latency",
          "RPC roundtrip latency us",
          MeasurementUnit.create(-6, seconds));
  public static final MeasurementDescriptor RPC_CLIENT_SERVER_ELAPSED_TIME =
      MeasurementDescriptor.create(
          "/rpc/client/server_elapsed_time",
          "Server elapsed time in msecs",
          MeasurementUnit.create(-3, seconds));
  public static final MeasurementDescriptor RPC_CLIENT_UNCOMPRESSED_REQUEST_BYTES =
      MeasurementDescriptor.create(
          "/rpc/client/uncompressed_request_bytes",
          "Uncompressed Request MB/s",
          MeasurementUnit.create(6, bytes, seconds));
  public static final MeasurementDescriptor RPC_CLIENT_UNCOMPRESSED_RESPONSE_BYTES =
      MeasurementDescriptor.create(
          "/rpc/client/uncompressed_response_bytes",
          "Uncompressed Request MB/s",
          MeasurementUnit.create(6, bytes, seconds));

  /**
   * Census defined rpc server {@link MeasurementDescriptor}s.
   */
  public static final MeasurementDescriptor RPC_SERVER_ERROR_COUNT =
      MeasurementDescriptor.create(
          "/rpc/server/error_count",
          "RPC Errors",
          MeasurementUnit.create(0, scalar));
  public static final MeasurementDescriptor RPC_SERVER_REQUEST_BYTES =
      MeasurementDescriptor.create(
          "/rpc/server/request_bytes",
          "Request MB/s",
          MeasurementUnit.create(6, bytes, seconds));
  public static final MeasurementDescriptor RPC_SERVER_RESPONSE_BYTES =
      MeasurementDescriptor.create(
          "/rpc/server/response_bytes",
          "Response MB/s",
          MeasurementUnit.create(6, bytes, seconds));
  public static final MeasurementDescriptor RPC_SERVER_SERVER_ELAPSED_TIME =
      MeasurementDescriptor.create(
          "/rpc/server/server_elapsed_time",
          "Server elapsed time in msecs",
          MeasurementUnit.create(-3, seconds));
  public static final MeasurementDescriptor RPC_SERVER_SERVER_LATENCY =
      MeasurementDescriptor.create(
          "/rpc/server/server_latency",
          "Latency in msecs",
          MeasurementUnit.create(-3, seconds));
  public static final MeasurementDescriptor RPC_SERVER_UNCOMPRESSED_REQUEST_BYTES =
      MeasurementDescriptor.create(
          "/rpc/server/uncompressed_request_bytes",
          "Uncompressed Request MB/s",
          MeasurementUnit.create(6, bytes, seconds));
  public static final MeasurementDescriptor RPC_SERVER_UNCOMPRESSED_RESPONSE_BYTES =
      MeasurementDescriptor.create(
          "/rpc/server/uncompressed_response_bytes",
{'fraction_non_alphanumeric': 0.08321802727811821, 'fraction_numerical': 0.004151017987744613, 'mean_word_length': 3.587035358114234, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5105592', 'n_tokens_mistral': 2830, 'n_tokens_neox': 2698, 'n_words': 674}