matlab-instrument-opentelemetry-tracing

Add OpenTelemetry tracing spans to MATLAB functions with automatic context propagation.

995|122|Updated Apr 3, 2026
One-click install
npx skills add https://github.com/matlab/matlab-agentic-toolkit --skill matlab-instrument-opentelemetry-tracing
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: matlab-instrument-opentelemetry-tracing
Source: https://github.com/matlab/matlab-agentic-toolkit/tree/main/skills-catalog/matlab-software-development/matlab-instrument-opentelemetry-tracing
Command: npx skills add https://github.com/matlab/matlab-agentic-toolkit --skill matlab-instrument-opentelemetry-tracing

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

Instrumenting MATLAB code with OpenTelemetry tracing is error-prone because the MATLAB API differs from other languages and spans rely on RAII lifecycle rules. This Skill ensures correct span creation, parent-child context propagation, error recording, and semantic attribute naming without modifying function signatures.

Core Features & Use Cases

  • Correct Instrumentation Pattern: Applies the canonical getTracer, startSpan, makeCurrent, setStatus pattern with RAII-based span lifecycle, avoiding redundant endSpan calls.
  • Error Handling and Loop Patterns: Provides try-catch templates with recordException and setStatus, plus the mandatory endSpan and clear(scope) pattern for per-iteration spans in loops.
  • Semantic Conventions: Enforces lowercase dot-separated attribute names with domain-noun namespaces, covering HTTP client, file I/O, database, and domain-specific attributes.
  • Use Case: A user asks to add distributed tracing to a MATLAB data pipeline; the Skill instruments each function so spans form a correct parent-child trace viewable in Jaeger or Grafana Tempo.

Quick Start

Add OpenTelemetry tracing spans to my MATLAB function processSensorData.m with proper error handling and attributes.

Frequently Asked Questions about matlab-instrument-opentelemetry-tracing

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I add OpenTelemetry tracing to MATLAB code?

Call opentelemetry.trace.getTracer inside each function, create a span with startSpan, and call makeCurrent so child spans inherit context automatically. Set the span status with setStatus before the function returns; the span ends automatically via RAII when it goes out of scope.

How do I create parent-child spans in MATLAB functions?

Call makeCurrent on every span so it becomes the current context. Child functions that call startSpan then automatically attach as children of the current span, with no explicit Context argument needed.

What MATLAB version supports OpenTelemetry tracing?

OpenTelemetry tracing in MATLAB requires R2022b or newer with the OpenTelemetry-MATLAB package version 1.11.0 or later installed. The package provides the opentelemetry.trace namespace used for all tracing calls.

Why does setAttribute not work in MATLAB OpenTelemetry?

The singular setAttribute method does not exist in the MATLAB OpenTelemetry API. Use setAttributes (plural) to attach one or more key-value pairs to a span, and pass the strings "Ok" or "Error" to setStatus since StatusCode enums are not available.

When should I not instrument MATLAB code with tracing?

Avoid instrumenting trivial helpers under five lines, functions called thousands of times in tight loops, and code inside parfor blocks because OTel context is not thread-safe in MATLAB. Metrics-only or logging-only needs also do not require tracing instrumentation.