Tabnine Logo
Tracer.withSpan
Code IndexAdd Tabnine to your IDE (free)

How to use
withSpan
method
in
io.opencensus.trace.Tracer

Best Java code snippets using io.opencensus.trace.Tracer.withSpan (Showing top 20 results out of 315)

origin: googleapis/google-cloud-java

@Override
public TransactionContext begin() {
 Preconditions.checkState(txn == null, "begin can only be called once");
 try (Scope s = tracer.withSpan(span)) {
  txn = session.newTransaction();
  session.setActive(this);
  txn.ensureTxn();
  txnState = TransactionState.STARTED;
  return txn;
 }
}
origin: googleapis/google-cloud-java

@Override
public TransactionContext resetForRetry() {
 if (txn == null || !txn.isAborted() && txnState != TransactionState.ABORTED) {
  throw new IllegalStateException(
    "resetForRetry can only be called if the previous attempt" + " aborted");
 }
 try (Scope s = tracer.withSpan(span)) {
  txn = session.newTransaction();
  txn.ensureTxn();
  txnState = TransactionState.STARTED;
  return txn;
 }
}
origin: googleapis/google-cloud-java

/** Transaction functions that returns its result in the provided SettableFuture. */
private <T> void runTransaction(
  final Transaction.Function<T> transactionCallback,
  final SettableApiFuture<T> resultFuture,
  final TransactionOptions options) {
 // span is intentionally not ended here. It will be ended by runTransactionAttempt on success
 // or error.
 Span span = tracer.spanBuilder("CloudFirestore.Transaction").startSpan();
 try (Scope s = tracer.withSpan(span)) {
  runTransactionAttempt(transactionCallback, resultFuture, options, span);
 }
}
origin: googleapis/google-cloud-java

@Override
public RewriteResponse continueRewrite(RewriteResponse previousResponse) {
 Span span = startSpan(HttpStorageRpcSpans.SPAN_NAME_CONTINUE_REWRITE);
 Scope scope = tracer.withSpan(span);
 try {
  return rewrite(previousResponse.rewriteRequest, previousResponse.rewriteToken);
 } finally {
  scope.close();
  span.end();
 }
}
origin: googleapis/google-cloud-java

@Override
public RewriteResponse openRewrite(RewriteRequest rewriteRequest) {
 Span span = startSpan(HttpStorageRpcSpans.SPAN_NAME_OPEN_REWRITE);
 Scope scope = tracer.withSpan(span);
 try {
  return rewrite(rewriteRequest, null);
 } finally {
  scope.close();
  span.end();
 }
}
origin: googleapis/google-cloud-java

@Override
public ReadContext singleUse() {
 Span span = tracer.spanBuilder(READ_ONLY_TRANSACTION).startSpan();
 try (Scope s = tracer.withSpan(span)) {
  return pool.getReadSession().singleUse();
 } catch (RuntimeException e) {
  TraceUtil.endSpanWithFailure(span, e);
  throw e;
 }
}
origin: googleapis/google-cloud-java

@Override
public ReadContext singleUse(TimestampBound bound) {
 Span span = tracer.spanBuilder(READ_ONLY_TRANSACTION).startSpan();
 try (Scope s = tracer.withSpan(span)) {
  return pool.getReadSession().singleUse(bound);
 } catch (RuntimeException e) {
  TraceUtil.endSpanWithFailure(span, e);
  throw e;
 }
}
origin: googleapis/google-cloud-java

@Override
public ReadOnlyTransaction singleUseReadOnlyTransaction() {
 Span span = tracer.spanBuilder(READ_ONLY_TRANSACTION).startSpan();
 try (Scope s = tracer.withSpan(span)) {
  return pool.getReadSession().singleUseReadOnlyTransaction();
 } catch (RuntimeException e) {
  TraceUtil.endSpanWithFailure(span, e);
  throw e;
 }
}
origin: googleapis/google-cloud-java

