24
24
import com .google .cloud .firestore .telemetry .MetricsUtil ;
25
25
import com .google .cloud .firestore .telemetry .MetricsUtil .MetricsContext ;
26
26
import com .google .cloud .firestore .telemetry .TelemetryConstants ;
27
+ import com .google .cloud .firestore .telemetry .TelemetryConstants .MetricType ;
27
28
import com .google .cloud .firestore .telemetry .TraceUtil ;
28
29
import com .google .cloud .firestore .telemetry .TraceUtil .Scope ;
29
30
import com .google .cloud .firestore .v1 .FirestoreClient .ListCollectionIdsPagedResponse ;
@@ -165,11 +166,11 @@ public ApiFuture<WriteResult> create(@Nonnull Map<String, Object> fields) {
165
166
WriteBatch writeBatch = rpcContext .getFirestore ().batch ();
166
167
ApiFuture <WriteResult > result = extractFirst (writeBatch .create (this , fields ).commit ());
167
168
span .endAtFuture (result );
168
- metricsContext .recordEndToEndLatencyAtFuture ( result );
169
+ metricsContext .recordLatencyAtFuture ( MetricType . END_TO_END_LATENCY , result );
169
170
return result ;
170
171
} catch (Exception error ) {
171
172
span .end (error );
172
- metricsContext .recordEndToEndLatency ( error );
173
+ metricsContext .recordLatency ( MetricType . END_TO_END_LATENCY , error );
173
174
throw error ;
174
175
}
175
176
}
@@ -191,11 +192,11 @@ public ApiFuture<WriteResult> create(@Nonnull Object pojo) {
191
192
WriteBatch writeBatch = rpcContext .getFirestore ().batch ();
192
193
ApiFuture <WriteResult > result = extractFirst (writeBatch .create (this , pojo ).commit ());
193
194
span .endAtFuture (result );
194
- metricsContext .recordEndToEndLatencyAtFuture ( result );
195
+ metricsContext .recordLatencyAtFuture ( MetricType . END_TO_END_LATENCY , result );
195
196
return result ;
196
197
} catch (Exception error ) {
197
198
span .end (error );
198
- metricsContext .recordEndToEndLatency ( error );
199
+ metricsContext .recordLatency ( MetricType . END_TO_END_LATENCY , error );
199
200
throw error ;
200
201
}
201
202
}
@@ -217,11 +218,11 @@ public ApiFuture<WriteResult> set(@Nonnull Map<String, Object> fields) {
217
218
WriteBatch writeBatch = rpcContext .getFirestore ().batch ();
218
219
ApiFuture <WriteResult > result = extractFirst (writeBatch .set (this , fields ).commit ());
219
220
span .endAtFuture (result );
220
- metricsContext .recordEndToEndLatencyAtFuture ( result );
221
+ metricsContext .recordLatencyAtFuture ( MetricType . END_TO_END_LATENCY , result );
221
222
return result ;
222
223
} catch (Exception error ) {
223
224
span .end (error );
224
- metricsContext .recordEndToEndLatency ( error );
225
+ metricsContext .recordLatency ( MetricType . END_TO_END_LATENCY , error );
225
226
throw error ;
226
227
}
227
228
}
@@ -246,11 +247,11 @@ public ApiFuture<WriteResult> set(
246
247
WriteBatch writeBatch = rpcContext .getFirestore ().batch ();
247
248
ApiFuture <WriteResult > result = extractFirst (writeBatch .set (this , fields , options ).commit ());
248
249
span .endAtFuture (result );
249
- metricsContext .recordEndToEndLatencyAtFuture ( result );
250
+ metricsContext .recordLatencyAtFuture ( MetricType . END_TO_END_LATENCY , result );
250
251
return result ;
251
252
} catch (Exception error ) {
252
253
span .end (error );
253
- metricsContext .recordEndToEndLatency ( error );
254
+ metricsContext .recordLatency ( MetricType . END_TO_END_LATENCY , error );
254
255
throw error ;
255
256
}
256
257
}
@@ -272,11 +273,11 @@ public ApiFuture<WriteResult> set(@Nonnull Object pojo) {
272
273
WriteBatch writeBatch = rpcContext .getFirestore ().batch ();
273
274
ApiFuture <WriteResult > result = extractFirst (writeBatch .set (this , pojo ).commit ());
274
275
span .endAtFuture (result );
275
- metricsContext .recordEndToEndLatencyAtFuture ( result );
276
+ metricsContext .recordLatencyAtFuture ( MetricType . END_TO_END_LATENCY , result );
276
277
return result ;
277
278
} catch (Exception error ) {
278
279
span .end (error );
279
- metricsContext .recordEndToEndLatency ( error );
280
+ metricsContext .recordLatency ( MetricType . END_TO_END_LATENCY , error );
280
281
throw error ;
281
282
}
282
283
}
@@ -300,11 +301,11 @@ public ApiFuture<WriteResult> set(@Nonnull Object pojo, @Nonnull SetOptions opti
300
301
WriteBatch writeBatch = rpcContext .getFirestore ().batch ();
301
302
ApiFuture <WriteResult > result = extractFirst (writeBatch .set (this , pojo , options ).commit ());
302
303
span .endAtFuture (result );
303
- metricsContext .recordEndToEndLatencyAtFuture ( result );
304
+ metricsContext .recordLatencyAtFuture ( MetricType . END_TO_END_LATENCY , result );
304
305
return result ;
305
306
} catch (Exception error ) {
306
307
span .end (error );
307
- metricsContext .recordEndToEndLatency ( error );
308
+ metricsContext .recordLatency ( MetricType . END_TO_END_LATENCY , error );
308
309
throw error ;
309
310
}
310
311
}
@@ -326,11 +327,11 @@ public ApiFuture<WriteResult> update(@Nonnull Map<String, Object> fields) {
326
327
WriteBatch writeBatch = rpcContext .getFirestore ().batch ();
327
328
ApiFuture <WriteResult > result = extractFirst (writeBatch .update (this , fields ).commit ());
328
329
span .endAtFuture (result );
329
- metricsContext .recordEndToEndLatencyAtFuture ( result );
330
+ metricsContext .recordLatencyAtFuture ( MetricType . END_TO_END_LATENCY , result );
330
331
return result ;
331
332
} catch (Exception error ) {
332
333
span .end (error );
333
- metricsContext .recordEndToEndLatency ( error );
334
+ metricsContext .recordLatency ( MetricType . END_TO_END_LATENCY , error );
334
335
throw error ;
335
336
}
336
337
}
@@ -354,11 +355,11 @@ public ApiFuture<WriteResult> update(@Nonnull Map<String, Object> fields, Precon
354
355
ApiFuture <WriteResult > result =
355
356
extractFirst (writeBatch .update (this , fields , options ).commit ());
356
357
span .endAtFuture (result );
357
- metricsContext .recordEndToEndLatencyAtFuture ( result );
358
+ metricsContext .recordLatencyAtFuture ( MetricType . END_TO_END_LATENCY , result );
358
359
return result ;
359
360
} catch (Exception error ) {
360
361
span .end (error );
361
- metricsContext .recordEndToEndLatency ( error );
362
+ metricsContext .recordLatency ( MetricType . END_TO_END_LATENCY , error );
362
363
throw error ;
363
364
}
364
365
}
@@ -384,11 +385,11 @@ public ApiFuture<WriteResult> update(
384
385
ApiFuture <WriteResult > result =
385
386
extractFirst (writeBatch .update (this , field , value , moreFieldsAndValues ).commit ());
386
387
span .endAtFuture (result );
387
- metricsContext .recordEndToEndLatencyAtFuture ( result );
388
+ metricsContext .recordLatencyAtFuture ( MetricType . END_TO_END_LATENCY , result );
388
389
return result ;
389
390
} catch (Exception error ) {
390
391
span .end (error );
391
- metricsContext .recordEndToEndLatency ( error );
392
+ metricsContext .recordLatency ( MetricType . END_TO_END_LATENCY , error );
392
393
throw error ;
393
394
}
394
395
}
@@ -414,11 +415,11 @@ public ApiFuture<WriteResult> update(
414
415
ApiFuture <WriteResult > result =
415
416
extractFirst (writeBatch .update (this , fieldPath , value , moreFieldsAndValues ).commit ());
416
417
span .endAtFuture (result );
417
- metricsContext .recordEndToEndLatencyAtFuture ( result );
418
+ metricsContext .recordLatencyAtFuture ( MetricType . END_TO_END_LATENCY , result );
418
419
return result ;
419
420
} catch (Exception error ) {
420
421
span .end (error );
421
- metricsContext .recordEndToEndLatency ( error );
422
+ metricsContext .recordLatency ( MetricType . END_TO_END_LATENCY , error );
422
423
throw error ;
423
424
}
424
425
}
@@ -449,11 +450,11 @@ public ApiFuture<WriteResult> update(
449
450
extractFirst (
450
451
writeBatch .update (this , options , field , value , moreFieldsAndValues ).commit ());
451
452
span .endAtFuture (result );
452
- metricsContext .recordEndToEndLatencyAtFuture ( result );
453
+ metricsContext .recordLatencyAtFuture ( MetricType . END_TO_END_LATENCY , result );
453
454
return result ;
454
455
} catch (Exception error ) {
455
456
span .end (error );
456
- metricsContext .recordEndToEndLatency ( error );
457
+ metricsContext .recordLatency ( MetricType . END_TO_END_LATENCY , error );
457
458
throw error ;
458
459
}
459
460
}
@@ -484,11 +485,11 @@ public ApiFuture<WriteResult> update(
484
485
extractFirst (
485
486
writeBatch .update (this , options , fieldPath , value , moreFieldsAndValues ).commit ());
486
487
span .endAtFuture (result );
487
- metricsContext .recordEndToEndLatencyAtFuture ( result );
488
+ metricsContext .recordLatencyAtFuture ( MetricType . END_TO_END_LATENCY , result );
488
489
return result ;
489
490
} catch (Exception error ) {
490
491
span .end (error );
491
- metricsContext .recordEndToEndLatency ( error );
492
+ metricsContext .recordLatency ( MetricType . END_TO_END_LATENCY , error );
492
493
throw error ;
493
494
}
494
495
}
@@ -509,11 +510,11 @@ public ApiFuture<WriteResult> delete(@Nonnull Precondition options) {
509
510
WriteBatch writeBatch = rpcContext .getFirestore ().batch ();
510
511
ApiFuture <WriteResult > result = extractFirst (writeBatch .delete (this , options ).commit ());
511
512
span .endAtFuture (result );
512
- metricsContext .recordEndToEndLatencyAtFuture ( result );
513
+ metricsContext .recordLatencyAtFuture ( MetricType . END_TO_END_LATENCY , result );
513
514
return result ;
514
515
} catch (Exception error ) {
515
516
span .end (error );
516
- metricsContext .recordEndToEndLatency ( error );
517
+ metricsContext .recordLatency ( MetricType . END_TO_END_LATENCY , error );
517
518
throw error ;
518
519
}
519
520
}
@@ -533,11 +534,11 @@ public ApiFuture<WriteResult> delete() {
533
534
WriteBatch writeBatch = rpcContext .getFirestore ().batch ();
534
535
ApiFuture <WriteResult > result = extractFirst (writeBatch .delete (this ).commit ());
535
536
span .endAtFuture (result );
536
- metricsContext .recordEndToEndLatencyAtFuture ( result );
537
+ metricsContext .recordLatencyAtFuture ( MetricType . END_TO_END_LATENCY , result );
537
538
return result ;
538
539
} catch (Exception error ) {
539
540
span .end (error );
540
- metricsContext .recordEndToEndLatency ( error );
541
+ metricsContext .recordLatency ( MetricType . END_TO_END_LATENCY , error );
541
542
throw error ;
542
543
}
543
544
}
@@ -558,11 +559,11 @@ public ApiFuture<DocumentSnapshot> get() {
558
559
try (Scope ignored = span .makeCurrent ()) {
559
560
ApiFuture <DocumentSnapshot > result = extractFirst (rpcContext .getFirestore ().getAll (this ));
560
561
span .endAtFuture (result );
561
- metricsContext .recordEndToEndLatencyAtFuture ( result );
562
+ metricsContext .recordLatencyAtFuture ( MetricType . END_TO_END_LATENCY , result );
562
563
return result ;
563
564
} catch (Exception error ) {
564
565
span .end (error );
565
- metricsContext .recordEndToEndLatency ( error );
566
+ metricsContext .recordLatency ( MetricType . END_TO_END_LATENCY , error );
566
567
throw error ;
567
568
}
568
569
}
@@ -585,11 +586,11 @@ public ApiFuture<DocumentSnapshot> get(FieldMask fieldMask) {
585
586
ApiFuture <DocumentSnapshot > result =
586
587
extractFirst (rpcContext .getFirestore ().getAll (new DocumentReference [] {this }, fieldMask ));
587
588
span .endAtFuture (result );
588
- metricsContext .recordEndToEndLatencyAtFuture ( result );
589
+ metricsContext .recordLatencyAtFuture ( MetricType . END_TO_END_LATENCY , result );
589
590
return result ;
590
591
} catch (Exception error ) {
591
592
span .end (error );
592
- metricsContext .recordEndToEndLatency ( error );
593
+ metricsContext .recordLatency ( MetricType . END_TO_END_LATENCY , error );
593
594
throw error ;
594
595
}
595
596
}
@@ -641,11 +642,11 @@ public void remove() {
641
642
}
642
643
};
643
644
span .end ();
644
- metricsContext .recordEndToEndLatency ( );
645
+ metricsContext .recordLatency ( MetricType . END_TO_END_LATENCY );
645
646
return result ;
646
647
} catch (ApiException exception ) {
647
648
span .end (exception );
648
- metricsContext .recordEndToEndLatency ( exception );
649
+ metricsContext .recordLatency ( MetricType . END_TO_END_LATENCY , exception );
649
650
throw FirestoreException .forApiException (exception );
650
651
}
651
652
}
0 commit comments