@Override public void onCompleted() { Tracing.getTracer() .getCurrentSpan() .addAnnotation( "Firestore.Query: Completed", ImmutableMap.of( "numDocuments", AttributeValue.longAttributeValue(numDocuments))); documentObserver.onCompleted(readTime); } };
private void backoff(Context context, BackOff backoff) { long delay = txn.getRetryDelayInMillis(backoff); txn = session.newTransaction(); span.addAnnotation( "Backing off", ImmutableMap.of("Delay", AttributeValue.longAttributeValue(delay))); sleeper.backoffSleep(context, delay); } }
ImmutableMap.of("Attempt", AttributeValue.longAttributeValue(attempt))); txn.ensureTxn(); span.addAnnotation( "Transaction Attempt Aborted in user operation. Retrying", ImmutableMap.of("Attempt", AttributeValue.longAttributeValue(attempt))); shouldRollback = false; backoff(context, backoff); ImmutableMap.<String, AttributeValue>builder() .putAll(TraceUtil.getExceptionAnnotations(toThrow)) .put("Attempt", AttributeValue.longAttributeValue(attempt)) .build()); throw toThrow; span.addAnnotation( "Transaction Attempt Succeeded", ImmutableMap.of("Attempt", AttributeValue.longAttributeValue(attempt))); return result; } catch (AbortedException e) { span.addAnnotation( "Transaction Attempt Aborted in Commit. Retrying", ImmutableMap.of("Attempt", AttributeValue.longAttributeValue(attempt))); backoff(context, backoff); } catch (SpannerException e) { ImmutableMap.<String, AttributeValue>builder() .putAll(TraceUtil.getExceptionAnnotations(e))
.addAnnotation( "Backing off", ImmutableMap.of("Delay", AttributeValue.longAttributeValue(backoffMillis))); final CountDownLatch latch = new CountDownLatch(1); final Context.CancellationListener listener =
span.addAnnotation( "Starting operation", ImmutableMap.of("Attempt", AttributeValue.longAttributeValue(attempt))); T result = callable.call(); return result;
@Override public void submit() { Span span = startSpan(HttpStorageRpcSpans.SPAN_NAME_BATCH_SUBMIT); Scope scope = tracer.withSpan(span); try { span.putAttribute("batch size", AttributeValue.longAttributeValue(batches.size())); for (BatchRequest batch : batches) { // TODO(hailongwen@): instrument 'google-api-java-client' to further break down the span. // Here we only add a annotation to at least know how much time each batch takes. span.addAnnotation("Execute batch request"); batch.setBatchUrl( new GenericUrl(String.format("%s/batch/storage/v1", options.getHost()))); batch.execute(); } } catch (IOException ex) { span.setStatus(Status.UNKNOWN.withDescription(ex.getMessage())); throw translate(ex); } finally { scope.close(); span.end(); } } }
.addAnnotation( "CloudFirestore.Commit", ImmutableMap.of("numDocuments", AttributeValue.longAttributeValue(mutations.size())));
"Firestore.BatchGet: Start", ImmutableMap.of( "numDocuments", AttributeValue.longAttributeValue(documentReferences.length)));
span.addAnnotation( "Start runTransaction", ImmutableMap.of("attemptsRemaining", AttributeValue.longAttributeValue(attemptsRemaining)));
/** {@inheritDoc} */ @Override public void connectionSelected(int id) { span.addAnnotation( "Connection selected", ImmutableMap.of("id", AttributeValue.longAttributeValue(id))); }
@Override protected void finalizeStats(Status status) { // Add an annotation for the total number of rows that were returned across all responses. operationSpan.addAnnotation("Total Rows Processed", ImmutableMap.of("rowCount", AttributeValue.longAttributeValue(totalRowsProcessed))); super.finalizeStats(status); }
void spanEnd(Span span, @Nullable P response, @Nullable Throwable error) { int statusCode = extractor.getStatusCode(response); if (span.getOptions().contains(Options.RECORD_EVENTS)) { span.putAttribute( HttpTraceAttributeConstants.HTTP_STATUS_CODE, AttributeValue.longAttributeValue(statusCode)); } span.setStatus(HttpTraceUtil.parseResponseStatus(statusCode, error)); span.end(); }
/** {@inheritDoc} */ @Override public void attemptFailed(Throwable error, Duration delay) { Map<String, AttributeValue> attributes = baseAttemptAttributes(); attributes.put("delay ms", AttributeValue.longAttributeValue(delay.toMillis())); populateError(attributes, error); String msg = error != null ? "Attempt failed" : "Operation incomplete"; span.addAnnotation(msg + ", scheduling next attempt", attributes); }
private void backoff(Context context, BackOff backoff) { long delay = txn.getRetryDelayInMillis(backoff); txn = session.newTransaction(); span.addAnnotation( "Backing off", ImmutableMap.of("Delay", AttributeValue.longAttributeValue(delay))); sleeper.backoffSleep(context, delay); } }
@Before public void setUp() { MockitoAnnotations.initMocks(this); attributes.put( "MyStringAttributeKey", AttributeValue.stringAttributeValue("MyStringAttributeValue")); attributes.put("MyLongAttributeKey", AttributeValue.longAttributeValue(123L)); attributes.put("MyBooleanAttributeKey", AttributeValue.booleanAttributeValue(false)); expectedAttributes.putAll(attributes); expectedAttributes.put( "MySingleStringAttributeKey", AttributeValue.stringAttributeValue("MySingleStringAttributeValue")); }
private static ImmutableMap<String, AttributeValue> sampleAttributes() { return ImmutableMap.of( "BOOL", AttributeValue.booleanAttributeValue(false), "LONG", AttributeValue.longAttributeValue(Long.MAX_VALUE), "STRING", AttributeValue.stringAttributeValue( "Judge of a man by his questions rather than by his answers. -- Voltaire")); }
@Before public void setUp() { attributesMap.put("MyAttributeKey0", AttributeValue.stringAttributeValue("MyStringAttribute")); attributesMap.put("MyAttributeKey1", AttributeValue.longAttributeValue(10)); attributesMap.put("MyAttributeKey2", AttributeValue.booleanAttributeValue(true)); }
@Test public void handleEndWithRecordEvents() { when(extractor.getStatusCode(any(Object.class))).thenReturn(0); handler.spanEnd(fakeSpan, response, error); verify(fakeSpan) .putAttribute(eq(HttpTraceAttributeConstants.HTTP_STATUS_CODE), attributeCaptor.capture()); AttributeValue attribute = attributeCaptor.getValue(); assertThat(attribute).isEqualTo(AttributeValue.longAttributeValue(0)); }
@Test public void attributeValue_ToString() { AttributeValue attribute = AttributeValue.stringAttributeValue("MyStringAttributeValue"); assertThat(attribute.toString()).contains("MyStringAttributeValue"); attribute = AttributeValue.booleanAttributeValue(true); assertThat(attribute.toString()).contains("true"); attribute = AttributeValue.longAttributeValue(123456L); assertThat(attribute.toString()).contains("123456"); attribute = AttributeValue.doubleAttributeValue(1.23456); assertThat(attribute.toString()).contains("1.23456"); } }
private static SpanData.TimedEvent<Annotation> sampleAnnotation() { return SpanData.TimedEvent.create( Timestamp.create(1519629872L, 987654321), Annotation.fromDescriptionAndAttributes( "annotation #1", ImmutableMap.of( "bool", AttributeValue.booleanAttributeValue(true), "long", AttributeValue.longAttributeValue(1337L), "string", AttributeValue.stringAttributeValue( "Kind words do not cost much. Yet they accomplish much. -- Pascal")))); }