@Override
public ReadOnlyTransaction readOnlyTransaction(TimestampBound bound) {
 Span span = tracer.spanBuilder(READ_ONLY_TRANSACTION).startSpan();
 try (Scope s = tracer.withSpan(span)) {
  return pool.getReadSession().readOnlyTransaction(bound);
 } catch (RuntimeException e) {
  TraceUtil.endSpanWithFailure(span, e);
  throw e;
 }
}
origin: googleapis/google-cloud-java

@Override
public TransactionManager transactionManager() {
 Span span = tracer.spanBuilder(READ_WRITE_TRANSACTION).startSpan();
 try (Scope s = tracer.withSpan(span)) {
  return pool.getReadWriteSession().transactionManager();
 } catch (RuntimeException e) {
  TraceUtil.endSpanWithFailure(span, e);
  throw e;
 }
}
origin: googleapis/google-cloud-java

@Override
public long executePartitionedUpdate(Statement stmt) {
 Span span = tracer.spanBuilder(PARTITION_DML_TRANSACTION).startSpan();
 try (Scope s = tracer.withSpan(span)) {
  return pool.getReadWriteSession().executePartitionedUpdate(stmt);
 } catch (RuntimeException e) {
  TraceUtil.endSpanWithFailure(span, e);
  throw e;
 }
}
origin: googleapis/google-cloud-java

@Override
public ReadOnlyTransaction singleUseReadOnlyTransaction(TimestampBound bound) {
 Span span = tracer.spanBuilder(READ_ONLY_TRANSACTION).startSpan();
 try (Scope s = tracer.withSpan(span)) {
  return pool.getReadSession().singleUseReadOnlyTransaction(bound);
 } catch (RuntimeException e) {
  TraceUtil.endSpanWithFailure(span, e);
  throw e;
 }
}
origin: googleapis/google-cloud-java

@Override
public TransactionRunner readWriteTransaction() {
 Span span = tracer.spanBuilder(READ_WRITE_TRANSACTION).startSpan();
 try (Scope s = tracer.withSpan(span)) {
  return pool.getReadWriteSession().readWriteTransaction();
 } catch (RuntimeException e) {
  TraceUtil.endSpanWithFailure(span, e);
  throw e;
 }
}
origin: googleapis/google-cloud-java

@Override
public ReadOnlyTransaction readOnlyTransaction() {
 Span span = tracer.spanBuilder(READ_ONLY_TRANSACTION).startSpan();
 try (Scope s = tracer.withSpan(span)) {
  return pool.getReadSession().readOnlyTransaction();
 } catch (RuntimeException e) {
  TraceUtil.endSpanWithFailure(span, e);
  throw e;
 }
}
origin: googleapis/google-cloud-java

@Override
public Timestamp write(Iterable<Mutation> mutations) throws SpannerException {
 Span span = tracer.spanBuilder(READ_WRITE_TRANSACTION).startSpan();
 try (Scope s = tracer.withSpan(span)) {
  return pool.getReadWriteSession().write(mutations);
 } catch (RuntimeException e) {
  TraceUtil.endSpanWithFailure(span, e);
  throw e;
 } finally {
  span.end();
 }
}
origin: googleapis/google-cloud-java

@Override
public Timestamp writeAtLeastOnce(Iterable<Mutation> mutations) throws SpannerException {
 Span span = tracer.spanBuilder(READ_WRITE_TRANSACTION).startSpan();
 try (Scope s = tracer.withSpan(span)) {
  return pool.getReadWriteSession().writeAtLeastOnce(mutations);
 } catch (RuntimeException e) {
  TraceUtil.endSpanWithFailure(span, e);
  throw e;
 } finally {
  span.end();
 }
}
origin: googleapis/google-cloud-java

@Override
public StorageObject patch(StorageObject storageObject, Map<Option, ?> options) {
 Span span = startSpan(HttpStorageRpcSpans.SPAN_NAME_PATCH_OBJECT);
 Scope scope = tracer.withSpan(span);
 try {
  return patchCall(storageObject, options).execute();
 } catch (IOException ex) {
  span.setStatus(Status.UNKNOWN.withDescription(ex.getMessage()));
  throw translate(ex);
 } finally {
  scope.close();
  span.end();
 }
}
origin: googleapis/google-cloud-java

