diff --git a/prj/coherence-core-components/src/main/java/com/tangosol/coherence/component/util/daemon/queueProcessor/service/grid/partitionedService/PartitionedCache.java b/prj/coherence-core-components/src/main/java/com/tangosol/coherence/component/util/daemon/queueProcessor/service/grid/partitionedService/PartitionedCache.java index faa2c5da74ec1..717b3db60128d 100644 --- a/prj/coherence-core-components/src/main/java/com/tangosol/coherence/component/util/daemon/queueProcessor/service/grid/partitionedService/PartitionedCache.java +++ b/prj/coherence-core-components/src/main/java/com/tangosol/coherence/component/util/daemon/queueProcessor/service/grid/partitionedService/PartitionedCache.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2024, Oracle and/or its affiliates. + * Copyright (c) 2000, 2025, Oracle and/or its affiliates. * * Licensed under the Universal Permissive License v 1.0 as shown at * https://oss.oracle.com/licenses/upl. @@ -22003,6 +22003,8 @@ public void read(com.tangosol.io.ReadBuffer.BufferInput input) { setAllowBackupRead(input.readBoolean()); } + + readTracing(input); } // Declared at the super level @@ -22048,6 +22050,8 @@ public void write(com.tangosol.io.WriteBuffer.BufferOutput output) super.write(output); output.writeBoolean(isAllowBackupRead()); + + writeTracing(output); } // ---- class: com.tangosol.coherence.component.util.daemon.queueProcessor.service.grid.partitionedService.PartitionedCache$GetRequest$Poll diff --git a/prj/coherence-tracing/opentelemetry/src/main/java/com/tangosol/internal/tracing/opentelemetry/OpenTelemetryTracer.java b/prj/coherence-tracing/opentelemetry/src/main/java/com/tangosol/internal/tracing/opentelemetry/OpenTelemetryTracer.java index 029ee1e7be3fb..cec1e9ed172ac 100644 --- a/prj/coherence-tracing/opentelemetry/src/main/java/com/tangosol/internal/tracing/opentelemetry/OpenTelemetryTracer.java +++ b/prj/coherence-tracing/opentelemetry/src/main/java/com/tangosol/internal/tracing/opentelemetry/OpenTelemetryTracer.java @@ -64,7 +64,8 @@ public Map inject(SpanContext spanContext) LiteMap injectTarget = new LiteMap<>(); TextMapPropagator propagator = GlobalOpenTelemetry.getPropagators().getTextMapPropagator(); - propagator.inject(Context.current(), injectTarget, new MapSetter()); + propagator.inject(Context.current().with( + io.opentelemetry.api.trace.Span.wrap(spanContext.underlying())), injectTarget, new MapSetter()); return injectTarget; } diff --git a/prj/test/functional/tracing/common/src/main/java/tracing/AbstractCacheOperationsTracingIT.java b/prj/test/functional/tracing/common/src/main/java/tracing/AbstractCacheOperationsTracingIT.java index 29594aee68104..a741739dae9ea 100644 --- a/prj/test/functional/tracing/common/src/main/java/tracing/AbstractCacheOperationsTracingIT.java +++ b/prj/test/functional/tracing/common/src/main/java/tracing/AbstractCacheOperationsTracingIT.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2023, Oracle and/or its affiliates. + * Copyright (c) 2000, 2025, Oracle and/or its affiliates. * * Licensed under the Universal Permissive License v 1.0 as shown at * https://oss.oracle.com/licenses/upl. @@ -86,35 +86,7 @@ public void testPutTracing(Validator validator) NamedCache cache = getNamedCache(); assertThat(cache, is(notNullValue())); - final AtomicBoolean entryInserted = new AtomicBoolean(); - final AtomicBoolean entryUpdated = new AtomicBoolean(); - final AtomicBoolean entryDeleted = new AtomicBoolean(); - cache.addMapListener(new MapListenerSupport.SynchronousListener() - { - @Override - public void entryInserted(MapEvent evt) - { - entryInserted.compareAndSet(false, true); - } - - @Override - public void entryUpdated(MapEvent evt) - { - entryUpdated.compareAndSet(false, true); - } - - @Override - public void entryDeleted(MapEvent evt) - { - entryDeleted.compareAndSet(false, true); - } - }); - cache.put("a", "1"); - - assertThat("entryInserted not invoked", entryInserted.get(), is(true)); - assertThat("entryUpdated incorrectly invoked", entryUpdated.get(), is(false)); - assertThat("entryDeleted incorrectly invoked", entryDeleted.get(), is(false)); }, "PUT", validator)); } @@ -133,36 +105,8 @@ public void testRemoveTracing(Validator validator) cache.put("a", "1"); // not too interested in this event - final AtomicBoolean entryInserted = new AtomicBoolean(); - final AtomicBoolean entryUpdated = new AtomicBoolean(); - final AtomicBoolean entryDeleted = new AtomicBoolean(); - cache.addMapListener(new MapListenerSupport.SynchronousListener() - { - @Override - public void entryInserted(MapEvent evt) - { - entryInserted.compareAndSet(false, true); - } - - @Override - public void entryUpdated(MapEvent evt) - { - entryUpdated.compareAndSet(false, true); - } - - @Override - public void entryDeleted(MapEvent evt) - { - entryDeleted.compareAndSet(false, true); - } - }); - cache.remove("a"); - - assertThat("entryInserted incorrectly invoked", entryInserted.get(), is(false)); - assertThat("entryUpdated incorrectly invoked", entryUpdated.get(), is(false)); - assertThat("entryDeleted not invoked", entryDeleted.get(), is(true)); - }, "PUT", validator)); + }, "REMOVE", validator)); } // ----- helper methods ------------------------------------------------- diff --git a/prj/test/functional/tracing/opentelemetry/core/src/main/java/opentelemetry/core/CacheOperationsTracingIT.java b/prj/test/functional/tracing/opentelemetry/core/src/main/java/opentelemetry/core/CacheOperationsTracingIT.java index bad6ad3433e1a..05ee247eaf163 100644 --- a/prj/test/functional/tracing/opentelemetry/core/src/main/java/opentelemetry/core/CacheOperationsTracingIT.java +++ b/prj/test/functional/tracing/opentelemetry/core/src/main/java/opentelemetry/core/CacheOperationsTracingIT.java @@ -1,11 +1,12 @@ /* - * Copyright (c) 2023, Oracle and/or its affiliates. + * Copyright (c) 2023, 2025, Oracle and/or its affiliates. * * Licensed under the Universal Permissive License v 1.0 as shown at * https://oss.oracle.com/licenses/upl. */ package opentelemetry.core; +import com.google.protobuf.ByteString; import com.oracle.bedrock.runtime.coherence.CoherenceClusterMember; import com.oracle.coherence.common.base.Blocking; @@ -178,7 +179,12 @@ public void testGetTracing() // validate server spans listExpected = TestingUtils.getSpans(listAllSpans, new String[] {"Get.dispatch", "Get.process"}, 2); assertThat(listExpected.size(), is(2)); - listExpected.forEach(span -> validateTagsForSpan(span, false, TestingUtils.MutationType.none)); + Span spanParent = listExpected.get(0); + listExpected.forEach(span -> + { + validateSpanAssociation(spanParent, span); + validateTagsForSpan(span, false, TestingUtils.MutationType.none); + }); }); } @@ -190,15 +196,19 @@ public void testPutTracing() List listAllSpans = TestingUtils.waitForAllSpans(m_collectorServer); // validate client spans - List listExpected = TestingUtils.getSpans(listAllSpans, - new String[] { "Put.request", "FilterEvent.process" }, 1); - assertThat(listExpected.size(), is(2)); + List listExpected = TestingUtils.getSpans(listAllSpans, new String[] { "Put.request"}, 1); + assertThat(listExpected.size(), is(1)); listExpected.forEach(span -> validateTagsForSpan(span, false, TestingUtils.MutationType.inserted)); // validate server spans listExpected = TestingUtils.getSpans(listAllSpans, new String[] {"Put.dispatch", "Put.process"}, 2); assertThat(listExpected.size(), is(2)); - listExpected.forEach(span -> validateTagsForSpan(span, false, TestingUtils.MutationType.inserted)); + Span spanParent = listExpected.get(0); + listExpected.forEach(span -> + { + validateSpanAssociation(spanParent, span); + validateTagsForSpan(span, false, TestingUtils.MutationType.inserted); + }); }); } @@ -210,20 +220,32 @@ public void testRemoveTracing() List listAllSpans = TestingUtils.waitForAllSpans(m_collectorServer); // validate client spans - List listExpected = TestingUtils.getSpans(listAllSpans, - new String[] { "Remove.request", "FilterEvent.process" }, 1); - assertThat(listExpected.size(), is(2)); + List listExpected = TestingUtils.getSpans(listAllSpans, new String[] { "Remove.request" }, 1); + assertThat(listExpected.size(), is(1)); listExpected.forEach(span -> validateTagsForSpan(span, false, TestingUtils.MutationType.deleted)); // validate server spans listExpected = TestingUtils.getSpans(listAllSpans, new String[] {"Remove.dispatch", "Remove.process"}, 2); assertThat(listExpected.size(), is(2)); - listExpected.forEach(span -> validateTagsForSpan(span, false, TestingUtils.MutationType.deleted)); + Span spanParent = listExpected.get(0); + listExpected.forEach(span -> + { + validateSpanAssociation(spanParent, span); + validateTagsForSpan(span, false, TestingUtils.MutationType.deleted); + }); }); } // ----- helper methods ------------------------------------------------- + /** + * Verify the trace-id for the starting span, is the same for inner spans. + */ + protected static void validateSpanAssociation(Span spanParent, Span spanAssociated) + { + assertThat("Trace IDs between parent and associated spans do not match", spanAssociated.getTraceId(), is(spanParent.getTraceId())); + } + /** * Verify the tags contained within the provided {@link Span span} contains the expected keys and or keys/values. * diff --git a/prj/test/functional/tracing/opentracing/src/main/java/opentracing/CacheOperationsTracingIT.java b/prj/test/functional/tracing/opentracing/src/main/java/opentracing/CacheOperationsTracingIT.java index 382f0f8d5fe7b..419a20259a621 100644 --- a/prj/test/functional/tracing/opentracing/src/main/java/opentracing/CacheOperationsTracingIT.java +++ b/prj/test/functional/tracing/opentracing/src/main/java/opentracing/CacheOperationsTracingIT.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2023, Oracle and/or its affiliates. + * Copyright (c) 2000, 2025, Oracle and/or its affiliates. * * Licensed under the Universal Permissive License v 1.0 as shown at * https://oss.oracle.com/licenses/upl. @@ -176,7 +176,7 @@ public void testPutTracing() validateReporter((reporter) -> { JaegerSpan[] localSpans = validateOpsPresent( - new String[] {"Put.request", "FilterEvent.process"}, + new String[] {"Put.request" }, AdaptiveTracerFactory.getReporter().getSpans()); Arrays.stream(localSpans).forEach( span -> validateTagsForSpan(span, false, MutationType.inserted)); @@ -197,7 +197,7 @@ public void testRemoveTracing() validateReporter((reporter) -> { JaegerSpan[] localSpans = validateOpsPresent( - new String[] {"Remove.request", "FilterEvent.process"}, + new String[] {"Remove.request" }, AdaptiveTracerFactory.getReporter().getSpans()); Arrays.stream(localSpans).forEach( span -> validateTagsForSpan(span, false, MutationType.deleted));