Package com.google.apphosting.runtime
Class TraceWriter
java.lang.Object
com.google.apphosting.runtime.TraceWriter
Stores trace spans for a single request, and flushes them into
RuntimePb.UPResponse.-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionTraceWriter(com.google.apphosting.api.CloudTraceContext context, MutableUpResponse upResponse) -
Method Summary
Modifier and TypeMethodDescriptionvoidaddStackTrace(com.google.apphosting.api.CloudTraceContext context, StackTraceElement[] stackTrace) Add stack trace into the current span.voidendApiSpan(com.google.apphosting.api.CloudTraceContext context) End the API span.voidEnd the request span.voidendSpan(com.google.apphosting.api.CloudTraceContext context) End the current span.voidFlush collected trace intoRuntimePb.UPResponse.com.google.apphosting.api.CloudTraceContextGets the current trace context.static TraceWritergetTraceWriterForRequest(com.google.apphosting.base.protos.RuntimePb.UPRequest upRequest, MutableUpResponse upResponse) voidSet a label on the current span.com.google.apphosting.api.CloudTraceContextstartApiSpan(com.google.apphosting.api.CloudTraceContext parentContext, String packageName, String methodName) Start a API span as a child of the current span.com.google.apphosting.api.CloudTraceContextstartChildSpan(com.google.apphosting.api.CloudTraceContext parentContext, String name) Start a new span as a child of the given context.voidstartRequestSpan(String name) Start a request span as a child of the current span.
-
Field Details
-
DEFAULT_MAX_TRACE
public static final int DEFAULT_MAX_TRACE- See Also:
-
MAX_TRACE_PROPERTY
- See Also:
-
-
Constructor Details
-
TraceWriter
public TraceWriter(com.google.apphosting.api.CloudTraceContext context, MutableUpResponse upResponse)
-
-
Method Details
-
getTraceWriterForRequest
@Nullable public static TraceWriter getTraceWriterForRequest(com.google.apphosting.base.protos.RuntimePb.UPRequest upRequest, MutableUpResponse upResponse) -
getTraceContext
public com.google.apphosting.api.CloudTraceContext getTraceContext()Gets the current trace context.- Returns:
- the current trace context.
-
startRequestSpan
Start a request span as a child of the current span.- Parameters:
name- the name of the request span
-
startApiSpan
public com.google.apphosting.api.CloudTraceContext startApiSpan(@Nullable com.google.apphosting.api.CloudTraceContext parentContext, String packageName, String methodName) Start a API span as a child of the current span.- Parameters:
parentContext- the parent contextpackageName- the name of the API packagemethodName- the name of the method within the API package- Returns:
- a child
CloudTraceContext
-
startChildSpan
public com.google.apphosting.api.CloudTraceContext startChildSpan(com.google.apphosting.api.CloudTraceContext parentContext, String name) Start a new span as a child of the given context.- Parameters:
parentContext- the parent contextname- the name of the child span- Returns:
- a child
CloudTraceContext
-
setLabel
Set a label on the current span.- Parameters:
context- the current contextkey- key of the labelvalue- value of the label
-
addStackTrace
public void addStackTrace(com.google.apphosting.api.CloudTraceContext context, StackTraceElement[] stackTrace) Add stack trace into the current span. The stack trace must be scrubbed for security before being passed to this method.- Parameters:
context- the current contextstackTrace- stack trace to be added
-
endSpan
public void endSpan(com.google.apphosting.api.CloudTraceContext context) End the current span.- Parameters:
context- the current context
-
endApiSpan
public void endApiSpan(com.google.apphosting.api.CloudTraceContext context) End the API span. TODO: Remove this function which is the same as endSpan.- Parameters:
context- the trace context of the API span
-
endRequestSpan
public void endRequestSpan()End the request span. -
flushTrace
public void flushTrace()Flush collected trace intoRuntimePb.UPResponse.
-