Hauptinhalt

Emit MATLAB Build Telemetry Data with OpenTelemetry Integration

R2026b
Since R2026a

You can instrument your MATLAB® builds with OpenTelemetry™ to emit detailed execution data, including build results, task spans, and other metrics. The build tool emits traces and metrics, which you can export to observability backends for monitoring and analysis, using the OpenTelemetry-MATLAB package. For more information on OpenTelemetry, see the OpenTelemetry documentation.

When you install the OpenTelemetry-MATLAB package, the build tool automatically instruments all builds. No changes to your build file are required.

Set Up OpenTelemetry Integration

To emit telemetry data from MATLAB builds, you need MATLAB R2026a or later and the OpenTelemetry-MATLAB package. For each MATLAB instance that participates in builds:

  1. Install the gRPC variant of the OpenTelemetry-MATLAB package — Use the Add-On Explorer in MATLAB to search for and install OpenTelemetry-MATLAB. Alternatively, download the otel-matlab.mltbx file from GitHub Releases and then double-click the file or use mpminstall. For installation instructions and examples, see MATLAB Interface to OpenTelemetry on GitHub®.

  2. Configure how the integration exports data — On the system that runs the MATLAB build, set the OTEL_EXPORTER_OTLP_ENDPOINT environment variable to the address of your OpenTelemetry collector or backend. The build tool exports telemetry data using the OTLP gRPC protocol. If you do not set this variable, the default endpoint is localhost:4317.

After you install the OpenTelemetry-MATLAB package, the build tool automatically emits telemetry data on subsequent runs. The instrumentation emits:

  • A trace with one parent span named "buildtool" that encompasses your entire build, with individual child spans for each task that executes

  • Metrics that track quantitative build data, such as task successes, failures, and skips

You can view the resulting traces and metrics in your observability backend.

Note

Tasks that execute on parallel workers do not emit telemetry data. Only tasks that run on the MATLAB client emit spans and metrics.

Use Environment Variables for Context Propagation

The build tool integrates with other tools, such as continuous integration (CI) systems, by using environment variables to propagate context. For more information, see the OpenTelemetry Environment Variables as Context Propagation Carriers page.

To link build traces to a parent trace in your CI pipeline, set the following environment variables on the system that runs the MATLAB build.

Environment VariableDescription
TRACE_IDTrace ID from the parent span
SPAN_IDSpan ID from the parent span
BAGGAGEComma-separated key-value pairs to attach as resource attributes (for example, cicd.pipeline.id=my_pipeline,cicd.pipeline.run_number=10)

For example, the OpenTelemetry plugin for Jenkins exposes these environment variables to downstream build steps automatically, enabling you to connect MATLAB build traces to the broader pipeline trace.

Use Existing OpenTelemetry Configuration

If you already configure OpenTelemetry in MATLAB elsewhere in your pipeline, you can prevent the build tool from overwriting your configuration. On the system that runs the MATLAB build, set the NO_MBT_OTEL_CONFIG environment variable to any value. For example:

setenv("NO_MBT_OTEL_CONFIG","1")

If you set this variable, the build tool still creates spans and records metrics using your existing configuration, but it does not set up or tear down the tracer provider, meter provider, logger provider, or exporters.

Telemetry Data Reference

The build tool emits telemetry data as traces and metrics. Each build produces a parent span with child spans for individual tasks, and counters that track task outcomes. The following subsections describe the attributes and metrics that the build tool produces.

Resource Attributes

All telemetry signals include the following resource attribute.

AttributeExample ValueDescription
service.namebuildtoolName of the telemetry source

Span Attributes

The build span ("buildtool") includes these attributes.

AttributeExample ValueDescription
buildtool.tasks3Total number of tasks in the build
buildtool.tasks.successful["check", "test"]Names of successful tasks
buildtool.tasks.failed[]Names of failed tasks
buildtool.tasks.skipped["archive"]Names of skipped tasks
buildtool.build.successes2Number of successful tasks
buildtool.build.failures0Number of failed tasks
buildtool.build.skips1Number of skipped tasks

Each task span includes these attributes.

AttributeExample ValueDescription
buildtool.task.nametestName of the task
buildtool.task.descriptionRun testsDescription of the task
buildtool.task.successfultrueWhether the task was successful
buildtool.task.failedfalseWhether the task failed
buildtool.task.skippedfalseWhether the task was skipped

Span Status

The build tool sets the span status to indicate the outcome of the build or task.

SpanConditionStatus CodeStatus Message
Build spanAll tasks succeedOk-
Build spanAny task failsErrorBuild completed, results not successful
Task spanTask succeedsOk-
Task spanTask failsErrorTask completed, results not successful

Metrics

The build tool records the following metrics.

MetricTypeDescription
buildtool.tasks.successfulCounterNumber of successful tasks
buildtool.tasks.failedCounterNumber of failed tasks
buildtool.tasks.skippedCounterNumber of skipped tasks
buildtool.build.successesCounterNumber of successful builds
buildtool.build.failuresCounterNumber of failed builds

See Also

Functions

Topics

External Websites