Functions

addTagToMetrics
I

Add a key value pair as a tag to system metrics.

addTagToSpan
I

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.

getMetricsProvider
I

Retrieve metrics provider.

getMetricsReporter
I

Retrieve metrics reporter.

getSpanContext
I

Retrieve a map of span context data.

getTracingProvider
I

Retrieve tracer provider.

isMetricsEnabled
I

Check whether metrics is enabled.

isObservabilityEnabled
I

Check whether observability is enabled.

isTracingEnabled
I

Check whether tracing is enabled.

lookupMetric

Retrieve 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.

addTagToMetrics

function addTagToMetrics(string tagKey, string tagValue) returns error?
Isolated Function

Add a key value pair as a tag to system metrics.

Parameters

  • tagValue string
  • Value of the tag

Return Type

(error?)

An error if an error occurred while attaching tag to System Metrics

addTagToSpan

function addTagToSpan(string tagKey, string tagValue, int spanId) returns error?
Isolated Function

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

Parameters

  • 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

function 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

function 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

getMetricsProvider

function getMetricsProvider() returns string
Isolated Function

Retrieve metrics provider.

Return Type

(string)

getMetricsReporter

function getMetricsReporter() returns string
Isolated Function

Retrieve metrics reporter.

Return Type

(string)

getSpanContext

function getSpanContext() returns map<string>
Isolated Function

Retrieve a map of span context data.

Return Type

(map<string>)

Map of span context data (traceId and spanId).

getTracingProvider

function getTracingProvider() returns string
Isolated Function

Retrieve tracer provider.

Return Type

(string)

isMetricsEnabled

function isMetricsEnabled() returns boolean
Isolated Function

Check whether metrics is enabled.

Return Type

(boolean)

isObservabilityEnabled

function isObservabilityEnabled() returns boolean
Isolated Function

Check whether observability is enabled.

Return Type

(boolean)

isTracingEnabled

function isTracingEnabled() returns boolean
Isolated Function

Check whether tracing is enabled.

Return Type

(boolean)

lookupMetric

function lookupMetric(string name, map<string>? tags) returns Counter | Gauge?

Retrieve 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 associated with the metric that should be looked up

Return Type

(Counter | Gauge?)

The metric instance

startRootSpan

function 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

function 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