Merged
Changes from 1 commit
Show all changes
8 commitsSelect commit Hold shift + click to select a range
5bf757e
feat: add session metrics
mayurkale228bc6fc7
Fix code reviews
mayurkale22b3c56b5
Change active sessions description
mayurkale22893b446
add numSessionsInUse metric
mayurkale22f2ebcdf
Fix package structure
mayurkale226ce5aa6
rename metric name and description
mayurkale2267c9690
fix nits
mayurkale221525a7d
createMockSession for metrics validations
mayurkale22File filter
Filter by extension
Conversations
Failed to load comments.
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Failed to load files.
Uh oh!
There was an error while loading. Please reload this page.
rename metric name and description
- Loading branch information
Uh oh!
There was an error while loading. Please reload this page.
commit 6ce5aa60d43e28ca05109122c7565ca0a380b86a
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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"); | ||
@@ -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."; | ||
mayurkale22 marked this conversation as resolved. Show resolved Hide resolvedUh oh!There was an error while loading. Please reload this page. | ||
static final String IN_USE_SESSIONS_DESCRIPTION = "The number of sessions currently in use"; | ||
mayurkale22 marked this conversation as resolved. Show resolved Hide resolvedUh oh!There was an error while loading. Please reload this page. | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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); | ||
skuruppu marked this conversation as resolved. Show resolved Hide resolvedUh oh!There was an error while loading. Please reload this page. | ||
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); | ||
} | ||
Add this suggestion to a batch that can be applied as a single commit. This suggestion is invalid because no changes were made to the code. Suggestions cannot be applied while the pull request is closed. Suggestions cannot be applied while viewing a subset of changes. Only one suggestion per line can be applied in a batch. Add this suggestion to a batch that can be applied as a single commit. Applying suggestions on deleted lines is not supported. You must change the existing code in this line in order to create a valid suggestion. Outdated suggestions cannot be applied. This suggestion has been applied or marked resolved. Suggestions cannot be applied from pending reviews. Suggestions cannot be applied on multi-line comments. Suggestions cannot be applied while the pull request is queued to merge. Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.