StartSpanOptions Class

  • java.lang.Object
    • com.azure.core.util.tracing.StartSpanOptions

public final class StartSpanOptions

Represents span options that are available before span starts and describe it.

Constructor Summary

Constructor Description
StartSpanOptions(SpanKind kind)

Create start options with given kind

Method Summary

Modifier and Type Method and Description
StartSpanOptions addLink(TracingLink link)

Add link to span.

Map<String,Object> getAttributes()

Gets all attributes on span that should be set before span is started.

List<TracingLink> getLinks()

Gets links to be set on span.

Context getRemoteParent()

Gets remote parent.

SpanKind getSpanKind()

Gets span kind.

Instant getStartTimestamp()

Gets span start time.

StartSpanOptions setAttribute(String key, Object value)

Sets attribute on span before its started.

StartSpanOptions setRemoteParent(Context parent)

Sets remote parent context.

StartSpanOptions setStartTimestamp(Instant timestamp)

Sets span start timestamp.

Methods inherited from java.lang.Object

Constructor Details

StartSpanOptions

public StartSpanOptions(SpanKind kind)

Create start options with given kind

Parameters:

kind - The kind of the span to be created.

Method Details

addLink

public StartSpanOptions addLink(TracingLink link)

Add link to span.

Parameters:

link - link.

Returns:

this instance for chaining.

getAttributes

public Map getAttributes()

Gets all attributes on span that should be set before span is started.

Returns:

attributes to be set on span and used for sampling.

getLinks

public List getLinks()

Gets links to be set on span.

Returns:

list of links.

getRemoteParent

public Context getRemoteParent()

Gets remote parent.

Returns:

context with remote parent span context on it.

getSpanKind

public SpanKind getSpanKind()

Gets span kind.

Returns:

span kind.

getStartTimestamp

public Instant getStartTimestamp()

Gets span start time.

Returns:

start timestamp.

setAttribute

public StartSpanOptions setAttribute(String key, Object value)

Sets attribute on span before its started. Such attributes may affect sampling decision. Adding duplicate attributes, update, or removal is discouraged, since underlying implementations behavior can vary.

Parameters:

key - attribute key.
value - attribute value. Note that underlying tracer implementations limit supported value types. OpenTelemetry implementation supports following types:
  • String
  • int
  • double
  • boolean
  • long
  • Arrays of the above

Returns:

this instance for chaining.

setRemoteParent

public StartSpanOptions setRemoteParent(Context parent)

Sets remote parent context.

Parameters:

parent - context with remote span context.

Returns:

this instance for chaining.

setStartTimestamp

public StartSpanOptions setStartTimestamp(Instant timestamp)

Sets span start timestamp. This is optional and used to record past spans. If not set, uses current time.

Parameters:

timestamp - span start time.

Returns:

this instance for chaining.

Applies to