@Override
public Notification createNotification(String bucket, Notification notification) {
 Span span = startSpan(HttpStorageRpcSpans.SPAN_NAME_CREATE_NOTIFICATION);
 Scope scope = tracer.withSpan(span);
 try {
  return storage.notifications().insert(bucket, notification).execute();
 } catch (IOException ex) {
  span.setStatus(Status.UNKNOWN.withDescription(ex.getMessage()));
  throw translate(ex);
 } finally {
  scope.close();
  span.end();
 }
}
origin: googleapis/google-cloud-java

@Override
public ObjectAccessControl createDefaultAcl(ObjectAccessControl acl) {
 Span span = startSpan(HttpStorageRpcSpans.SPAN_NAME_CREATE_OBJECT_DEFAULT_ACL);
 Scope scope = tracer.withSpan(span);
 try {
  return storage.defaultObjectAccessControls().insert(acl.getBucket(), acl).execute();
 } catch (IOException ex) {
  span.setStatus(Status.UNKNOWN.withDescription(ex.getMessage()));
  throw translate(ex);
 } finally {
  scope.close();
  span.end();
 }
}
origin: googleapis/google-cloud-java

@Override
public List<ObjectAccessControl> listDefaultAcls(String bucket) {
 Span span = startSpan(HttpStorageRpcSpans.SPAN_NAME_LIST_OBJECT_DEFAULT_ACLS);
 Scope scope = tracer.withSpan(span);
 try {
  return storage.defaultObjectAccessControls().list(bucket).execute().getItems();
 } catch (IOException ex) {
  span.setStatus(Status.UNKNOWN.withDescription(ex.getMessage()));
  throw translate(ex);
 } finally {
  scope.close();
  span.end();
 }
}
io.opencensus.traceTracerwithSpan

Javadoc

Enters the scope of code where the given Span is in the current Context, and returns an object that represents that scope. The scope is exited when the returned object is closed.

Supports try-with-resource idiom.

Can be called with BlankSpan to enter a scope of code where tracing is stopped.

Example of usage:

 
private static Tracer tracer = Tracing.getTracer();span.end(); 
} 
}

Prior to Java SE 7, you can use a finally block to ensure that a resource is closed regardless of whether the try statement completes normally or abruptly.

Example of usage prior to Java SE7:

 
private static Tracer tracer = Tracing.getTracer();finally  
ws.close(); 
} 
span.end(); 
} 
}

Popular methods of Tracer

  • spanBuilder
    Returns a SpanBuilder to create and start a new child Span as a child of to the current Span if any,
  • getCurrentSpan
    Gets the current Span from the current Context.To install a Span to the current Context use #withSpa
  • spanBuilderWithExplicitParent
    Returns a SpanBuilder to create and start a new child Span (or root if parent is null or has an inva
  • spanBuilderWithRemoteParent
    Returns a SpanBuilder to create and start a new child Span (or root if parent is SpanContext#INVALID
  • getNoopTracer
    Returns the no-op implementation of the Tracer.

Popular in Java

  • Reading from database using SQL prepared statement
  • getOriginalFilename (MultipartFile)
    Return the original filename in the client's filesystem.This may contain path information depending
  • putExtra (Intent)
  • startActivity (Activity)
  • HttpServer (com.sun.net.httpserver)
    This class implements a simple HTTP server. A HttpServer is bound to an IP address and port number a
  • Kernel (java.awt.image)
  • SocketException (java.net)
    This SocketException may be thrown during socket creation or setting options, and is the superclass
  • ByteBuffer (java.nio)
    A buffer for bytes. A byte buffer can be created in either one of the following ways: * #allocate
  • Cipher (javax.crypto)
    This class provides access to implementations of cryptographic ciphers for encryption and decryption
  • Servlet (javax.servlet)
    Defines methods that all servlets must implement. A servlet is a small Java program that runs within
  • Top PhpStorm plugins
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now