You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@causeway.apache.org by da...@apache.org on 2026/09/23 14:39:53 UTC
(causeway) 03/03: CAUSEWAY-4059: improves semantic span names
This is an automated email from the ASF dual-hosted git repository.
danhaywood pushed a commit to branch CAUSEWAY-4059
in repository https://gitbox.apache.org/repos/asf/causeway.git
commit 1959d8672ea5762350009a605723ded1612cb696
Author: Dan Haywood <da...@haywood-associates.co.uk>
AuthorDate: Wed Sep 23 15:39:44 2026 +0100
CAUSEWAY-4059: improves semantic span names
---
adoc/micrometer-tracing-operations.adoc | 29 ++++--
.../observation/CausewayObservationNaming.java | 110 +++++++++++++++++++++
.../observation/CausewayObservationNamingTest.java | 66 +++++++++++++
.../executor/MemberExecutorServiceDefault.java | 11 ++-
...actionFailureIsRecordedAndRethrown.approved.txt | 4 +-
...tionHasStableNameTagsAndRootParent.approved.txt | 10 +-
...emberExecutorServiceDefaultObservationTest.java | 6 +-
.../changes/improve-semantic-span-names/tasks.md | 22 ++---
.../improve-semantic-span-names/validation.md | 34 +++++++
regressiontests/tracing-compatibility/pom.xml | 5 +
.../tracing/MicrometerTracingAgentFixture.java | 29 +++++-
.../MicrometerTracingCompatibilityTest.java | 28 +++++-
.../observation/WicketRenderObservationTest.java | 96 +++++++++++++++---
.../components/actions/ActionParametersPanel.java | 8 ++
.../WicketRenderObservationDescriptor.java | 46 +++++++--
15 files changed, 444 insertions(+), 60 deletions(-)
diff --git a/adoc/micrometer-tracing-operations.adoc b/adoc/micrometer-tracing-operations.adoc
index 92bfa45453a..2a73e41fa63 100644
--- a/adoc/micrometer-tracing-operations.adoc
+++ b/adoc/micrometer-tracing-operations.adoc
@@ -78,7 +78,7 @@ Select `my-causeway-app-local` in Jaeger and look for these ordered boundaries:
----
HTTP
-> causeway.root.interaction
- -> causeway.action.invocation
+ -> invoke update-name on customer
-> JDBC
----
@@ -215,13 +215,18 @@ See link:https://learn.microsoft.com/en-us/azure/container-apps/environment-vari
== What Causeway Adds
-With the `observation` profile active, Causeway adds two stable semantic spans:
+With the `observation` profile active, Causeway adds two core semantic observations:
-* `causeway.root.interaction` covers one top-level Causeway interaction;
-* `causeway.action.invocation` covers an action invocation.
+* `causeway.root.interaction` covers one top-level Causeway interaction and retains that stable span display name;
+* `causeway.action.invocation` covers an action invocation and uses a compact display name such as `invoke update-name on customer`.
+The stable observation name remains `causeway.action.invocation` even though the contextual name becomes the exported tracing span display name.
Action spans carry the bounded attributes `causeway.action.id` and `causeway.execution.initiatedBy`.
-Causeway does not add action arguments, return values, target instance identifiers, user names, tenancy tokens, or other instance-specific application data to these semantic spans.
+The full `causeway.action.id` is authoritative for filtering and disambiguates actions whose compact display names are equal or truncated.
+
+Contextual names use normalized, lower-hyphen forms of static logical type and member names rather than localized friendly names.
+Micrometer Tracing 1.0.12 limits its normalized display name to 50 characters, so tracing backends can show a truncated contextual name while the canonical attributes remain complete.
+Causeway does not add action arguments, return values, target instance identifiers, object titles, bookmarks, user names, tenancy tokens, or other instance-specific application data to names or attributes on these semantic spans.
=== Wicket Entity Page Rendering
@@ -229,18 +234,28 @@ When the Wicket viewer renders an entity page, Causeway adds semantic spans for
[source,text]
----
-causeway.wicket.page.render
+render customer
├── causeway.wicket.fieldset.render
│ ├── causeway.wicket.property.render
│ └── causeway.wicket.action.render
├── causeway.wicket.collection.render
-└── causeway.wicket.action.render
+├── causeway.wicket.action.render
+└── prompt update-name on customer
----
Ajax responses create spans only for the instrumented regions included in the partial render, so an Ajax trace need not contain `causeway.wicket.page.render`.
Automatic JDBC spans become descendants of the active region span when database work occurs during that region's rendering.
+The entity-page observation retains the stable name `causeway.wicket.page.render` but uses a compact contextual display name such as `render customer`.
+Fieldset, property, collection, and action-button observations retain their stable names as display names.
+
+A parameterized action prompt creates one `causeway.wicket.action.prompt.render` observation around the enclosing prompt panel's actual render callback, with a compact display name such as `prompt update-name on customer`.
+The same semantic boundary applies to inline, modal, and sidebar presentation styles.
+It does not cover defaults, choices, validation, visibility, usability, authorization, or other prompt preparation completed outside that render callback.
+Individual action parameters do not create property render spans.
+
Wicket spans use `causeway.object.type` together with the applicable bounded attribute `causeway.fieldset.id`, `causeway.property.id`, `causeway.collection.id`, or `causeway.action.id`.
+The full canonical attributes remain authoritative when a page or prompt contextual name is compact, ambiguous, or truncated.
These identifiers describe static application structure.
Causeway does not attach property values, rendered labels, object titles, bookmarks, action arguments, user names, tenancy tokens, collection-row identities, or generated Wicket component paths.
diff --git a/core/config/src/main/java/org/apache/causeway/core/config/observation/CausewayObservationNaming.java b/core/config/src/main/java/org/apache/causeway/core/config/observation/CausewayObservationNaming.java
new file mode 100644
index 00000000000..fb696c4a56c
--- /dev/null
+++ b/core/config/src/main/java/org/apache/causeway/core/config/observation/CausewayObservationNaming.java
@@ -0,0 +1,110 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.causeway.core.config.observation;
+
+import java.util.Objects;
+
+/**
+ * Creates compact, bounded-cardinality contextual names for semantic observations.
+ *
+ * @since 2.2
+ */
+public final class CausewayObservationNaming {
+
+ private CausewayObservationNaming() {}
+
+ public static String forType(
+ final String operation,
+ final String logicalTypeName) {
+ return token(operation) + " " + token(simpleTypeName(logicalTypeName));
+ }
+
+ public static String forMember(
+ final String operation,
+ final String logicalTypeName,
+ final String memberLogicalName) {
+ return token(operation)
+ + " " + token(memberLogicalName)
+ + " on " + token(simpleTypeName(logicalTypeName));
+ }
+
+ private static String simpleTypeName(final String logicalTypeName) {
+ final String typeName = requireText(logicalTypeName, "logicalTypeName");
+ int separator = -1;
+ for (int i = 0; i < typeName.length(); i++) {
+ switch (typeName.charAt(i)) {
+ case '.':
+ case '/':
+ case '\\':
+ case ':':
+ case '$':
+ separator = i;
+ break;
+ default:
+ break;
+ }
+ }
+ return separator >= 0 && separator + 1 < typeName.length()
+ ? typeName.substring(separator + 1)
+ : typeName;
+ }
+
+ private static String token(final String value) {
+ final String text = requireText(value, "contextual name token");
+ final StringBuilder normalized = new StringBuilder(text.length());
+ boolean separatorPending = false;
+ char previous = 0;
+ for (int i = 0; i < text.length(); i++) {
+ final char current = text.charAt(i);
+ if(Character.isLetterOrDigit(current)) {
+ if(normalized.length() > 0
+ && (separatorPending
+ || Character.isUpperCase(current)
+ && (Character.isLowerCase(previous)
+ || Character.isDigit(previous)))) {
+ appendSeparator(normalized);
+ }
+ normalized.append(Character.toLowerCase(current));
+ separatorPending = false;
+ previous = current;
+ } else {
+ separatorPending = normalized.length() > 0;
+ previous = 0;
+ }
+ }
+ if(normalized.length() == 0) {
+ throw new IllegalArgumentException("contextual name token must contain a letter or digit");
+ }
+ return normalized.toString();
+ }
+
+ private static void appendSeparator(final StringBuilder normalized) {
+ if(normalized.charAt(normalized.length() - 1) != '-') {
+ normalized.append('-');
+ }
+ }
+
+ private static String requireText(final String value, final String name) {
+ Objects.requireNonNull(value, name);
+ if(value.trim().isEmpty()) {
+ throw new IllegalArgumentException(name + " must not be blank");
+ }
+ return value;
+ }
+}
diff --git a/core/config/src/test/java/org/apache/causeway/core/config/observation/CausewayObservationNamingTest.java b/core/config/src/test/java/org/apache/causeway/core/config/observation/CausewayObservationNamingTest.java
new file mode 100644
index 00000000000..67926fb723d
--- /dev/null
+++ b/core/config/src/test/java/org/apache/causeway/core/config/observation/CausewayObservationNamingTest.java
@@ -0,0 +1,66 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.causeway.core.config.observation;
+
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+class CausewayObservationNamingTest {
+
+ @Test
+ void typeNameIsCompactAndNormalized() {
+ assertEquals("render customer",
+ CausewayObservationNaming.forType("render", "demo.Customer"));
+ assertEquals("render customer",
+ CausewayObservationNaming.forType("render", "other/context:Customer"));
+ }
+
+ @Test
+ void memberNameIsOperationFirstAndNormalized() {
+ assertEquals("invoke update-name on customer",
+ CausewayObservationNaming.forMember(
+ "invoke", "demo.Customer", "updateName"));
+ assertEquals("prompt create-url on customer",
+ CausewayObservationNaming.forMember(
+ "prompt", "demo.Customer", "createURL"));
+ }
+
+ @Test
+ void compactNamesCanCollideWhileCanonicalIdentifiersRemainExternal() {
+ assertEquals(
+ CausewayObservationNaming.forMember(
+ "invoke", "sales.Customer", "updateName"),
+ CausewayObservationNaming.forMember(
+ "invoke", "support.Customer", "updateName"));
+ }
+
+ @Test
+ void longNameKeepsDiagnosticOperationAndMemberBeforeType() {
+ final String contextualName = CausewayObservationNaming.forMember(
+ "invoke",
+ "demo.CustomerWithAnUnusuallyLongLogicalTypeName",
+ "performAnUnusuallyLongAdministrativeOperation");
+
+ assertTrue(contextualName.startsWith(
+ "invoke perform-an-unusually-long-administrative-operation on "));
+ assertTrue(contextualName.length() > 50);
+ }
+}
diff --git a/core/runtimeservices/src/main/java/org/apache/causeway/core/runtimeservices/executor/MemberExecutorServiceDefault.java b/core/runtimeservices/src/main/java/org/apache/causeway/core/runtimeservices/executor/MemberExecutorServiceDefault.java
index 5a52e4d64f0..b1ad81fc07d 100644
--- a/core/runtimeservices/src/main/java/org/apache/causeway/core/runtimeservices/executor/MemberExecutorServiceDefault.java
+++ b/core/runtimeservices/src/main/java/org/apache/causeway/core/runtimeservices/executor/MemberExecutorServiceDefault.java
@@ -50,6 +50,7 @@
import org.apache.causeway.core.config.CausewayConfiguration;
import org.apache.causeway.core.config.observation.CausewayObservationIntegration;
import org.apache.causeway.core.config.observation.CausewayObservationIntegration.ObservationProvider;
+import org.apache.causeway.core.config.observation.CausewayObservationNaming;
import org.apache.causeway.core.config.progmodel.ProgrammingModelConstants.MessageTemplate;
import org.apache.causeway.core.metamodel.commons.CanonicalInvoker;
import org.apache.causeway.core.metamodel.consent.InteractionInitiatedBy;
@@ -142,11 +143,13 @@ public Optional<InteractionInternal> getInteraction() {
public ManagedObject invokeAction(
final @NonNull ActionExecutor actionExecutor) {
- final String actionId = actionExecutor.getOwningAction()
- .getFeatureIdentifier()
- .getLogicalIdentityString("#");
+ final var actionIdentifier = actionExecutor.getOwningAction().getFeatureIdentifier();
+ final String actionId = actionIdentifier.getLogicalIdentityString("#");
return observationProvider().get(ACTION_OBSERVATION_NAME)
- .contextualName(ACTION_OBSERVATION_NAME)
+ .contextualName(CausewayObservationNaming.forMember(
+ "invoke",
+ actionIdentifier.logicalTypeName(),
+ actionIdentifier.memberLogicalName()))
.lowCardinalityKeyValue(ACTION_ID_TAG, actionId)
.lowCardinalityKeyValue(
INITIATED_BY_TAG,
diff --git a/core/runtimeservices/src/test/java/org/apache/causeway/core/runtimeservices/executor/MemberExecutorServiceDefaultObservationTest.actionFailureIsRecordedAndRethrown.approved.txt b/core/runtimeservices/src/test/java/org/apache/causeway/core/runtimeservices/executor/MemberExecutorServiceDefaultObservationTest.actionFailureIsRecordedAndRethrown.approved.txt
index f525e3a2c41..15a9199f9be 100644
--- a/core/runtimeservices/src/test/java/org/apache/causeway/core/runtimeservices/executor/MemberExecutorServiceDefaultObservationTest.actionFailureIsRecordedAndRethrown.approved.txt
+++ b/core/runtimeservices/src/test/java/org/apache/causeway/core/runtimeservices/executor/MemberExecutorServiceDefaultObservationTest.actionFailureIsRecordedAndRethrown.approved.txt
@@ -7,10 +7,10 @@ This approval checks:
- No current observation remains after failure.
Observed lifecycle:
-1. onStart(name=causeway.action.invocation, parent=<none>, causeway.action.id=demo.Customer#updateName(), causeway.execution.initiatedBy=PASS_THROUGH)
+1. onStart(name=causeway.action.invocation, contextualName=invoke update-name on customer, parent=<none>, causeway.action.id=demo.Customer#updateName(), causeway.execution.initiatedBy=PASS_THROUGH)
2. onScopeOpened(name=causeway.action.invocation)
3. onScopeClosed(name=causeway.action.invocation)
4. onError(type=ReflectiveActionException, message=IllegalStateException thrown while invoking fail action failed)
-5. onStop(name=causeway.action.invocation)
+5. onStop(name=causeway.action.invocation, contextualName=invoke update-name on customer)
6. failure returned to caller: ReflectiveActionException: IllegalStateException thrown while invoking fail action failed
7. current observation after failure: <none>
\ No newline at end of file
diff --git a/core/runtimeservices/src/test/java/org/apache/causeway/core/runtimeservices/executor/MemberExecutorServiceDefaultObservationTest.actionObservationHasStableNameTagsAndRootParent.approved.txt b/core/runtimeservices/src/test/java/org/apache/causeway/core/runtimeservices/executor/MemberExecutorServiceDefaultObservationTest.actionObservationHasStableNameTagsAndRootParent.approved.txt
index f6e0d1b64b3..df4d7e488ee 100644
--- a/core/runtimeservices/src/test/java/org/apache/causeway/core/runtimeservices/executor/MemberExecutorServiceDefaultObservationTest.actionObservationHasStableNameTagsAndRootParent.approved.txt
+++ b/core/runtimeservices/src/test/java/org/apache/causeway/core/runtimeservices/executor/MemberExecutorServiceDefaultObservationTest.actionObservationHasStableNameTagsAndRootParent.approved.txt
@@ -1,18 +1,18 @@
Scenario: Action observation name, metadata, and root parentage
This approval checks:
-- The action uses one stable operation name.
+- The action keeps one stable observation name and adds a meaningful contextual name.
- The action identifier is an explicit low-cardinality attribute.
- The initiation mode is an explicit low-cardinality attribute.
- The action observation is a child of the current root observation.
- Action arguments, results, targets, users, and tenancy values are not captured.
Observed lifecycle:
-1. onStart(name=test root, parent=<none>, causeway.action.id=<absent>, causeway.execution.initiatedBy=<absent>)
+1. onStart(name=test root, contextualName=null, parent=<none>, causeway.action.id=<absent>, causeway.execution.initiatedBy=<absent>)
2. onScopeOpened(name=test root)
-3. onStart(name=causeway.action.invocation, parent=test root, causeway.action.id=demo.Customer#updateName(), causeway.execution.initiatedBy=PASS_THROUGH)
+3. onStart(name=causeway.action.invocation, contextualName=invoke update-name on customer, parent=test root, causeway.action.id=demo.Customer#updateName(), causeway.execution.initiatedBy=PASS_THROUGH)
4. onScopeOpened(name=causeway.action.invocation)
5. onScopeClosed(name=causeway.action.invocation)
-6. onStop(name=causeway.action.invocation)
+6. onStop(name=causeway.action.invocation, contextualName=invoke update-name on customer)
7. onScopeClosed(name=test root)
-8. onStop(name=test root)
\ No newline at end of file
+8. onStop(name=test root, contextualName=null)
\ No newline at end of file
diff --git a/core/runtimeservices/src/test/java/org/apache/causeway/core/runtimeservices/executor/MemberExecutorServiceDefaultObservationTest.java b/core/runtimeservices/src/test/java/org/apache/causeway/core/runtimeservices/executor/MemberExecutorServiceDefaultObservationTest.java
index 449c5c9996d..65e8ae3ea70 100644
--- a/core/runtimeservices/src/test/java/org/apache/causeway/core/runtimeservices/executor/MemberExecutorServiceDefaultObservationTest.java
+++ b/core/runtimeservices/src/test/java/org/apache/causeway/core/runtimeservices/executor/MemberExecutorServiceDefaultObservationTest.java
@@ -79,7 +79,7 @@ void actionObservationHasStableNameTagsAndRootParent() throws Exception {
Approvals.verify(report(
"Action observation name, metadata, and root parentage",
List.of(
- "The action uses one stable operation name.",
+ "The action keeps one stable observation name and adds a meaningful contextual name.",
"The action identifier is an explicit low-cardinality attribute.",
"The initiation mode is an explicit low-cardinality attribute.",
"The action observation is a child of the current root observation.",
@@ -208,6 +208,7 @@ public void onStart(final Observation.Context context) {
? context.getParentObservation().getContextView().getName()
: "<none>";
record("onStart(name=" + context.getName()
+ + ", contextualName=" + context.getContextualName()
+ ", parent=" + parentName
+ ", causeway.action.id=" + value(context, "causeway.action.id")
+ ", causeway.execution.initiatedBy="
@@ -232,7 +233,8 @@ public void onScopeClosed(final Observation.Context context) {
@Override
public void onStop(final Observation.Context context) {
- record("onStop(name=" + context.getName() + ")");
+ record("onStop(name=" + context.getName()
+ + ", contextualName=" + context.getContextualName() + ")");
}
@Override
diff --git a/openspec/changes/improve-semantic-span-names/tasks.md b/openspec/changes/improve-semantic-span-names/tasks.md
index bc9bfacfe9f..677d74f4f59 100644
--- a/openspec/changes/improve-semantic-span-names/tasks.md
+++ b/openspec/changes/improve-semantic-span-names/tasks.md
@@ -1,22 +1,22 @@
## 1. Contextual Naming Foundation
-- [ ] 1.1 Add an internal observation naming helper that produces bounded operation-first contextual names from logical type and member identifiers without using instance data or localized labels.
-- [ ] 1.2 Add focused unit tests for simple and namespaced logical types, action members, normalization, collisions, and names long enough to encounter the tracing display-name limit.
+- [x] 1.1 Add an internal observation naming helper that produces bounded operation-first contextual names from logical type and member identifiers without using instance data or localized labels.
+- [x] 1.2 Add focused unit tests for simple and namespaced logical types, action members, normalization, collisions, and names long enough to encounter the tracing display-name limit.
## 2. Action Invocation Naming
-- [ ] 2.1 Update `MemberExecutorServiceDefault` to assign the existing action-invocation observation a contextual name derived from the owning action's logical type and member name while retaining the stable observation name and canonical attributes.
-- [ ] 2.2 Extend the action observation tests to verify the contextual name, stable observation name, canonical action identifier, parentage, success lifecycle, and failure lifecycle.
+- [x] 2.1 Update `MemberExecutorServiceDefault` to assign the existing action-invocation observation a contextual name derived from the owning action's logical type and member name while retaining the stable observation name and canonical attributes.
+- [x] 2.2 Extend the action observation tests to verify the contextual name, stable observation name, canonical action identifier, parentage, success lifecycle, and failure lifecycle.
## 3. Wicket Page and Prompt Rendering
-- [ ] 3.1 Update the Wicket render descriptor so entity-page observations receive a contextual name derived from the logical object type while existing fine-grained region contextual names remain stable.
-- [ ] 3.2 Add the `causeway.wicket.action.prompt.render` descriptor with compact contextual naming and canonical `causeway.object.type` and `causeway.action.id` attributes.
-- [ ] 3.3 Attach the reusable render observation behavior once at the common `ActionParametersPanel` boundary without instrumenting individual parameter fields or presentation-specific prompt shells.
-- [ ] 3.4 Extend Wicket observation tests to cover page naming, prompt metadata, render lifecycle and parentage, no-op operation, serialization safety, parameter exclusion, and the absence of duplicate prompt observations across supported presentation styles.
+- [x] 3.1 Update the Wicket render descriptor so entity-page observations receive a contextual name derived from the logical object type while existing fine-grained region contextual names remain stable.
+- [x] 3.2 Add the `causeway.wicket.action.prompt.render` descriptor with compact contextual naming and canonical `causeway.object.type` and `causeway.action.id` attributes.
+- [x] 3.3 Attach the reusable render observation behavior once at the common `ActionParametersPanel` boundary without instrumenting individual parameter fields or presentation-specific prompt shells.
+- [x] 3.4 Extend Wicket observation tests to cover page naming, prompt metadata, render lifecycle and parentage, no-op operation, serialization safety, parameter exclusion, and the absence of duplicate prompt observations across supported presentation styles.
## 4. Documentation and Validation
-- [ ] 4.1 Update `adoc/micrometer-tracing-operations.adoc` with the contextual naming convention, canonical-attribute guidance, 50-character tracing limit, prompt render boundary, privacy rules, and changed example trace tree.
-- [ ] 4.2 Run the focused core configuration, runtime-services, and Wicket UI observation test suites and record the results.
-- [ ] 4.3 Validate a representative action invocation, entity-page render, and parameterized action prompt against the Java-agent tracing fixture or local Jaeger, confirming meaningful display names, canonical attributes, correct nesting, and no per-parameter span amplification.
+- [x] 4.1 Update `adoc/micrometer-tracing-operations.adoc` with the contextual naming convention, canonical-attribute guidance, 50-character tracing limit, prompt render boundary, privacy rules, and changed example trace tree.
+- [x] 4.2 Run the focused core configuration, runtime-services, and Wicket UI observation test suites and record the results.
+- [x] 4.3 Validate a representative action invocation, entity-page render, and parameterized action prompt against the Java-agent tracing fixture or local Jaeger, confirming meaningful display names, canonical attributes, correct nesting, and no per-parameter span amplification.
diff --git a/openspec/changes/improve-semantic-span-names/validation.md b/openspec/changes/improve-semantic-span-names/validation.md
new file mode 100644
index 00000000000..28e655157ef
--- /dev/null
+++ b/openspec/changes/improve-semantic-span-names/validation.md
@@ -0,0 +1,34 @@
+## Automated Validation
+
+Production compilation succeeded through `viewers/wicket/ui` with Java 11 release output and tests skipped.
+
+The focused suites were run in the Maven reactor with Java 25, `maven.compiler.release=11`, and `maven.compiler.proc=full`:
+
+- `CausewayObservationNamingTest`: 4 tests, 0 failures, 0 errors, 0 skipped.
+- `MemberExecutorServiceDefaultObservationTest`: 3 tests, 0 failures, 0 errors, 0 skipped.
+- `WicketRenderObservationTest`: 11 tests, 0 failures, 0 errors, 0 skipped.
+
+The tracing compatibility fixture was compiled in the reactor and then run on its validated Java 11 and OpenTelemetry Java agent 1.31.0 baseline:
+
+- `MicrometerTracingCompatibilityTest`: 2 tests, 0 failures, 0 errors, 0 skipped.
+
+## Exported Trace Evidence
+
+The Java-agent fixture exported one trace containing the automatic HTTP and JDBC spans together with the Causeway root interaction, page render, prompt render, and action invocation spans.
+
+The observed semantic hierarchy included:
+
+[source,text]
+----
+causeway.root.interaction
+├── render tracing-fixture
+│ └── prompt execute-jdbc on tracing-fixture
+└── invoke execute-jdbc on tracing-fixture
+ └── JDBC
+----
+
+The page span exported `causeway.object.type=causeway.TracingFixture`.
+The prompt span exported `causeway.object.type=causeway.TracingFixture` and `causeway.action.id=causeway.TracingFixture#executeJdbc()`.
+The action span exported the same canonical action identifier, and the JDBC span remained a child of the action invocation.
+
+The Wicket focused suite additionally verified that the enclosing action prompt receives one render behavior, individual parameter models remain excluded from property spans, no-op rendering is unchanged, descriptors remain serializable without active telemetry, and prompt rendering retains page parentage.
diff --git a/regressiontests/tracing-compatibility/pom.xml b/regressiontests/tracing-compatibility/pom.xml
index 5d6ba07e591..7a4cac3a3e0 100644
--- a/regressiontests/tracing-compatibility/pom.xml
+++ b/regressiontests/tracing-compatibility/pom.xml
@@ -66,6 +66,11 @@
<artifactId>causeway-core-webapp</artifactId>
<scope>test</scope>
</dependency>
+ <dependency>
+ <groupId>org.apache.causeway.viewer</groupId>
+ <artifactId>causeway-viewer-wicket-ui</artifactId>
+ <scope>test</scope>
+ </dependency>
<!-- Keep this version under Spring Boot 2.7.18 dependency management. -->
<dependency>
diff --git a/regressiontests/tracing-compatibility/src/test/java/org/apache/causeway/regressiontests/tracing/MicrometerTracingAgentFixture.java b/regressiontests/tracing-compatibility/src/test/java/org/apache/causeway/regressiontests/tracing/MicrometerTracingAgentFixture.java
index 3380841a3ff..0c2cd1cf5cc 100644
--- a/regressiontests/tracing-compatibility/src/test/java/org/apache/causeway/regressiontests/tracing/MicrometerTracingAgentFixture.java
+++ b/regressiontests/tracing-compatibility/src/test/java/org/apache/causeway/regressiontests/tracing/MicrometerTracingAgentFixture.java
@@ -71,6 +71,7 @@
import org.apache.causeway.core.runtimeservices.session.InteractionServiceDefault;
import org.apache.causeway.core.runtimeservices.transaction.TransactionServiceSpring;
import org.apache.causeway.core.webapp.modules.observation.CausewayForegroundTraceFilter;
+import org.apache.causeway.viewer.wicket.ui.observation.WicketRenderObservationDescriptor;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
@@ -92,7 +93,11 @@
public final class MicrometerTracingAgentFixture {
static final String ROOT_INTERACTION_NAME = "causeway.root.interaction";
- static final String ACTION_INVOCATION_NAME = "causeway.action.invocation";
+ static final String ACTION_INVOCATION_NAME = "invoke execute-jdbc on tracing-fixture";
+ static final String PAGE_RENDER_NAME = "render tracing-fixture";
+ static final String PROMPT_RENDER_NAME = "prompt execute-jdbc on tracing-fixture";
+ static final String ACTION_ID = "causeway.TracingFixture#executeJdbc()";
+ static final String OBJECT_TYPE = "causeway.TracingFixture";
static final String SUCCESS_MARKER = "CAUSEWAY_TRACING_FIXTURE_OK";
private MicrometerTracingAgentFixture() {
@@ -128,12 +133,14 @@ private static void executeHttpRequest(
@RestController
public static final class SemanticTracingController {
+ private final CausewayObservationIntegration observationIntegration;
private final InteractionServiceDefault interactionService;
private final MemberExecutorServiceDefault memberExecutorService;
private final ActionExecutor actionExecutor;
public SemanticTracingController(
final CausewayObservationIntegration observationIntegration) throws Exception {
+ this.observationIntegration = observationIntegration;
this.interactionService = interactionService(observationIntegration);
this.memberExecutorService = memberExecutorService(observationIntegration);
this.actionExecutor = actionExecutor();
@@ -144,7 +151,23 @@ public SemanticTracingController(
public void trace() {
interactionService.call(
mock(InteractionContext.class),
- () -> memberExecutorService.invokeAction(actionExecutor));
+ () -> {
+ renderPageAndPrompt();
+ return memberExecutorService.invokeAction(actionExecutor);
+ });
+ }
+
+ private void renderPageAndPrompt() {
+ final WicketRenderObservationDescriptor page =
+ WicketRenderObservationDescriptor.page(OBJECT_TYPE);
+ final WicketRenderObservationDescriptor prompt =
+ WicketRenderObservationDescriptor.actionPrompt(
+ OBJECT_TYPE, ACTION_ID, "executeJdbc");
+ page.customize(observationIntegration.createNotStarted(
+ getClass(), page.getRegion().getObservationName()))
+ .observe(() -> prompt.customize(observationIntegration.createNotStarted(
+ getClass(), prompt.getRegion().getObservationName()))
+ .observe(() -> {}));
}
}
@@ -211,7 +234,7 @@ private static ActionExecutor actionExecutor() throws Exception {
final ObjectAction owningAction = mock(ObjectAction.class);
when(owningAction.getFeatureIdentifier()).thenReturn(Identifier.actionIdentifier(
- LogicalType.eager(JdbcAction.class, "causeway.TracingFixture"),
+ LogicalType.eager(JdbcAction.class, OBJECT_TYPE),
"executeJdbc"));
return new ActionExecutor(
diff --git a/regressiontests/tracing-compatibility/src/test/java/org/apache/causeway/regressiontests/tracing/MicrometerTracingCompatibilityTest.java b/regressiontests/tracing-compatibility/src/test/java/org/apache/causeway/regressiontests/tracing/MicrometerTracingCompatibilityTest.java
index 101191af086..2ed48b4b71c 100644
--- a/regressiontests/tracing-compatibility/src/test/java/org/apache/causeway/regressiontests/tracing/MicrometerTracingCompatibilityTest.java
+++ b/regressiontests/tracing-compatibility/src/test/java/org/apache/causeway/regressiontests/tracing/MicrometerTracingCompatibilityTest.java
@@ -80,6 +80,20 @@ void javaAgentExportsHttpRootInteractionActionAndJdbcAncestry() throws Exception
.findFirst()
.orElseGet(() -> fail("Action span is not a child of the root interaction.\n"
+ describe(spans) + "\n" + result.output));
+ final ExportedSpan pageSpan = spans.stream()
+ .filter(span -> MicrometerTracingAgentFixture.PAGE_RENDER_NAME.equals(span.name))
+ .filter(span -> rootSpan.traceId.equals(span.traceId))
+ .filter(span -> rootSpan.spanId.equals(span.parentSpanId))
+ .findFirst()
+ .orElseGet(() -> fail("Page render span is not a child of the root interaction.\n"
+ + describe(spans) + "\n" + result.output));
+ final ExportedSpan promptSpan = spans.stream()
+ .filter(span -> MicrometerTracingAgentFixture.PROMPT_RENDER_NAME.equals(span.name))
+ .filter(span -> pageSpan.traceId.equals(span.traceId))
+ .filter(span -> pageSpan.spanId.equals(span.parentSpanId))
+ .findFirst()
+ .orElseGet(() -> fail("Prompt render span is not a child of the page render.\n"
+ + describe(spans) + "\n" + result.output));
final ExportedSpan jdbcSpan = spans.stream()
.filter(span -> actionSpan.traceId.equals(span.traceId))
.filter(span -> actionSpan.spanId.equals(span.parentSpanId))
@@ -97,12 +111,22 @@ void javaAgentExportsHttpRootInteractionActionAndJdbcAncestry() throws Exception
assertEquals(httpSpan.traceId, rootSpan.traceId);
assertEquals(rootSpan.traceId, actionSpan.traceId);
assertEquals(actionSpan.traceId, jdbcSpan.traceId);
+ assertEquals(MicrometerTracingAgentFixture.ACTION_ID,
+ actionSpan.attributes.get("causeway.action.id"));
+ assertEquals(MicrometerTracingAgentFixture.OBJECT_TYPE,
+ pageSpan.attributes.get("causeway.object.type"));
+ assertEquals(MicrometerTracingAgentFixture.OBJECT_TYPE,
+ promptSpan.attributes.get("causeway.object.type"));
+ assertEquals(MicrometerTracingAgentFixture.ACTION_ID,
+ promptSpan.attributes.get("causeway.action.id"));
System.out.printf(
- "CAUSEWAY_TRACING_EVIDENCE traceId=%s http=%s rootSpanId=%s actionSpanId=%s jdbcSpanId=%s%n",
+ "CAUSEWAY_TRACING_EVIDENCE traceId=%s http=%s rootSpanId=%s page=%s prompt=%s action=%s jdbcSpanId=%s%n",
rootSpan.traceId,
httpSpan.name,
rootSpan.spanId,
- actionSpan.spanId,
+ pageSpan.name,
+ promptSpan.name,
+ actionSpan.name,
jdbcSpan.spanId);
}
}
diff --git a/viewers/wicket/ui-test/src/test/java/org/apache/causeway/viewer/wicket/ui/observation/WicketRenderObservationTest.java b/viewers/wicket/ui-test/src/test/java/org/apache/causeway/viewer/wicket/ui/observation/WicketRenderObservationTest.java
index 47c17d43f2d..527e12613df 100644
--- a/viewers/wicket/ui-test/src/test/java/org/apache/causeway/viewer/wicket/ui/observation/WicketRenderObservationTest.java
+++ b/viewers/wicket/ui-test/src/test/java/org/apache/causeway/viewer/wicket/ui/observation/WicketRenderObservationTest.java
@@ -49,6 +49,7 @@
import org.apache.causeway.viewer.wicket.model.models.ScalarModel;
import org.apache.causeway.viewer.wicket.model.models.ScalarParameterModel;
import org.apache.causeway.viewer.wicket.model.models.ScalarPropertyModel;
+import org.apache.causeway.viewer.wicket.ui.components.actions.ActionParametersPanel;
import io.micrometer.observation.Observation;
import io.micrometer.observation.ObservationHandler;
@@ -84,6 +85,35 @@ void descriptorsUseStableNamesAndSafeIdentifiers() {
WicketRenderObservationDescriptor.fieldset(OBJECT_TYPE, null).getMemberId());
}
+ @Test
+ void pageAndPromptDescriptorsUseMeaningfulContextualNames() {
+ final ObservationRegistry registry = registryWith(new RecordingHandler());
+ final WicketRenderObservationDescriptor page =
+ WicketRenderObservationDescriptor.page(OBJECT_TYPE);
+ final WicketRenderObservationDescriptor prompt =
+ WicketRenderObservationDescriptor.actionPrompt(
+ OBJECT_TYPE,
+ OBJECT_TYPE + "#updateName()",
+ "updateName");
+
+ final Observation pageObservation = page.customize(
+ Observation.createNotStarted(page.getRegion().getObservationName(), registry));
+ final Observation promptObservation = prompt.customize(
+ Observation.createNotStarted(prompt.getRegion().getObservationName(), registry));
+
+ assertEquals("causeway.wicket.page.render", pageObservation.getContext().getName());
+ assertEquals("render customer", pageObservation.getContext().getContextualName());
+ assertEquals("causeway.wicket.action.prompt.render", promptObservation.getContext().getName());
+ assertEquals("prompt update-name on customer",
+ promptObservation.getContext().getContextualName());
+ assertEquals(OBJECT_TYPE,
+ promptObservation.getContext().getLowCardinalityKeyValue(
+ "causeway.object.type").getValue());
+ assertEquals(OBJECT_TYPE + "#updateName()",
+ promptObservation.getContext().getLowCardinalityKeyValue(
+ "causeway.action.id").getValue());
+ }
+
@Test
void nestedLifecycleClosesScopesInReverseOrder() {
final RecordingHandler handler = new RecordingHandler();
@@ -164,23 +194,29 @@ void actualWicketRenderingPreservesComponentTreeParentage() {
"component", integration,
WicketRenderObservationDescriptor.page(OBJECT_TYPE));
page.add(new ObservedContainer(
- "property", integration,
- WicketRenderObservationDescriptor.property(
- OBJECT_TYPE, OBJECT_TYPE + "#name")));
+ "prompt", integration,
+ WicketRenderObservationDescriptor.actionPrompt(
+ OBJECT_TYPE,
+ OBJECT_TYPE + "#updateName()",
+ "updateName")));
tester.startComponentInPage(page, Markup.of(
- "<div wicket:id='component'><span wicket:id='property'></span></div>"));
+ "<div wicket:id='component'><span wicket:id='prompt'></span></div>"));
assertEquals(List.of(
"causeway.wicket.page.render<-null",
- "causeway.wicket.property.render<-causeway.wicket.page.render"), handler.parents);
+ "causeway.wicket.action.prompt.render<-causeway.wicket.page.render"),
+ handler.parents);
+ assertEquals(List.of(
+ "render customer",
+ "prompt update-name on customer"), handler.contextualNames);
assertEquals(List.of(
"start:causeway.wicket.page.render",
"scope-opened:causeway.wicket.page.render",
- "start:causeway.wicket.property.render",
- "scope-opened:causeway.wicket.property.render",
- "scope-closed:causeway.wicket.property.render",
- "stop:causeway.wicket.property.render",
+ "start:causeway.wicket.action.prompt.render",
+ "scope-opened:causeway.wicket.action.prompt.render",
+ "scope-closed:causeway.wicket.action.prompt.render",
+ "stop:causeway.wicket.action.prompt.render",
"scope-closed:causeway.wicket.page.render",
"stop:causeway.wicket.page.render"), handler.events);
assertNull(integration.observationRegistry().getCurrentObservation());
@@ -195,12 +231,14 @@ void noopObservationLeavesWicketRenderingUnchanged() {
new CausewayObservationIntegration(ObservationRegistry.NOOP);
final WicketTester tester = new WicketTester();
try {
- final ObservedContainer property = new ObservedContainer(
+ final ObservedContainer prompt = new ObservedContainer(
"component", integration,
- WicketRenderObservationDescriptor.property(
- OBJECT_TYPE, OBJECT_TYPE + "#name"));
+ WicketRenderObservationDescriptor.actionPrompt(
+ OBJECT_TYPE,
+ OBJECT_TYPE + "#updateName()",
+ "updateName"));
- tester.startComponentInPage(property, Markup.of(
+ tester.startComponentInPage(prompt, Markup.of(
"<span wicket:id='component'>value</span>"));
tester.assertComponent("component", ObservedContainer.class);
@@ -255,16 +293,40 @@ public void onClick(final AjaxRequestTarget target) {
@Test
void serializationRetainsDescriptorButNotActiveTelemetry() throws Exception {
final WicketRenderObservationBehavior original = behaviorFor(
- WicketRenderObservationDescriptor.fieldset(OBJECT_TYPE, "identity"));
+ WicketRenderObservationDescriptor.actionPrompt(
+ OBJECT_TYPE, OBJECT_TYPE + "#updateName()", "updateName"));
original.activate(new ObservationClosure());
final WicketRenderObservationBehavior restored = roundTrip(original);
assertFalse(restored.isActive());
- assertEquals("causeway.wicket.fieldset.render",
+ assertEquals("causeway.wicket.action.prompt.render",
restored.descriptor().getRegion().getObservationName());
+ assertEquals("prompt update-name on customer",
+ restored.descriptor().getContextualName());
assertEquals(OBJECT_TYPE, restored.descriptor().getObjectType());
- assertEquals("identity", restored.descriptor().getMemberId());
+ assertEquals(OBJECT_TYPE + "#updateName()", restored.descriptor().getMemberId());
+ }
+
+ @Test
+ void actionParametersPanelHasOnePromptObservationBehavior() {
+ final Identifier actionId = Identifier.actionIdentifier(
+ LogicalType.eager(Object.class, OBJECT_TYPE), "updateName");
+ final ObjectAction action = mock(ObjectAction.class);
+ when(action.getFeatureIdentifier()).thenReturn(actionId);
+ final ActionModel actionModel = mock(ActionModel.class);
+ when(actionModel.getAction()).thenReturn(action);
+
+ final WicketTester tester = new WicketTester();
+ try {
+ final ActionParametersPanel panel =
+ new ActionParametersPanel("prompt", actionModel);
+
+ assertEquals(1,
+ panel.getBehaviors(WicketRenderObservationBehavior.class).size());
+ } finally {
+ tester.destroy();
+ }
}
@Test
@@ -386,6 +448,7 @@ private static final class RecordingHandler
private final List<String> events = new ArrayList<>();
private final List<String> errors = new ArrayList<>();
private final List<String> parents = new ArrayList<>();
+ private final List<String> contextualNames = new ArrayList<>();
@Override
public boolean supportsContext(final Observation.Context context) {
@@ -395,6 +458,7 @@ public boolean supportsContext(final Observation.Context context) {
@Override
public void onStart(final Observation.Context context) {
events.add("start:" + context.getName());
+ contextualNames.add(context.getContextualName());
parents.add(context.getName() + "<-" + (context.getParentObservation() != null
? context.getParentObservation().getContextView().getName()
: "null"));
diff --git a/viewers/wicket/ui/src/main/java/org/apache/causeway/viewer/wicket/ui/components/actions/ActionParametersPanel.java b/viewers/wicket/ui/src/main/java/org/apache/causeway/viewer/wicket/ui/components/actions/ActionParametersPanel.java
index f76822b32e7..602aa663bde 100644
--- a/viewers/wicket/ui/src/main/java/org/apache/causeway/viewer/wicket/ui/components/actions/ActionParametersPanel.java
+++ b/viewers/wicket/ui/src/main/java/org/apache/causeway/viewer/wicket/ui/components/actions/ActionParametersPanel.java
@@ -24,6 +24,8 @@
import org.apache.causeway.viewer.commons.model.components.UiComponentType;
import org.apache.causeway.viewer.wicket.model.models.ActionModel;
import org.apache.causeway.viewer.wicket.ui.components.property.PropertyEditPanel;
+import org.apache.causeway.viewer.wicket.ui.observation.WicketRenderObservationBehavior;
+import org.apache.causeway.viewer.wicket.ui.observation.WicketRenderObservationDescriptor;
import org.apache.causeway.viewer.wicket.ui.panels.PanelAbstract;
import org.apache.causeway.viewer.wicket.ui.util.Wkt;
@@ -48,6 +50,12 @@ public class ActionParametersPanel
public ActionParametersPanel(final String id, final ActionModel actionModel) {
super(id, actionModel);
+ final var actionIdentifier = actionModel.getAction().getFeatureIdentifier();
+ WicketRenderObservationBehavior.addTo(this,
+ WicketRenderObservationDescriptor.actionPrompt(
+ actionIdentifier.logicalTypeName(),
+ actionIdentifier.getLogicalIdentityString("#"),
+ actionIdentifier.memberLogicalName()));
}
ActionModel getActionModel() {
diff --git a/viewers/wicket/ui/src/main/java/org/apache/causeway/viewer/wicket/ui/observation/WicketRenderObservationDescriptor.java b/viewers/wicket/ui/src/main/java/org/apache/causeway/viewer/wicket/ui/observation/WicketRenderObservationDescriptor.java
index 4187b86f35b..81261cf8251 100644
--- a/viewers/wicket/ui/src/main/java/org/apache/causeway/viewer/wicket/ui/observation/WicketRenderObservationDescriptor.java
+++ b/viewers/wicket/ui/src/main/java/org/apache/causeway/viewer/wicket/ui/observation/WicketRenderObservationDescriptor.java
@@ -26,6 +26,8 @@
import lombok.Getter;
import lombok.RequiredArgsConstructor;
+import org.apache.causeway.core.config.observation.CausewayObservationNaming;
+
/**
* Serializable, instance-data-free description of a semantic Wicket render region.
*
@@ -45,20 +47,25 @@ public enum Region {
FIELDSET("causeway.wicket.fieldset.render", "causeway.fieldset.id"),
PROPERTY("causeway.wicket.property.render", "causeway.property.id"),
COLLECTION("causeway.wicket.collection.render", "causeway.collection.id"),
- ACTION("causeway.wicket.action.render", "causeway.action.id");
+ ACTION("causeway.wicket.action.render", "causeway.action.id"),
+ ACTION_PROMPT("causeway.wicket.action.prompt.render", "causeway.action.id");
private final String observationName;
private final String memberTag;
}
public static WicketRenderObservationDescriptor page(final String objectType) {
- return new WicketRenderObservationDescriptor(Region.PAGE, objectType, null);
+ return new WicketRenderObservationDescriptor(
+ Region.PAGE,
+ objectType,
+ null,
+ CausewayObservationNaming.forType("render", objectType));
}
public static WicketRenderObservationDescriptor fieldset(
final String objectType,
final String fieldsetId) {
- return new WicketRenderObservationDescriptor(
+ return stableDescriptor(
Region.FIELDSET,
objectType,
fieldsetId != null && !fieldsetId.isEmpty() ? fieldsetId : "<default>");
@@ -67,31 +74,54 @@ public static WicketRenderObservationDescriptor fieldset(
public static WicketRenderObservationDescriptor property(
final String objectType,
final String propertyId) {
- return new WicketRenderObservationDescriptor(Region.PROPERTY, objectType, propertyId);
+ return stableDescriptor(Region.PROPERTY, objectType, propertyId);
}
public static WicketRenderObservationDescriptor collection(
final String objectType,
final String collectionId) {
- return new WicketRenderObservationDescriptor(Region.COLLECTION, objectType, collectionId);
+ return stableDescriptor(Region.COLLECTION, objectType, collectionId);
}
public static WicketRenderObservationDescriptor action(
final String objectType,
final String actionId) {
- return new WicketRenderObservationDescriptor(Region.ACTION, objectType, actionId);
+ return stableDescriptor(Region.ACTION, objectType, actionId);
+ }
+
+ public static WicketRenderObservationDescriptor actionPrompt(
+ final String objectType,
+ final String actionId,
+ final String actionMemberName) {
+ return new WicketRenderObservationDescriptor(
+ Region.ACTION_PROMPT,
+ objectType,
+ actionId,
+ CausewayObservationNaming.forMember(
+ "prompt", objectType, actionMemberName));
+ }
+
+ private static WicketRenderObservationDescriptor stableDescriptor(
+ final Region region,
+ final String objectType,
+ final String memberId) {
+ return new WicketRenderObservationDescriptor(
+ region, objectType, memberId, region.getObservationName());
}
private final Region region;
private final String objectType;
private final String memberId;
+ private final String contextualName;
private WicketRenderObservationDescriptor(
final Region region,
final String objectType,
- final String memberId) {
+ final String memberId,
+ final String contextualName) {
this.region = Objects.requireNonNull(region, "region");
this.objectType = Objects.requireNonNull(objectType, "objectType");
+ this.contextualName = Objects.requireNonNull(contextualName, "contextualName");
if(region.getMemberTag() != null) {
this.memberId = Objects.requireNonNull(memberId, "memberId");
} else {
@@ -101,7 +131,7 @@ private WicketRenderObservationDescriptor(
public Observation customize(final Observation observation) {
Observation customized = observation
- .contextualName(region.getObservationName())
+ .contextualName(contextualName)
.lowCardinalityKeyValue(OBJECT_TYPE_TAG, objectType);
if(region.getMemberTag() != null) {
customized = customized.lowCardinalityKeyValue(region.getMemberTag(), memberId);