Skip to content

Commit d140926

Browse files
committed
fix: use Commit as method name for per-attempt metrics
The per-attempt transaction count should use METHOD_COMMIT (Commit) since each attempt records a commit operation. The overall transaction latency continues to use METHOD_TRANSACTION_RUN (Transaction.Run).
1 parent 615cbc5 commit d140926

File tree

3 files changed

+6
-6
lines changed

3 files changed

+6
-6
lines changed

java-datastore/google-cloud-datastore/src/main/java/com/google/cloud/datastore/DatastoreImpl.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,7 @@ private void recordAttempt(String status) {
240240
attributes.put(TelemetryConstants.ATTRIBUTES_KEY_STATUS, status);
241241
attributes.put(
242242
TelemetryConstants.ATTRIBUTES_KEY_METHOD_NAME,
243-
TelemetryConstants.METHOD_TRANSACTION_RUN);
243+
TelemetryConstants.METHOD_COMMIT);
244244
metricsRecorder.recordTransactionAttemptCount(1, attributes);
245245
}
246246

java-datastore/google-cloud-datastore/src/test/java/com/google/cloud/datastore/DatastoreImplMetricsTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ public void runInTransaction_recordsPerAttemptCountOnSuccess() {
142142
assertThat(point).isNotNull();
143143
assertThat(point.getValue()).isEqualTo(1);
144144
assertThat(point.getAttributes().get(AttributeKey.stringKey("method_name")))
145-
.isEqualTo("Transaction.Run");
145+
.isEqualTo("Commit");
146146

147147
EasyMock.verify(rpcFactoryMock, rpcMock);
148148
}

java-datastore/google-cloud-datastore/src/test/java/com/google/cloud/datastore/telemetry/OpenTelemetryMetricsRecorderTest.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ public void recordTransactionAttemptCount_recordsCounterWithAttributes() {
9191
attributes.put(TelemetryConstants.ATTRIBUTES_KEY_STATUS, "ABORTED");
9292
attributes.put(
9393
TelemetryConstants.ATTRIBUTES_KEY_METHOD_NAME,
94-
TelemetryConstants.METHOD_TRANSACTION_RUN);
94+
TelemetryConstants.METHOD_COMMIT);
9595

9696
recorder.recordTransactionAttemptCount(1, attributes);
9797

@@ -116,7 +116,7 @@ public void recordTransactionAttemptCount_recordsCounterWithAttributes() {
116116
assertThat(point.getValue()).isEqualTo(1);
117117
assertThat(point.getAttributes().get(AttributeKey.stringKey("status"))).isEqualTo("ABORTED");
118118
assertThat(point.getAttributes().get(AttributeKey.stringKey("method_name")))
119-
.isEqualTo("Transaction.Run");
119+
.isEqualTo("Commit");
120120
}
121121

122122
@Test
@@ -125,13 +125,13 @@ public void recordTransactionAttemptCount_multipleAttempts_accumulates() {
125125
abortedAttributes.put(TelemetryConstants.ATTRIBUTES_KEY_STATUS, "ABORTED");
126126
abortedAttributes.put(
127127
TelemetryConstants.ATTRIBUTES_KEY_METHOD_NAME,
128-
TelemetryConstants.METHOD_TRANSACTION_RUN);
128+
TelemetryConstants.METHOD_COMMIT);
129129

130130
Map<String, String> okAttributes = new HashMap<>();
131131
okAttributes.put(TelemetryConstants.ATTRIBUTES_KEY_STATUS, "OK");
132132
okAttributes.put(
133133
TelemetryConstants.ATTRIBUTES_KEY_METHOD_NAME,
134-
TelemetryConstants.METHOD_TRANSACTION_RUN);
134+
TelemetryConstants.METHOD_COMMIT);
135135

136136
// Simulate a retry scenario: first attempt ABORTED, second attempt OK
137137
recorder.recordTransactionAttemptCount(1, abortedAttributes);

0 commit comments

Comments
 (0)