Package com.newrelic.telemetry.spans
Class Span.SpanBuilder
- java.lang.Object
-
- com.newrelic.telemetry.spans.Span.SpanBuilder
-
- Enclosing class:
- Span
public static class Span.SpanBuilder extends java.lang.Object
A class for holding the variables associated with a Span object and creating a new Span object with those variables
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Span.SpanBuilder
attributes(Attributes attributes)
Span
build()
Span.SpanBuilder
durationMs(double durationMs)
Span.SpanBuilder
name(java.lang.String name)
Span.SpanBuilder
parentId(java.lang.String parentId)
Span.SpanBuilder
serviceName(java.lang.String serviceName)
Span.SpanBuilder
timestamp(long timestamp)
java.lang.String
toString()
Span.SpanBuilder
traceId(java.lang.String traceId)
Span.SpanBuilder
withError()
Call this to indicate that the span contains an error condition.Span.SpanBuilder
withError(java.lang.String errorMessage)
Call this to indicate that the span contains an error condition with the given message.Span.SpanBuilder
withError(java.lang.String errorMessage, java.lang.String errorClass)
Call this to indicate that the span contains an error condition with the given message and class.
-
-
-
Method Detail
-
attributes
public Span.SpanBuilder attributes(Attributes attributes)
- Parameters:
attributes
- Dimensional attributes as key-value pairs, associated with the Span object to be created. SeeAttributes
. Note: This replaces all attributes that exist on the builder, including those that may have been set via the withError() methods.- Returns:
- The SpanBuilder object with its attributes variable set to the given attributes object
-
traceId
public Span.SpanBuilder traceId(java.lang.String traceId)
- Parameters:
traceId
- The ID used to identify a request as it crosses process boundaries, and in turn link span events- Returns:
- The SpanBuilder object with its traceId variable set to the given Trace Id
-
timestamp
public Span.SpanBuilder timestamp(long timestamp)
- Parameters:
timestamp
- The start time of the span event in epoch milliseconds- Returns:
- The SpanBuilder object with its timestamp variable set to the given timestamp
-
serviceName
public Span.SpanBuilder serviceName(java.lang.String serviceName)
- Parameters:
serviceName
- The name of the service this Span event occurred in- Returns:
- The SpanBuilder object with its serviceName variable set to the given Service Name
-
durationMs
public Span.SpanBuilder durationMs(double durationMs)
- Parameters:
durationMs
- The duration of the Span event, in milliseconds- Returns:
- The SpanBuilder object with its durationMs variable set to the given duration
-
name
public Span.SpanBuilder name(java.lang.String name)
- Parameters:
name
- The name of the Span event- Returns:
- The SpanBuilder object with its name variable set to the given name
-
parentId
public Span.SpanBuilder parentId(java.lang.String parentId)
- Parameters:
parentId
- The Id of the parent span for this Span event. If it is a root span, this variable should stay null, or not set- Returns:
- The SpanBuilder object with its parentId variable set to the given Parent ID
-
withError
public Span.SpanBuilder withError()
Call this to indicate that the span contains an error condition.- Returns:
- The SpanBuilder instance with the error field set to true
-
withError
public Span.SpanBuilder withError(java.lang.String errorMessage)
Call this to indicate that the span contains an error condition with the given message. If attributes() has already set the error.message attribute, this will overwrite it.- Parameters:
errorMessage
- The error message to be placed into the "error.message" attribute- Returns:
- The SpanBuilder instance with the error field set to true
-
withError
public Span.SpanBuilder withError(java.lang.String errorMessage, java.lang.String errorClass)
Call this to indicate that the span contains an error condition with the given message and class. If attributes() has already set the error.message or error.class attributes, they will be overwritten.- Parameters:
errorMessage
- The error message to be placed into the "error.message" attributeerrorClass
- The error class to be placed into the "error.class" attribute- Returns:
- The SpanBuilder instance with the error field set to true
-
build
public Span build()
- Returns:
- A Span object with the variables assigned to the builder class
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
- Returns:
- A string representing this SpanBuilder object and listing its variables
-
-