Functions - observe

addTagToSpan
I

Add a key value pair as a tag to the span.

ballerina/observe:0.8.0.<init>0
finishSpan

Finish the current span.

getAllMetrics

Retrieve all registered metrics including default metrics from the ballerina runtime, and user defined metrics.

isObservabilityEnabled
I

Checks of either metrics or tracing had been enabled.

lookupMetric

Retrieves the specific metric that is described by the given name and tags.

startRootSpan

Start a span with no parent span.

startSpan

Start a span and create child relationship to current active span or user specified span.

addTagToSpan

(string tagKey, string tagValue, int spanId)

returns error?
Isolated Function

Add a key value pair as a tag to the span.

Parameters

  • tagKey string
  • Key of the tag

  • tagValue string
  • Value of the tag

  • spanId int (default -1)
  • Id of span to which the tags should be added or -1 to add tags to the current active span

  • Return Type

    (error?)
  • An error if an error occurred while attaching tag to the span

ballerina/observe:0.8.0.<init>0

()

returns error?

finishSpan

(int spanId)

returns error?

Finish the current span.

Parameters

  • spanId int
  • Id of span to finish

  • Return Type

    (error?)
  • An error if an error occurred while finishing the span

getAllMetrics

()

returns Metric[]

Retrieve all registered metrics including default metrics from the ballerina runtime, and user defined metrics.

  • Return Type

    (Metric[])
  • Array of all registered metrics.

isObservabilityEnabled

()

returns boolean
Isolated Function

Checks of either metrics or tracing had been enabled.

  • Return Type

    (boolean)
  • True if observability had been enabled.

lookupMetric

(string name, map<string> tags)

returns Counter | Gauge?

Retrieves the specific metric that is described by the given name and tags.

Parameters

  • name string
  • Name of the metric to lookup.

  • tags map<string> (default <map<string>?> ())
  • The key/value pair tags that associated with the metric that should be looked up.

startRootSpan

(string spanName, map<string> tags)

returns int

Start a span with no parent span.

Parameters

  • spanName string
  • Name of the span

  • tags map<string> (default <map<string>?> ())
  • Tags to be associated to the span

  • Return Type

    (int)
  • SpanId of the started span

startSpan

(string spanName, map<string> tags, int parentSpanId)

returns int | error

Start a span and create child relationship to current active span or user specified span.

Parameters

  • spanName string
  • Name of the span

  • tags map<string> (default <map<string>?> ())
  • Tags to be associated to the span

  • parentSpanId int (default -1)
  • Id of the parent span or -1 if parent span should be taken from system trace

  • Return Type

    (int | error)
  • SpanId of the started span