PrevPrevious commit
Next Next commit
rename metric name and description
  • Loading branch information
@mayurkale22
mayurkale22 committedFeb 6, 2020
commit 6ce5aa60d43e28ca05109122c7565ca0a380b86a
Original file line numberDiff line numberDiff line change
Expand Up@@ -20,7 +20,7 @@
import io.opencensus.metrics.LabelValue;

/** A helper class that holds OpenCensus's related constants. */
public class MetricRegistryConstants {
class MetricRegistryConstants {

// The label keys are used to uniquely identify timeseries.
private static final LabelKey DATABASE = LabelKey.create("database", "Target database");
Expand All@@ -32,22 +32,22 @@ public class MetricRegistryConstants {
/** The label value is used to represent missing value. */
private static final LabelValue UNSET_LABEL = LabelValue.create(null);

public static final ImmutableList<LabelKey> SPANNER_LABEL_KEYS =
static final ImmutableList<LabelKey> SPANNER_LABEL_KEYS =
ImmutableList.of(DATABASE, INSTANCE_ID, LIBRARY_VERSION);

public static final ImmutableList<LabelValue> SPANNER_DEFAULT_LABEL_VALUES =
static final ImmutableList<LabelValue> SPANNER_DEFAULT_LABEL_VALUES =
ImmutableList.of(UNSET_LABEL, UNSET_LABEL, UNSET_LABEL);

/** Unit to represent counts. */
public static final String COUNT = "1";
static final String COUNT = "1";

// The Metric name and description
public static final String ACTIVE_SESSIONS = "cloud.google.com/java/spanner/active_sessions";
public static final String MAX_SESSIONS = "cloud.google.com/java/spanner/max_sessions";
public static final String SESSIONS_IN_USE = "cloud.google.com/java/spanner/sessions_in_use";
public static final String ACTIVE_SESSIONS_DESCRIPTION =
"Max number of sessions in use during the last 10 minutes";
public static final String MAX_SESSIONS_DESCRIPTION = "The number of max sessions configured";
public static final String SESSIONS_IN_USE_DESCRIPTION =
"The number of sessions checked out from the pool";
static final String MAX_IN_USE_SESSIONS = "cloud.google.com/java/spanner/max_in_use_session";
static final String MAX_ALLOWED_SESSIONS = "cloud.google.com/java/spanner/max_allowed_sessions";
static final String IN_USE_SESSIONS = "cloud.google.com/java/spanner/in_use_sessions";
static final String MAX_IN_USE_SESSIONS_DESCRIPTION =
"The max number of sessions in use during the last 10 minutes interval";
static final String MAX_ALLOWED_SESSIONS_DESCRIPTION =
"The Maximum number of sessions allowed. Configurable by the user.";
static final String IN_USE_SESSIONS_DESCRIPTION = "The number of sessions currently in use";
}
Original file line numberDiff line numberDiff line change
Expand Up@@ -32,11 +32,11 @@
import java.util.List;
import java.util.Map;

public class MetricRegistryTestUtils {
class MetricRegistryTestUtils {

public static class MetricsRecord {
public final Map<String, Number> metrics;
public final Map<List<LabelKey>, List<LabelValue>> labels;
static class MetricsRecord {
final Map<String, Number> metrics;
final Map<List<LabelKey>, List<LabelValue>> labels;

private MetricsRecord() {
this.metrics = Maps.newHashMap();
Expand DownExpand Up@@ -78,11 +78,11 @@ public static final class FakeMetricRegistry extends MetricRegistry {

private MetricsRecord record;

public FakeMetricRegistry() {
FakeMetricRegistry() {
record = new MetricsRecord();
}

public MetricsRecord pollRecord() {
MetricsRecord pollRecord() {
return record;
}

Expand Down
Original file line numberDiff line numberDiff line change
Expand Up@@ -1581,11 +1581,11 @@ public void testSessionMetrics() {
runMaintainanceLoop(clock, pool, pool.poolMaintainer.numClosureCycles);

MetricsRecord record = metricRegistry.pollRecord();
assertThat(record.metrics).containsEntry(MetricRegistryConstants.ACTIVE_SESSIONS, 0L);
assertThat(record.metrics).containsEntry(MetricRegistryConstants.SESSIONS_IN_USE, 0L);
assertThat(record.metrics).containsEntry(MetricRegistryConstants.MAX_IN_USE_SESSIONS, 0L);
assertThat(record.metrics).containsEntry(MetricRegistryConstants.IN_USE_SESSIONS, 0L);
assertThat(record.metrics)
.containsEntry(
MetricRegistryConstants.MAX_SESSIONS, Long.valueOf(options.getMaxSessions()));
MetricRegistryConstants.MAX_ALLOWED_SESSIONS, Long.valueOf(options.getMaxSessions()));
assertThat(record.labels).containsEntry(SPANNER_LABEL_KEYS, labelValues);
}

Expand Down