From 5f059e3ef999bc127631a988e685a118f1714464 Mon Sep 17 00:00:00 2001 From: Albert ten Napel Date: Wed, 1 Apr 2026 16:09:32 +0200 Subject: [PATCH 1/2] Document the Java tracing API --- .../refguide/runtime/tracing-in-runtime.md | 36 +++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/content/en/docs/refguide/runtime/tracing-in-runtime.md b/content/en/docs/refguide/runtime/tracing-in-runtime.md index b97cc97de5f..8a6b18b0a92 100644 --- a/content/en/docs/refguide/runtime/tracing-in-runtime.md +++ b/content/en/docs/refguide/runtime/tracing-in-runtime.md @@ -165,3 +165,39 @@ You can also collect metrics data (CPU load, memory, etc.) and logs using OpenTe * See the [OpenTelemetry](/refguide/metrics/#opentelemetry) section of *Metrics* for a guide on how to setup metrics with OpenTelemetry. * See [Request to Create New Log Subscriber in Open Telemetry Format](/refguide/monitoring-mendix-runtime/#new-log-sub-opentelemetry) in *Monitoring Mendix Runtime* for a guide on how to setup logs with OpenTelemetry. + +## Custom Spans in Java Actions + +{{% alert color="info" %}} +Custom spans in Java actions was introduced in Mendix 11.10.0. +{{% /alert %}} + +Custom spans can be created in Java actions using the `Core.tracing()` API. + +Below is an example of how to create a span and wrap some code with it. The `run` method will start and close the span, set the span status and handle exceptions. + +```java +Core.tracing() + .createSpan("my span name") + .withAttribute("attribute key", "attribute value") + .run(span -> { + // the code here will be wrapped by the span + }); +``` + +If the flow of control is more complicated then you can also manually handle the lifecycle of the span using the `start` and `close` methods. + +```java +var span = Core.tracing() + .createSpan("my span name") + .withAttribute("attribute key", "attribute value") + .start(); +try { + // your code + span.setStatus(Span.Status.OK); +} catch (Throwable exc) { + span.setError(exc); +} finally { + span.close(); +} +``` From 73b3e9ffd0801c09c0cb74505a6d0f95a20d2ed5 Mon Sep 17 00:00:00 2001 From: Mark van Ments <35492184+MarkvanMents@users.noreply.github.com> Date: Tue, 14 Apr 2026 11:06:31 +0200 Subject: [PATCH 2/2] Fix grammar and clarity in tracing documentation --- content/en/docs/refguide/runtime/tracing-in-runtime.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/content/en/docs/refguide/runtime/tracing-in-runtime.md b/content/en/docs/refguide/runtime/tracing-in-runtime.md index 8a6b18b0a92..4e96b67a08d 100644 --- a/content/en/docs/refguide/runtime/tracing-in-runtime.md +++ b/content/en/docs/refguide/runtime/tracing-in-runtime.md @@ -174,7 +174,7 @@ Custom spans in Java actions was introduced in Mendix 11.10.0. Custom spans can be created in Java actions using the `Core.tracing()` API. -Below is an example of how to create a span and wrap some code with it. The `run` method will start and close the span, set the span status and handle exceptions. +Below is an example of how to create a span and wrap some code in it. The `run` method starts and closes the span, sets the span status and handles exceptions. ```java Core.tracing() @@ -185,7 +185,7 @@ Core.tracing() }); ``` -If the flow of control is more complicated then you can also manually handle the lifecycle of the span using the `start` and `close` methods. +If the flow of control is more complicated, then you can also handle the lifecycle of the span manually using the `start` and `close` methods. ```java var span = Core.tracing()