Functions - observe

addTagToSpan

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

finishSpan

Finish the current span.

getAllMetrics

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

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?

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

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.

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 ())
  • 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 ())
  • 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 ())
  • 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