public abstract class CloudTrace extends Object
| Constructor and Description |
|---|
CloudTrace(ApiProxy.Environment env)
Creates a new CloudTrace object and binds it to a given Environment.
|
| Modifier and Type | Method and Description |
|---|---|
static void |
endSpan(ApiProxy.Environment env,
CloudTraceContext context,
CloudTraceContext parent)
Ends the span for the given context.
|
protected abstract void |
endSpanImpl(CloudTraceContext context) |
static @Nullable CloudTraceContext |
getCurrentContext(ApiProxy.Environment env)
Returns the current trace context for the given environment and the current thread.
|
protected abstract @Nullable CloudTraceContext |
getDefaultContext()
Returns the default context when a thread-specific one doesn't exist.
|
static void |
setCurrentContext(ApiProxy.Environment env,
@Nullable CloudTraceContext context)
Sets the current trace context for the current environment and the current thread.
|
static void |
setLabel(ApiProxy.Environment env,
CloudTraceContext context,
String key,
String value)
Sets a key:value label on the span for the given context.
|
protected abstract void |
setLabelImpl(CloudTraceContext context,
String key,
String value) |
static @Nullable CloudTraceContext |
startChildSpan(ApiProxy.Environment env,
CloudTraceContext context,
String name)
Starts a new span as the child of the given context.
|
protected abstract @Nullable CloudTraceContext |
startChildSpanImpl(CloudTraceContext context,
String name) |
public CloudTrace(ApiProxy.Environment env)
env - the environment object to bind this object to.public static @Nullable CloudTraceContext getCurrentContext(ApiProxy.Environment env)
env - the current environment.public static void setCurrentContext(ApiProxy.Environment env, @Nullable CloudTraceContext context)
env - the current environment.context - the current trace context.protected abstract @Nullable CloudTraceContext getDefaultContext()
public static @Nullable CloudTraceContext startChildSpan(ApiProxy.Environment env, CloudTraceContext context, String name)
env - the environment object to get the current context from.context - parent context of the child span. Must match the current context.name - name of the child span.public static void setLabel(ApiProxy.Environment env, CloudTraceContext context, String key, String value)
env - the environment object to get the current context.context - context of the span. Must match the current context.key - key of the label.value - value of the label.public static void endSpan(ApiProxy.Environment env, CloudTraceContext context, CloudTraceContext parent)
env - the environment object to get the current context.context - context of the span. Must match the current context.parent - parent context of the span. It becomes the current context after the call.protected abstract @Nullable CloudTraceContext startChildSpanImpl(CloudTraceContext context, String name)
protected abstract void setLabelImpl(CloudTraceContext context, String key, String value)
protected abstract void endSpanImpl(CloudTraceContext context)
Copyright © 2022. All rights reserved.