From a631796c6aa21a1e915a8d844f87e6077c77c0e3 Mon Sep 17 00:00:00 2001 From: "Boslet, Cory (cb645j)" Date: Tue, 3 Dec 2024 15:10:56 -0500 Subject: [PATCH 01/23] Added initial commit of camunda instrumentation --- .../camunda-7.18/javaagent/build.gradle.kts | 22 ++++ .../CamundaActivityExecutionGetter.java | 20 +++ .../CamundaActivityExecutionLocalSetter.java | 14 ++ .../CamundaActivityExecutionSetter.java | 14 ++ .../behavior/CamundaBehaviorSingletons.java | 41 ++++++ .../CamundaBehaviorSpanNameExtractor.java | 24 ++++ ...lementActivityBehaviorInstrumentation.java | 116 +++++++++++++++++ ...CallableElementActivityBehaviorModule.java | 46 +++++++ ...dEventActivityBehaviorInstrumentation.java | 121 ++++++++++++++++++ ...CamundaEndEventActivityBehaviorModule.java | 48 +++++++ ...alTaskActivityBehaviorInstrumentation.java | 121 ++++++++++++++++++ ...ndaExternalTaskActivityBehaviorModule.java | 46 +++++++ ...daTaskActivityBehaviorInstrumentation.java | 101 +++++++++++++++ .../CamundaTaskActivityBehaviorModule.java | 46 +++++++ .../behavior/CamundaVariableMapSetter.java | 14 ++ .../v7_18/common/CamundaCommonRequest.java | 71 ++++++++++ .../CamundaVariableAttributeExtractor.java | 28 ++++ ...ContinuationJobHandlerInstrumentation.java | 112 ++++++++++++++++ ...undaAsyncContinuationJobHandlerModule.java | 46 +++++++ .../jobs/CamundaExecutionEntityGetter.java | 20 +++ .../v7_18/jobs/CamundaJobSingletons.java | 41 ++++++ .../jobs/CamundaJobSpanNameExtractor.java | 14 ++ ...ndaActivityInstantiationBuilderSetter.java | 16 +++ ...sInstanceModificationBuilderImpSetter.java | 17 +++ ...ssInstantiationBuilderInstrumentation.java | 93 ++++++++++++++ ...undaProcessInstantiationBuilderModule.java | 48 +++++++ .../processes/CamundaProcessSingletons.java | 41 ++++++ .../CamundaProcessSpanNameExtractor.java | 14 ++ .../v7_18/task/CamundaExternalTaskGetter.java | 20 +++ .../v7_18/task/CamundaTaskSingletons.java | 38 ++++++ .../task/CamundaTaskSpanNameExtractor.java | 14 ++ ...CamundaTopicSubscriptionManagerModule.java | 46 +++++++ ...opicSubscriptionMangerInstrumentation.java | 111 ++++++++++++++++ 33 files changed, 1584 insertions(+) create mode 100644 instrumentation/camunda/camunda-7.18/javaagent/build.gradle.kts create mode 100644 instrumentation/camunda/camunda-7.18/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_18/behavior/CamundaActivityExecutionGetter.java create mode 100644 instrumentation/camunda/camunda-7.18/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_18/behavior/CamundaActivityExecutionLocalSetter.java create mode 100644 instrumentation/camunda/camunda-7.18/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_18/behavior/CamundaActivityExecutionSetter.java create mode 100644 instrumentation/camunda/camunda-7.18/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_18/behavior/CamundaBehaviorSingletons.java create mode 100644 instrumentation/camunda/camunda-7.18/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_18/behavior/CamundaBehaviorSpanNameExtractor.java create mode 100644 instrumentation/camunda/camunda-7.18/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_18/behavior/CamundaCallableElementActivityBehaviorInstrumentation.java create mode 100644 instrumentation/camunda/camunda-7.18/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_18/behavior/CamundaCallableElementActivityBehaviorModule.java create mode 100644 instrumentation/camunda/camunda-7.18/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_18/behavior/CamundaEndEventActivityBehaviorInstrumentation.java create mode 100644 instrumentation/camunda/camunda-7.18/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_18/behavior/CamundaEndEventActivityBehaviorModule.java create mode 100644 instrumentation/camunda/camunda-7.18/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_18/behavior/CamundaExternalTaskActivityBehaviorInstrumentation.java create mode 100644 instrumentation/camunda/camunda-7.18/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_18/behavior/CamundaExternalTaskActivityBehaviorModule.java create mode 100644 instrumentation/camunda/camunda-7.18/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_18/behavior/CamundaTaskActivityBehaviorInstrumentation.java create mode 100644 instrumentation/camunda/camunda-7.18/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_18/behavior/CamundaTaskActivityBehaviorModule.java create mode 100644 instrumentation/camunda/camunda-7.18/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_18/behavior/CamundaVariableMapSetter.java create mode 100644 instrumentation/camunda/camunda-7.18/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_18/common/CamundaCommonRequest.java create mode 100644 instrumentation/camunda/camunda-7.18/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_18/common/CamundaVariableAttributeExtractor.java create mode 100644 instrumentation/camunda/camunda-7.18/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_18/jobs/CamundaAsyncContinuationJobHandlerInstrumentation.java create mode 100644 instrumentation/camunda/camunda-7.18/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_18/jobs/CamundaAsyncContinuationJobHandlerModule.java create mode 100644 instrumentation/camunda/camunda-7.18/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_18/jobs/CamundaExecutionEntityGetter.java create mode 100644 instrumentation/camunda/camunda-7.18/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_18/jobs/CamundaJobSingletons.java create mode 100644 instrumentation/camunda/camunda-7.18/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_18/jobs/CamundaJobSpanNameExtractor.java create mode 100644 instrumentation/camunda/camunda-7.18/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_18/processes/CamundaActivityInstantiationBuilderSetter.java create mode 100644 instrumentation/camunda/camunda-7.18/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_18/processes/CamundaProcessInstanceModificationBuilderImpSetter.java create mode 100644 instrumentation/camunda/camunda-7.18/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_18/processes/CamundaProcessInstantiationBuilderInstrumentation.java create mode 100644 instrumentation/camunda/camunda-7.18/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_18/processes/CamundaProcessInstantiationBuilderModule.java create mode 100644 instrumentation/camunda/camunda-7.18/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_18/processes/CamundaProcessSingletons.java create mode 100644 instrumentation/camunda/camunda-7.18/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_18/processes/CamundaProcessSpanNameExtractor.java create mode 100644 instrumentation/camunda/camunda-7.18/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_18/task/CamundaExternalTaskGetter.java create mode 100644 instrumentation/camunda/camunda-7.18/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_18/task/CamundaTaskSingletons.java create mode 100644 instrumentation/camunda/camunda-7.18/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_18/task/CamundaTaskSpanNameExtractor.java create mode 100644 instrumentation/camunda/camunda-7.18/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_18/task/CamundaTopicSubscriptionManagerModule.java create mode 100644 instrumentation/camunda/camunda-7.18/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_18/task/CamundaTopicSubscriptionMangerInstrumentation.java diff --git a/instrumentation/camunda/camunda-7.18/javaagent/build.gradle.kts b/instrumentation/camunda/camunda-7.18/javaagent/build.gradle.kts new file mode 100644 index 000000000000..66c0ea3c8e0f --- /dev/null +++ b/instrumentation/camunda/camunda-7.18/javaagent/build.gradle.kts @@ -0,0 +1,22 @@ +plugins { + id("otel.javaagent-instrumentation") +} + +muzzle { + pass { + group.set("org.camunda.bpm") + module.set("camunda-engine") + + // have not tested with versions prior to 7.18.0 + versions.set("[7.18.0,)") + } +} + + +dependencies { + implementation("org.camunda.bpm:camunda-engine:7.18.0") + implementation("org.camunda.bpm:camunda-external-task-client:7.18.0") + + api("com.google.auto.value:auto-value-annotations:1.6") + annotationProcessor("com.google.auto.value:auto-value:1.6") +} diff --git a/instrumentation/camunda/camunda-7.18/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_18/behavior/CamundaActivityExecutionGetter.java b/instrumentation/camunda/camunda-7.18/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_18/behavior/CamundaActivityExecutionGetter.java new file mode 100644 index 000000000000..c6eaf8cbfbac --- /dev/null +++ b/instrumentation/camunda/camunda-7.18/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_18/behavior/CamundaActivityExecutionGetter.java @@ -0,0 +1,20 @@ +package io.opentelemetry.javaagent.instrumentation.camunda.v7_18.behavior; + +import org.camunda.bpm.engine.impl.pvm.delegate.ActivityExecution; + +import io.opentelemetry.context.propagation.TextMapGetter; + +public class CamundaActivityExecutionGetter implements TextMapGetter { + + @Override + public Iterable keys(ActivityExecution carrier) { + return carrier.getVariableNames(); + } + + @Override + public String get(ActivityExecution carrier, String key) { + Object variable = carrier.getVariables().get(key); + return variable == null ? null : variable.toString(); + } + +} diff --git a/instrumentation/camunda/camunda-7.18/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_18/behavior/CamundaActivityExecutionLocalSetter.java b/instrumentation/camunda/camunda-7.18/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_18/behavior/CamundaActivityExecutionLocalSetter.java new file mode 100644 index 000000000000..36bf109d5158 --- /dev/null +++ b/instrumentation/camunda/camunda-7.18/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_18/behavior/CamundaActivityExecutionLocalSetter.java @@ -0,0 +1,14 @@ +package io.opentelemetry.javaagent.instrumentation.camunda.v7_18.behavior; + +import org.camunda.bpm.engine.impl.pvm.delegate.ActivityExecution; + +import io.opentelemetry.context.propagation.TextMapSetter; + +public class CamundaActivityExecutionLocalSetter implements TextMapSetter { + + @Override + public void set(ActivityExecution carrier, String key, String value) { + carrier.setVariableLocal(key, value); + } + +} diff --git a/instrumentation/camunda/camunda-7.18/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_18/behavior/CamundaActivityExecutionSetter.java b/instrumentation/camunda/camunda-7.18/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_18/behavior/CamundaActivityExecutionSetter.java new file mode 100644 index 000000000000..7e5229060be4 --- /dev/null +++ b/instrumentation/camunda/camunda-7.18/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_18/behavior/CamundaActivityExecutionSetter.java @@ -0,0 +1,14 @@ +package io.opentelemetry.javaagent.instrumentation.camunda.v7_18.behavior; + +import org.camunda.bpm.engine.impl.pvm.delegate.ActivityExecution; + +import io.opentelemetry.context.propagation.TextMapSetter; + +public class CamundaActivityExecutionSetter implements TextMapSetter { + + @Override + public void set(ActivityExecution carrier, String key, String value) { + carrier.setVariable(key, value); + } + +} diff --git a/instrumentation/camunda/camunda-7.18/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_18/behavior/CamundaBehaviorSingletons.java b/instrumentation/camunda/camunda-7.18/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_18/behavior/CamundaBehaviorSingletons.java new file mode 100644 index 000000000000..1a745dab6eb3 --- /dev/null +++ b/instrumentation/camunda/camunda-7.18/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_18/behavior/CamundaBehaviorSingletons.java @@ -0,0 +1,41 @@ +package io.opentelemetry.javaagent.instrumentation.camunda.v7_18.behavior; + +import io.opentelemetry.javaagent.camunda.v7_18.behavior.CamundaBehaviorSpanNameExtractor; +import io.opentelemetry.javaagent.camunda.v7_18.common.CamundaCommonRequest; +import io.opentelemetry.javaagent.camunda.v7_18.common.CamundaVariableAttributeExtractor; + +import io.opentelemetry.api.GlobalOpenTelemetry; +import io.opentelemetry.api.OpenTelemetry; +import io.opentelemetry.instrumentation.api.instrumenter.Instrumenter; +import io.opentelemetry.instrumentation.api.instrumenter.InstrumenterBuilder; +import io.opentelemetry.javaagent.bootstrap.internal.InstrumentationConfig; + +public class CamundaBehaviorSingletons { + + private static final Instrumenter instrumenter; + + private static final OpenTelemetry opentelemetry; + + private static final boolean propagationEnabled; + + static { + + opentelemetry = GlobalOpenTelemetry.get(); + + InstrumenterBuilder builder = Instrumenter + .builder(opentelemetry, "io.opentelemetry.camunda-behavior", + new CamundaBehaviorSpanNameExtractor()) + .addAttributesExtractor(new CamundaVariableAttributeExtractor()); + + instrumenter = builder.buildInstrumenter(); + } + + public static OpenTelemetry getOpentelemetry() { + return opentelemetry; + } + + public static Instrumenter getInstumenter() { + return instrumenter; + } + +} diff --git a/instrumentation/camunda/camunda-7.18/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_18/behavior/CamundaBehaviorSpanNameExtractor.java b/instrumentation/camunda/camunda-7.18/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_18/behavior/CamundaBehaviorSpanNameExtractor.java new file mode 100644 index 000000000000..fa99d53e9228 --- /dev/null +++ b/instrumentation/camunda/camunda-7.18/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_18/behavior/CamundaBehaviorSpanNameExtractor.java @@ -0,0 +1,24 @@ +package io.opentelemetry.javaagent.instrumentation.camunda.v7_18.behavior; + +import java.util.Arrays; + +import io.opentelemetry.javaagent.camunda.v7_18.common.CamundaCommonRequest; + +import io.opentelemetry.instrumentation.api.instrumenter.SpanNameExtractor; + +public class CamundaBehaviorSpanNameExtractor implements SpanNameExtractor { + + @Override + public String extract(CamundaCommonRequest request) { + String[] eventTypes = { "Start", "End" }; + String type = "Task"; + if (request.getActivityName().isPresent() + && Arrays.stream(eventTypes).anyMatch(request.getActivityName().get()::equals)) { + type = "Event"; + + } + return String.format("%s %s", request.getActivityName().orElse("Plugin"), type); + + } + +} diff --git a/instrumentation/camunda/camunda-7.18/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_18/behavior/CamundaCallableElementActivityBehaviorInstrumentation.java b/instrumentation/camunda/camunda-7.18/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_18/behavior/CamundaCallableElementActivityBehaviorInstrumentation.java new file mode 100644 index 000000000000..326b85da7dfa --- /dev/null +++ b/instrumentation/camunda/camunda-7.18/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_18/behavior/CamundaCallableElementActivityBehaviorInstrumentation.java @@ -0,0 +1,116 @@ +package io.opentelemetry.javaagent.instrumentation.camunda.v7_18.behavior; + +import static io.opentelemetry.javaagent.instrumentation.camunda.v7_18.behavior.CamundaBehaviorSingletons.getInstumenter; +import static io.opentelemetry.javaagent.instrumentation.camunda.v7_18.behavior.CamundaBehaviorSingletons.getOpentelemetry; +import static io.opentelemetry.javaagent.extension.matcher.AgentElementMatchers.hasClassesNamed; +import static io.opentelemetry.javaagent.extension.matcher.AgentElementMatchers.hasSuperType; +import static net.bytebuddy.matcher.ElementMatchers.named; + +import java.util.Optional; + +import org.camunda.bpm.engine.impl.pvm.delegate.ActivityExecution; +import org.camunda.bpm.engine.variable.VariableMap; + +import java.util.logging.Level; + +import io.opentelemetry.javaagent.camunda.v7_18.behavior.CamundaActivityExecutionGetter; +import io.opentelemetry.javaagent.camunda.v7_18.behavior.CamundaVariableMapSetter; +import io.opentelemetry.javaagent.camunda.v7_18.common.CamundaCommonRequest; + +import io.opentelemetry.api.trace.SpanContext; +import io.opentelemetry.context.Context; +import io.opentelemetry.context.Scope; +import io.opentelemetry.javaagent.bootstrap.Java8BytecodeBridge; +import io.opentelemetry.javaagent.extension.instrumentation.TypeInstrumentation; +import io.opentelemetry.javaagent.extension.instrumentation.TypeTransformer; +import net.bytebuddy.asm.Advice; +import net.bytebuddy.description.type.TypeDescription; +import net.bytebuddy.matcher.ElementMatcher; +import net.bytebuddy.matcher.ElementMatchers; + +public class CamundaCallableElementActivityBehaviorInstrumentation implements TypeInstrumentation { + + @Override + public ElementMatcher classLoaderOptimization() { + return hasClassesNamed("org.camunda.bpm.engine.impl.bpmn.behavior.CallableElementActivityBehavior"); + } + + @Override + public ElementMatcher typeMatcher() { + return hasSuperType(named("org.camunda.bpm.engine.impl.bpmn.behavior.CallableElementActivityBehavior")); + } + + @Override + public void transform(TypeTransformer transformer) { + transformer.applyAdviceToMethod(ElementMatchers.isMethod().and(ElementMatchers.named("startInstance")), + this.getClass().getName() + "$CamundaCallableElementActivityBehaviorAdvice"); + } + + public static class CamundaCallableElementActivityBehaviorAdvice { + + @Advice.OnMethodEnter(suppress = Throwable.class) + public static void addTracingEnter(@Advice.Argument(0) ActivityExecution execution, + @Advice.Argument(1) VariableMap variables, @Advice.Local("request") CamundaCommonRequest request, + @Advice.Local("otelParentScope") Scope parentScope, @Advice.Local("otelContext") Context context, + @Advice.Local("otelScope") Scope scope) { + + + if (execution == null) { + //log warning + return; + } + + request = new CamundaCommonRequest(); + request.setProcessDefinitionId(Optional.ofNullable(execution.getProcessDefinitionId())); + request.setProcessInstanceId(Optional.ofNullable(execution.getProcessInstanceId())); + request.setActivityId(Optional.ofNullable(execution.getCurrentActivityId())); + request.setActivityName(Optional.ofNullable(execution.getCurrentActivityName())); + + String processInstanceId = execution.getProcessInstanceId(); + + if (Java8BytecodeBridge.currentContext() == Java8BytecodeBridge.rootContext()) { + //log + } + + Context parentContext = getOpentelemetry().getPropagators().getTextMapPropagator() + .extract(Java8BytecodeBridge.currentContext(), execution, new CamundaActivityExecutionGetter()); + + parentScope = parentContext.makeCurrent(); + + if (getInstumenter().shouldStart(Java8BytecodeBridge.currentContext(), request)) { + context = getInstumenter().start(Java8BytecodeBridge.currentContext(), request); + scope = context.makeCurrent(); + + // Inject subflow trace context as pi variables so they are propagated and + // accessible + + SpanContext currentSpanContext = Java8BytecodeBridge.spanFromContext(context).getSpanContext(); + if (currentSpanContext.isValid()) { + getOpentelemetry().getPropagators().getTextMapPropagator().inject(context, variables, + new CamundaVariableMapSetter()); + } + + } + + } + + @Advice.OnMethodExit(onThrowable = Throwable.class, suppress = Throwable.class) + public static void closeTrace(@Advice.Argument(0) ActivityExecution execution, + @Advice.Local("request") CamundaCommonRequest request, + @Advice.Local("otelParentScope") Scope parentScope, @Advice.Local("otelContext") Context context, + @Advice.Local("otelScope") Scope scope, @Advice.Thrown Throwable throwable) { + + + if (context != null && scope != null) { + getInstumenter().end(context, request, "NA", throwable); + scope.close(); + } + + if (parentScope != null) { + parentScope.close(); + } + + } + } + +} diff --git a/instrumentation/camunda/camunda-7.18/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_18/behavior/CamundaCallableElementActivityBehaviorModule.java b/instrumentation/camunda/camunda-7.18/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_18/behavior/CamundaCallableElementActivityBehaviorModule.java new file mode 100644 index 000000000000..5acddb198dc6 --- /dev/null +++ b/instrumentation/camunda/camunda-7.18/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_18/behavior/CamundaCallableElementActivityBehaviorModule.java @@ -0,0 +1,46 @@ +package com.att.sre.otel.javaagent.instrumentation.camunda.v7_18.behavior; + +import static io.opentelemetry.javaagent.extension.matcher.AgentElementMatchers.hasClassesNamed; + +import java.util.Arrays; +import java.util.Collections; +import java.util.List; + +import com.google.auto.service.AutoService; + +import io.opentelemetry.javaagent.extension.instrumentation.InstrumentationModule; +import io.opentelemetry.javaagent.extension.instrumentation.TypeInstrumentation; +import io.opentelemetry.sdk.autoconfigure.spi.ConfigProperties; +import net.bytebuddy.matcher.ElementMatcher; + +@AutoService(InstrumentationModule.class) +public class CamundaCallableElementActivityBehaviorModule extends InstrumentationModule { + + public CamundaCallableElementActivityBehaviorModule() { + super("camunda", "camunda-behavior", "camunda-behavior-7_18"); + } + + @Override + public boolean defaultEnabled(ConfigProperties config) { + return config.getBoolean("otel.instrumentation.common.default-enabled", true); + } + + @Override + public List typeInstrumentations() { + return Collections.singletonList(new CamundaCallableElementActivityBehaviorInstrumentation()); + } + + @Override + public ElementMatcher.Junction classLoaderMatcher() { + return hasClassesNamed("org.camunda.bpm.engine.impl.bpmn.behavior.CallableElementActivityBehavior"); + } + + String[] helperClassnames = { "io.opentelemetry.javaagent.instrumentation.camunda.v7_18.behavior", + "io.opentelemetry.javaagent.instrumentation.camunda.v7_18.common" }; + + @Override + public boolean isHelperClass(String classname) { + return super.isHelperClass(classname) || Arrays.stream(helperClassnames).anyMatch(c -> classname.startsWith(c)); + } + +} diff --git a/instrumentation/camunda/camunda-7.18/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_18/behavior/CamundaEndEventActivityBehaviorInstrumentation.java b/instrumentation/camunda/camunda-7.18/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_18/behavior/CamundaEndEventActivityBehaviorInstrumentation.java new file mode 100644 index 000000000000..067c42c67396 --- /dev/null +++ b/instrumentation/camunda/camunda-7.18/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_18/behavior/CamundaEndEventActivityBehaviorInstrumentation.java @@ -0,0 +1,121 @@ +package io.opentelemetry.javaagent.instrumentation.camunda.v7_18.behavior; + +import static io.opentelemetry.javaagent.instrumentation.camunda.v7_18.behavior.CamundaBehaviorSingletons.getInstumenter; +import static io.opentelemetry.javaagent.instrumentation.camunda.v7_18.behavior.CamundaBehaviorSingletons.getOpentelemetry; +import static io.opentelemetry.javaagent.extension.matcher.AgentElementMatchers.hasClassesNamed; +import static net.bytebuddy.matcher.ElementMatchers.named; +import static net.bytebuddy.matcher.ElementMatchers.anyOf; + +import java.util.Optional; + +import org.camunda.bpm.engine.impl.pvm.delegate.ActivityExecution; +import org.camunda.bpm.model.bpmn.instance.CompensateEventDefinition; +import org.camunda.bpm.model.bpmn.instance.EndEvent; +import org.camunda.bpm.model.bpmn.instance.ErrorEventDefinition; +import org.camunda.bpm.model.bpmn.instance.EventDefinition; +import org.camunda.bpm.model.bpmn.instance.TerminateEventDefinition; + +import io.opentelemetry.javaagent.camunda.v7_18.behavior.CamundaActivityExecutionGetter; +import io.opentelemetry.javaagent.camunda.v7_18.common.CamundaCommonRequest; + +import io.opentelemetry.context.Context; +import io.opentelemetry.context.Scope; +import io.opentelemetry.javaagent.bootstrap.Java8BytecodeBridge; +import io.opentelemetry.javaagent.extension.instrumentation.TypeInstrumentation; +import io.opentelemetry.javaagent.extension.instrumentation.TypeTransformer; +import net.bytebuddy.asm.Advice; +import net.bytebuddy.description.type.TypeDescription; +import net.bytebuddy.matcher.ElementMatcher; +import net.bytebuddy.matcher.ElementMatchers; + +public class CamundaEndEventActivityBehaviorInstrumentation implements TypeInstrumentation { + + @Override + public ElementMatcher classLoaderOptimization() { + return hasClassesNamed("org.camunda.bpm.engine.impl.bpmn.behavior.TerminateEndEventActivityBehavior"); + } + + @Override + public ElementMatcher typeMatcher() { + return named("org.camunda.bpm.engine.impl.bpmn.behavior.TerminateEndEventActivityBehavior") + .or(named("org.camunda.bpm.engine.impl.bpmn.behavior.NoneEndEventActivityBehavior") + .or(named("org.camunda.bpm.engine.impl.bpmn.behavior.ErrorEndEventActivityBehavior"))); + } + + @Override + public void transform(TypeTransformer transformer) { + transformer.applyAdviceToMethod(ElementMatchers.isMethod().and(ElementMatchers.named("execute")), + this.getClass().getName() + "$CamundaEndEventActivityBehaviorAdvice"); + } + + public static class CamundaEndEventActivityBehaviorAdvice { + + @Advice.OnMethodEnter(suppress = Throwable.class) + public static void addTracingEnter(@Advice.Argument(0) ActivityExecution execution, + @Advice.Local("request") CamundaCommonRequest request, + @Advice.Local("otelParentScope") Scope parentScope, @Advice.Local("otelContext") Context context, + @Advice.Local("otelScope") Scope scope) { + + if (execution == null) { + return; + } + + request = new CamundaCommonRequest(); + request.setProcessDefinitionId(Optional.ofNullable(execution.getProcessDefinitionId())); + request.setProcessInstanceId(Optional.ofNullable(execution.getProcessInstanceId())); + request.setActivityId(Optional.ofNullable(execution.getCurrentActivityId())); + + if (execution.getBpmnModelElementInstance() != null) { + //TODO lambda does not work due to access modifier + + // TODO add other events execution.getBpmnModelElementInstance() instanceof + // EndEvent + EndEvent e = (EndEvent) execution.getBpmnModelElementInstance(); + + for (EventDefinition ed : e.getEventDefinitions()) { + if (ed instanceof TerminateEventDefinition) { + request.setActivityName(Optional.of("End")); + }else if(ed instanceof ErrorEventDefinition) { + request.setActivityName(Optional.of("Error End")); + }else if(ed instanceof CompensateEventDefinition) { + request.setActivityName(Optional.of("Compensation End")); + }else { + request.setActivityName(Optional.of("End")); + } + } + } + + String processInstanceId = execution.getProcessInstanceId(); + + Context parentContext = getOpentelemetry().getPropagators().getTextMapPropagator() + .extract(Java8BytecodeBridge.currentContext(), execution, new CamundaActivityExecutionGetter()); + + parentScope = parentContext.makeCurrent(); + + if (getInstumenter().shouldStart(Java8BytecodeBridge.currentContext(), request)) { + context = getInstumenter().start(Java8BytecodeBridge.currentContext(), request); + scope = context.makeCurrent(); + + } + + } + + @Advice.OnMethodExit(onThrowable = Throwable.class, suppress = Throwable.class) + public static void closeSpan(@Advice.Local("request") CamundaCommonRequest request, + @Advice.Local("otelParentScope") Scope parentScope, @Advice.Local("otelContext") Context context, + @Advice.Local("otelScope") Scope scope, @Advice.Thrown Throwable throwable) { + + + if (context != null && scope != null) { + getInstumenter().end(context, request, "NA", throwable); + scope.close(); + } + + if (parentScope != null) { + parentScope.close(); + } + + } + } + +} diff --git a/instrumentation/camunda/camunda-7.18/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_18/behavior/CamundaEndEventActivityBehaviorModule.java b/instrumentation/camunda/camunda-7.18/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_18/behavior/CamundaEndEventActivityBehaviorModule.java new file mode 100644 index 000000000000..26a81dbcd2ed --- /dev/null +++ b/instrumentation/camunda/camunda-7.18/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_18/behavior/CamundaEndEventActivityBehaviorModule.java @@ -0,0 +1,48 @@ +package com.att.sre.otel.javaagent.instrumentation.camunda.v7_18.behavior; + +import static io.opentelemetry.javaagent.extension.matcher.AgentElementMatchers.hasClassesNamed; + +import java.util.Arrays; +import java.util.Collections; +import java.util.List; + +import com.google.auto.service.AutoService; + +import io.opentelemetry.javaagent.extension.instrumentation.InstrumentationModule; +import io.opentelemetry.javaagent.extension.instrumentation.TypeInstrumentation; +import io.opentelemetry.sdk.autoconfigure.spi.ConfigProperties; +import net.bytebuddy.matcher.ElementMatcher; + +@AutoService(InstrumentationModule.class) +public class CamundaEndEventActivityBehaviorModule extends InstrumentationModule { + + public CamundaEndEventActivityBehaviorModule() { + super("camunda", "camunda-behavior", "camunda-behavior-7_18"); + } + + @Override + public boolean defaultEnabled(ConfigProperties config) { + return config.getBoolean("otel.instrumentation.common.default-enabled", true); + } + + @Override + public List typeInstrumentations() { + return Collections.singletonList(new CamundaEndEventActivityBehaviorInstrumentation()); + } + + @Override + public ElementMatcher.Junction classLoaderMatcher() { + return hasClassesNamed("org.camunda.bpm.engine.impl.bpmn.behavior.TerminateEndEventActivityBehavior", + "org.camunda.bpm.engine.impl.bpmn.behavior.NoneEndEventActivityBehavior", + "org.camunda.bpm.engine.impl.bpmn.behavior.ErrorEndEventActivityBehavior"); + } + + String[] helperClassnames = { "com.att.sre.otel.javaagent.instrumentation.camunda.v7_18.behavior", + "com.att.sre.otel.javaagent.instrumentation.camunda.v7_18.common" }; + + @Override + public boolean isHelperClass(String classname) { + return super.isHelperClass(classname) || Arrays.stream(helperClassnames).anyMatch(c -> classname.startsWith(c)); + } + +} diff --git a/instrumentation/camunda/camunda-7.18/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_18/behavior/CamundaExternalTaskActivityBehaviorInstrumentation.java b/instrumentation/camunda/camunda-7.18/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_18/behavior/CamundaExternalTaskActivityBehaviorInstrumentation.java new file mode 100644 index 000000000000..83f6c29175ba --- /dev/null +++ b/instrumentation/camunda/camunda-7.18/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_18/behavior/CamundaExternalTaskActivityBehaviorInstrumentation.java @@ -0,0 +1,121 @@ +package com.att.sre.otel.javaagent.instrumentation.camunda.v7_18.behavior; + +import static com.att.sre.otel.javaagent.instrumentation.camunda.v7_18.behavior.CamundaBehaviorSingletons.getInstumenter; +import static com.att.sre.otel.javaagent.instrumentation.camunda.v7_18.behavior.CamundaBehaviorSingletons.getOpentelemetry; +import static io.opentelemetry.javaagent.extension.matcher.AgentElementMatchers.hasClassesNamed; +import static net.bytebuddy.matcher.ElementMatchers.named; + +import java.util.HashMap; +import java.util.Map; +import java.util.Optional; +import java.util.logging.Level; + +import org.camunda.bpm.engine.impl.pvm.delegate.ActivityExecution; + +import io.opentelemetry.javaagent.camunda.v7_18.behavior.CamundaActivityExecutionGetter; +import io.opentelemetry.javaagent.camunda.v7_18.behavior.CamundaActivityExecutionLocalSetter; +import io.opentelemetry.javaagent.camunda.v7_18.behavior.CamundaActivityExecutionSetter; +import io.opentelemetry.javaagent.camunda.v7_18.behavior.CamundaVariableMapSetter; +import io.opentelemetry.javaagent.camunda.v7_18.common.CamundaCommonRequest; + +import io.opentelemetry.api.trace.SpanContext; +import io.opentelemetry.context.Context; +import io.opentelemetry.context.Scope; +import io.opentelemetry.javaagent.bootstrap.Java8BytecodeBridge; +import io.opentelemetry.javaagent.extension.instrumentation.TypeInstrumentation; +import io.opentelemetry.javaagent.extension.instrumentation.TypeTransformer; +import net.bytebuddy.asm.Advice; +import net.bytebuddy.description.type.TypeDescription; +import net.bytebuddy.matcher.ElementMatcher; +import net.bytebuddy.matcher.ElementMatchers; + +public class CamundaExternalTaskActivityBehaviorInstrumentation implements TypeInstrumentation { + + @Override + public ElementMatcher classLoaderOptimization() { + return hasClassesNamed("org.camunda.bpm.engine.impl.bpmn.behavior.ExternalTaskActivityBehavior"); + } + + @Override + public ElementMatcher typeMatcher() { + return named("org.camunda.bpm.engine.impl.bpmn.behavior.ExternalTaskActivityBehavior"); + } + + @Override + public void transform(TypeTransformer transformer) { + transformer.applyAdviceToMethod(ElementMatchers.isMethod().and(ElementMatchers.named("execute")), + this.getClass().getName() + "$CamundaExternalTaskActivityBehaviorAdvice"); + + } + + public static class CamundaExternalTaskActivityBehaviorAdvice { + + /** + * Sets parent context to process instance. Creates new context and span. + * propagates current context to variable set for topic to retrieve. + * + * @param execution + * @param request + * @param parentScope + * @param parentContext + * @param context + * @param scope + */ + @Advice.OnMethodEnter(suppress = Throwable.class) + public static void addTracingEnter(@Advice.Argument(0) ActivityExecution execution, + @Advice.Local("request") CamundaCommonRequest request, + @Advice.Local("otelParentScope") Scope parentScope, + @Advice.Local("otelParentContext") Context parentContext, @Advice.Local("otelContext") Context context, + @Advice.Local("otelScope") Scope scope) { + + + if (execution == null) { + return; + } + + request = new CamundaCommonRequest(); + request.setProcessDefinitionId(Optional.ofNullable(execution.getProcessDefinitionId())); + request.setProcessInstanceId(Optional.ofNullable(execution.getProcessInstanceId())); + request.setActivityId(Optional.ofNullable(execution.getCurrentActivityId())); + request.setActivityName(Optional.ofNullable(execution.getCurrentActivityName())); + + String processInstanceId = execution.getProcessInstanceId(); + + if (Java8BytecodeBridge.currentContext() == Java8BytecodeBridge.rootContext()) { + } + + parentContext = getOpentelemetry().getPropagators().getTextMapPropagator() + .extract(Java8BytecodeBridge.currentContext(), execution, new CamundaActivityExecutionGetter()); + + parentScope = parentContext.makeCurrent(); + + if (getInstumenter().shouldStart(Java8BytecodeBridge.currentContext(), request)) { + context = getInstumenter().start(Java8BytecodeBridge.currentContext(), request); + scope = context.makeCurrent(); + + getOpentelemetry().getPropagators().getTextMapPropagator().inject(context, execution, + new CamundaActivityExecutionLocalSetter()); + } + + } + + @Advice.OnMethodExit(onThrowable = Throwable.class, suppress = Throwable.class) + public static void closeTrace(@Advice.Local("request") CamundaCommonRequest request, + @Advice.Local("otelParentScope") Scope parentScope, + @Advice.Local("otelParentContext") Context parentContext, @Advice.Local("otelContext") Context context, + @Advice.Local("otelScope") Scope scope, @Advice.Thrown Throwable throwable) { + + + if (context != null && scope != null) { + getInstumenter().end(context, request, "NA", throwable); + scope.close(); + } + + if (parentScope != null) { + parentScope.close(); + } + + } + } + +} diff --git a/instrumentation/camunda/camunda-7.18/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_18/behavior/CamundaExternalTaskActivityBehaviorModule.java b/instrumentation/camunda/camunda-7.18/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_18/behavior/CamundaExternalTaskActivityBehaviorModule.java new file mode 100644 index 000000000000..31cd2bcc2303 --- /dev/null +++ b/instrumentation/camunda/camunda-7.18/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_18/behavior/CamundaExternalTaskActivityBehaviorModule.java @@ -0,0 +1,46 @@ +package io.opentelemetry.javaagent.instrumentation.camunda.v7_18.behavior; + +import static io.opentelemetry.javaagent.extension.matcher.AgentElementMatchers.hasClassesNamed; + +import java.util.Arrays; +import java.util.Collections; +import java.util.List; + +import com.google.auto.service.AutoService; + +import io.opentelemetry.javaagent.extension.instrumentation.InstrumentationModule; +import io.opentelemetry.javaagent.extension.instrumentation.TypeInstrumentation; +import io.opentelemetry.sdk.autoconfigure.spi.ConfigProperties; +import net.bytebuddy.matcher.ElementMatcher; + +@AutoService(InstrumentationModule.class) +public class CamundaExternalTaskActivityBehaviorModule extends InstrumentationModule { + + public CamundaExternalTaskActivityBehaviorModule() { + super("camunda", "camunda-behavior", "camunda-behavior-7_18"); + } + + @Override + public boolean defaultEnabled(ConfigProperties config) { + return config.getBoolean("otel.instrumentation.common.default-enabled", true); + } + + @Override + public List typeInstrumentations() { + return Collections.singletonList(new CamundaExternalTaskActivityBehaviorInstrumentation()); + } + + @Override + public ElementMatcher.Junction classLoaderMatcher() { + return hasClassesNamed("org.camunda.bpm.engine.impl.bpmn.behavior.ExternalTaskActivityBehavior"); + } + + String[] helperClassnames = { "io.opentelemetry.javaagent.instrumentation.camunda.v7_18.behavior", + "io.opentelemetry.javaagent.instrumentation.camunda.v7_18.common" }; + + @Override + public boolean isHelperClass(String classname) { + return super.isHelperClass(classname) || Arrays.stream(helperClassnames).anyMatch(c -> classname.startsWith(c)); + } + +} diff --git a/instrumentation/camunda/camunda-7.18/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_18/behavior/CamundaTaskActivityBehaviorInstrumentation.java b/instrumentation/camunda/camunda-7.18/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_18/behavior/CamundaTaskActivityBehaviorInstrumentation.java new file mode 100644 index 000000000000..1c7dd80130da --- /dev/null +++ b/instrumentation/camunda/camunda-7.18/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_18/behavior/CamundaTaskActivityBehaviorInstrumentation.java @@ -0,0 +1,101 @@ +package io.opentelemetry.javaagent.instrumentation.camunda.v7_18.behavior; + +import static io.opentelemetry.javaagent.instrumentation.camunda.v7_18.behavior.CamundaBehaviorSingletons.getInstumenter; +import static io.opentelemetry.javaagent.instrumentation.camunda.v7_18.behavior.CamundaBehaviorSingletons.getOpentelemetry; +import static io.opentelemetry.javaagent.extension.matcher.AgentElementMatchers.hasClassesNamed; +import static io.opentelemetry.javaagent.extension.matcher.AgentElementMatchers.hasSuperType; +import static net.bytebuddy.matcher.ElementMatchers.named; + +import java.util.Optional; +import java.util.logging.Level; + +import org.camunda.bpm.engine.impl.pvm.delegate.ActivityExecution; + +import io.opentelemetry.javaagent.camunda.v7_18.behavior.CamundaActivityExecutionGetter; +import io.opentelemetry.javaagent.camunda.v7_18.common.CamundaCommonRequest; + +import io.opentelemetry.api.trace.SpanContext; +import io.opentelemetry.context.Context; +import io.opentelemetry.context.Scope; +import io.opentelemetry.javaagent.bootstrap.Java8BytecodeBridge; +import io.opentelemetry.javaagent.extension.instrumentation.TypeInstrumentation; +import io.opentelemetry.javaagent.extension.instrumentation.TypeTransformer; +import net.bytebuddy.asm.Advice; +import net.bytebuddy.description.type.TypeDescription; +import net.bytebuddy.matcher.ElementMatcher; +import net.bytebuddy.matcher.ElementMatchers; + +public class CamundaTaskActivityBehaviorInstrumentation implements TypeInstrumentation { + + @Override + public ElementMatcher classLoaderOptimization() { + return hasClassesNamed("org.camunda.bpm.engine.impl.bpmn.behavior.TaskActivityBehavior"); + } + + @Override + public ElementMatcher typeMatcher() { + return hasSuperType(named("org.camunda.bpm.engine.impl.bpmn.behavior.TaskActivityBehavior")); + } + + @Override + public void transform(TypeTransformer transformer) { + transformer.applyAdviceToMethod(ElementMatchers.isMethod().and(ElementMatchers.named("performExecution")), + this.getClass().getName() + "$CamundaTaskActivityBehaviorAdvice"); + } + + public static class CamundaTaskActivityBehaviorAdvice { + + @Advice.OnMethodEnter(suppress = Throwable.class) + public static void addTracingEnter(@Advice.Argument(0) ActivityExecution execution, + @Advice.Local("request") CamundaCommonRequest request, + @Advice.Local("otelParentScope") Scope parentScope, @Advice.Local("otelContext") Context context, + @Advice.Local("otelScope") Scope scope) { + + + if (execution == null) { + return; + } + + request = new CamundaCommonRequest(); + request.setProcessDefinitionId(Optional.ofNullable(execution.getProcessDefinitionId())); + request.setProcessInstanceId(Optional.ofNullable(execution.getProcessInstanceId())); + request.setActivityId(Optional.ofNullable(execution.getCurrentActivityId())); + request.setActivityName(Optional.ofNullable(execution.getCurrentActivityName())); + + String processInstanceId = execution.getProcessInstanceId(); + + if (Java8BytecodeBridge.currentContext() == Java8BytecodeBridge.rootContext()) { + } + + Context parentContext = getOpentelemetry().getPropagators().getTextMapPropagator() + .extract(Java8BytecodeBridge.currentContext(), execution, new CamundaActivityExecutionGetter()); + + parentScope = parentContext.makeCurrent(); + + if (getInstumenter().shouldStart(Java8BytecodeBridge.currentContext(), request)) { + context = getInstumenter().start(Java8BytecodeBridge.currentContext(), request); + scope = context.makeCurrent(); + + } + + } + + @Advice.OnMethodExit(onThrowable = Throwable.class, suppress = Throwable.class) + public static void closeTrace(@Advice.Local("request") CamundaCommonRequest request, + @Advice.Local("otelParentScope") Scope parentScope, @Advice.Local("otelContext") Context context, + @Advice.Local("otelScope") Scope scope, @Advice.Thrown Throwable throwable) { + + + if (context != null && scope != null) { + getInstumenter().end(context, request, "NA", throwable); + scope.close(); + } + + if (parentScope != null) { + parentScope.close(); + } + + } + } + +} diff --git a/instrumentation/camunda/camunda-7.18/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_18/behavior/CamundaTaskActivityBehaviorModule.java b/instrumentation/camunda/camunda-7.18/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_18/behavior/CamundaTaskActivityBehaviorModule.java new file mode 100644 index 000000000000..a29e4e766e42 --- /dev/null +++ b/instrumentation/camunda/camunda-7.18/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_18/behavior/CamundaTaskActivityBehaviorModule.java @@ -0,0 +1,46 @@ +package io.opentelemetry.javaagent.instrumentation.camunda.v7_18.behavior; + +import static io.opentelemetry.javaagent.extension.matcher.AgentElementMatchers.hasClassesNamed; + +import java.util.Arrays; +import java.util.Collections; +import java.util.List; + +import com.google.auto.service.AutoService; + +import io.opentelemetry.javaagent.extension.instrumentation.InstrumentationModule; +import io.opentelemetry.javaagent.extension.instrumentation.TypeInstrumentation; +import io.opentelemetry.sdk.autoconfigure.spi.ConfigProperties; +import net.bytebuddy.matcher.ElementMatcher; + +@AutoService(InstrumentationModule.class) +public class CamundaTaskActivityBehaviorModule extends InstrumentationModule { + + public CamundaTaskActivityBehaviorModule() { + super("camunda", "camunda-behavior", "camunda-behavior-7_18"); + } + + @Override + public boolean defaultEnabled(ConfigProperties config) { + return config.getBoolean("otel.instrumentation.common.default-enabled", true); + } + + @Override + public List typeInstrumentations() { + return Collections.singletonList(new CamundaTaskActivityBehaviorInstrumentation()); + } + + @Override + public ElementMatcher.Junction classLoaderMatcher() { + return hasClassesNamed("org.camunda.bpm.engine.impl.bpmn.behavior.TaskActivityBehavior"); + } + + String[] helperClassnames = { "io.opentelemetry.javaagent.instrumentation.camunda.v7_18.behavior", + "io.opentelemetry.javaagent.instrumentation.camunda.v7_18.common"}; + + @Override + public boolean isHelperClass(String classname) { + return super.isHelperClass(classname) || Arrays.stream(helperClassnames).anyMatch(c -> classname.startsWith(c)); + } + +} diff --git a/instrumentation/camunda/camunda-7.18/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_18/behavior/CamundaVariableMapSetter.java b/instrumentation/camunda/camunda-7.18/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_18/behavior/CamundaVariableMapSetter.java new file mode 100644 index 000000000000..d8db3a6aadf7 --- /dev/null +++ b/instrumentation/camunda/camunda-7.18/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_18/behavior/CamundaVariableMapSetter.java @@ -0,0 +1,14 @@ +package io.opentelemetry.javaagent.instrumentation.camunda.v7_18.behavior; + +import org.camunda.bpm.engine.variable.VariableMap; + +import io.opentelemetry.context.propagation.TextMapSetter; + +public class CamundaVariableMapSetter implements TextMapSetter { + + @Override + public void set(VariableMap carrier, String key, String value) { + carrier.put(key, value); + } + +} diff --git a/instrumentation/camunda/camunda-7.18/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_18/common/CamundaCommonRequest.java b/instrumentation/camunda/camunda-7.18/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_18/common/CamundaCommonRequest.java new file mode 100644 index 000000000000..18de18f8220c --- /dev/null +++ b/instrumentation/camunda/camunda-7.18/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_18/common/CamundaCommonRequest.java @@ -0,0 +1,71 @@ +package io.opentelemetry.javaagent.instrumentation.camunda.v7_18.common; + +import java.util.Optional; + +public class CamundaCommonRequest { + + private Optional processDefinitionId = Optional.empty(); + private Optional processDefinitionKey = Optional.empty(); + private Optional processInstanceId = Optional.empty(); + private Optional activityId = Optional.empty(); + private Optional activityName = Optional.empty(); + private Optional topicName = Optional.empty(); + private Optional topicWorkerId = Optional.empty(); + + public Optional getProcessDefinitionId() { + return processDefinitionId; + } + + public void setProcessDefinitionId(Optional processDefinitionId) { + this.processDefinitionId = processDefinitionId; + } + + public Optional getProcessDefinitionKey() { + return processDefinitionKey; + } + + public void setProcessDefinitionKey(Optional processDefinitionKey) { + this.processDefinitionKey = processDefinitionKey; + } + + public Optional getProcessInstanceId() { + return processInstanceId; + } + + public void setProcessInstanceId(Optional processInstanceId) { + this.processInstanceId = processInstanceId; + } + + public Optional getActivityId() { + return activityId; + } + + public void setActivityId(Optional activityId) { + this.activityId = activityId; + } + + public Optional getActivityName() { + return activityName; + } + + public void setActivityName(Optional activityName) { + this.activityName = activityName; + } + + public Optional getTopicName() { + return topicName; + } + + public void setTopicName(Optional topicName) { + this.topicName = topicName; + } + + public Optional getTopicWorkerId() { + return topicWorkerId; + } + + public void setTopicWorkerId(Optional topicWorkerId) { + this.topicWorkerId = topicWorkerId; + } + +} diff --git a/instrumentation/camunda/camunda-7.18/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_18/common/CamundaVariableAttributeExtractor.java b/instrumentation/camunda/camunda-7.18/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_18/common/CamundaVariableAttributeExtractor.java new file mode 100644 index 000000000000..b1f3bc405503 --- /dev/null +++ b/instrumentation/camunda/camunda-7.18/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_18/common/CamundaVariableAttributeExtractor.java @@ -0,0 +1,28 @@ +package io.opentelemetry.javaagent.instrumentation.camunda.v7_18.common; + +import io.opentelemetry.api.common.AttributesBuilder; +import io.opentelemetry.context.Context; +import io.opentelemetry.instrumentation.api.instrumenter.AttributesExtractor; + +public class CamundaVariableAttributeExtractor implements AttributesExtractor { + + @Override + public void onStart(AttributesBuilder attributes, Context parentContext, CamundaCommonRequest request) { + + request.getProcessDefinitionKey().ifPresent(pdk -> attributes.put("camunda.processdefinitionkey", pdk)); + request.getProcessDefinitionId().ifPresent(pdi -> attributes.put("camunda.processdefinitionid", pdi)); + request.getProcessInstanceId().ifPresent(pid -> attributes.put("camunda.processinstanceid", pid)); + request.getActivityId().ifPresent(aid -> attributes.put("camunda.activityid", aid)); + request.getActivityName().ifPresent(an -> attributes.put("camunda.activityname", an)); + request.getTopicName().ifPresent(tn -> attributes.put("camunda.topicname", tn)); + request.getTopicWorkerId().ifPresent(twi -> attributes.put("camunda.topicworkerid", twi)); + } + + @Override + public void onEnd(AttributesBuilder attributes, Context context, CamundaCommonRequest request, String response, + Throwable error) { + // TODO Auto-generated method stub + + } + +} diff --git a/instrumentation/camunda/camunda-7.18/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_18/jobs/CamundaAsyncContinuationJobHandlerInstrumentation.java b/instrumentation/camunda/camunda-7.18/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_18/jobs/CamundaAsyncContinuationJobHandlerInstrumentation.java new file mode 100644 index 000000000000..2fc9b52e8216 --- /dev/null +++ b/instrumentation/camunda/camunda-7.18/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_18/jobs/CamundaAsyncContinuationJobHandlerInstrumentation.java @@ -0,0 +1,112 @@ +package io.opentelemetry.javaagent.instrumentation.camunda.v7_18.jobs; + +import static io.opentelemetry.javaagent.extension.matcher.AgentElementMatchers.hasClassesNamed; + +import java.util.Optional; + +import static io.opentelemetry.javaagent.instrumentation.camunda.v7_18.jobs.CamundaJobSingletons.getInstumenter; +import static io.opentelemetry.javaagent.instrumentation.camunda.v7_18.jobs.CamundaJobSingletons.getOpentelemetry; + +import org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity; + +import io.opentelemetry.javaagent.instrumentation.camunda.v7_18.common.CamundaCommonRequest; +import io.opentelemetry.javaagent.instrumentation.camunda.v7_18.jobs.CamundaExecutionEntityGetter; + +import io.opentelemetry.api.trace.SpanContext; +import io.opentelemetry.context.Context; +import io.opentelemetry.context.Scope; +import io.opentelemetry.javaagent.bootstrap.Java8BytecodeBridge; +import io.opentelemetry.javaagent.extension.instrumentation.TypeInstrumentation; +import io.opentelemetry.javaagent.extension.instrumentation.TypeTransformer; +import net.bytebuddy.asm.Advice; +import net.bytebuddy.description.type.TypeDescription; +import net.bytebuddy.matcher.ElementMatcher; +import net.bytebuddy.matcher.ElementMatchers; + +public class CamundaAsyncContinuationJobHandlerInstrumentation implements TypeInstrumentation { + + @Override + public ElementMatcher classLoaderOptimization() { + return hasClassesNamed("org.camunda.bpm.engine.impl.jobexecutor.AsyncContinuationJobHandler"); + } + + @Override + public ElementMatcher typeMatcher() { + return ElementMatchers.named("org.camunda.bpm.engine.impl.jobexecutor.AsyncContinuationJobHandler"); + } + + @Override + public void transform(TypeTransformer transformer) { + transformer + .applyAdviceToMethod( + ElementMatchers.isMethod().and(ElementMatchers.named("execute")) + .and(ElementMatchers.takesArgument(1, + ElementMatchers.named( + "org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity"))), + this.getClass().getName() + "$CamundaAsyncContinuationJobHandlerAdvice"); + } + + public static class CamundaAsyncContinuationJobHandlerAdvice { + @Advice.OnMethodEnter(suppress = Throwable.class) + public static void addTracingEnter(@Advice.Argument(1) ExecutionEntity executionEntity, + @Advice.Local("request") CamundaCommonRequest request, + @Advice.Local("otelParentScope") Scope parentScope, @Advice.Local("otelContext") Context context, + @Advice.Local("otelScope") Scope scope) { + + + if (executionEntity == null) { + return; + } + + request = new CamundaCommonRequest(); + request.setProcessDefinitionId(Optional.ofNullable(executionEntity.getProcessDefinitionId())); + if (executionEntity.getProcessDefinition() != null) { + request.setProcessDefinitionKey(Optional.ofNullable(executionEntity.getProcessDefinition().getKey())); + } + request.setProcessInstanceId(Optional.ofNullable(executionEntity.getProcessInstanceId())); + request.setActivityId(Optional.ofNullable(executionEntity.getActivityId())); + if (executionEntity.getActivity() != null) { + request.setActivityName(Optional.ofNullable(executionEntity.getActivity().getName())); + } + + String processInstanceId = executionEntity.getProcessInstanceId(); + + if (Java8BytecodeBridge.currentContext() == Java8BytecodeBridge.rootContext()) { + System.out.println("No initial span context for process instance " + processInstanceId); + } + + Context parentContext = getOpentelemetry().getPropagators().getTextMapPropagator() + .extract(Java8BytecodeBridge.currentContext(), executionEntity, new CamundaExecutionEntityGetter()); + + parentScope = parentContext.makeCurrent(); + + if (getInstumenter().shouldStart(Java8BytecodeBridge.currentContext(), request)) { + context = getInstumenter().start(Java8BytecodeBridge.currentContext(), request); + scope = context.makeCurrent(); + + } else { + System.out.println("Unable to start telemetry for process " + processInstanceId); + } + + } + + @Advice.OnMethodExit(onThrowable = Throwable.class, suppress = Throwable.class) + public static void closeTrace(@Advice.Argument(1) ExecutionEntity executionEntity, + @Advice.Local("request") CamundaCommonRequest request, + @Advice.Local("otelParentScope") Scope parentScope, @Advice.Local("otelContext") Context context, + @Advice.Local("otelScope") Scope scope, @Advice.Thrown Throwable throwable) { + + + if (context != null && scope != null) { + getInstumenter().end(context, request, "NA", throwable); + scope.close(); + } + + if (parentScope != null) { + parentScope.close(); + } + + } + } + +} diff --git a/instrumentation/camunda/camunda-7.18/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_18/jobs/CamundaAsyncContinuationJobHandlerModule.java b/instrumentation/camunda/camunda-7.18/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_18/jobs/CamundaAsyncContinuationJobHandlerModule.java new file mode 100644 index 000000000000..63b5f8e9a595 --- /dev/null +++ b/instrumentation/camunda/camunda-7.18/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_18/jobs/CamundaAsyncContinuationJobHandlerModule.java @@ -0,0 +1,46 @@ +package io.opentelemetry.javaagent.instrumentation.camunda.v7_18.jobs; + +import static io.opentelemetry.javaagent.extension.matcher.AgentElementMatchers.hasClassesNamed; + +import java.util.Arrays; +import java.util.Collections; +import java.util.List; + +import com.google.auto.service.AutoService; + +import io.opentelemetry.javaagent.extension.instrumentation.InstrumentationModule; +import io.opentelemetry.javaagent.extension.instrumentation.TypeInstrumentation; +import io.opentelemetry.sdk.autoconfigure.spi.ConfigProperties; +import net.bytebuddy.matcher.ElementMatcher; + +@AutoService(InstrumentationModule.class) +public class CamundaAsyncContinuationJobHandlerModule extends InstrumentationModule { + + public CamundaAsyncContinuationJobHandlerModule() { + super("camunda", "camunda-job", "camunda-job-7_18"); + } + + @Override + public boolean defaultEnabled(ConfigProperties config) { + return config.getBoolean("otel.instrumentation.common.default-enabled", true); + } + + @Override + public List typeInstrumentations() { + return Collections.singletonList(new CamundaAsyncContinuationJobHandlerInstrumentation()); + } + + @Override + public ElementMatcher.Junction classLoaderMatcher() { + return hasClassesNamed("org.camunda.bpm.engine.impl.jobexecutor.AsyncContinuationJobHandler"); + } + + String[] helperClassnames = { "io.opentelemetry.javaagent.instrumentation.camunda.v7_18.jobs", + "io.opentelemetry.javaagent.instrumentation.camunda.v7_18.common"}; + + @Override + public boolean isHelperClass(String classname) { + return super.isHelperClass(classname) || Arrays.stream(helperClassnames).anyMatch(c -> classname.startsWith(c)); + } + +} diff --git a/instrumentation/camunda/camunda-7.18/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_18/jobs/CamundaExecutionEntityGetter.java b/instrumentation/camunda/camunda-7.18/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_18/jobs/CamundaExecutionEntityGetter.java new file mode 100644 index 000000000000..dc04180f6c36 --- /dev/null +++ b/instrumentation/camunda/camunda-7.18/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_18/jobs/CamundaExecutionEntityGetter.java @@ -0,0 +1,20 @@ +package io.opentelemetry.javaagent.instrumentation.camunda.v7_18.jobs; + +import org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity; + +import io.opentelemetry.context.propagation.TextMapGetter; + +public class CamundaExecutionEntityGetter implements TextMapGetter { + + @Override + public Iterable keys(ExecutionEntity carrier) { + return carrier.getVariableNames(); + } + + @Override + public String get(ExecutionEntity carrier, String key) { + Object variable = carrier.getVariables().get(key); + return variable == null ? null : variable.toString(); + } + +} diff --git a/instrumentation/camunda/camunda-7.18/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_18/jobs/CamundaJobSingletons.java b/instrumentation/camunda/camunda-7.18/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_18/jobs/CamundaJobSingletons.java new file mode 100644 index 000000000000..f640c38b2d18 --- /dev/null +++ b/instrumentation/camunda/camunda-7.18/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_18/jobs/CamundaJobSingletons.java @@ -0,0 +1,41 @@ +package io.opentelemetry.javaagent.instrumentation.camunda.v7_18.jobs; + +import org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity; + +import io.opentelemetry.javaagent.instrumentation.camunda.v7_18.common.CamundaCommonRequest; +import io.opentelemetry.javaagent.instrumentation.camunda.v7_18.common.CamundaVariableAttributeExtractor; +import io.opentelemetry.javaagent.instrumentation.camunda.v7_18.jobs.CamundaJobSpanNameExtractor; + +import io.opentelemetry.api.GlobalOpenTelemetry; +import io.opentelemetry.api.OpenTelemetry; +import io.opentelemetry.instrumentation.api.instrumenter.Instrumenter; +import io.opentelemetry.instrumentation.api.instrumenter.InstrumenterBuilder; + +public class CamundaJobSingletons { + + private static final Instrumenter instrumenter; + + private static final OpenTelemetry opentelemetry; + + static { + + opentelemetry = GlobalOpenTelemetry.get(); + + InstrumenterBuilder builder = Instrumenter + .builder(opentelemetry, "io.opentelemetry.camunda-job", + new CamundaJobSpanNameExtractor()) + .addAttributesExtractor(new CamundaVariableAttributeExtractor()); + + instrumenter = builder.buildInstrumenter(); + } + + public static OpenTelemetry getOpentelemetry() { + return opentelemetry; + } + + public static Instrumenter getInstumenter() { + return instrumenter; + } + + +} diff --git a/instrumentation/camunda/camunda-7.18/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_18/jobs/CamundaJobSpanNameExtractor.java b/instrumentation/camunda/camunda-7.18/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_18/jobs/CamundaJobSpanNameExtractor.java new file mode 100644 index 000000000000..943d6e7871f8 --- /dev/null +++ b/instrumentation/camunda/camunda-7.18/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_18/jobs/CamundaJobSpanNameExtractor.java @@ -0,0 +1,14 @@ +package io.opentelemetry.javaagent.instrumentation.camunda.v7_18.jobs; + +import com.att.sre.otel.instrumentation.camunda.v7_18.common.CamundaCommonRequest; + +import io.opentelemetry.instrumentation.api.instrumenter.SpanNameExtractor; + +public class CamundaJobSpanNameExtractor implements SpanNameExtractor { + + @Override + public String extract(CamundaCommonRequest request) { + return String.format("%s AsyncContinuation", request.getActivityName().get()); + } + +} diff --git a/instrumentation/camunda/camunda-7.18/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_18/processes/CamundaActivityInstantiationBuilderSetter.java b/instrumentation/camunda/camunda-7.18/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_18/processes/CamundaActivityInstantiationBuilderSetter.java new file mode 100644 index 000000000000..f08b19de728a --- /dev/null +++ b/instrumentation/camunda/camunda-7.18/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_18/processes/CamundaActivityInstantiationBuilderSetter.java @@ -0,0 +1,16 @@ +package io.opentelemetry.javaagent.instrumentation.camunda.v7_18.processes; + +import org.camunda.bpm.engine.runtime.ActivityInstantiationBuilder; + +import io.opentelemetry.context.propagation.TextMapSetter; + +//TODO Bound it to ProcessInstanceModificationBuilder ?? +public class CamundaActivityInstantiationBuilderSetter implements TextMapSetter> { + + @Override + public void set(ActivityInstantiationBuilder carrier, String key, String value) { + carrier.setVariable(key, value); + + } + +} diff --git a/instrumentation/camunda/camunda-7.18/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_18/processes/CamundaProcessInstanceModificationBuilderImpSetter.java b/instrumentation/camunda/camunda-7.18/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_18/processes/CamundaProcessInstanceModificationBuilderImpSetter.java new file mode 100644 index 000000000000..215278a1eea6 --- /dev/null +++ b/instrumentation/camunda/camunda-7.18/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_18/processes/CamundaProcessInstanceModificationBuilderImpSetter.java @@ -0,0 +1,17 @@ +package io.opentelemetry.javaagent.instrumentation.camunda.v7_18.processes; + +import org.camunda.bpm.engine.impl.ProcessInstanceModificationBuilderImpl; + +import io.opentelemetry.context.propagation.TextMapSetter; + +//TODO use this or activityinstanctiationbuildersetter ?? +public class CamundaProcessInstanceModificationBuilderImpSetter + implements TextMapSetter { + + @Override + public void set(ProcessInstanceModificationBuilderImpl carrier, String key, String value) { + carrier.setVariable(key, value); + + } + +} diff --git a/instrumentation/camunda/camunda-7.18/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_18/processes/CamundaProcessInstantiationBuilderInstrumentation.java b/instrumentation/camunda/camunda-7.18/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_18/processes/CamundaProcessInstantiationBuilderInstrumentation.java new file mode 100644 index 000000000000..55a916e9c071 --- /dev/null +++ b/instrumentation/camunda/camunda-7.18/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_18/processes/CamundaProcessInstantiationBuilderInstrumentation.java @@ -0,0 +1,93 @@ +package io.opentelemetry.javaagent.instrumentation.camunda.v7_18.processes; + +import static io.opentelemetry.javaagent.extension.matcher.AgentElementMatchers.hasClassesNamed; +import static io.opentelemetry.javaagent.extension.matcher.AgentElementMatchers.hasSuperType; +import static net.bytebuddy.matcher.ElementMatchers.isMethod; +import static net.bytebuddy.matcher.ElementMatchers.named; + +import java.util.Optional; + +import io.opentelemetry.javaagent.instrumentation.camunda.v7_18.common.CamundaCommonRequest; +import io.opentelemetry.javaagent.instrumentation.camunda.v7_18.processes.CamundaActivityInstantiationBuilderSetter; +import io.opentelemetry.javaagent.instrumentation.camunda.v7_18.processes.CamundaProcessSingletons; + +import org.camunda.bpm.engine.impl.ProcessInstanceModificationBuilderImpl; +import org.camunda.bpm.engine.runtime.ProcessInstance; + +import io.opentelemetry.api.trace.SpanContext; +import io.opentelemetry.context.Context; +import io.opentelemetry.context.Scope; +import io.opentelemetry.javaagent.bootstrap.Java8BytecodeBridge; +import io.opentelemetry.javaagent.extension.instrumentation.TypeInstrumentation; +import io.opentelemetry.javaagent.extension.instrumentation.TypeTransformer; +import net.bytebuddy.asm.Advice; +import net.bytebuddy.description.type.TypeDescription; +import net.bytebuddy.matcher.ElementMatcher; + +public class CamundaProcessInstantiationBuilderInstrumentation implements TypeInstrumentation { + + @Override + public ElementMatcher classLoaderOptimization() { + return hasClassesNamed("org.camunda.bpm.engine.runtime.ProcessInstantiationBuilder"); + } + + @Override + public ElementMatcher typeMatcher() { + return hasSuperType(named("org.camunda.bpm.engine.runtime.ProcessInstantiationBuilder")); + } + + @Override + public void transform(TypeTransformer transformer) { + // comment out for now because it causes duplicate spans + // transformer.applyAdviceToMethod(isMethod().and(named("execute")), + // this.getClass().getName() + + // "$CamundaProcessInstantiationBuilderExecuteAdvice"); + + transformer.applyAdviceToMethod(isMethod().and(named("executeWithVariablesInReturn")), + this.getClass().getName() + "$CamundaProcessInstantiationBuilderExecuteWithVariablesAdvice"); + + } + + public static class CamundaProcessInstantiationBuilderExecuteWithVariablesAdvice { + + @Advice.OnMethodEnter(suppress = Throwable.class) + public static void addTracingEnter( + @Advice.FieldValue("modificationBuilder") ProcessInstanceModificationBuilderImpl modificationBuilder, + @Advice.FieldValue("processDefinitionKey") String processDefinitionKey, + @Advice.FieldValue("businessKey") String businessKey, + @Advice.Local("request") CamundaCommonRequest request, @Advice.Local("otelContext") Context context, + @Advice.Local("otelScope") Scope scope) { + + request = new CamundaCommonRequest(); + request.setProcessDefinitionKey(Optional.ofNullable(processDefinitionKey)); + + Context parentContext = Java8BytecodeBridge.currentContext(); + + if (CamundaProcessSingletons.getInstumenter().shouldStart(parentContext, request)) { + context = CamundaProcessSingletons.getInstumenter().start(parentContext, request); + scope = context.makeCurrent(); + + SpanContext currentSpanContext = Java8BytecodeBridge.spanFromContext(context).getSpanContext(); + if (currentSpanContext.isValid()) { + CamundaProcessSingletons.getOpentelemetry().getPropagators().getTextMapPropagator() + .inject(context, modificationBuilder, new CamundaActivityInstantiationBuilderSetter()); + } + + } + } + + @Advice.OnMethodExit(onThrowable = Throwable.class, suppress = Throwable.class) + public static void closeTrace(@Advice.FieldValue("processDefinitionKey") String processDefinitionKey, + @Advice.Local("request") CamundaCommonRequest request, @Advice.Local("otelContext") Context context, + @Advice.Local("otelScope") Scope scope, @Advice.Thrown Throwable throwable, + @Advice.Return ProcessInstance pi) { + + if (context != null && scope != null) { + CamundaProcessSingletons.getInstumenter().end(context, request, "NA", throwable); + scope.close(); + } + + } + } + +} diff --git a/instrumentation/camunda/camunda-7.18/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_18/processes/CamundaProcessInstantiationBuilderModule.java b/instrumentation/camunda/camunda-7.18/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_18/processes/CamundaProcessInstantiationBuilderModule.java new file mode 100644 index 000000000000..7472cb4fe233 --- /dev/null +++ b/instrumentation/camunda/camunda-7.18/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_18/processes/CamundaProcessInstantiationBuilderModule.java @@ -0,0 +1,48 @@ +package io.opentelemetry.javaagent.instrumentation.camunda.v7_18.processes; + +import static io.opentelemetry.javaagent.extension.matcher.AgentElementMatchers.hasClassesNamed; + +import java.util.Arrays; +import java.util.Collections; +import java.util.List; +import java.util.logging.Logger; + +import com.google.auto.service.AutoService; + +import io.opentelemetry.javaagent.extension.instrumentation.InstrumentationModule; +import io.opentelemetry.javaagent.extension.instrumentation.TypeInstrumentation; +import io.opentelemetry.sdk.autoconfigure.spi.ConfigProperties; +import net.bytebuddy.matcher.ElementMatcher; + +@AutoService(InstrumentationModule.class) +public class CamundaProcessInstantiationBuilderModule extends InstrumentationModule { + + public CamundaProcessInstantiationBuilderModule() { + super("camunda", "camunda-process", "camunda-process-7_18"); + } + + @Override + public List typeInstrumentations() { + return Collections.singletonList(new CamundaProcessInstantiationBuilderInstrumentation()); + } + + @Override + public boolean defaultEnabled(ConfigProperties config) { + return config.getBoolean("otel.instrumentation.common.default-enabled", true); + } + + @Override + public ElementMatcher.Junction classLoaderMatcher() { + + return hasClassesNamed("org.camunda.bpm.engine.runtime.ProcessInstantiationBuilder"); + } + + String[] helperClassnames = { "io.opentelemetry.javaagent.instrumentation.camunda.v7_18.processes", + "io.opentelemetry.javaagent.instrumentation.camunda.v7_18.common" }; + + @Override + public boolean isHelperClass(String classname) { + return super.isHelperClass(classname) || Arrays.stream(helperClassnames).anyMatch(c -> classname.startsWith(c)); + } + +} diff --git a/instrumentation/camunda/camunda-7.18/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_18/processes/CamundaProcessSingletons.java b/instrumentation/camunda/camunda-7.18/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_18/processes/CamundaProcessSingletons.java new file mode 100644 index 000000000000..a1e6f4e0b175 --- /dev/null +++ b/instrumentation/camunda/camunda-7.18/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_18/processes/CamundaProcessSingletons.java @@ -0,0 +1,41 @@ +package io.opentelemetry.javaagent.instrumentation.camunda.v7_18.processes; + +import io.opentelemetry.javaagent.instrumentation.camunda.v7_18.common.CamundaCommonRequest; +import io.opentelemetry.javaagent.instrumentation.camunda.v7_18.common.CamundaVariableAttributeExtractor; +import io.opentelemetry.javaagent.instrumentation.camunda.v7_18.processes.CamundaProcessSpanNameExtractor; + +import io.opentelemetry.api.GlobalOpenTelemetry; +import io.opentelemetry.api.OpenTelemetry; +import io.opentelemetry.instrumentation.api.instrumenter.Instrumenter; +import io.opentelemetry.instrumentation.api.instrumenter.InstrumenterBuilder; +import io.opentelemetry.javaagent.bootstrap.internal.InstrumentationConfig; + +public class CamundaProcessSingletons { + + private static final Instrumenter instrumenter; + + private static final OpenTelemetry opentelemetry; + + private static final boolean propagationEnabled; + + static { + + opentelemetry = GlobalOpenTelemetry.get(); + + InstrumenterBuilder builder = Instrumenter + .builder(opentelemetry, "io.opentelemetry.camunda-process", + new CamundaProcessSpanNameExtractor()) + .addAttributesExtractor(new CamundaVariableAttributeExtractor()); + + instrumenter = builder.buildInstrumenter(); + } + + public static OpenTelemetry getOpentelemetry() { + return opentelemetry; + } + + public static Instrumenter getInstumenter() { + return instrumenter; + } + +} diff --git a/instrumentation/camunda/camunda-7.18/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_18/processes/CamundaProcessSpanNameExtractor.java b/instrumentation/camunda/camunda-7.18/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_18/processes/CamundaProcessSpanNameExtractor.java new file mode 100644 index 000000000000..e2ebe4346c59 --- /dev/null +++ b/instrumentation/camunda/camunda-7.18/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_18/processes/CamundaProcessSpanNameExtractor.java @@ -0,0 +1,14 @@ +package io.opentelemetry.javaagent.instrumentation.camunda.v7_18.processes; + +import io.opentelemetry.javaagent.instrumentation.camunda.v7_18.common.CamundaCommonRequest; + +import io.opentelemetry.instrumentation.api.instrumenter.SpanNameExtractor; + +public class CamundaProcessSpanNameExtractor implements SpanNameExtractor { + + @Override + public String extract(CamundaCommonRequest request) { + return request.getProcessDefinitionKey().get(); + } + +} diff --git a/instrumentation/camunda/camunda-7.18/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_18/task/CamundaExternalTaskGetter.java b/instrumentation/camunda/camunda-7.18/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_18/task/CamundaExternalTaskGetter.java new file mode 100644 index 000000000000..a33a80809d78 --- /dev/null +++ b/instrumentation/camunda/camunda-7.18/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_18/task/CamundaExternalTaskGetter.java @@ -0,0 +1,20 @@ +package io.opentelemetry.javaagent.instrumentation.camunda.v7_18.task; + +import org.camunda.bpm.client.task.ExternalTask; + +import io.opentelemetry.context.propagation.TextMapGetter; + +public class CamundaExternalTaskGetter implements TextMapGetter { + + @Override + public Iterable keys(ExternalTask carrier) { + return carrier.getAllVariables().keySet(); + } + + @Override + public String get(ExternalTask carrier, String key) { + Object variable = carrier.getAllVariables().get(key); + return variable == null ? null : variable.toString(); + } + +} diff --git a/instrumentation/camunda/camunda-7.18/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_18/task/CamundaTaskSingletons.java b/instrumentation/camunda/camunda-7.18/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_18/task/CamundaTaskSingletons.java new file mode 100644 index 000000000000..fffbc1f9a4dc --- /dev/null +++ b/instrumentation/camunda/camunda-7.18/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_18/task/CamundaTaskSingletons.java @@ -0,0 +1,38 @@ +package io.opentelemetry.javaagent.instrumentation.camunda.v7_18.task; + +import io.opentelemetry.javaagent.instrumentation.camunda.v7_18.common.CamundaCommonRequest; +import io.opentelemetry.javaagent.instrumentation.camunda.v7_18.common.CamundaVariableAttributeExtractor; +import io.opentelemetry.javaagent.instrumentation.camunda.v7_18.task.CamundaTaskSpanNameExtractor; + +import io.opentelemetry.api.GlobalOpenTelemetry; +import io.opentelemetry.api.OpenTelemetry; +import io.opentelemetry.instrumentation.api.instrumenter.Instrumenter; +import io.opentelemetry.instrumentation.api.instrumenter.InstrumenterBuilder; + +public class CamundaTaskSingletons { + + private static final Instrumenter instrumenter; + + private static final OpenTelemetry opentelemetry; + + static { + + opentelemetry = GlobalOpenTelemetry.get(); + + InstrumenterBuilder builder = Instrumenter + .builder(opentelemetry, "io.opentelemetry.camunda-task", + new CamundaTaskSpanNameExtractor()) + .addAttributesExtractor(new CamundaVariableAttributeExtractor()); + + instrumenter = builder.buildInstrumenter(); + } + + public static OpenTelemetry getOpentelemetry() { + return opentelemetry; + } + + public static Instrumenter getInstumenter() { + return instrumenter; + } + +} diff --git a/instrumentation/camunda/camunda-7.18/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_18/task/CamundaTaskSpanNameExtractor.java b/instrumentation/camunda/camunda-7.18/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_18/task/CamundaTaskSpanNameExtractor.java new file mode 100644 index 000000000000..be234ae6fbda --- /dev/null +++ b/instrumentation/camunda/camunda-7.18/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_18/task/CamundaTaskSpanNameExtractor.java @@ -0,0 +1,14 @@ +package io.opentelemetry.javaagent.instrumentation.camunda.v7_18.task; + +import io.opentelemetry.javaagent.instrumentation.camunda.v7_18.common.CamundaCommonRequest; + +import io.opentelemetry.instrumentation.api.instrumenter.SpanNameExtractor; + +public class CamundaTaskSpanNameExtractor implements SpanNameExtractor { + + @Override + public String extract(CamundaCommonRequest request) { + return String.format("%s Topic", request.getTopicName().get()); + } + +} diff --git a/instrumentation/camunda/camunda-7.18/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_18/task/CamundaTopicSubscriptionManagerModule.java b/instrumentation/camunda/camunda-7.18/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_18/task/CamundaTopicSubscriptionManagerModule.java new file mode 100644 index 000000000000..1d214cba5f9b --- /dev/null +++ b/instrumentation/camunda/camunda-7.18/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_18/task/CamundaTopicSubscriptionManagerModule.java @@ -0,0 +1,46 @@ +package io.opentelemetry.javaagent.instrumentation.camunda.v7_18.task; + +import static io.opentelemetry.javaagent.extension.matcher.AgentElementMatchers.hasClassesNamed; + +import java.util.Arrays; +import java.util.Collections; +import java.util.List; + +import com.google.auto.service.AutoService; + +import io.opentelemetry.javaagent.extension.instrumentation.InstrumentationModule; +import io.opentelemetry.javaagent.extension.instrumentation.TypeInstrumentation; +import io.opentelemetry.sdk.autoconfigure.spi.ConfigProperties; +import net.bytebuddy.matcher.ElementMatcher; + +@AutoService(InstrumentationModule.class) +public class CamundaTopicSubscriptionManagerModule extends InstrumentationModule { + + public CamundaTopicSubscriptionManagerModule() { + super("camunda", "camunda-task", "camunda-task-7_18"); + } + + @Override + public boolean defaultEnabled(ConfigProperties config) { + return config.getBoolean("otel.instrumentation.common.default-enabled", true); + } + + @Override + public List typeInstrumentations() { + return Collections.singletonList(new CamundaTopicSubscriptionMangerInstrumentation()); + } + + @Override + public ElementMatcher.Junction classLoaderMatcher() { + return hasClassesNamed("org.camunda.bpm.client.topic.impl.TopicSubscriptionManager"); + } + + String[] helperClassnames = { "io.opentelemetry.javaagent.instrumentation.camunda.v7_18.task", + "io.opentelemetry.javaagent.instrumentation.camunda.v7_18.common" }; + + @Override + public boolean isHelperClass(String classname) { + return super.isHelperClass(classname) || Arrays.stream(helperClassnames).anyMatch(c -> classname.startsWith(c)); + } + +} diff --git a/instrumentation/camunda/camunda-7.18/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_18/task/CamundaTopicSubscriptionMangerInstrumentation.java b/instrumentation/camunda/camunda-7.18/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_18/task/CamundaTopicSubscriptionMangerInstrumentation.java new file mode 100644 index 000000000000..f4cee3721c9e --- /dev/null +++ b/instrumentation/camunda/camunda-7.18/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_18/task/CamundaTopicSubscriptionMangerInstrumentation.java @@ -0,0 +1,111 @@ +package io.opentelemetry.javaagent.instrumentation.camunda.v7_18.task; + +import static io.opentelemetry.javaagent.instrumentationn.camunda.v7_18.task.CamundaTaskSingletons.getInstumenter; +import static io.opentelemetry.javaagent.instrumentationn.camunda.v7_18.task.CamundaTaskSingletons.getOpentelemetry; +import static io.opentelemetry.javaagent.extension.matcher.AgentElementMatchers.hasClassesNamed; +import static net.bytebuddy.matcher.ElementMatchers.named; + +import java.util.Map; +import java.util.Optional; + +import org.camunda.bpm.client.task.ExternalTask; +import org.camunda.bpm.client.task.impl.ExternalTaskImpl; +import org.camunda.bpm.client.variable.impl.TypedValueField; +import org.camunda.bpm.client.variable.impl.TypedValues; +import org.camunda.bpm.client.variable.impl.VariableValue; + +import io.opentelemetry.javaagent.instrumentation.camunda.v7_18.common.CamundaCommonRequest; +import io.opentelemetry.javaagent.instrumentation.camunda.v7_18.task.CamundaExternalTaskGetter; + +import io.opentelemetry.api.trace.SpanContext; +import io.opentelemetry.context.Context; +import io.opentelemetry.context.Scope; +import io.opentelemetry.javaagent.bootstrap.Java8BytecodeBridge; +import io.opentelemetry.javaagent.extension.instrumentation.TypeInstrumentation; +import io.opentelemetry.javaagent.extension.instrumentation.TypeTransformer; +import net.bytebuddy.asm.Advice; +import net.bytebuddy.description.type.TypeDescription; +import net.bytebuddy.matcher.ElementMatcher; +import net.bytebuddy.matcher.ElementMatchers; + +public class CamundaTopicSubscriptionMangerInstrumentation implements TypeInstrumentation { + + @Override + public ElementMatcher classLoaderOptimization() { + return hasClassesNamed("org.camunda.bpm.client.topic.impl.TopicSubscriptionManager"); + } + + @Override + public ElementMatcher typeMatcher() { + return named("org.camunda.bpm.client.topic.impl.TopicSubscriptionManager"); + } + + @Override + public void transform(TypeTransformer transformer) { + transformer.applyAdviceToMethod(ElementMatchers.isMethod().and(named("handleExternalTask")), + this.getClass().getName() + "$CamundaTopicSubscriptionMangerAdvice"); + } + + public static class CamundaTopicSubscriptionMangerAdvice { + + @Advice.OnMethodEnter(suppress = Throwable.class) + public static void addTracingEnter(@Advice.FieldValue("typedValues") TypedValues typedValues, + @Advice.Argument(0) ExternalTask externalTask, @Advice.Local("request") CamundaCommonRequest request, + @Advice.Local("otelParentScope") Scope parentScope, @Advice.Local("otelContext") Context context, + @Advice.Local("otelScope") Scope scope) { + + + if (externalTask == null) { + return; + } + + request = new CamundaCommonRequest(); + request.setProcessDefinitionKey(Optional.ofNullable(externalTask.getProcessDefinitionKey())); + request.setProcessInstanceId(Optional.ofNullable(externalTask.getProcessInstanceId())); + request.setTopicName(Optional.ofNullable(externalTask.getTopicName())); + request.setTopicWorkerId(Optional.ofNullable(externalTask.getWorkerId())); + + String id = externalTask.getTopicName() + " " + externalTask.getWorkerId(); + + if (Java8BytecodeBridge.currentContext() == Java8BytecodeBridge.rootContext()) { + //log + } + + ExternalTaskImpl task = (ExternalTaskImpl) externalTask; + + Map variables = task.getVariables(); + + Map wrappedVariables = typedValues.wrapVariables(externalTask, variables); + + task.setReceivedVariableMap(wrappedVariables); + + Context parentContext = getOpentelemetry().getPropagators().getTextMapPropagator() + .extract(Java8BytecodeBridge.currentContext(), externalTask, new CamundaExternalTaskGetter()); + + parentScope = parentContext.makeCurrent(); + + if (getInstumenter().shouldStart(Java8BytecodeBridge.currentContext(), request)) { + context = getInstumenter().start(Java8BytecodeBridge.currentContext(), request); + scope = context.makeCurrent(); + + } + + } + + @Advice.OnMethodExit(onThrowable = Throwable.class, suppress = Throwable.class) + public static void closeTrace(@Advice.Local("otelParentScope") Scope parentScope, + @Advice.Local("request") CamundaCommonRequest request, @Advice.Local("otelContext") Context context, + @Advice.Local("otelScope") Scope scope, @Advice.Thrown Throwable throwable) { + + if (context != null && scope != null) { + getInstumenter().end(context, request, "NA", throwable); + scope.close(); + } + + if (parentScope != null) { + parentScope.close(); + } + + } + } +} From 979c3770c035aaacb42b90f91d2d0ed47f7afc1b Mon Sep 17 00:00:00 2001 From: "Boslet, Cory (cb645j)" Date: Thu, 5 Dec 2024 15:20:11 -0500 Subject: [PATCH 02/23] Add module to parent settings --- settings.gradle.kts | 1 + 1 file changed, 1 insertion(+) diff --git a/settings.gradle.kts b/settings.gradle.kts index 4460bf268d1d..f002914bb531 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -217,6 +217,7 @@ include(":instrumentation:c3p0-0.9:library") include(":instrumentation:c3p0-0.9:testing") include(":instrumentation:camel-2.20:javaagent") include(":instrumentation:camel-2.20:javaagent-unit-tests") +include(":instrumentation:camunda-7.18:javaagent") include(":instrumentation:cassandra:cassandra-3.0:javaagent") include(":instrumentation:cassandra:cassandra-4.0:javaagent") include(":instrumentation:cassandra:cassandra-4.4:javaagent") From 4fbdbf8f0f41a224aa7646ee51bbb15e02b85320 Mon Sep 17 00:00:00 2001 From: "Boslet, Cory (cb645j)" Date: Mon, 9 Dec 2024 14:41:40 -0500 Subject: [PATCH 03/23] Reorganized project structure and fixed gradle settings --- .../javaagent/build.gradle.kts | 3 +-- .../behavior/CamundaBehaviorSingletons.java | 8 ++++---- ...leElementActivityBehaviorInstrumentation.java | 12 ++++++------ ...ndaCallableElementActivityBehaviorModule.java | 7 ++++--- ...aEndEventActivityBehaviorInstrumentation.java | 10 +++++----- .../CamundaEndEventActivityBehaviorModule.java | 7 ++++--- ...ernalTaskActivityBehaviorInstrumentation.java | 16 ++++++++-------- ...amundaExternalTaskActivityBehaviorModule.java | 7 ++++--- ...mundaTaskActivityBehaviorInstrumentation.java | 10 +++++----- .../CamundaTaskActivityBehaviorModule.java | 7 ++++--- ...yncContinuationJobHandlerInstrumentation.java | 10 +++++----- ...CamundaAsyncContinuationJobHandlerModule.java | 7 ++++--- .../camunda/v7_0}/jobs/CamundaJobSingletons.java | 8 ++++---- ...ocessInstantiationBuilderInstrumentation.java | 8 ++++---- ...CamundaProcessInstantiationBuilderModule.java | 7 ++++--- .../processes/CamundaProcessSingletons.java | 8 ++++---- .../v7_0}/task/CamundaTaskSingletons.java | 8 ++++---- .../CamundaTopicSubscriptionManagerModule.java | 7 ++++--- ...daTopicSubscriptionMangerInstrumentation.java | 10 +++++----- .../camunda/camunda-7.0/library/build.gradle.kts | 15 +++++++++++++++ .../behavior/CamundaActivityExecutionGetter.java | 2 +- .../CamundaActivityExecutionLocalSetter.java | 2 +- .../behavior/CamundaActivityExecutionSetter.java | 2 +- .../CamundaBehaviorSpanNameExtractor.java | 4 ++-- .../v7_0}/behavior/CamundaVariableMapSetter.java | 2 +- .../v7_0}/common/CamundaCommonRequest.java | 3 ++- .../CamundaVariableAttributeExtractor.java | 2 +- .../v7_0}/jobs/CamundaExecutionEntityGetter.java | 2 +- .../v7_0}/jobs/CamundaJobSpanNameExtractor.java | 4 ++-- ...amundaActivityInstantiationBuilderSetter.java | 2 +- ...cessInstanceModificationBuilderImpSetter.java | 2 +- .../CamundaProcessSpanNameExtractor.java | 4 ++-- .../v7_0}/task/CamundaExternalTaskGetter.java | 2 +- .../v7_0}/task/CamundaTaskSpanNameExtractor.java | 4 ++-- settings.gradle.kts | 4 +++- 35 files changed, 120 insertions(+), 96 deletions(-) rename instrumentation/camunda/{camunda-7.18 => camunda-7.0}/javaagent/build.gradle.kts (73%) rename instrumentation/camunda/{camunda-7.18/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_18 => camunda-7.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_0}/behavior/CamundaBehaviorSingletons.java (77%) rename instrumentation/camunda/{camunda-7.18/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_18 => camunda-7.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_0}/behavior/CamundaCallableElementActivityBehaviorInstrumentation.java (90%) rename instrumentation/camunda/{camunda-7.18/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_18 => camunda-7.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_0}/behavior/CamundaCallableElementActivityBehaviorModule.java (86%) rename instrumentation/camunda/{camunda-7.18/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_18 => camunda-7.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_0}/behavior/CamundaEndEventActivityBehaviorInstrumentation.java (92%) rename instrumentation/camunda/{camunda-7.18/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_18 => camunda-7.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_0}/behavior/CamundaEndEventActivityBehaviorModule.java (84%) rename instrumentation/camunda/{camunda-7.18/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_18 => camunda-7.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_0}/behavior/CamundaExternalTaskActivityBehaviorInstrumentation.java (84%) rename instrumentation/camunda/{camunda-7.18/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_18 => camunda-7.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_0}/behavior/CamundaExternalTaskActivityBehaviorModule.java (86%) rename instrumentation/camunda/{camunda-7.18/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_18 => camunda-7.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_0}/behavior/CamundaTaskActivityBehaviorInstrumentation.java (91%) rename instrumentation/camunda/{camunda-7.18/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_18 => camunda-7.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_0}/behavior/CamundaTaskActivityBehaviorModule.java (86%) rename instrumentation/camunda/{camunda-7.18/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_18 => camunda-7.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_0}/jobs/CamundaAsyncContinuationJobHandlerInstrumentation.java (92%) rename instrumentation/camunda/{camunda-7.18/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_18 => camunda-7.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_0}/jobs/CamundaAsyncContinuationJobHandlerModule.java (87%) rename instrumentation/camunda/{camunda-7.18/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_18 => camunda-7.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_0}/jobs/CamundaJobSingletons.java (74%) rename instrumentation/camunda/{camunda-7.18/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_18 => camunda-7.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_0}/processes/CamundaProcessInstantiationBuilderInstrumentation.java (90%) rename instrumentation/camunda/{camunda-7.18/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_18 => camunda-7.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_0}/processes/CamundaProcessInstantiationBuilderModule.java (86%) rename instrumentation/camunda/{camunda-7.18/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_18 => camunda-7.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_0}/processes/CamundaProcessSingletons.java (74%) rename instrumentation/camunda/{camunda-7.18/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_18 => camunda-7.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_0}/task/CamundaTaskSingletons.java (72%) rename instrumentation/camunda/{camunda-7.18/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_18 => camunda-7.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_0}/task/CamundaTopicSubscriptionManagerModule.java (87%) rename instrumentation/camunda/{camunda-7.18/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_18 => camunda-7.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_0}/task/CamundaTopicSubscriptionMangerInstrumentation.java (91%) create mode 100644 instrumentation/camunda/camunda-7.0/library/build.gradle.kts rename instrumentation/camunda/{camunda-7.18/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_18 => camunda-7.0/library/src/main/java/io/opentelemetry/instrumentation/camunda/v7_0}/behavior/CamundaActivityExecutionGetter.java (87%) rename instrumentation/camunda/{camunda-7.18/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_18 => camunda-7.0/library/src/main/java/io/opentelemetry/instrumentation/camunda/v7_0}/behavior/CamundaActivityExecutionLocalSetter.java (82%) rename instrumentation/camunda/{camunda-7.18/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_18 => camunda-7.0/library/src/main/java/io/opentelemetry/instrumentation/camunda/v7_0}/behavior/CamundaActivityExecutionSetter.java (82%) rename instrumentation/camunda/{camunda-7.18/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_18 => camunda-7.0/library/src/main/java/io/opentelemetry/instrumentation/camunda/v7_0}/behavior/CamundaBehaviorSpanNameExtractor.java (79%) rename instrumentation/camunda/{camunda-7.18/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_18 => camunda-7.0/library/src/main/java/io/opentelemetry/instrumentation/camunda/v7_0}/behavior/CamundaVariableMapSetter.java (80%) rename instrumentation/camunda/{camunda-7.18/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_18 => camunda-7.0/library/src/main/java/io/opentelemetry/instrumentation/camunda/v7_0}/common/CamundaCommonRequest.java (96%) rename instrumentation/camunda/{camunda-7.18/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_18 => camunda-7.0/library/src/main/java/io/opentelemetry/instrumentation/camunda/v7_0}/common/CamundaVariableAttributeExtractor.java (94%) rename instrumentation/camunda/{camunda-7.18/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_18 => camunda-7.0/library/src/main/java/io/opentelemetry/instrumentation/camunda/v7_0}/jobs/CamundaExecutionEntityGetter.java (87%) rename instrumentation/camunda/{camunda-7.18/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_18 => camunda-7.0/library/src/main/java/io/opentelemetry/instrumentation/camunda/v7_0}/jobs/CamundaJobSpanNameExtractor.java (67%) rename instrumentation/camunda/{camunda-7.18/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_18 => camunda-7.0/library/src/main/java/io/opentelemetry/instrumentation/camunda/v7_0}/processes/CamundaActivityInstantiationBuilderSetter.java (85%) rename instrumentation/camunda/{camunda-7.18/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_18 => camunda-7.0/library/src/main/java/io/opentelemetry/instrumentation/camunda/v7_0}/processes/CamundaProcessInstanceModificationBuilderImpSetter.java (86%) rename instrumentation/camunda/{camunda-7.18/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_18 => camunda-7.0/library/src/main/java/io/opentelemetry/instrumentation/camunda/v7_0}/processes/CamundaProcessSpanNameExtractor.java (63%) rename instrumentation/camunda/{camunda-7.18/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_18 => camunda-7.0/library/src/main/java/io/opentelemetry/instrumentation/camunda/v7_0}/task/CamundaExternalTaskGetter.java (87%) rename instrumentation/camunda/{camunda-7.18/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_18 => camunda-7.0/library/src/main/java/io/opentelemetry/instrumentation/camunda/v7_0}/task/CamundaTaskSpanNameExtractor.java (65%) diff --git a/instrumentation/camunda/camunda-7.18/javaagent/build.gradle.kts b/instrumentation/camunda/camunda-7.0/javaagent/build.gradle.kts similarity index 73% rename from instrumentation/camunda/camunda-7.18/javaagent/build.gradle.kts rename to instrumentation/camunda/camunda-7.0/javaagent/build.gradle.kts index 66c0ea3c8e0f..d59d0cec75a6 100644 --- a/instrumentation/camunda/camunda-7.18/javaagent/build.gradle.kts +++ b/instrumentation/camunda/camunda-7.0/javaagent/build.gradle.kts @@ -14,8 +14,7 @@ muzzle { dependencies { - implementation("org.camunda.bpm:camunda-engine:7.18.0") - implementation("org.camunda.bpm:camunda-external-task-client:7.18.0") + implementation(project(":instrumentation:camunda:camunda-7.0:library")) api("com.google.auto.value:auto-value-annotations:1.6") annotationProcessor("com.google.auto.value:auto-value:1.6") diff --git a/instrumentation/camunda/camunda-7.18/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_18/behavior/CamundaBehaviorSingletons.java b/instrumentation/camunda/camunda-7.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_0/behavior/CamundaBehaviorSingletons.java similarity index 77% rename from instrumentation/camunda/camunda-7.18/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_18/behavior/CamundaBehaviorSingletons.java rename to instrumentation/camunda/camunda-7.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_0/behavior/CamundaBehaviorSingletons.java index 1a745dab6eb3..a0e30ddc06ee 100644 --- a/instrumentation/camunda/camunda-7.18/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_18/behavior/CamundaBehaviorSingletons.java +++ b/instrumentation/camunda/camunda-7.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_0/behavior/CamundaBehaviorSingletons.java @@ -1,8 +1,8 @@ -package io.opentelemetry.javaagent.instrumentation.camunda.v7_18.behavior; +package io.opentelemetry.javaagent.instrumentation.camunda.v7_0.behavior; -import io.opentelemetry.javaagent.camunda.v7_18.behavior.CamundaBehaviorSpanNameExtractor; -import io.opentelemetry.javaagent.camunda.v7_18.common.CamundaCommonRequest; -import io.opentelemetry.javaagent.camunda.v7_18.common.CamundaVariableAttributeExtractor; +import io.opentelemetry.camunda.v7_0.behavior.CamundaBehaviorSpanNameExtractor; +import io.opentelemetry.camunda.v7_0.common.CamundaCommonRequest; +import io.opentelemetry.camunda.v7_0.common.CamundaVariableAttributeExtractor; import io.opentelemetry.api.GlobalOpenTelemetry; import io.opentelemetry.api.OpenTelemetry; diff --git a/instrumentation/camunda/camunda-7.18/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_18/behavior/CamundaCallableElementActivityBehaviorInstrumentation.java b/instrumentation/camunda/camunda-7.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_0/behavior/CamundaCallableElementActivityBehaviorInstrumentation.java similarity index 90% rename from instrumentation/camunda/camunda-7.18/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_18/behavior/CamundaCallableElementActivityBehaviorInstrumentation.java rename to instrumentation/camunda/camunda-7.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_0/behavior/CamundaCallableElementActivityBehaviorInstrumentation.java index 326b85da7dfa..a8f5d2f0d211 100644 --- a/instrumentation/camunda/camunda-7.18/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_18/behavior/CamundaCallableElementActivityBehaviorInstrumentation.java +++ b/instrumentation/camunda/camunda-7.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_0/behavior/CamundaCallableElementActivityBehaviorInstrumentation.java @@ -1,7 +1,7 @@ -package io.opentelemetry.javaagent.instrumentation.camunda.v7_18.behavior; +package io.opentelemetry.javaagent.instrumentation.camunda.v7_0.behavior; -import static io.opentelemetry.javaagent.instrumentation.camunda.v7_18.behavior.CamundaBehaviorSingletons.getInstumenter; -import static io.opentelemetry.javaagent.instrumentation.camunda.v7_18.behavior.CamundaBehaviorSingletons.getOpentelemetry; +import static io.opentelemetry.javaagent.instrumentation.camunda.v7_0.behavior.CamundaBehaviorSingletons.getInstumenter; +import static io.opentelemetry.javaagent.instrumentation.camunda.v7_0.behavior.CamundaBehaviorSingletons.getOpentelemetry; import static io.opentelemetry.javaagent.extension.matcher.AgentElementMatchers.hasClassesNamed; import static io.opentelemetry.javaagent.extension.matcher.AgentElementMatchers.hasSuperType; import static net.bytebuddy.matcher.ElementMatchers.named; @@ -13,9 +13,9 @@ import java.util.logging.Level; -import io.opentelemetry.javaagent.camunda.v7_18.behavior.CamundaActivityExecutionGetter; -import io.opentelemetry.javaagent.camunda.v7_18.behavior.CamundaVariableMapSetter; -import io.opentelemetry.javaagent.camunda.v7_18.common.CamundaCommonRequest; +import io.opentelemetry.javaagent.camunda.v7_0.behavior.CamundaActivityExecutionGetter; +import io.opentelemetry.javaagent.camunda.v7_0.behavior.CamundaVariableMapSetter; +import io.opentelemetry.javaagent.camunda.v7_0.common.CamundaCommonRequest; import io.opentelemetry.api.trace.SpanContext; import io.opentelemetry.context.Context; diff --git a/instrumentation/camunda/camunda-7.18/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_18/behavior/CamundaCallableElementActivityBehaviorModule.java b/instrumentation/camunda/camunda-7.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_0/behavior/CamundaCallableElementActivityBehaviorModule.java similarity index 86% rename from instrumentation/camunda/camunda-7.18/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_18/behavior/CamundaCallableElementActivityBehaviorModule.java rename to instrumentation/camunda/camunda-7.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_0/behavior/CamundaCallableElementActivityBehaviorModule.java index 5acddb198dc6..8bac8a9f1a4e 100644 --- a/instrumentation/camunda/camunda-7.18/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_18/behavior/CamundaCallableElementActivityBehaviorModule.java +++ b/instrumentation/camunda/camunda-7.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_0/behavior/CamundaCallableElementActivityBehaviorModule.java @@ -1,4 +1,4 @@ -package com.att.sre.otel.javaagent.instrumentation.camunda.v7_18.behavior; +package io.opentelemetry.javaagent.instrumentation.camunda.v7_0.behavior; import static io.opentelemetry.javaagent.extension.matcher.AgentElementMatchers.hasClassesNamed; @@ -35,8 +35,9 @@ public ElementMatcher.Junction classLoaderMatcher() { return hasClassesNamed("org.camunda.bpm.engine.impl.bpmn.behavior.CallableElementActivityBehavior"); } - String[] helperClassnames = { "io.opentelemetry.javaagent.instrumentation.camunda.v7_18.behavior", - "io.opentelemetry.javaagent.instrumentation.camunda.v7_18.common" }; + String[] helperClassnames = { "io.opentelemetry.javaagent.instrumentation.camunda.v7_0.behavior", + "io.opentelemetry.instrumentation.camunda.v7_0.behavior", + "io.opentelemetry.instrumentation.camunda.v7_0.common" }; @Override public boolean isHelperClass(String classname) { diff --git a/instrumentation/camunda/camunda-7.18/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_18/behavior/CamundaEndEventActivityBehaviorInstrumentation.java b/instrumentation/camunda/camunda-7.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_0/behavior/CamundaEndEventActivityBehaviorInstrumentation.java similarity index 92% rename from instrumentation/camunda/camunda-7.18/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_18/behavior/CamundaEndEventActivityBehaviorInstrumentation.java rename to instrumentation/camunda/camunda-7.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_0/behavior/CamundaEndEventActivityBehaviorInstrumentation.java index 067c42c67396..0e31c1cf3a37 100644 --- a/instrumentation/camunda/camunda-7.18/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_18/behavior/CamundaEndEventActivityBehaviorInstrumentation.java +++ b/instrumentation/camunda/camunda-7.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_0/behavior/CamundaEndEventActivityBehaviorInstrumentation.java @@ -1,7 +1,7 @@ -package io.opentelemetry.javaagent.instrumentation.camunda.v7_18.behavior; +package io.opentelemetry.javaagent.instrumentation.camunda.v7_0.behavior; -import static io.opentelemetry.javaagent.instrumentation.camunda.v7_18.behavior.CamundaBehaviorSingletons.getInstumenter; -import static io.opentelemetry.javaagent.instrumentation.camunda.v7_18.behavior.CamundaBehaviorSingletons.getOpentelemetry; +import static io.opentelemetry.javaagent.instrumentation.camunda.v7_0.behavior.CamundaBehaviorSingletons.getInstumenter; +import static io.opentelemetry.javaagent.instrumentation.camunda.v7_0.behavior.CamundaBehaviorSingletons.getOpentelemetry; import static io.opentelemetry.javaagent.extension.matcher.AgentElementMatchers.hasClassesNamed; import static net.bytebuddy.matcher.ElementMatchers.named; import static net.bytebuddy.matcher.ElementMatchers.anyOf; @@ -15,8 +15,8 @@ import org.camunda.bpm.model.bpmn.instance.EventDefinition; import org.camunda.bpm.model.bpmn.instance.TerminateEventDefinition; -import io.opentelemetry.javaagent.camunda.v7_18.behavior.CamundaActivityExecutionGetter; -import io.opentelemetry.javaagent.camunda.v7_18.common.CamundaCommonRequest; +import io.opentelemetry.camunda.v7_0.behavior.CamundaActivityExecutionGetter; +import io.opentelemetry.camunda.v7_0.common.CamundaCommonRequest; import io.opentelemetry.context.Context; import io.opentelemetry.context.Scope; diff --git a/instrumentation/camunda/camunda-7.18/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_18/behavior/CamundaEndEventActivityBehaviorModule.java b/instrumentation/camunda/camunda-7.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_0/behavior/CamundaEndEventActivityBehaviorModule.java similarity index 84% rename from instrumentation/camunda/camunda-7.18/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_18/behavior/CamundaEndEventActivityBehaviorModule.java rename to instrumentation/camunda/camunda-7.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_0/behavior/CamundaEndEventActivityBehaviorModule.java index 26a81dbcd2ed..f8d88c3430f1 100644 --- a/instrumentation/camunda/camunda-7.18/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_18/behavior/CamundaEndEventActivityBehaviorModule.java +++ b/instrumentation/camunda/camunda-7.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_0/behavior/CamundaEndEventActivityBehaviorModule.java @@ -1,4 +1,4 @@ -package com.att.sre.otel.javaagent.instrumentation.camunda.v7_18.behavior; +package io.opentelemetry.javaagent.instrumentation.camunda.v7_0.behavior; import static io.opentelemetry.javaagent.extension.matcher.AgentElementMatchers.hasClassesNamed; @@ -37,8 +37,9 @@ public ElementMatcher.Junction classLoaderMatcher() { "org.camunda.bpm.engine.impl.bpmn.behavior.ErrorEndEventActivityBehavior"); } - String[] helperClassnames = { "com.att.sre.otel.javaagent.instrumentation.camunda.v7_18.behavior", - "com.att.sre.otel.javaagent.instrumentation.camunda.v7_18.common" }; + String[] helperClassnames = { "io.opentelemetry.javaagent.instrumentation.camunda.v7_0.behavior", + "io.opentelemetry.instrumentation.camunda.v7_0.behavior", + "io.opentelemetry.instrumentation.camunda.v7_0.common" }; @Override public boolean isHelperClass(String classname) { diff --git a/instrumentation/camunda/camunda-7.18/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_18/behavior/CamundaExternalTaskActivityBehaviorInstrumentation.java b/instrumentation/camunda/camunda-7.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_0/behavior/CamundaExternalTaskActivityBehaviorInstrumentation.java similarity index 84% rename from instrumentation/camunda/camunda-7.18/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_18/behavior/CamundaExternalTaskActivityBehaviorInstrumentation.java rename to instrumentation/camunda/camunda-7.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_0/behavior/CamundaExternalTaskActivityBehaviorInstrumentation.java index 83f6c29175ba..b6acff89e58a 100644 --- a/instrumentation/camunda/camunda-7.18/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_18/behavior/CamundaExternalTaskActivityBehaviorInstrumentation.java +++ b/instrumentation/camunda/camunda-7.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_0/behavior/CamundaExternalTaskActivityBehaviorInstrumentation.java @@ -1,7 +1,7 @@ -package com.att.sre.otel.javaagent.instrumentation.camunda.v7_18.behavior; +package io.opentelemetry.javaagent.instrumentation.camunda.v7_0.behavior; -import static com.att.sre.otel.javaagent.instrumentation.camunda.v7_18.behavior.CamundaBehaviorSingletons.getInstumenter; -import static com.att.sre.otel.javaagent.instrumentation.camunda.v7_18.behavior.CamundaBehaviorSingletons.getOpentelemetry; +import static io.opentelemetry.javaagent.instrumentation.camunda.v7_0.behavior.CamundaBehaviorSingletons.getInstumenter; +import static io.opentelemetry.javaagent.instrumentation.camunda.v7_0.behavior.CamundaBehaviorSingletons.getOpentelemetry; import static io.opentelemetry.javaagent.extension.matcher.AgentElementMatchers.hasClassesNamed; import static net.bytebuddy.matcher.ElementMatchers.named; @@ -12,11 +12,11 @@ import org.camunda.bpm.engine.impl.pvm.delegate.ActivityExecution; -import io.opentelemetry.javaagent.camunda.v7_18.behavior.CamundaActivityExecutionGetter; -import io.opentelemetry.javaagent.camunda.v7_18.behavior.CamundaActivityExecutionLocalSetter; -import io.opentelemetry.javaagent.camunda.v7_18.behavior.CamundaActivityExecutionSetter; -import io.opentelemetry.javaagent.camunda.v7_18.behavior.CamundaVariableMapSetter; -import io.opentelemetry.javaagent.camunda.v7_18.common.CamundaCommonRequest; +import io.opentelemetry.camunda.v7_0.behavior.CamundaActivityExecutionGetter; +import io.opentelemetry.camunda.v7_0.behavior.CamundaActivityExecutionLocalSetter; +import io.opentelemetry.camunda.v7_0.behavior.CamundaActivityExecutionSetter; +import io.opentelemetry.camunda.v7_0.behavior.CamundaVariableMapSetter; +import io.opentelemetry.camunda.v7_0.common.CamundaCommonRequest; import io.opentelemetry.api.trace.SpanContext; import io.opentelemetry.context.Context; diff --git a/instrumentation/camunda/camunda-7.18/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_18/behavior/CamundaExternalTaskActivityBehaviorModule.java b/instrumentation/camunda/camunda-7.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_0/behavior/CamundaExternalTaskActivityBehaviorModule.java similarity index 86% rename from instrumentation/camunda/camunda-7.18/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_18/behavior/CamundaExternalTaskActivityBehaviorModule.java rename to instrumentation/camunda/camunda-7.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_0/behavior/CamundaExternalTaskActivityBehaviorModule.java index 31cd2bcc2303..a5d9f3ea9732 100644 --- a/instrumentation/camunda/camunda-7.18/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_18/behavior/CamundaExternalTaskActivityBehaviorModule.java +++ b/instrumentation/camunda/camunda-7.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_0/behavior/CamundaExternalTaskActivityBehaviorModule.java @@ -1,4 +1,4 @@ -package io.opentelemetry.javaagent.instrumentation.camunda.v7_18.behavior; +package io.opentelemetry.javaagent.instrumentation.camunda.v7_0.behavior; import static io.opentelemetry.javaagent.extension.matcher.AgentElementMatchers.hasClassesNamed; @@ -35,8 +35,9 @@ public ElementMatcher.Junction classLoaderMatcher() { return hasClassesNamed("org.camunda.bpm.engine.impl.bpmn.behavior.ExternalTaskActivityBehavior"); } - String[] helperClassnames = { "io.opentelemetry.javaagent.instrumentation.camunda.v7_18.behavior", - "io.opentelemetry.javaagent.instrumentation.camunda.v7_18.common" }; + String[] helperClassnames = { "io.opentelemetry.javaagent.instrumentation.camunda.v7_0.behavior", + "io.opentelemetry.instrumentation.camunda.v7_0.behavior", + "io.opentelemetry.instrumentation.camunda.v7_0.common" }; @Override public boolean isHelperClass(String classname) { diff --git a/instrumentation/camunda/camunda-7.18/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_18/behavior/CamundaTaskActivityBehaviorInstrumentation.java b/instrumentation/camunda/camunda-7.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_0/behavior/CamundaTaskActivityBehaviorInstrumentation.java similarity index 91% rename from instrumentation/camunda/camunda-7.18/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_18/behavior/CamundaTaskActivityBehaviorInstrumentation.java rename to instrumentation/camunda/camunda-7.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_0/behavior/CamundaTaskActivityBehaviorInstrumentation.java index 1c7dd80130da..acd1bab3e285 100644 --- a/instrumentation/camunda/camunda-7.18/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_18/behavior/CamundaTaskActivityBehaviorInstrumentation.java +++ b/instrumentation/camunda/camunda-7.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_0/behavior/CamundaTaskActivityBehaviorInstrumentation.java @@ -1,7 +1,7 @@ -package io.opentelemetry.javaagent.instrumentation.camunda.v7_18.behavior; +package io.opentelemetry.javaagent.instrumentation.camunda.v7_0.behavior; -import static io.opentelemetry.javaagent.instrumentation.camunda.v7_18.behavior.CamundaBehaviorSingletons.getInstumenter; -import static io.opentelemetry.javaagent.instrumentation.camunda.v7_18.behavior.CamundaBehaviorSingletons.getOpentelemetry; +import static io.opentelemetry.javaagent.instrumentation.camunda.v7_0.behavior.CamundaBehaviorSingletons.getInstumenter; +import static io.opentelemetry.javaagent.instrumentation.camunda.v7_0.behavior.CamundaBehaviorSingletons.getOpentelemetry; import static io.opentelemetry.javaagent.extension.matcher.AgentElementMatchers.hasClassesNamed; import static io.opentelemetry.javaagent.extension.matcher.AgentElementMatchers.hasSuperType; import static net.bytebuddy.matcher.ElementMatchers.named; @@ -11,8 +11,8 @@ import org.camunda.bpm.engine.impl.pvm.delegate.ActivityExecution; -import io.opentelemetry.javaagent.camunda.v7_18.behavior.CamundaActivityExecutionGetter; -import io.opentelemetry.javaagent.camunda.v7_18.common.CamundaCommonRequest; +import io.opentelemetry.camunda.v7_0.behavior.CamundaActivityExecutionGetter; +import io.opentelemetry.camunda.v7_0.common.CamundaCommonRequest; import io.opentelemetry.api.trace.SpanContext; import io.opentelemetry.context.Context; diff --git a/instrumentation/camunda/camunda-7.18/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_18/behavior/CamundaTaskActivityBehaviorModule.java b/instrumentation/camunda/camunda-7.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_0/behavior/CamundaTaskActivityBehaviorModule.java similarity index 86% rename from instrumentation/camunda/camunda-7.18/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_18/behavior/CamundaTaskActivityBehaviorModule.java rename to instrumentation/camunda/camunda-7.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_0/behavior/CamundaTaskActivityBehaviorModule.java index a29e4e766e42..d4c09a403295 100644 --- a/instrumentation/camunda/camunda-7.18/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_18/behavior/CamundaTaskActivityBehaviorModule.java +++ b/instrumentation/camunda/camunda-7.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_0/behavior/CamundaTaskActivityBehaviorModule.java @@ -1,4 +1,4 @@ -package io.opentelemetry.javaagent.instrumentation.camunda.v7_18.behavior; +package io.opentelemetry.javaagent.instrumentation.camunda.v7_0.behavior; import static io.opentelemetry.javaagent.extension.matcher.AgentElementMatchers.hasClassesNamed; @@ -35,8 +35,9 @@ public ElementMatcher.Junction classLoaderMatcher() { return hasClassesNamed("org.camunda.bpm.engine.impl.bpmn.behavior.TaskActivityBehavior"); } - String[] helperClassnames = { "io.opentelemetry.javaagent.instrumentation.camunda.v7_18.behavior", - "io.opentelemetry.javaagent.instrumentation.camunda.v7_18.common"}; + String[] helperClassnames = { "io.opentelemetry.javaagent.instrumentation.camunda.v7_0.behavior", + "io.opentelemetry.instrumentation.camunda.v7_0.behavior", + "io.opentelemetry.instrumentation.camunda.v7_0.common"}; @Override public boolean isHelperClass(String classname) { diff --git a/instrumentation/camunda/camunda-7.18/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_18/jobs/CamundaAsyncContinuationJobHandlerInstrumentation.java b/instrumentation/camunda/camunda-7.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_0/jobs/CamundaAsyncContinuationJobHandlerInstrumentation.java similarity index 92% rename from instrumentation/camunda/camunda-7.18/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_18/jobs/CamundaAsyncContinuationJobHandlerInstrumentation.java rename to instrumentation/camunda/camunda-7.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_0/jobs/CamundaAsyncContinuationJobHandlerInstrumentation.java index 2fc9b52e8216..00aef60740ff 100644 --- a/instrumentation/camunda/camunda-7.18/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_18/jobs/CamundaAsyncContinuationJobHandlerInstrumentation.java +++ b/instrumentation/camunda/camunda-7.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_0/jobs/CamundaAsyncContinuationJobHandlerInstrumentation.java @@ -1,16 +1,16 @@ -package io.opentelemetry.javaagent.instrumentation.camunda.v7_18.jobs; +package io.opentelemetry.javaagent.instrumentation.camunda.v7_0.jobs; import static io.opentelemetry.javaagent.extension.matcher.AgentElementMatchers.hasClassesNamed; import java.util.Optional; -import static io.opentelemetry.javaagent.instrumentation.camunda.v7_18.jobs.CamundaJobSingletons.getInstumenter; -import static io.opentelemetry.javaagent.instrumentation.camunda.v7_18.jobs.CamundaJobSingletons.getOpentelemetry; +import static io.opentelemetry.javaagent.instrumentation.camunda.v7_0.jobs.CamundaJobSingletons.getInstumenter; +import static io.opentelemetry.javaagent.instrumentation.camunda.v7_0.jobs.CamundaJobSingletons.getOpentelemetry; import org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity; -import io.opentelemetry.javaagent.instrumentation.camunda.v7_18.common.CamundaCommonRequest; -import io.opentelemetry.javaagent.instrumentation.camunda.v7_18.jobs.CamundaExecutionEntityGetter; +import io.opentelemetry.instrumentation.camunda.v7_0.common.CamundaCommonRequest; +import io.opentelemetry.instrumentation.camunda.v7_0.jobs.CamundaExecutionEntityGetter; import io.opentelemetry.api.trace.SpanContext; import io.opentelemetry.context.Context; diff --git a/instrumentation/camunda/camunda-7.18/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_18/jobs/CamundaAsyncContinuationJobHandlerModule.java b/instrumentation/camunda/camunda-7.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_0/jobs/CamundaAsyncContinuationJobHandlerModule.java similarity index 87% rename from instrumentation/camunda/camunda-7.18/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_18/jobs/CamundaAsyncContinuationJobHandlerModule.java rename to instrumentation/camunda/camunda-7.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_0/jobs/CamundaAsyncContinuationJobHandlerModule.java index 63b5f8e9a595..0ae39888ac80 100644 --- a/instrumentation/camunda/camunda-7.18/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_18/jobs/CamundaAsyncContinuationJobHandlerModule.java +++ b/instrumentation/camunda/camunda-7.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_0/jobs/CamundaAsyncContinuationJobHandlerModule.java @@ -1,4 +1,4 @@ -package io.opentelemetry.javaagent.instrumentation.camunda.v7_18.jobs; +package io.opentelemetry.javaagent.instrumentation.camunda.v7_0.jobs; import static io.opentelemetry.javaagent.extension.matcher.AgentElementMatchers.hasClassesNamed; @@ -35,8 +35,9 @@ public ElementMatcher.Junction classLoaderMatcher() { return hasClassesNamed("org.camunda.bpm.engine.impl.jobexecutor.AsyncContinuationJobHandler"); } - String[] helperClassnames = { "io.opentelemetry.javaagent.instrumentation.camunda.v7_18.jobs", - "io.opentelemetry.javaagent.instrumentation.camunda.v7_18.common"}; + String[] helperClassnames = { "io.opentelemetry.javaagent.instrumentation.camunda.v7_0.jobs", + "io.opentelemetry.instrumentation.camunda.v7_0.jobs", + "io.opentelemetry.instrumentation.camunda.v7_0.common"}; @Override public boolean isHelperClass(String classname) { diff --git a/instrumentation/camunda/camunda-7.18/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_18/jobs/CamundaJobSingletons.java b/instrumentation/camunda/camunda-7.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_0/jobs/CamundaJobSingletons.java similarity index 74% rename from instrumentation/camunda/camunda-7.18/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_18/jobs/CamundaJobSingletons.java rename to instrumentation/camunda/camunda-7.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_0/jobs/CamundaJobSingletons.java index f640c38b2d18..1c643c5aaa5e 100644 --- a/instrumentation/camunda/camunda-7.18/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_18/jobs/CamundaJobSingletons.java +++ b/instrumentation/camunda/camunda-7.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_0/jobs/CamundaJobSingletons.java @@ -1,10 +1,10 @@ -package io.opentelemetry.javaagent.instrumentation.camunda.v7_18.jobs; +package io.opentelemetry.javaagent.instrumentation.camunda.v7_0.jobs; import org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity; -import io.opentelemetry.javaagent.instrumentation.camunda.v7_18.common.CamundaCommonRequest; -import io.opentelemetry.javaagent.instrumentation.camunda.v7_18.common.CamundaVariableAttributeExtractor; -import io.opentelemetry.javaagent.instrumentation.camunda.v7_18.jobs.CamundaJobSpanNameExtractor; +import io.opentelemetry.instrumentation.camunda.v7_0.common.CamundaCommonRequest; +import io.opentelemetry.instrumentation.camunda.v7_0.common.CamundaVariableAttributeExtractor; +import io.opentelemetry.instrumentation.camunda.v7_0.jobs.CamundaJobSpanNameExtractor; import io.opentelemetry.api.GlobalOpenTelemetry; import io.opentelemetry.api.OpenTelemetry; diff --git a/instrumentation/camunda/camunda-7.18/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_18/processes/CamundaProcessInstantiationBuilderInstrumentation.java b/instrumentation/camunda/camunda-7.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_0/processes/CamundaProcessInstantiationBuilderInstrumentation.java similarity index 90% rename from instrumentation/camunda/camunda-7.18/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_18/processes/CamundaProcessInstantiationBuilderInstrumentation.java rename to instrumentation/camunda/camunda-7.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_0/processes/CamundaProcessInstantiationBuilderInstrumentation.java index 55a916e9c071..f69c9536f0b6 100644 --- a/instrumentation/camunda/camunda-7.18/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_18/processes/CamundaProcessInstantiationBuilderInstrumentation.java +++ b/instrumentation/camunda/camunda-7.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_0/processes/CamundaProcessInstantiationBuilderInstrumentation.java @@ -1,4 +1,4 @@ -package io.opentelemetry.javaagent.instrumentation.camunda.v7_18.processes; +package io.opentelemetry.javaagent.instrumentation.camunda.v7_0.processes; import static io.opentelemetry.javaagent.extension.matcher.AgentElementMatchers.hasClassesNamed; import static io.opentelemetry.javaagent.extension.matcher.AgentElementMatchers.hasSuperType; @@ -7,9 +7,9 @@ import java.util.Optional; -import io.opentelemetry.javaagent.instrumentation.camunda.v7_18.common.CamundaCommonRequest; -import io.opentelemetry.javaagent.instrumentation.camunda.v7_18.processes.CamundaActivityInstantiationBuilderSetter; -import io.opentelemetry.javaagent.instrumentation.camunda.v7_18.processes.CamundaProcessSingletons; +import io.opentelemetry.instrumentation.camunda.v7_0.common.CamundaCommonRequest; +import io.opentelemetry.instrumentation.camunda.v7_0.processes.CamundaActivityInstantiationBuilderSetter; +import io.opentelemetry.javaagent.instrumentation.camunda.v7_0.processes.CamundaProcessSingletons; import org.camunda.bpm.engine.impl.ProcessInstanceModificationBuilderImpl; import org.camunda.bpm.engine.runtime.ProcessInstance; diff --git a/instrumentation/camunda/camunda-7.18/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_18/processes/CamundaProcessInstantiationBuilderModule.java b/instrumentation/camunda/camunda-7.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_0/processes/CamundaProcessInstantiationBuilderModule.java similarity index 86% rename from instrumentation/camunda/camunda-7.18/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_18/processes/CamundaProcessInstantiationBuilderModule.java rename to instrumentation/camunda/camunda-7.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_0/processes/CamundaProcessInstantiationBuilderModule.java index 7472cb4fe233..b8e7c828d787 100644 --- a/instrumentation/camunda/camunda-7.18/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_18/processes/CamundaProcessInstantiationBuilderModule.java +++ b/instrumentation/camunda/camunda-7.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_0/processes/CamundaProcessInstantiationBuilderModule.java @@ -1,4 +1,4 @@ -package io.opentelemetry.javaagent.instrumentation.camunda.v7_18.processes; +package io.opentelemetry.javaagent.instrumentation.camunda.v7_0.processes; import static io.opentelemetry.javaagent.extension.matcher.AgentElementMatchers.hasClassesNamed; @@ -37,8 +37,9 @@ public ElementMatcher.Junction classLoaderMatcher() { return hasClassesNamed("org.camunda.bpm.engine.runtime.ProcessInstantiationBuilder"); } - String[] helperClassnames = { "io.opentelemetry.javaagent.instrumentation.camunda.v7_18.processes", - "io.opentelemetry.javaagent.instrumentation.camunda.v7_18.common" }; + String[] helperClassnames = { "io.opentelemetry.javaagent.instrumentation.camunda.v7_0.processes", + "io.opentelemetry.instrumentation.camunda.v7_0.processes", + "io.opentelemetry.instrumentation.camunda.v7_0.common" }; @Override public boolean isHelperClass(String classname) { diff --git a/instrumentation/camunda/camunda-7.18/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_18/processes/CamundaProcessSingletons.java b/instrumentation/camunda/camunda-7.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_0/processes/CamundaProcessSingletons.java similarity index 74% rename from instrumentation/camunda/camunda-7.18/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_18/processes/CamundaProcessSingletons.java rename to instrumentation/camunda/camunda-7.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_0/processes/CamundaProcessSingletons.java index a1e6f4e0b175..93c38999391d 100644 --- a/instrumentation/camunda/camunda-7.18/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_18/processes/CamundaProcessSingletons.java +++ b/instrumentation/camunda/camunda-7.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_0/processes/CamundaProcessSingletons.java @@ -1,8 +1,8 @@ -package io.opentelemetry.javaagent.instrumentation.camunda.v7_18.processes; +package io.opentelemetry.javaagent.instrumentation.camunda.v7_0.processes; -import io.opentelemetry.javaagent.instrumentation.camunda.v7_18.common.CamundaCommonRequest; -import io.opentelemetry.javaagent.instrumentation.camunda.v7_18.common.CamundaVariableAttributeExtractor; -import io.opentelemetry.javaagent.instrumentation.camunda.v7_18.processes.CamundaProcessSpanNameExtractor; +import io.opentelemetry.instrumentation.camunda.v7_0.common.CamundaCommonRequest; +import io.opentelemetry.instrumentation.camunda.v7_0.common.CamundaVariableAttributeExtractor; +import io.opentelemetry.instrumentation.camunda.v7_0.processes.CamundaProcessSpanNameExtractor; import io.opentelemetry.api.GlobalOpenTelemetry; import io.opentelemetry.api.OpenTelemetry; diff --git a/instrumentation/camunda/camunda-7.18/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_18/task/CamundaTaskSingletons.java b/instrumentation/camunda/camunda-7.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_0/task/CamundaTaskSingletons.java similarity index 72% rename from instrumentation/camunda/camunda-7.18/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_18/task/CamundaTaskSingletons.java rename to instrumentation/camunda/camunda-7.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_0/task/CamundaTaskSingletons.java index fffbc1f9a4dc..eec56ed42788 100644 --- a/instrumentation/camunda/camunda-7.18/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_18/task/CamundaTaskSingletons.java +++ b/instrumentation/camunda/camunda-7.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_0/task/CamundaTaskSingletons.java @@ -1,8 +1,8 @@ -package io.opentelemetry.javaagent.instrumentation.camunda.v7_18.task; +package io.opentelemetry.javaagent.instrumentation.camunda.v7_0.task; -import io.opentelemetry.javaagent.instrumentation.camunda.v7_18.common.CamundaCommonRequest; -import io.opentelemetry.javaagent.instrumentation.camunda.v7_18.common.CamundaVariableAttributeExtractor; -import io.opentelemetry.javaagent.instrumentation.camunda.v7_18.task.CamundaTaskSpanNameExtractor; +import io.opentelemetry.instrumentation.camunda.v7_0.common.CamundaCommonRequest; +import io.opentelemetry.instrumentation.camunda.v7_0.common.CamundaVariableAttributeExtractor; +import io.opentelemetry.instrumentation.camunda.v7_0.task.CamundaTaskSpanNameExtractor; import io.opentelemetry.api.GlobalOpenTelemetry; import io.opentelemetry.api.OpenTelemetry; diff --git a/instrumentation/camunda/camunda-7.18/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_18/task/CamundaTopicSubscriptionManagerModule.java b/instrumentation/camunda/camunda-7.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_0/task/CamundaTopicSubscriptionManagerModule.java similarity index 87% rename from instrumentation/camunda/camunda-7.18/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_18/task/CamundaTopicSubscriptionManagerModule.java rename to instrumentation/camunda/camunda-7.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_0/task/CamundaTopicSubscriptionManagerModule.java index 1d214cba5f9b..e364fa36de7e 100644 --- a/instrumentation/camunda/camunda-7.18/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_18/task/CamundaTopicSubscriptionManagerModule.java +++ b/instrumentation/camunda/camunda-7.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_0/task/CamundaTopicSubscriptionManagerModule.java @@ -1,4 +1,4 @@ -package io.opentelemetry.javaagent.instrumentation.camunda.v7_18.task; +package io.opentelemetry.javaagent.instrumentation.camunda.v7_0.task; import static io.opentelemetry.javaagent.extension.matcher.AgentElementMatchers.hasClassesNamed; @@ -35,8 +35,9 @@ public ElementMatcher.Junction classLoaderMatcher() { return hasClassesNamed("org.camunda.bpm.client.topic.impl.TopicSubscriptionManager"); } - String[] helperClassnames = { "io.opentelemetry.javaagent.instrumentation.camunda.v7_18.task", - "io.opentelemetry.javaagent.instrumentation.camunda.v7_18.common" }; + String[] helperClassnames = { "io.opentelemetry.javaagent.instrumentation.camunda.v7_0.task", + "io.opentelemetry.instrumentation.camunda.v7_0.task", + "io.opentelemetry.instrumentation.camunda.v7_0.common" }; @Override public boolean isHelperClass(String classname) { diff --git a/instrumentation/camunda/camunda-7.18/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_18/task/CamundaTopicSubscriptionMangerInstrumentation.java b/instrumentation/camunda/camunda-7.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_0/task/CamundaTopicSubscriptionMangerInstrumentation.java similarity index 91% rename from instrumentation/camunda/camunda-7.18/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_18/task/CamundaTopicSubscriptionMangerInstrumentation.java rename to instrumentation/camunda/camunda-7.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_0/task/CamundaTopicSubscriptionMangerInstrumentation.java index f4cee3721c9e..95b102a537ef 100644 --- a/instrumentation/camunda/camunda-7.18/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_18/task/CamundaTopicSubscriptionMangerInstrumentation.java +++ b/instrumentation/camunda/camunda-7.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_0/task/CamundaTopicSubscriptionMangerInstrumentation.java @@ -1,7 +1,7 @@ -package io.opentelemetry.javaagent.instrumentation.camunda.v7_18.task; +package io.opentelemetry.javaagent.instrumentation.camunda.v7_0.task; -import static io.opentelemetry.javaagent.instrumentationn.camunda.v7_18.task.CamundaTaskSingletons.getInstumenter; -import static io.opentelemetry.javaagent.instrumentationn.camunda.v7_18.task.CamundaTaskSingletons.getOpentelemetry; +import static io.opentelemetry.javaagent.instrumentationn.camunda.v7_0.task.CamundaTaskSingletons.getInstumenter; +import static io.opentelemetry.javaagent.instrumentationn.camunda.v7_0.task.CamundaTaskSingletons.getOpentelemetry; import static io.opentelemetry.javaagent.extension.matcher.AgentElementMatchers.hasClassesNamed; import static net.bytebuddy.matcher.ElementMatchers.named; @@ -14,8 +14,8 @@ import org.camunda.bpm.client.variable.impl.TypedValues; import org.camunda.bpm.client.variable.impl.VariableValue; -import io.opentelemetry.javaagent.instrumentation.camunda.v7_18.common.CamundaCommonRequest; -import io.opentelemetry.javaagent.instrumentation.camunda.v7_18.task.CamundaExternalTaskGetter; +import io.opentelemetry.instrumentation.camunda.v7_0.common.CamundaCommonRequest; +import io.opentelemetry.instrumentation.camunda.v7_0.task.CamundaExternalTaskGetter; import io.opentelemetry.api.trace.SpanContext; import io.opentelemetry.context.Context; diff --git a/instrumentation/camunda/camunda-7.0/library/build.gradle.kts b/instrumentation/camunda/camunda-7.0/library/build.gradle.kts new file mode 100644 index 000000000000..2494f932a4f9 --- /dev/null +++ b/instrumentation/camunda/camunda-7.0/library/build.gradle.kts @@ -0,0 +1,15 @@ +plugins { + id("otel.library-instrumentation") +} + +dependencies { + implementation("org.camunda.bpm:camunda-engine:7.18.0") + implementation("org.camunda.bpm:camunda-external-task-client:7.18.0") + + api("com.google.auto.value:auto-value-annotations:1.6") + annotationProcessor("com.google.auto.value:auto-value:1.6") +} + +tasks.withType().configureEach { + usesService(gradle.sharedServices.registrations["testcontainersBuildService"].service) +} diff --git a/instrumentation/camunda/camunda-7.18/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_18/behavior/CamundaActivityExecutionGetter.java b/instrumentation/camunda/camunda-7.0/library/src/main/java/io/opentelemetry/instrumentation/camunda/v7_0/behavior/CamundaActivityExecutionGetter.java similarity index 87% rename from instrumentation/camunda/camunda-7.18/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_18/behavior/CamundaActivityExecutionGetter.java rename to instrumentation/camunda/camunda-7.0/library/src/main/java/io/opentelemetry/instrumentation/camunda/v7_0/behavior/CamundaActivityExecutionGetter.java index c6eaf8cbfbac..6a67a8e04e95 100644 --- a/instrumentation/camunda/camunda-7.18/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_18/behavior/CamundaActivityExecutionGetter.java +++ b/instrumentation/camunda/camunda-7.0/library/src/main/java/io/opentelemetry/instrumentation/camunda/v7_0/behavior/CamundaActivityExecutionGetter.java @@ -1,4 +1,4 @@ -package io.opentelemetry.javaagent.instrumentation.camunda.v7_18.behavior; +package io.opentelemetry.instrumentation.camunda.v7_0.behavior; import org.camunda.bpm.engine.impl.pvm.delegate.ActivityExecution; diff --git a/instrumentation/camunda/camunda-7.18/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_18/behavior/CamundaActivityExecutionLocalSetter.java b/instrumentation/camunda/camunda-7.0/library/src/main/java/io/opentelemetry/instrumentation/camunda/v7_0/behavior/CamundaActivityExecutionLocalSetter.java similarity index 82% rename from instrumentation/camunda/camunda-7.18/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_18/behavior/CamundaActivityExecutionLocalSetter.java rename to instrumentation/camunda/camunda-7.0/library/src/main/java/io/opentelemetry/instrumentation/camunda/v7_0/behavior/CamundaActivityExecutionLocalSetter.java index 36bf109d5158..8dd4148aa4bf 100644 --- a/instrumentation/camunda/camunda-7.18/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_18/behavior/CamundaActivityExecutionLocalSetter.java +++ b/instrumentation/camunda/camunda-7.0/library/src/main/java/io/opentelemetry/instrumentation/camunda/v7_0/behavior/CamundaActivityExecutionLocalSetter.java @@ -1,4 +1,4 @@ -package io.opentelemetry.javaagent.instrumentation.camunda.v7_18.behavior; +package io.opentelemetry.instrumentation.camunda.v7_0.behavior; import org.camunda.bpm.engine.impl.pvm.delegate.ActivityExecution; diff --git a/instrumentation/camunda/camunda-7.18/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_18/behavior/CamundaActivityExecutionSetter.java b/instrumentation/camunda/camunda-7.0/library/src/main/java/io/opentelemetry/instrumentation/camunda/v7_0/behavior/CamundaActivityExecutionSetter.java similarity index 82% rename from instrumentation/camunda/camunda-7.18/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_18/behavior/CamundaActivityExecutionSetter.java rename to instrumentation/camunda/camunda-7.0/library/src/main/java/io/opentelemetry/instrumentation/camunda/v7_0/behavior/CamundaActivityExecutionSetter.java index 7e5229060be4..6784d3711df2 100644 --- a/instrumentation/camunda/camunda-7.18/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_18/behavior/CamundaActivityExecutionSetter.java +++ b/instrumentation/camunda/camunda-7.0/library/src/main/java/io/opentelemetry/instrumentation/camunda/v7_0/behavior/CamundaActivityExecutionSetter.java @@ -1,4 +1,4 @@ -package io.opentelemetry.javaagent.instrumentation.camunda.v7_18.behavior; +package io.opentelemetry.instrumentation.camunda.v7_0.behavior; import org.camunda.bpm.engine.impl.pvm.delegate.ActivityExecution; diff --git a/instrumentation/camunda/camunda-7.18/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_18/behavior/CamundaBehaviorSpanNameExtractor.java b/instrumentation/camunda/camunda-7.0/library/src/main/java/io/opentelemetry/instrumentation/camunda/v7_0/behavior/CamundaBehaviorSpanNameExtractor.java similarity index 79% rename from instrumentation/camunda/camunda-7.18/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_18/behavior/CamundaBehaviorSpanNameExtractor.java rename to instrumentation/camunda/camunda-7.0/library/src/main/java/io/opentelemetry/instrumentation/camunda/v7_0/behavior/CamundaBehaviorSpanNameExtractor.java index fa99d53e9228..d01e2d4c236c 100644 --- a/instrumentation/camunda/camunda-7.18/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_18/behavior/CamundaBehaviorSpanNameExtractor.java +++ b/instrumentation/camunda/camunda-7.0/library/src/main/java/io/opentelemetry/instrumentation/camunda/v7_0/behavior/CamundaBehaviorSpanNameExtractor.java @@ -1,8 +1,8 @@ -package io.opentelemetry.javaagent.instrumentation.camunda.v7_18.behavior; +package io.opentelemetry.instrumentation.camunda.v7_0.behavior; import java.util.Arrays; -import io.opentelemetry.javaagent.camunda.v7_18.common.CamundaCommonRequest; +import io.opentelemetry.camunda.v7_0.common.CamundaCommonRequest; import io.opentelemetry.instrumentation.api.instrumenter.SpanNameExtractor; diff --git a/instrumentation/camunda/camunda-7.18/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_18/behavior/CamundaVariableMapSetter.java b/instrumentation/camunda/camunda-7.0/library/src/main/java/io/opentelemetry/instrumentation/camunda/v7_0/behavior/CamundaVariableMapSetter.java similarity index 80% rename from instrumentation/camunda/camunda-7.18/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_18/behavior/CamundaVariableMapSetter.java rename to instrumentation/camunda/camunda-7.0/library/src/main/java/io/opentelemetry/instrumentation/camunda/v7_0/behavior/CamundaVariableMapSetter.java index d8db3a6aadf7..87fc1472baa3 100644 --- a/instrumentation/camunda/camunda-7.18/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_18/behavior/CamundaVariableMapSetter.java +++ b/instrumentation/camunda/camunda-7.0/library/src/main/java/io/opentelemetry/instrumentation/camunda/v7_0/behavior/CamundaVariableMapSetter.java @@ -1,4 +1,4 @@ -package io.opentelemetry.javaagent.instrumentation.camunda.v7_18.behavior; +package io.opentelemetry.instrumentation.camunda.v7_0.behavior; import org.camunda.bpm.engine.variable.VariableMap; diff --git a/instrumentation/camunda/camunda-7.18/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_18/common/CamundaCommonRequest.java b/instrumentation/camunda/camunda-7.0/library/src/main/java/io/opentelemetry/instrumentation/camunda/v7_0/common/CamundaCommonRequest.java similarity index 96% rename from instrumentation/camunda/camunda-7.18/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_18/common/CamundaCommonRequest.java rename to instrumentation/camunda/camunda-7.0/library/src/main/java/io/opentelemetry/instrumentation/camunda/v7_0/common/CamundaCommonRequest.java index 18de18f8220c..154de1c49343 100644 --- a/instrumentation/camunda/camunda-7.18/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_18/common/CamundaCommonRequest.java +++ b/instrumentation/camunda/camunda-7.0/library/src/main/java/io/opentelemetry/instrumentation/camunda/v7_0/common/CamundaCommonRequest.java @@ -1,4 +1,4 @@ -package io.opentelemetry.javaagent.instrumentation.camunda.v7_18.common; +package io.opentelemetry.instrumentation.camunda.v7_0.common; import java.util.Optional; @@ -32,6 +32,7 @@ public Optional getProcessInstanceId() { return processInstanceId; } + public void setProcessInstanceId(Optional processInstanceId) { this.processInstanceId = processInstanceId; } diff --git a/instrumentation/camunda/camunda-7.18/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_18/common/CamundaVariableAttributeExtractor.java b/instrumentation/camunda/camunda-7.0/library/src/main/java/io/opentelemetry/instrumentation/camunda/v7_0/common/CamundaVariableAttributeExtractor.java similarity index 94% rename from instrumentation/camunda/camunda-7.18/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_18/common/CamundaVariableAttributeExtractor.java rename to instrumentation/camunda/camunda-7.0/library/src/main/java/io/opentelemetry/instrumentation/camunda/v7_0/common/CamundaVariableAttributeExtractor.java index b1f3bc405503..e8b30d79e933 100644 --- a/instrumentation/camunda/camunda-7.18/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_18/common/CamundaVariableAttributeExtractor.java +++ b/instrumentation/camunda/camunda-7.0/library/src/main/java/io/opentelemetry/instrumentation/camunda/v7_0/common/CamundaVariableAttributeExtractor.java @@ -1,4 +1,4 @@ -package io.opentelemetry.javaagent.instrumentation.camunda.v7_18.common; +package io.opentelemetry.instrumentation.camunda.v7_0.common; import io.opentelemetry.api.common.AttributesBuilder; import io.opentelemetry.context.Context; diff --git a/instrumentation/camunda/camunda-7.18/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_18/jobs/CamundaExecutionEntityGetter.java b/instrumentation/camunda/camunda-7.0/library/src/main/java/io/opentelemetry/instrumentation/camunda/v7_0/jobs/CamundaExecutionEntityGetter.java similarity index 87% rename from instrumentation/camunda/camunda-7.18/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_18/jobs/CamundaExecutionEntityGetter.java rename to instrumentation/camunda/camunda-7.0/library/src/main/java/io/opentelemetry/instrumentation/camunda/v7_0/jobs/CamundaExecutionEntityGetter.java index dc04180f6c36..d58cd3f689bc 100644 --- a/instrumentation/camunda/camunda-7.18/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_18/jobs/CamundaExecutionEntityGetter.java +++ b/instrumentation/camunda/camunda-7.0/library/src/main/java/io/opentelemetry/instrumentation/camunda/v7_0/jobs/CamundaExecutionEntityGetter.java @@ -1,4 +1,4 @@ -package io.opentelemetry.javaagent.instrumentation.camunda.v7_18.jobs; +package io.opentelemetry.instrumentation.camunda.v7_0.jobs; import org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity; diff --git a/instrumentation/camunda/camunda-7.18/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_18/jobs/CamundaJobSpanNameExtractor.java b/instrumentation/camunda/camunda-7.0/library/src/main/java/io/opentelemetry/instrumentation/camunda/v7_0/jobs/CamundaJobSpanNameExtractor.java similarity index 67% rename from instrumentation/camunda/camunda-7.18/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_18/jobs/CamundaJobSpanNameExtractor.java rename to instrumentation/camunda/camunda-7.0/library/src/main/java/io/opentelemetry/instrumentation/camunda/v7_0/jobs/CamundaJobSpanNameExtractor.java index 943d6e7871f8..82568028c635 100644 --- a/instrumentation/camunda/camunda-7.18/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_18/jobs/CamundaJobSpanNameExtractor.java +++ b/instrumentation/camunda/camunda-7.0/library/src/main/java/io/opentelemetry/instrumentation/camunda/v7_0/jobs/CamundaJobSpanNameExtractor.java @@ -1,6 +1,6 @@ -package io.opentelemetry.javaagent.instrumentation.camunda.v7_18.jobs; +package io.opentelemetry.instrumentation.camunda.v7_0.jobs; -import com.att.sre.otel.instrumentation.camunda.v7_18.common.CamundaCommonRequest; +import io.opentelemetry.instrumentation.camunda.v7_0.common.CamundaCommonRequest; import io.opentelemetry.instrumentation.api.instrumenter.SpanNameExtractor; diff --git a/instrumentation/camunda/camunda-7.18/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_18/processes/CamundaActivityInstantiationBuilderSetter.java b/instrumentation/camunda/camunda-7.0/library/src/main/java/io/opentelemetry/instrumentation/camunda/v7_0/processes/CamundaActivityInstantiationBuilderSetter.java similarity index 85% rename from instrumentation/camunda/camunda-7.18/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_18/processes/CamundaActivityInstantiationBuilderSetter.java rename to instrumentation/camunda/camunda-7.0/library/src/main/java/io/opentelemetry/instrumentation/camunda/v7_0/processes/CamundaActivityInstantiationBuilderSetter.java index f08b19de728a..6c276718cc1a 100644 --- a/instrumentation/camunda/camunda-7.18/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_18/processes/CamundaActivityInstantiationBuilderSetter.java +++ b/instrumentation/camunda/camunda-7.0/library/src/main/java/io/opentelemetry/instrumentation/camunda/v7_0/processes/CamundaActivityInstantiationBuilderSetter.java @@ -1,4 +1,4 @@ -package io.opentelemetry.javaagent.instrumentation.camunda.v7_18.processes; +package io.opentelemetry.instrumentation.camunda.v7_0.processes; import org.camunda.bpm.engine.runtime.ActivityInstantiationBuilder; diff --git a/instrumentation/camunda/camunda-7.18/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_18/processes/CamundaProcessInstanceModificationBuilderImpSetter.java b/instrumentation/camunda/camunda-7.0/library/src/main/java/io/opentelemetry/instrumentation/camunda/v7_0/processes/CamundaProcessInstanceModificationBuilderImpSetter.java similarity index 86% rename from instrumentation/camunda/camunda-7.18/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_18/processes/CamundaProcessInstanceModificationBuilderImpSetter.java rename to instrumentation/camunda/camunda-7.0/library/src/main/java/io/opentelemetry/instrumentation/camunda/v7_0/processes/CamundaProcessInstanceModificationBuilderImpSetter.java index 215278a1eea6..34df4f6bbae2 100644 --- a/instrumentation/camunda/camunda-7.18/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_18/processes/CamundaProcessInstanceModificationBuilderImpSetter.java +++ b/instrumentation/camunda/camunda-7.0/library/src/main/java/io/opentelemetry/instrumentation/camunda/v7_0/processes/CamundaProcessInstanceModificationBuilderImpSetter.java @@ -1,4 +1,4 @@ -package io.opentelemetry.javaagent.instrumentation.camunda.v7_18.processes; +package io.opentelemetry.instrumentation.camunda.v7_0.processes; import org.camunda.bpm.engine.impl.ProcessInstanceModificationBuilderImpl; diff --git a/instrumentation/camunda/camunda-7.18/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_18/processes/CamundaProcessSpanNameExtractor.java b/instrumentation/camunda/camunda-7.0/library/src/main/java/io/opentelemetry/instrumentation/camunda/v7_0/processes/CamundaProcessSpanNameExtractor.java similarity index 63% rename from instrumentation/camunda/camunda-7.18/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_18/processes/CamundaProcessSpanNameExtractor.java rename to instrumentation/camunda/camunda-7.0/library/src/main/java/io/opentelemetry/instrumentation/camunda/v7_0/processes/CamundaProcessSpanNameExtractor.java index e2ebe4346c59..e47ae93cf1a6 100644 --- a/instrumentation/camunda/camunda-7.18/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_18/processes/CamundaProcessSpanNameExtractor.java +++ b/instrumentation/camunda/camunda-7.0/library/src/main/java/io/opentelemetry/instrumentation/camunda/v7_0/processes/CamundaProcessSpanNameExtractor.java @@ -1,6 +1,6 @@ -package io.opentelemetry.javaagent.instrumentation.camunda.v7_18.processes; +package io.opentelemetry.instrumentation.camunda.v7_0.processes; -import io.opentelemetry.javaagent.instrumentation.camunda.v7_18.common.CamundaCommonRequest; +import io.opentelemetry.instrumentation.camunda.v7_0.common.CamundaCommonRequest; import io.opentelemetry.instrumentation.api.instrumenter.SpanNameExtractor; diff --git a/instrumentation/camunda/camunda-7.18/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_18/task/CamundaExternalTaskGetter.java b/instrumentation/camunda/camunda-7.0/library/src/main/java/io/opentelemetry/instrumentation/camunda/v7_0/task/CamundaExternalTaskGetter.java similarity index 87% rename from instrumentation/camunda/camunda-7.18/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_18/task/CamundaExternalTaskGetter.java rename to instrumentation/camunda/camunda-7.0/library/src/main/java/io/opentelemetry/instrumentation/camunda/v7_0/task/CamundaExternalTaskGetter.java index a33a80809d78..478503c212e6 100644 --- a/instrumentation/camunda/camunda-7.18/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_18/task/CamundaExternalTaskGetter.java +++ b/instrumentation/camunda/camunda-7.0/library/src/main/java/io/opentelemetry/instrumentation/camunda/v7_0/task/CamundaExternalTaskGetter.java @@ -1,4 +1,4 @@ -package io.opentelemetry.javaagent.instrumentation.camunda.v7_18.task; +package io.opentelemetry.instrumentation.camunda.v7_0.task; import org.camunda.bpm.client.task.ExternalTask; diff --git a/instrumentation/camunda/camunda-7.18/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_18/task/CamundaTaskSpanNameExtractor.java b/instrumentation/camunda/camunda-7.0/library/src/main/java/io/opentelemetry/instrumentation/camunda/v7_0/task/CamundaTaskSpanNameExtractor.java similarity index 65% rename from instrumentation/camunda/camunda-7.18/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_18/task/CamundaTaskSpanNameExtractor.java rename to instrumentation/camunda/camunda-7.0/library/src/main/java/io/opentelemetry/instrumentation/camunda/v7_0/task/CamundaTaskSpanNameExtractor.java index be234ae6fbda..d34299ff057a 100644 --- a/instrumentation/camunda/camunda-7.18/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_18/task/CamundaTaskSpanNameExtractor.java +++ b/instrumentation/camunda/camunda-7.0/library/src/main/java/io/opentelemetry/instrumentation/camunda/v7_0/task/CamundaTaskSpanNameExtractor.java @@ -1,6 +1,6 @@ -package io.opentelemetry.javaagent.instrumentation.camunda.v7_18.task; +package io.opentelemetry.instrumentation.camunda.v7_0.task; -import io.opentelemetry.javaagent.instrumentation.camunda.v7_18.common.CamundaCommonRequest; +import io.opentelemetry.instrumentation.camunda.v7_0.common.CamundaCommonRequest; import io.opentelemetry.instrumentation.api.instrumenter.SpanNameExtractor; diff --git a/settings.gradle.kts b/settings.gradle.kts index f002914bb531..7709c354fc19 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -217,7 +217,9 @@ include(":instrumentation:c3p0-0.9:library") include(":instrumentation:c3p0-0.9:testing") include(":instrumentation:camel-2.20:javaagent") include(":instrumentation:camel-2.20:javaagent-unit-tests") -include(":instrumentation:camunda-7.18:javaagent") +include(":instrumentation:camunda:camunda-7:javaagent") +include(":instrumentation:camunda:camunda-7:library") +include(":instrumentation:camunda:camunda-7:testing") include(":instrumentation:cassandra:cassandra-3.0:javaagent") include(":instrumentation:cassandra:cassandra-4.0:javaagent") include(":instrumentation:cassandra:cassandra-4.4:javaagent") From 7b268c0720579e4b57bfcd05035584f1a71fd9c1 Mon Sep 17 00:00:00 2001 From: "Boslet, Cory (cb645j)" Date: Mon, 9 Dec 2024 15:58:23 -0500 Subject: [PATCH 04/23] fix the version reference in the build settings --- settings.gradle.kts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/settings.gradle.kts b/settings.gradle.kts index 7709c354fc19..ce6a72204c3f 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -217,9 +217,9 @@ include(":instrumentation:c3p0-0.9:library") include(":instrumentation:c3p0-0.9:testing") include(":instrumentation:camel-2.20:javaagent") include(":instrumentation:camel-2.20:javaagent-unit-tests") -include(":instrumentation:camunda:camunda-7:javaagent") -include(":instrumentation:camunda:camunda-7:library") -include(":instrumentation:camunda:camunda-7:testing") +include(":instrumentation:camunda:camunda-7.0:javaagent") +include(":instrumentation:camunda:camunda-7.0:library") +include(":instrumentation:camunda:camunda-7.0:testing") include(":instrumentation:cassandra:cassandra-3.0:javaagent") include(":instrumentation:cassandra:cassandra-4.0:javaagent") include(":instrumentation:cassandra:cassandra-4.4:javaagent") From c6aa4c20754475dd1856a0fecee2fb22c0956e82 Mon Sep 17 00:00:00 2001 From: "Boslet, Cory (cb645j)" Date: Wed, 11 Dec 2024 13:20:23 -0500 Subject: [PATCH 05/23] Fixed the formatting for spotless --- .../camunda-7.0/javaagent/build.gradle.kts | 7 +- .../behavior/CamundaBehaviorSingletons.java | 49 ++-- ...lementActivityBehaviorInstrumentation.java | 204 +++++++++-------- ...CallableElementActivityBehaviorModule.java | 72 +++--- ...dEventActivityBehaviorInstrumentation.java | 212 +++++++++--------- ...CamundaEndEventActivityBehaviorModule.java | 76 ++++--- ...alTaskActivityBehaviorInstrumentation.java | 202 +++++++++-------- ...ndaExternalTaskActivityBehaviorModule.java | 72 +++--- ...daTaskActivityBehaviorInstrumentation.java | 165 +++++++------- .../CamundaTaskActivityBehaviorModule.java | 71 +++--- ...ContinuationJobHandlerInstrumentation.java | 196 ++++++++-------- ...undaAsyncContinuationJobHandlerModule.java | 71 +++--- .../v7_0/jobs/CamundaJobSingletons.java | 49 ++-- ...ssInstantiationBuilderInstrumentation.java | 154 +++++++------ ...undaProcessInstantiationBuilderModule.java | 74 +++--- .../processes/CamundaProcessSingletons.java | 51 +++-- .../v7_0/task/CamundaTaskSingletons.java | 46 ++-- ...CamundaTopicSubscriptionManagerModule.java | 71 +++--- ...opicSubscriptionMangerInstrumentation.java | 195 ++++++++-------- 19 files changed, 1071 insertions(+), 966 deletions(-) diff --git a/instrumentation/camunda/camunda-7.0/javaagent/build.gradle.kts b/instrumentation/camunda/camunda-7.0/javaagent/build.gradle.kts index d59d0cec75a6..e5261f20fe6d 100644 --- a/instrumentation/camunda/camunda-7.0/javaagent/build.gradle.kts +++ b/instrumentation/camunda/camunda-7.0/javaagent/build.gradle.kts @@ -12,10 +12,9 @@ muzzle { } } - dependencies { - implementation(project(":instrumentation:camunda:camunda-7.0:library")) + implementation(project(":instrumentation:camunda:camunda-7.0:library")) - api("com.google.auto.value:auto-value-annotations:1.6") - annotationProcessor("com.google.auto.value:auto-value:1.6") + api("com.google.auto.value:auto-value-annotations:1.6") + annotationProcessor("com.google.auto.value:auto-value:1.6") } diff --git a/instrumentation/camunda/camunda-7.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_0/behavior/CamundaBehaviorSingletons.java b/instrumentation/camunda/camunda-7.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_0/behavior/CamundaBehaviorSingletons.java index a0e30ddc06ee..adde8621625b 100644 --- a/instrumentation/camunda/camunda-7.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_0/behavior/CamundaBehaviorSingletons.java +++ b/instrumentation/camunda/camunda-7.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_0/behavior/CamundaBehaviorSingletons.java @@ -1,41 +1,44 @@ +/* + * Copyright The OpenTelemetry Authors + * SPDX-License-Identifier: Apache-2.0 + */ + package io.opentelemetry.javaagent.instrumentation.camunda.v7_0.behavior; +import io.opentelemetry.api.GlobalOpenTelemetry; +import io.opentelemetry.api.OpenTelemetry; import io.opentelemetry.camunda.v7_0.behavior.CamundaBehaviorSpanNameExtractor; import io.opentelemetry.camunda.v7_0.common.CamundaCommonRequest; import io.opentelemetry.camunda.v7_0.common.CamundaVariableAttributeExtractor; - -import io.opentelemetry.api.GlobalOpenTelemetry; -import io.opentelemetry.api.OpenTelemetry; import io.opentelemetry.instrumentation.api.instrumenter.Instrumenter; import io.opentelemetry.instrumentation.api.instrumenter.InstrumenterBuilder; -import io.opentelemetry.javaagent.bootstrap.internal.InstrumentationConfig; public class CamundaBehaviorSingletons { - private static final Instrumenter instrumenter; - - private static final OpenTelemetry opentelemetry; - - private static final boolean propagationEnabled; + private static final Instrumenter instrumenter; - static { + private static final OpenTelemetry opentelemetry; - opentelemetry = GlobalOpenTelemetry.get(); + private static final boolean propagationEnabled; - InstrumenterBuilder builder = Instrumenter - .builder(opentelemetry, "io.opentelemetry.camunda-behavior", - new CamundaBehaviorSpanNameExtractor()) - .addAttributesExtractor(new CamundaVariableAttributeExtractor()); + static { + opentelemetry = GlobalOpenTelemetry.get(); - instrumenter = builder.buildInstrumenter(); - } + InstrumenterBuilder builder = + Instrumenter.builder( + opentelemetry, + "io.opentelemetry.camunda-behavior", + new CamundaBehaviorSpanNameExtractor()) + .addAttributesExtractor(new CamundaVariableAttributeExtractor()); - public static OpenTelemetry getOpentelemetry() { - return opentelemetry; - } + instrumenter = builder.buildInstrumenter(); + } - public static Instrumenter getInstumenter() { - return instrumenter; - } + public static OpenTelemetry getOpentelemetry() { + return opentelemetry; + } + public static Instrumenter getInstumenter() { + return instrumenter; + } } diff --git a/instrumentation/camunda/camunda-7.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_0/behavior/CamundaCallableElementActivityBehaviorInstrumentation.java b/instrumentation/camunda/camunda-7.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_0/behavior/CamundaCallableElementActivityBehaviorInstrumentation.java index a8f5d2f0d211..d43db2f433f5 100644 --- a/instrumentation/camunda/camunda-7.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_0/behavior/CamundaCallableElementActivityBehaviorInstrumentation.java +++ b/instrumentation/camunda/camunda-7.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_0/behavior/CamundaCallableElementActivityBehaviorInstrumentation.java @@ -1,116 +1,128 @@ +/* + * Copyright The OpenTelemetry Authors + * SPDX-License-Identifier: Apache-2.0 + */ + package io.opentelemetry.javaagent.instrumentation.camunda.v7_0.behavior; -import static io.opentelemetry.javaagent.instrumentation.camunda.v7_0.behavior.CamundaBehaviorSingletons.getInstumenter; -import static io.opentelemetry.javaagent.instrumentation.camunda.v7_0.behavior.CamundaBehaviorSingletons.getOpentelemetry; import static io.opentelemetry.javaagent.extension.matcher.AgentElementMatchers.hasClassesNamed; import static io.opentelemetry.javaagent.extension.matcher.AgentElementMatchers.hasSuperType; +import static io.opentelemetry.javaagent.instrumentation.camunda.v7_0.behavior.CamundaBehaviorSingletons.getInstumenter; +import static io.opentelemetry.javaagent.instrumentation.camunda.v7_0.behavior.CamundaBehaviorSingletons.getOpentelemetry; import static net.bytebuddy.matcher.ElementMatchers.named; -import java.util.Optional; - -import org.camunda.bpm.engine.impl.pvm.delegate.ActivityExecution; -import org.camunda.bpm.engine.variable.VariableMap; - -import java.util.logging.Level; - -import io.opentelemetry.javaagent.camunda.v7_0.behavior.CamundaActivityExecutionGetter; -import io.opentelemetry.javaagent.camunda.v7_0.behavior.CamundaVariableMapSetter; -import io.opentelemetry.javaagent.camunda.v7_0.common.CamundaCommonRequest; - import io.opentelemetry.api.trace.SpanContext; import io.opentelemetry.context.Context; import io.opentelemetry.context.Scope; import io.opentelemetry.javaagent.bootstrap.Java8BytecodeBridge; +import io.opentelemetry.javaagent.camunda.v7_0.behavior.CamundaActivityExecutionGetter; +import io.opentelemetry.javaagent.camunda.v7_0.behavior.CamundaVariableMapSetter; +import io.opentelemetry.javaagent.camunda.v7_0.common.CamundaCommonRequest; import io.opentelemetry.javaagent.extension.instrumentation.TypeInstrumentation; import io.opentelemetry.javaagent.extension.instrumentation.TypeTransformer; +import java.util.Optional; import net.bytebuddy.asm.Advice; import net.bytebuddy.description.type.TypeDescription; import net.bytebuddy.matcher.ElementMatcher; import net.bytebuddy.matcher.ElementMatchers; +import org.camunda.bpm.engine.impl.pvm.delegate.ActivityExecution; +import org.camunda.bpm.engine.variable.VariableMap; public class CamundaCallableElementActivityBehaviorInstrumentation implements TypeInstrumentation { - @Override - public ElementMatcher classLoaderOptimization() { - return hasClassesNamed("org.camunda.bpm.engine.impl.bpmn.behavior.CallableElementActivityBehavior"); - } - - @Override - public ElementMatcher typeMatcher() { - return hasSuperType(named("org.camunda.bpm.engine.impl.bpmn.behavior.CallableElementActivityBehavior")); - } - - @Override - public void transform(TypeTransformer transformer) { - transformer.applyAdviceToMethod(ElementMatchers.isMethod().and(ElementMatchers.named("startInstance")), - this.getClass().getName() + "$CamundaCallableElementActivityBehaviorAdvice"); - } - - public static class CamundaCallableElementActivityBehaviorAdvice { - - @Advice.OnMethodEnter(suppress = Throwable.class) - public static void addTracingEnter(@Advice.Argument(0) ActivityExecution execution, - @Advice.Argument(1) VariableMap variables, @Advice.Local("request") CamundaCommonRequest request, - @Advice.Local("otelParentScope") Scope parentScope, @Advice.Local("otelContext") Context context, - @Advice.Local("otelScope") Scope scope) { - - - if (execution == null) { - //log warning - return; - } - - request = new CamundaCommonRequest(); - request.setProcessDefinitionId(Optional.ofNullable(execution.getProcessDefinitionId())); - request.setProcessInstanceId(Optional.ofNullable(execution.getProcessInstanceId())); - request.setActivityId(Optional.ofNullable(execution.getCurrentActivityId())); - request.setActivityName(Optional.ofNullable(execution.getCurrentActivityName())); - - String processInstanceId = execution.getProcessInstanceId(); - - if (Java8BytecodeBridge.currentContext() == Java8BytecodeBridge.rootContext()) { - //log - } - - Context parentContext = getOpentelemetry().getPropagators().getTextMapPropagator() - .extract(Java8BytecodeBridge.currentContext(), execution, new CamundaActivityExecutionGetter()); - - parentScope = parentContext.makeCurrent(); - - if (getInstumenter().shouldStart(Java8BytecodeBridge.currentContext(), request)) { - context = getInstumenter().start(Java8BytecodeBridge.currentContext(), request); - scope = context.makeCurrent(); - - // Inject subflow trace context as pi variables so they are propagated and - // accessible - - SpanContext currentSpanContext = Java8BytecodeBridge.spanFromContext(context).getSpanContext(); - if (currentSpanContext.isValid()) { - getOpentelemetry().getPropagators().getTextMapPropagator().inject(context, variables, - new CamundaVariableMapSetter()); - } - - } - - } - - @Advice.OnMethodExit(onThrowable = Throwable.class, suppress = Throwable.class) - public static void closeTrace(@Advice.Argument(0) ActivityExecution execution, - @Advice.Local("request") CamundaCommonRequest request, - @Advice.Local("otelParentScope") Scope parentScope, @Advice.Local("otelContext") Context context, - @Advice.Local("otelScope") Scope scope, @Advice.Thrown Throwable throwable) { - - - if (context != null && scope != null) { - getInstumenter().end(context, request, "NA", throwable); - scope.close(); - } - - if (parentScope != null) { - parentScope.close(); - } - - } - } - + @Override + public ElementMatcher classLoaderOptimization() { + return hasClassesNamed( + "org.camunda.bpm.engine.impl.bpmn.behavior.CallableElementActivityBehavior"); + } + + @Override + public ElementMatcher typeMatcher() { + return hasSuperType( + named("org.camunda.bpm.engine.impl.bpmn.behavior.CallableElementActivityBehavior")); + } + + @Override + public void transform(TypeTransformer transformer) { + transformer.applyAdviceToMethod( + ElementMatchers.isMethod().and(ElementMatchers.named("startInstance")), + this.getClass().getName() + "$CamundaCallableElementActivityBehaviorAdvice"); + } + + public static class CamundaCallableElementActivityBehaviorAdvice { + + @Advice.OnMethodEnter(suppress = Throwable.class) + public static void addTracingEnter( + @Advice.Argument(0) ActivityExecution execution, + @Advice.Argument(1) VariableMap variables, + @Advice.Local("request") CamundaCommonRequest request, + @Advice.Local("otelParentScope") Scope parentScope, + @Advice.Local("otelContext") Context context, + @Advice.Local("otelScope") Scope scope) { + + if (execution == null) { + // log warning + return; + } + + request = new CamundaCommonRequest(); + request.setProcessDefinitionId(Optional.ofNullable(execution.getProcessDefinitionId())); + request.setProcessInstanceId(Optional.ofNullable(execution.getProcessInstanceId())); + request.setActivityId(Optional.ofNullable(execution.getCurrentActivityId())); + request.setActivityName(Optional.ofNullable(execution.getCurrentActivityName())); + + String processInstanceId = execution.getProcessInstanceId(); + + if (Java8BytecodeBridge.currentContext() == Java8BytecodeBridge.rootContext()) { + // log + } + + Context parentContext = + getOpentelemetry() + .getPropagators() + .getTextMapPropagator() + .extract( + Java8BytecodeBridge.currentContext(), + execution, + new CamundaActivityExecutionGetter()); + + parentScope = parentContext.makeCurrent(); + + if (getInstumenter().shouldStart(Java8BytecodeBridge.currentContext(), request)) { + context = getInstumenter().start(Java8BytecodeBridge.currentContext(), request); + scope = context.makeCurrent(); + + // Inject subflow trace context as pi variables so they are propagated and + // accessible + + SpanContext currentSpanContext = + Java8BytecodeBridge.spanFromContext(context).getSpanContext(); + if (currentSpanContext.isValid()) { + getOpentelemetry() + .getPropagators() + .getTextMapPropagator() + .inject(context, variables, new CamundaVariableMapSetter()); + } + } + } + + @Advice.OnMethodExit(onThrowable = Throwable.class, suppress = Throwable.class) + public static void closeTrace( + @Advice.Argument(0) ActivityExecution execution, + @Advice.Local("request") CamundaCommonRequest request, + @Advice.Local("otelParentScope") Scope parentScope, + @Advice.Local("otelContext") Context context, + @Advice.Local("otelScope") Scope scope, + @Advice.Thrown Throwable throwable) { + + if (context != null && scope != null) { + getInstumenter().end(context, request, "NA", throwable); + scope.close(); + } + + if (parentScope != null) { + parentScope.close(); + } + } + } } diff --git a/instrumentation/camunda/camunda-7.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_0/behavior/CamundaCallableElementActivityBehaviorModule.java b/instrumentation/camunda/camunda-7.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_0/behavior/CamundaCallableElementActivityBehaviorModule.java index 8bac8a9f1a4e..0e131ad4c83a 100644 --- a/instrumentation/camunda/camunda-7.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_0/behavior/CamundaCallableElementActivityBehaviorModule.java +++ b/instrumentation/camunda/camunda-7.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_0/behavior/CamundaCallableElementActivityBehaviorModule.java @@ -1,47 +1,53 @@ +/* + * Copyright The OpenTelemetry Authors + * SPDX-License-Identifier: Apache-2.0 + */ + package io.opentelemetry.javaagent.instrumentation.camunda.v7_0.behavior; import static io.opentelemetry.javaagent.extension.matcher.AgentElementMatchers.hasClassesNamed; -import java.util.Arrays; -import java.util.Collections; -import java.util.List; - import com.google.auto.service.AutoService; - import io.opentelemetry.javaagent.extension.instrumentation.InstrumentationModule; import io.opentelemetry.javaagent.extension.instrumentation.TypeInstrumentation; import io.opentelemetry.sdk.autoconfigure.spi.ConfigProperties; +import java.util.Arrays; +import java.util.Collections; +import java.util.List; import net.bytebuddy.matcher.ElementMatcher; @AutoService(InstrumentationModule.class) public class CamundaCallableElementActivityBehaviorModule extends InstrumentationModule { - public CamundaCallableElementActivityBehaviorModule() { - super("camunda", "camunda-behavior", "camunda-behavior-7_18"); - } - - @Override - public boolean defaultEnabled(ConfigProperties config) { - return config.getBoolean("otel.instrumentation.common.default-enabled", true); - } - - @Override - public List typeInstrumentations() { - return Collections.singletonList(new CamundaCallableElementActivityBehaviorInstrumentation()); - } - - @Override - public ElementMatcher.Junction classLoaderMatcher() { - return hasClassesNamed("org.camunda.bpm.engine.impl.bpmn.behavior.CallableElementActivityBehavior"); - } - - String[] helperClassnames = { "io.opentelemetry.javaagent.instrumentation.camunda.v7_0.behavior", - "io.opentelemetry.instrumentation.camunda.v7_0.behavior", - "io.opentelemetry.instrumentation.camunda.v7_0.common" }; - - @Override - public boolean isHelperClass(String classname) { - return super.isHelperClass(classname) || Arrays.stream(helperClassnames).anyMatch(c -> classname.startsWith(c)); - } - + public CamundaCallableElementActivityBehaviorModule() { + super("camunda", "camunda-behavior", "camunda-behavior-7_18"); + } + + @Override + public boolean defaultEnabled(ConfigProperties config) { + return config.getBoolean("otel.instrumentation.common.default-enabled", true); + } + + @Override + public List typeInstrumentations() { + return Collections.singletonList(new CamundaCallableElementActivityBehaviorInstrumentation()); + } + + @Override + public ElementMatcher.Junction classLoaderMatcher() { + return hasClassesNamed( + "org.camunda.bpm.engine.impl.bpmn.behavior.CallableElementActivityBehavior"); + } + + String[] helperClassnames = { + "io.opentelemetry.javaagent.instrumentation.camunda.v7_0.behavior", + "io.opentelemetry.instrumentation.camunda.v7_0.behavior", + "io.opentelemetry.instrumentation.camunda.v7_0.common" + }; + + @Override + public boolean isHelperClass(String classname) { + return super.isHelperClass(classname) + || Arrays.stream(helperClassnames).anyMatch(c -> classname.startsWith(c)); + } } diff --git a/instrumentation/camunda/camunda-7.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_0/behavior/CamundaEndEventActivityBehaviorInstrumentation.java b/instrumentation/camunda/camunda-7.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_0/behavior/CamundaEndEventActivityBehaviorInstrumentation.java index 0e31c1cf3a37..74113e2989db 100644 --- a/instrumentation/camunda/camunda-7.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_0/behavior/CamundaEndEventActivityBehaviorInstrumentation.java +++ b/instrumentation/camunda/camunda-7.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_0/behavior/CamundaEndEventActivityBehaviorInstrumentation.java @@ -1,121 +1,133 @@ +/* + * Copyright The OpenTelemetry Authors + * SPDX-License-Identifier: Apache-2.0 + */ + package io.opentelemetry.javaagent.instrumentation.camunda.v7_0.behavior; +import static io.opentelemetry.javaagent.extension.matcher.AgentElementMatchers.hasClassesNamed; import static io.opentelemetry.javaagent.instrumentation.camunda.v7_0.behavior.CamundaBehaviorSingletons.getInstumenter; import static io.opentelemetry.javaagent.instrumentation.camunda.v7_0.behavior.CamundaBehaviorSingletons.getOpentelemetry; -import static io.opentelemetry.javaagent.extension.matcher.AgentElementMatchers.hasClassesNamed; import static net.bytebuddy.matcher.ElementMatchers.named; -import static net.bytebuddy.matcher.ElementMatchers.anyOf; - -import java.util.Optional; - -import org.camunda.bpm.engine.impl.pvm.delegate.ActivityExecution; -import org.camunda.bpm.model.bpmn.instance.CompensateEventDefinition; -import org.camunda.bpm.model.bpmn.instance.EndEvent; -import org.camunda.bpm.model.bpmn.instance.ErrorEventDefinition; -import org.camunda.bpm.model.bpmn.instance.EventDefinition; -import org.camunda.bpm.model.bpmn.instance.TerminateEventDefinition; import io.opentelemetry.camunda.v7_0.behavior.CamundaActivityExecutionGetter; import io.opentelemetry.camunda.v7_0.common.CamundaCommonRequest; - import io.opentelemetry.context.Context; import io.opentelemetry.context.Scope; import io.opentelemetry.javaagent.bootstrap.Java8BytecodeBridge; import io.opentelemetry.javaagent.extension.instrumentation.TypeInstrumentation; import io.opentelemetry.javaagent.extension.instrumentation.TypeTransformer; +import java.util.Optional; import net.bytebuddy.asm.Advice; import net.bytebuddy.description.type.TypeDescription; import net.bytebuddy.matcher.ElementMatcher; import net.bytebuddy.matcher.ElementMatchers; +import org.camunda.bpm.engine.impl.pvm.delegate.ActivityExecution; +import org.camunda.bpm.model.bpmn.instance.CompensateEventDefinition; +import org.camunda.bpm.model.bpmn.instance.EndEvent; +import org.camunda.bpm.model.bpmn.instance.ErrorEventDefinition; +import org.camunda.bpm.model.bpmn.instance.EventDefinition; +import org.camunda.bpm.model.bpmn.instance.TerminateEventDefinition; public class CamundaEndEventActivityBehaviorInstrumentation implements TypeInstrumentation { - @Override - public ElementMatcher classLoaderOptimization() { - return hasClassesNamed("org.camunda.bpm.engine.impl.bpmn.behavior.TerminateEndEventActivityBehavior"); - } - - @Override - public ElementMatcher typeMatcher() { - return named("org.camunda.bpm.engine.impl.bpmn.behavior.TerminateEndEventActivityBehavior") - .or(named("org.camunda.bpm.engine.impl.bpmn.behavior.NoneEndEventActivityBehavior") - .or(named("org.camunda.bpm.engine.impl.bpmn.behavior.ErrorEndEventActivityBehavior"))); - } - - @Override - public void transform(TypeTransformer transformer) { - transformer.applyAdviceToMethod(ElementMatchers.isMethod().and(ElementMatchers.named("execute")), - this.getClass().getName() + "$CamundaEndEventActivityBehaviorAdvice"); - } - - public static class CamundaEndEventActivityBehaviorAdvice { - - @Advice.OnMethodEnter(suppress = Throwable.class) - public static void addTracingEnter(@Advice.Argument(0) ActivityExecution execution, - @Advice.Local("request") CamundaCommonRequest request, - @Advice.Local("otelParentScope") Scope parentScope, @Advice.Local("otelContext") Context context, - @Advice.Local("otelScope") Scope scope) { - - if (execution == null) { - return; - } - - request = new CamundaCommonRequest(); - request.setProcessDefinitionId(Optional.ofNullable(execution.getProcessDefinitionId())); - request.setProcessInstanceId(Optional.ofNullable(execution.getProcessInstanceId())); - request.setActivityId(Optional.ofNullable(execution.getCurrentActivityId())); - - if (execution.getBpmnModelElementInstance() != null) { - //TODO lambda does not work due to access modifier - - // TODO add other events execution.getBpmnModelElementInstance() instanceof - // EndEvent - EndEvent e = (EndEvent) execution.getBpmnModelElementInstance(); - - for (EventDefinition ed : e.getEventDefinitions()) { - if (ed instanceof TerminateEventDefinition) { - request.setActivityName(Optional.of("End")); - }else if(ed instanceof ErrorEventDefinition) { - request.setActivityName(Optional.of("Error End")); - }else if(ed instanceof CompensateEventDefinition) { - request.setActivityName(Optional.of("Compensation End")); - }else { - request.setActivityName(Optional.of("End")); - } - } - } - - String processInstanceId = execution.getProcessInstanceId(); - - Context parentContext = getOpentelemetry().getPropagators().getTextMapPropagator() - .extract(Java8BytecodeBridge.currentContext(), execution, new CamundaActivityExecutionGetter()); - - parentScope = parentContext.makeCurrent(); - - if (getInstumenter().shouldStart(Java8BytecodeBridge.currentContext(), request)) { - context = getInstumenter().start(Java8BytecodeBridge.currentContext(), request); - scope = context.makeCurrent(); - - } - - } - - @Advice.OnMethodExit(onThrowable = Throwable.class, suppress = Throwable.class) - public static void closeSpan(@Advice.Local("request") CamundaCommonRequest request, - @Advice.Local("otelParentScope") Scope parentScope, @Advice.Local("otelContext") Context context, - @Advice.Local("otelScope") Scope scope, @Advice.Thrown Throwable throwable) { - - - if (context != null && scope != null) { - getInstumenter().end(context, request, "NA", throwable); - scope.close(); - } - - if (parentScope != null) { - parentScope.close(); - } - - } - } - + @Override + public ElementMatcher classLoaderOptimization() { + return hasClassesNamed( + "org.camunda.bpm.engine.impl.bpmn.behavior.TerminateEndEventActivityBehavior"); + } + + @Override + public ElementMatcher typeMatcher() { + return named("org.camunda.bpm.engine.impl.bpmn.behavior.TerminateEndEventActivityBehavior") + .or( + named("org.camunda.bpm.engine.impl.bpmn.behavior.NoneEndEventActivityBehavior") + .or( + named( + "org.camunda.bpm.engine.impl.bpmn.behavior.ErrorEndEventActivityBehavior"))); + } + + @Override + public void transform(TypeTransformer transformer) { + transformer.applyAdviceToMethod( + ElementMatchers.isMethod().and(ElementMatchers.named("execute")), + this.getClass().getName() + "$CamundaEndEventActivityBehaviorAdvice"); + } + + public static class CamundaEndEventActivityBehaviorAdvice { + + @Advice.OnMethodEnter(suppress = Throwable.class) + public static void addTracingEnter( + @Advice.Argument(0) ActivityExecution execution, + @Advice.Local("request") CamundaCommonRequest request, + @Advice.Local("otelParentScope") Scope parentScope, + @Advice.Local("otelContext") Context context, + @Advice.Local("otelScope") Scope scope) { + + if (execution == null) { + return; + } + + request = new CamundaCommonRequest(); + request.setProcessDefinitionId(Optional.ofNullable(execution.getProcessDefinitionId())); + request.setProcessInstanceId(Optional.ofNullable(execution.getProcessInstanceId())); + request.setActivityId(Optional.ofNullable(execution.getCurrentActivityId())); + + if (execution.getBpmnModelElementInstance() != null) { + // TODO lambda does not work due to access modifier + + // TODO add other events execution.getBpmnModelElementInstance() instanceof + // EndEvent + EndEvent e = (EndEvent) execution.getBpmnModelElementInstance(); + + for (EventDefinition ed : e.getEventDefinitions()) { + if (ed instanceof TerminateEventDefinition) { + request.setActivityName(Optional.of("End")); + } else if (ed instanceof ErrorEventDefinition) { + request.setActivityName(Optional.of("Error End")); + } else if (ed instanceof CompensateEventDefinition) { + request.setActivityName(Optional.of("Compensation End")); + } else { + request.setActivityName(Optional.of("End")); + } + } + } + + String processInstanceId = execution.getProcessInstanceId(); + + Context parentContext = + getOpentelemetry() + .getPropagators() + .getTextMapPropagator() + .extract( + Java8BytecodeBridge.currentContext(), + execution, + new CamundaActivityExecutionGetter()); + + parentScope = parentContext.makeCurrent(); + + if (getInstumenter().shouldStart(Java8BytecodeBridge.currentContext(), request)) { + context = getInstumenter().start(Java8BytecodeBridge.currentContext(), request); + scope = context.makeCurrent(); + } + } + + @Advice.OnMethodExit(onThrowable = Throwable.class, suppress = Throwable.class) + public static void closeSpan( + @Advice.Local("request") CamundaCommonRequest request, + @Advice.Local("otelParentScope") Scope parentScope, + @Advice.Local("otelContext") Context context, + @Advice.Local("otelScope") Scope scope, + @Advice.Thrown Throwable throwable) { + + if (context != null && scope != null) { + getInstumenter().end(context, request, "NA", throwable); + scope.close(); + } + + if (parentScope != null) { + parentScope.close(); + } + } + } } diff --git a/instrumentation/camunda/camunda-7.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_0/behavior/CamundaEndEventActivityBehaviorModule.java b/instrumentation/camunda/camunda-7.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_0/behavior/CamundaEndEventActivityBehaviorModule.java index f8d88c3430f1..0d75b6fee130 100644 --- a/instrumentation/camunda/camunda-7.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_0/behavior/CamundaEndEventActivityBehaviorModule.java +++ b/instrumentation/camunda/camunda-7.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_0/behavior/CamundaEndEventActivityBehaviorModule.java @@ -1,49 +1,55 @@ +/* + * Copyright The OpenTelemetry Authors + * SPDX-License-Identifier: Apache-2.0 + */ + package io.opentelemetry.javaagent.instrumentation.camunda.v7_0.behavior; import static io.opentelemetry.javaagent.extension.matcher.AgentElementMatchers.hasClassesNamed; -import java.util.Arrays; -import java.util.Collections; -import java.util.List; - import com.google.auto.service.AutoService; - import io.opentelemetry.javaagent.extension.instrumentation.InstrumentationModule; import io.opentelemetry.javaagent.extension.instrumentation.TypeInstrumentation; import io.opentelemetry.sdk.autoconfigure.spi.ConfigProperties; +import java.util.Arrays; +import java.util.Collections; +import java.util.List; import net.bytebuddy.matcher.ElementMatcher; @AutoService(InstrumentationModule.class) public class CamundaEndEventActivityBehaviorModule extends InstrumentationModule { - public CamundaEndEventActivityBehaviorModule() { - super("camunda", "camunda-behavior", "camunda-behavior-7_18"); - } - - @Override - public boolean defaultEnabled(ConfigProperties config) { - return config.getBoolean("otel.instrumentation.common.default-enabled", true); - } - - @Override - public List typeInstrumentations() { - return Collections.singletonList(new CamundaEndEventActivityBehaviorInstrumentation()); - } - - @Override - public ElementMatcher.Junction classLoaderMatcher() { - return hasClassesNamed("org.camunda.bpm.engine.impl.bpmn.behavior.TerminateEndEventActivityBehavior", - "org.camunda.bpm.engine.impl.bpmn.behavior.NoneEndEventActivityBehavior", - "org.camunda.bpm.engine.impl.bpmn.behavior.ErrorEndEventActivityBehavior"); - } - - String[] helperClassnames = { "io.opentelemetry.javaagent.instrumentation.camunda.v7_0.behavior", - "io.opentelemetry.instrumentation.camunda.v7_0.behavior", - "io.opentelemetry.instrumentation.camunda.v7_0.common" }; - - @Override - public boolean isHelperClass(String classname) { - return super.isHelperClass(classname) || Arrays.stream(helperClassnames).anyMatch(c -> classname.startsWith(c)); - } - + public CamundaEndEventActivityBehaviorModule() { + super("camunda", "camunda-behavior", "camunda-behavior-7_18"); + } + + @Override + public boolean defaultEnabled(ConfigProperties config) { + return config.getBoolean("otel.instrumentation.common.default-enabled", true); + } + + @Override + public List typeInstrumentations() { + return Collections.singletonList(new CamundaEndEventActivityBehaviorInstrumentation()); + } + + @Override + public ElementMatcher.Junction classLoaderMatcher() { + return hasClassesNamed( + "org.camunda.bpm.engine.impl.bpmn.behavior.TerminateEndEventActivityBehavior", + "org.camunda.bpm.engine.impl.bpmn.behavior.NoneEndEventActivityBehavior", + "org.camunda.bpm.engine.impl.bpmn.behavior.ErrorEndEventActivityBehavior"); + } + + String[] helperClassnames = { + "io.opentelemetry.javaagent.instrumentation.camunda.v7_0.behavior", + "io.opentelemetry.instrumentation.camunda.v7_0.behavior", + "io.opentelemetry.instrumentation.camunda.v7_0.common" + }; + + @Override + public boolean isHelperClass(String classname) { + return super.isHelperClass(classname) + || Arrays.stream(helperClassnames).anyMatch(c -> classname.startsWith(c)); + } } diff --git a/instrumentation/camunda/camunda-7.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_0/behavior/CamundaExternalTaskActivityBehaviorInstrumentation.java b/instrumentation/camunda/camunda-7.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_0/behavior/CamundaExternalTaskActivityBehaviorInstrumentation.java index b6acff89e58a..55edf964fba9 100644 --- a/instrumentation/camunda/camunda-7.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_0/behavior/CamundaExternalTaskActivityBehaviorInstrumentation.java +++ b/instrumentation/camunda/camunda-7.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_0/behavior/CamundaExternalTaskActivityBehaviorInstrumentation.java @@ -1,121 +1,125 @@ +/* + * Copyright The OpenTelemetry Authors + * SPDX-License-Identifier: Apache-2.0 + */ + package io.opentelemetry.javaagent.instrumentation.camunda.v7_0.behavior; +import static io.opentelemetry.javaagent.extension.matcher.AgentElementMatchers.hasClassesNamed; import static io.opentelemetry.javaagent.instrumentation.camunda.v7_0.behavior.CamundaBehaviorSingletons.getInstumenter; import static io.opentelemetry.javaagent.instrumentation.camunda.v7_0.behavior.CamundaBehaviorSingletons.getOpentelemetry; -import static io.opentelemetry.javaagent.extension.matcher.AgentElementMatchers.hasClassesNamed; import static net.bytebuddy.matcher.ElementMatchers.named; -import java.util.HashMap; -import java.util.Map; -import java.util.Optional; -import java.util.logging.Level; - -import org.camunda.bpm.engine.impl.pvm.delegate.ActivityExecution; - import io.opentelemetry.camunda.v7_0.behavior.CamundaActivityExecutionGetter; import io.opentelemetry.camunda.v7_0.behavior.CamundaActivityExecutionLocalSetter; -import io.opentelemetry.camunda.v7_0.behavior.CamundaActivityExecutionSetter; -import io.opentelemetry.camunda.v7_0.behavior.CamundaVariableMapSetter; import io.opentelemetry.camunda.v7_0.common.CamundaCommonRequest; - -import io.opentelemetry.api.trace.SpanContext; import io.opentelemetry.context.Context; import io.opentelemetry.context.Scope; import io.opentelemetry.javaagent.bootstrap.Java8BytecodeBridge; import io.opentelemetry.javaagent.extension.instrumentation.TypeInstrumentation; import io.opentelemetry.javaagent.extension.instrumentation.TypeTransformer; +import java.util.Optional; import net.bytebuddy.asm.Advice; import net.bytebuddy.description.type.TypeDescription; import net.bytebuddy.matcher.ElementMatcher; import net.bytebuddy.matcher.ElementMatchers; +import org.camunda.bpm.engine.impl.pvm.delegate.ActivityExecution; public class CamundaExternalTaskActivityBehaviorInstrumentation implements TypeInstrumentation { - @Override - public ElementMatcher classLoaderOptimization() { - return hasClassesNamed("org.camunda.bpm.engine.impl.bpmn.behavior.ExternalTaskActivityBehavior"); - } - - @Override - public ElementMatcher typeMatcher() { - return named("org.camunda.bpm.engine.impl.bpmn.behavior.ExternalTaskActivityBehavior"); - } - - @Override - public void transform(TypeTransformer transformer) { - transformer.applyAdviceToMethod(ElementMatchers.isMethod().and(ElementMatchers.named("execute")), - this.getClass().getName() + "$CamundaExternalTaskActivityBehaviorAdvice"); - - } - - public static class CamundaExternalTaskActivityBehaviorAdvice { - - /** - * Sets parent context to process instance. Creates new context and span. - * propagates current context to variable set for topic to retrieve. - * - * @param execution - * @param request - * @param parentScope - * @param parentContext - * @param context - * @param scope - */ - @Advice.OnMethodEnter(suppress = Throwable.class) - public static void addTracingEnter(@Advice.Argument(0) ActivityExecution execution, - @Advice.Local("request") CamundaCommonRequest request, - @Advice.Local("otelParentScope") Scope parentScope, - @Advice.Local("otelParentContext") Context parentContext, @Advice.Local("otelContext") Context context, - @Advice.Local("otelScope") Scope scope) { - - - if (execution == null) { - return; - } - - request = new CamundaCommonRequest(); - request.setProcessDefinitionId(Optional.ofNullable(execution.getProcessDefinitionId())); - request.setProcessInstanceId(Optional.ofNullable(execution.getProcessInstanceId())); - request.setActivityId(Optional.ofNullable(execution.getCurrentActivityId())); - request.setActivityName(Optional.ofNullable(execution.getCurrentActivityName())); - - String processInstanceId = execution.getProcessInstanceId(); - - if (Java8BytecodeBridge.currentContext() == Java8BytecodeBridge.rootContext()) { - } - - parentContext = getOpentelemetry().getPropagators().getTextMapPropagator() - .extract(Java8BytecodeBridge.currentContext(), execution, new CamundaActivityExecutionGetter()); - - parentScope = parentContext.makeCurrent(); - - if (getInstumenter().shouldStart(Java8BytecodeBridge.currentContext(), request)) { - context = getInstumenter().start(Java8BytecodeBridge.currentContext(), request); - scope = context.makeCurrent(); - - getOpentelemetry().getPropagators().getTextMapPropagator().inject(context, execution, - new CamundaActivityExecutionLocalSetter()); - } - - } - - @Advice.OnMethodExit(onThrowable = Throwable.class, suppress = Throwable.class) - public static void closeTrace(@Advice.Local("request") CamundaCommonRequest request, - @Advice.Local("otelParentScope") Scope parentScope, - @Advice.Local("otelParentContext") Context parentContext, @Advice.Local("otelContext") Context context, - @Advice.Local("otelScope") Scope scope, @Advice.Thrown Throwable throwable) { - - - if (context != null && scope != null) { - getInstumenter().end(context, request, "NA", throwable); - scope.close(); - } - - if (parentScope != null) { - parentScope.close(); - } - - } - } - + @Override + public ElementMatcher classLoaderOptimization() { + return hasClassesNamed( + "org.camunda.bpm.engine.impl.bpmn.behavior.ExternalTaskActivityBehavior"); + } + + @Override + public ElementMatcher typeMatcher() { + return named("org.camunda.bpm.engine.impl.bpmn.behavior.ExternalTaskActivityBehavior"); + } + + @Override + public void transform(TypeTransformer transformer) { + transformer.applyAdviceToMethod( + ElementMatchers.isMethod().and(ElementMatchers.named("execute")), + this.getClass().getName() + "$CamundaExternalTaskActivityBehaviorAdvice"); + } + + public static class CamundaExternalTaskActivityBehaviorAdvice { + + /** + * Sets parent context to process instance. Creates new context and span. propagates current + * context to variable set for topic to retrieve. + * + * @param execution + * @param request + * @param parentScope + * @param parentContext + * @param context + * @param scope + */ + @Advice.OnMethodEnter(suppress = Throwable.class) + public static void addTracingEnter( + @Advice.Argument(0) ActivityExecution execution, + @Advice.Local("request") CamundaCommonRequest request, + @Advice.Local("otelParentScope") Scope parentScope, + @Advice.Local("otelParentContext") Context parentContext, + @Advice.Local("otelContext") Context context, + @Advice.Local("otelScope") Scope scope) { + + if (execution == null) { + return; + } + + request = new CamundaCommonRequest(); + request.setProcessDefinitionId(Optional.ofNullable(execution.getProcessDefinitionId())); + request.setProcessInstanceId(Optional.ofNullable(execution.getProcessInstanceId())); + request.setActivityId(Optional.ofNullable(execution.getCurrentActivityId())); + request.setActivityName(Optional.ofNullable(execution.getCurrentActivityName())); + + String processInstanceId = execution.getProcessInstanceId(); + + if (Java8BytecodeBridge.currentContext() == Java8BytecodeBridge.rootContext()) {} + + parentContext = + getOpentelemetry() + .getPropagators() + .getTextMapPropagator() + .extract( + Java8BytecodeBridge.currentContext(), + execution, + new CamundaActivityExecutionGetter()); + + parentScope = parentContext.makeCurrent(); + + if (getInstumenter().shouldStart(Java8BytecodeBridge.currentContext(), request)) { + context = getInstumenter().start(Java8BytecodeBridge.currentContext(), request); + scope = context.makeCurrent(); + + getOpentelemetry() + .getPropagators() + .getTextMapPropagator() + .inject(context, execution, new CamundaActivityExecutionLocalSetter()); + } + } + + @Advice.OnMethodExit(onThrowable = Throwable.class, suppress = Throwable.class) + public static void closeTrace( + @Advice.Local("request") CamundaCommonRequest request, + @Advice.Local("otelParentScope") Scope parentScope, + @Advice.Local("otelParentContext") Context parentContext, + @Advice.Local("otelContext") Context context, + @Advice.Local("otelScope") Scope scope, + @Advice.Thrown Throwable throwable) { + + if (context != null && scope != null) { + getInstumenter().end(context, request, "NA", throwable); + scope.close(); + } + + if (parentScope != null) { + parentScope.close(); + } + } + } } diff --git a/instrumentation/camunda/camunda-7.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_0/behavior/CamundaExternalTaskActivityBehaviorModule.java b/instrumentation/camunda/camunda-7.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_0/behavior/CamundaExternalTaskActivityBehaviorModule.java index a5d9f3ea9732..a7022fb241f1 100644 --- a/instrumentation/camunda/camunda-7.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_0/behavior/CamundaExternalTaskActivityBehaviorModule.java +++ b/instrumentation/camunda/camunda-7.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_0/behavior/CamundaExternalTaskActivityBehaviorModule.java @@ -1,47 +1,53 @@ +/* + * Copyright The OpenTelemetry Authors + * SPDX-License-Identifier: Apache-2.0 + */ + package io.opentelemetry.javaagent.instrumentation.camunda.v7_0.behavior; import static io.opentelemetry.javaagent.extension.matcher.AgentElementMatchers.hasClassesNamed; -import java.util.Arrays; -import java.util.Collections; -import java.util.List; - import com.google.auto.service.AutoService; - import io.opentelemetry.javaagent.extension.instrumentation.InstrumentationModule; import io.opentelemetry.javaagent.extension.instrumentation.TypeInstrumentation; import io.opentelemetry.sdk.autoconfigure.spi.ConfigProperties; +import java.util.Arrays; +import java.util.Collections; +import java.util.List; import net.bytebuddy.matcher.ElementMatcher; @AutoService(InstrumentationModule.class) public class CamundaExternalTaskActivityBehaviorModule extends InstrumentationModule { - public CamundaExternalTaskActivityBehaviorModule() { - super("camunda", "camunda-behavior", "camunda-behavior-7_18"); - } - - @Override - public boolean defaultEnabled(ConfigProperties config) { - return config.getBoolean("otel.instrumentation.common.default-enabled", true); - } - - @Override - public List typeInstrumentations() { - return Collections.singletonList(new CamundaExternalTaskActivityBehaviorInstrumentation()); - } - - @Override - public ElementMatcher.Junction classLoaderMatcher() { - return hasClassesNamed("org.camunda.bpm.engine.impl.bpmn.behavior.ExternalTaskActivityBehavior"); - } - - String[] helperClassnames = { "io.opentelemetry.javaagent.instrumentation.camunda.v7_0.behavior", - "io.opentelemetry.instrumentation.camunda.v7_0.behavior", - "io.opentelemetry.instrumentation.camunda.v7_0.common" }; - - @Override - public boolean isHelperClass(String classname) { - return super.isHelperClass(classname) || Arrays.stream(helperClassnames).anyMatch(c -> classname.startsWith(c)); - } - + public CamundaExternalTaskActivityBehaviorModule() { + super("camunda", "camunda-behavior", "camunda-behavior-7_18"); + } + + @Override + public boolean defaultEnabled(ConfigProperties config) { + return config.getBoolean("otel.instrumentation.common.default-enabled", true); + } + + @Override + public List typeInstrumentations() { + return Collections.singletonList(new CamundaExternalTaskActivityBehaviorInstrumentation()); + } + + @Override + public ElementMatcher.Junction classLoaderMatcher() { + return hasClassesNamed( + "org.camunda.bpm.engine.impl.bpmn.behavior.ExternalTaskActivityBehavior"); + } + + String[] helperClassnames = { + "io.opentelemetry.javaagent.instrumentation.camunda.v7_0.behavior", + "io.opentelemetry.instrumentation.camunda.v7_0.behavior", + "io.opentelemetry.instrumentation.camunda.v7_0.common" + }; + + @Override + public boolean isHelperClass(String classname) { + return super.isHelperClass(classname) + || Arrays.stream(helperClassnames).anyMatch(c -> classname.startsWith(c)); + } } diff --git a/instrumentation/camunda/camunda-7.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_0/behavior/CamundaTaskActivityBehaviorInstrumentation.java b/instrumentation/camunda/camunda-7.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_0/behavior/CamundaTaskActivityBehaviorInstrumentation.java index acd1bab3e285..a77f8eed9b73 100644 --- a/instrumentation/camunda/camunda-7.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_0/behavior/CamundaTaskActivityBehaviorInstrumentation.java +++ b/instrumentation/camunda/camunda-7.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_0/behavior/CamundaTaskActivityBehaviorInstrumentation.java @@ -1,101 +1,106 @@ +/* + * Copyright The OpenTelemetry Authors + * SPDX-License-Identifier: Apache-2.0 + */ + package io.opentelemetry.javaagent.instrumentation.camunda.v7_0.behavior; -import static io.opentelemetry.javaagent.instrumentation.camunda.v7_0.behavior.CamundaBehaviorSingletons.getInstumenter; -import static io.opentelemetry.javaagent.instrumentation.camunda.v7_0.behavior.CamundaBehaviorSingletons.getOpentelemetry; import static io.opentelemetry.javaagent.extension.matcher.AgentElementMatchers.hasClassesNamed; import static io.opentelemetry.javaagent.extension.matcher.AgentElementMatchers.hasSuperType; +import static io.opentelemetry.javaagent.instrumentation.camunda.v7_0.behavior.CamundaBehaviorSingletons.getInstumenter; +import static io.opentelemetry.javaagent.instrumentation.camunda.v7_0.behavior.CamundaBehaviorSingletons.getOpentelemetry; import static net.bytebuddy.matcher.ElementMatchers.named; -import java.util.Optional; -import java.util.logging.Level; - -import org.camunda.bpm.engine.impl.pvm.delegate.ActivityExecution; - import io.opentelemetry.camunda.v7_0.behavior.CamundaActivityExecutionGetter; import io.opentelemetry.camunda.v7_0.common.CamundaCommonRequest; - -import io.opentelemetry.api.trace.SpanContext; import io.opentelemetry.context.Context; import io.opentelemetry.context.Scope; import io.opentelemetry.javaagent.bootstrap.Java8BytecodeBridge; import io.opentelemetry.javaagent.extension.instrumentation.TypeInstrumentation; import io.opentelemetry.javaagent.extension.instrumentation.TypeTransformer; +import java.util.Optional; import net.bytebuddy.asm.Advice; import net.bytebuddy.description.type.TypeDescription; import net.bytebuddy.matcher.ElementMatcher; import net.bytebuddy.matcher.ElementMatchers; +import org.camunda.bpm.engine.impl.pvm.delegate.ActivityExecution; public class CamundaTaskActivityBehaviorInstrumentation implements TypeInstrumentation { - @Override - public ElementMatcher classLoaderOptimization() { - return hasClassesNamed("org.camunda.bpm.engine.impl.bpmn.behavior.TaskActivityBehavior"); - } - - @Override - public ElementMatcher typeMatcher() { - return hasSuperType(named("org.camunda.bpm.engine.impl.bpmn.behavior.TaskActivityBehavior")); - } - - @Override - public void transform(TypeTransformer transformer) { - transformer.applyAdviceToMethod(ElementMatchers.isMethod().and(ElementMatchers.named("performExecution")), - this.getClass().getName() + "$CamundaTaskActivityBehaviorAdvice"); - } - - public static class CamundaTaskActivityBehaviorAdvice { - - @Advice.OnMethodEnter(suppress = Throwable.class) - public static void addTracingEnter(@Advice.Argument(0) ActivityExecution execution, - @Advice.Local("request") CamundaCommonRequest request, - @Advice.Local("otelParentScope") Scope parentScope, @Advice.Local("otelContext") Context context, - @Advice.Local("otelScope") Scope scope) { - - - if (execution == null) { - return; - } - - request = new CamundaCommonRequest(); - request.setProcessDefinitionId(Optional.ofNullable(execution.getProcessDefinitionId())); - request.setProcessInstanceId(Optional.ofNullable(execution.getProcessInstanceId())); - request.setActivityId(Optional.ofNullable(execution.getCurrentActivityId())); - request.setActivityName(Optional.ofNullable(execution.getCurrentActivityName())); - - String processInstanceId = execution.getProcessInstanceId(); - - if (Java8BytecodeBridge.currentContext() == Java8BytecodeBridge.rootContext()) { - } - - Context parentContext = getOpentelemetry().getPropagators().getTextMapPropagator() - .extract(Java8BytecodeBridge.currentContext(), execution, new CamundaActivityExecutionGetter()); - - parentScope = parentContext.makeCurrent(); - - if (getInstumenter().shouldStart(Java8BytecodeBridge.currentContext(), request)) { - context = getInstumenter().start(Java8BytecodeBridge.currentContext(), request); - scope = context.makeCurrent(); - - } - - } - - @Advice.OnMethodExit(onThrowable = Throwable.class, suppress = Throwable.class) - public static void closeTrace(@Advice.Local("request") CamundaCommonRequest request, - @Advice.Local("otelParentScope") Scope parentScope, @Advice.Local("otelContext") Context context, - @Advice.Local("otelScope") Scope scope, @Advice.Thrown Throwable throwable) { - - - if (context != null && scope != null) { - getInstumenter().end(context, request, "NA", throwable); - scope.close(); - } - - if (parentScope != null) { - parentScope.close(); - } - - } - } - + @Override + public ElementMatcher classLoaderOptimization() { + return hasClassesNamed("org.camunda.bpm.engine.impl.bpmn.behavior.TaskActivityBehavior"); + } + + @Override + public ElementMatcher typeMatcher() { + return hasSuperType(named("org.camunda.bpm.engine.impl.bpmn.behavior.TaskActivityBehavior")); + } + + @Override + public void transform(TypeTransformer transformer) { + transformer.applyAdviceToMethod( + ElementMatchers.isMethod().and(ElementMatchers.named("performExecution")), + this.getClass().getName() + "$CamundaTaskActivityBehaviorAdvice"); + } + + public static class CamundaTaskActivityBehaviorAdvice { + + @Advice.OnMethodEnter(suppress = Throwable.class) + public static void addTracingEnter( + @Advice.Argument(0) ActivityExecution execution, + @Advice.Local("request") CamundaCommonRequest request, + @Advice.Local("otelParentScope") Scope parentScope, + @Advice.Local("otelContext") Context context, + @Advice.Local("otelScope") Scope scope) { + + if (execution == null) { + return; + } + + request = new CamundaCommonRequest(); + request.setProcessDefinitionId(Optional.ofNullable(execution.getProcessDefinitionId())); + request.setProcessInstanceId(Optional.ofNullable(execution.getProcessInstanceId())); + request.setActivityId(Optional.ofNullable(execution.getCurrentActivityId())); + request.setActivityName(Optional.ofNullable(execution.getCurrentActivityName())); + + String processInstanceId = execution.getProcessInstanceId(); + + if (Java8BytecodeBridge.currentContext() == Java8BytecodeBridge.rootContext()) {} + + Context parentContext = + getOpentelemetry() + .getPropagators() + .getTextMapPropagator() + .extract( + Java8BytecodeBridge.currentContext(), + execution, + new CamundaActivityExecutionGetter()); + + parentScope = parentContext.makeCurrent(); + + if (getInstumenter().shouldStart(Java8BytecodeBridge.currentContext(), request)) { + context = getInstumenter().start(Java8BytecodeBridge.currentContext(), request); + scope = context.makeCurrent(); + } + } + + @Advice.OnMethodExit(onThrowable = Throwable.class, suppress = Throwable.class) + public static void closeTrace( + @Advice.Local("request") CamundaCommonRequest request, + @Advice.Local("otelParentScope") Scope parentScope, + @Advice.Local("otelContext") Context context, + @Advice.Local("otelScope") Scope scope, + @Advice.Thrown Throwable throwable) { + + if (context != null && scope != null) { + getInstumenter().end(context, request, "NA", throwable); + scope.close(); + } + + if (parentScope != null) { + parentScope.close(); + } + } + } } diff --git a/instrumentation/camunda/camunda-7.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_0/behavior/CamundaTaskActivityBehaviorModule.java b/instrumentation/camunda/camunda-7.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_0/behavior/CamundaTaskActivityBehaviorModule.java index d4c09a403295..5573874c3e24 100644 --- a/instrumentation/camunda/camunda-7.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_0/behavior/CamundaTaskActivityBehaviorModule.java +++ b/instrumentation/camunda/camunda-7.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_0/behavior/CamundaTaskActivityBehaviorModule.java @@ -1,47 +1,52 @@ +/* + * Copyright The OpenTelemetry Authors + * SPDX-License-Identifier: Apache-2.0 + */ + package io.opentelemetry.javaagent.instrumentation.camunda.v7_0.behavior; import static io.opentelemetry.javaagent.extension.matcher.AgentElementMatchers.hasClassesNamed; -import java.util.Arrays; -import java.util.Collections; -import java.util.List; - import com.google.auto.service.AutoService; - import io.opentelemetry.javaagent.extension.instrumentation.InstrumentationModule; import io.opentelemetry.javaagent.extension.instrumentation.TypeInstrumentation; import io.opentelemetry.sdk.autoconfigure.spi.ConfigProperties; +import java.util.Arrays; +import java.util.Collections; +import java.util.List; import net.bytebuddy.matcher.ElementMatcher; @AutoService(InstrumentationModule.class) public class CamundaTaskActivityBehaviorModule extends InstrumentationModule { - public CamundaTaskActivityBehaviorModule() { - super("camunda", "camunda-behavior", "camunda-behavior-7_18"); - } - - @Override - public boolean defaultEnabled(ConfigProperties config) { - return config.getBoolean("otel.instrumentation.common.default-enabled", true); - } - - @Override - public List typeInstrumentations() { - return Collections.singletonList(new CamundaTaskActivityBehaviorInstrumentation()); - } - - @Override - public ElementMatcher.Junction classLoaderMatcher() { - return hasClassesNamed("org.camunda.bpm.engine.impl.bpmn.behavior.TaskActivityBehavior"); - } - - String[] helperClassnames = { "io.opentelemetry.javaagent.instrumentation.camunda.v7_0.behavior", - "io.opentelemetry.instrumentation.camunda.v7_0.behavior", - "io.opentelemetry.instrumentation.camunda.v7_0.common"}; - - @Override - public boolean isHelperClass(String classname) { - return super.isHelperClass(classname) || Arrays.stream(helperClassnames).anyMatch(c -> classname.startsWith(c)); - } - + public CamundaTaskActivityBehaviorModule() { + super("camunda", "camunda-behavior", "camunda-behavior-7_18"); + } + + @Override + public boolean defaultEnabled(ConfigProperties config) { + return config.getBoolean("otel.instrumentation.common.default-enabled", true); + } + + @Override + public List typeInstrumentations() { + return Collections.singletonList(new CamundaTaskActivityBehaviorInstrumentation()); + } + + @Override + public ElementMatcher.Junction classLoaderMatcher() { + return hasClassesNamed("org.camunda.bpm.engine.impl.bpmn.behavior.TaskActivityBehavior"); + } + + String[] helperClassnames = { + "io.opentelemetry.javaagent.instrumentation.camunda.v7_0.behavior", + "io.opentelemetry.instrumentation.camunda.v7_0.behavior", + "io.opentelemetry.instrumentation.camunda.v7_0.common" + }; + + @Override + public boolean isHelperClass(String classname) { + return super.isHelperClass(classname) + || Arrays.stream(helperClassnames).anyMatch(c -> classname.startsWith(c)); + } } diff --git a/instrumentation/camunda/camunda-7.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_0/jobs/CamundaAsyncContinuationJobHandlerInstrumentation.java b/instrumentation/camunda/camunda-7.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_0/jobs/CamundaAsyncContinuationJobHandlerInstrumentation.java index 00aef60740ff..59873c4e409a 100644 --- a/instrumentation/camunda/camunda-7.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_0/jobs/CamundaAsyncContinuationJobHandlerInstrumentation.java +++ b/instrumentation/camunda/camunda-7.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_0/jobs/CamundaAsyncContinuationJobHandlerInstrumentation.java @@ -1,112 +1,122 @@ +/* + * Copyright The OpenTelemetry Authors + * SPDX-License-Identifier: Apache-2.0 + */ + package io.opentelemetry.javaagent.instrumentation.camunda.v7_0.jobs; import static io.opentelemetry.javaagent.extension.matcher.AgentElementMatchers.hasClassesNamed; - -import java.util.Optional; - import static io.opentelemetry.javaagent.instrumentation.camunda.v7_0.jobs.CamundaJobSingletons.getInstumenter; import static io.opentelemetry.javaagent.instrumentation.camunda.v7_0.jobs.CamundaJobSingletons.getOpentelemetry; -import org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity; - -import io.opentelemetry.instrumentation.camunda.v7_0.common.CamundaCommonRequest; -import io.opentelemetry.instrumentation.camunda.v7_0.jobs.CamundaExecutionEntityGetter; - -import io.opentelemetry.api.trace.SpanContext; import io.opentelemetry.context.Context; import io.opentelemetry.context.Scope; +import io.opentelemetry.instrumentation.camunda.v7_0.common.CamundaCommonRequest; +import io.opentelemetry.instrumentation.camunda.v7_0.jobs.CamundaExecutionEntityGetter; import io.opentelemetry.javaagent.bootstrap.Java8BytecodeBridge; import io.opentelemetry.javaagent.extension.instrumentation.TypeInstrumentation; import io.opentelemetry.javaagent.extension.instrumentation.TypeTransformer; +import java.util.Optional; import net.bytebuddy.asm.Advice; import net.bytebuddy.description.type.TypeDescription; import net.bytebuddy.matcher.ElementMatcher; import net.bytebuddy.matcher.ElementMatchers; +import org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity; public class CamundaAsyncContinuationJobHandlerInstrumentation implements TypeInstrumentation { - @Override - public ElementMatcher classLoaderOptimization() { - return hasClassesNamed("org.camunda.bpm.engine.impl.jobexecutor.AsyncContinuationJobHandler"); - } - - @Override - public ElementMatcher typeMatcher() { - return ElementMatchers.named("org.camunda.bpm.engine.impl.jobexecutor.AsyncContinuationJobHandler"); - } - - @Override - public void transform(TypeTransformer transformer) { - transformer - .applyAdviceToMethod( - ElementMatchers.isMethod().and(ElementMatchers.named("execute")) - .and(ElementMatchers.takesArgument(1, - ElementMatchers.named( - "org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity"))), - this.getClass().getName() + "$CamundaAsyncContinuationJobHandlerAdvice"); - } - - public static class CamundaAsyncContinuationJobHandlerAdvice { - @Advice.OnMethodEnter(suppress = Throwable.class) - public static void addTracingEnter(@Advice.Argument(1) ExecutionEntity executionEntity, - @Advice.Local("request") CamundaCommonRequest request, - @Advice.Local("otelParentScope") Scope parentScope, @Advice.Local("otelContext") Context context, - @Advice.Local("otelScope") Scope scope) { - - - if (executionEntity == null) { - return; - } - - request = new CamundaCommonRequest(); - request.setProcessDefinitionId(Optional.ofNullable(executionEntity.getProcessDefinitionId())); - if (executionEntity.getProcessDefinition() != null) { - request.setProcessDefinitionKey(Optional.ofNullable(executionEntity.getProcessDefinition().getKey())); - } - request.setProcessInstanceId(Optional.ofNullable(executionEntity.getProcessInstanceId())); - request.setActivityId(Optional.ofNullable(executionEntity.getActivityId())); - if (executionEntity.getActivity() != null) { - request.setActivityName(Optional.ofNullable(executionEntity.getActivity().getName())); - } - - String processInstanceId = executionEntity.getProcessInstanceId(); - - if (Java8BytecodeBridge.currentContext() == Java8BytecodeBridge.rootContext()) { - System.out.println("No initial span context for process instance " + processInstanceId); - } - - Context parentContext = getOpentelemetry().getPropagators().getTextMapPropagator() - .extract(Java8BytecodeBridge.currentContext(), executionEntity, new CamundaExecutionEntityGetter()); - - parentScope = parentContext.makeCurrent(); - - if (getInstumenter().shouldStart(Java8BytecodeBridge.currentContext(), request)) { - context = getInstumenter().start(Java8BytecodeBridge.currentContext(), request); - scope = context.makeCurrent(); - - } else { - System.out.println("Unable to start telemetry for process " + processInstanceId); - } - - } - - @Advice.OnMethodExit(onThrowable = Throwable.class, suppress = Throwable.class) - public static void closeTrace(@Advice.Argument(1) ExecutionEntity executionEntity, - @Advice.Local("request") CamundaCommonRequest request, - @Advice.Local("otelParentScope") Scope parentScope, @Advice.Local("otelContext") Context context, - @Advice.Local("otelScope") Scope scope, @Advice.Thrown Throwable throwable) { - - - if (context != null && scope != null) { - getInstumenter().end(context, request, "NA", throwable); - scope.close(); - } - - if (parentScope != null) { - parentScope.close(); - } - - } - } - + @Override + public ElementMatcher classLoaderOptimization() { + return hasClassesNamed("org.camunda.bpm.engine.impl.jobexecutor.AsyncContinuationJobHandler"); + } + + @Override + public ElementMatcher typeMatcher() { + return ElementMatchers.named( + "org.camunda.bpm.engine.impl.jobexecutor.AsyncContinuationJobHandler"); + } + + @Override + public void transform(TypeTransformer transformer) { + transformer.applyAdviceToMethod( + ElementMatchers.isMethod() + .and(ElementMatchers.named("execute")) + .and( + ElementMatchers.takesArgument( + 1, + ElementMatchers.named( + "org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity"))), + this.getClass().getName() + "$CamundaAsyncContinuationJobHandlerAdvice"); + } + + public static class CamundaAsyncContinuationJobHandlerAdvice { + @Advice.OnMethodEnter(suppress = Throwable.class) + public static void addTracingEnter( + @Advice.Argument(1) ExecutionEntity executionEntity, + @Advice.Local("request") CamundaCommonRequest request, + @Advice.Local("otelParentScope") Scope parentScope, + @Advice.Local("otelContext") Context context, + @Advice.Local("otelScope") Scope scope) { + + if (executionEntity == null) { + return; + } + + request = new CamundaCommonRequest(); + request.setProcessDefinitionId(Optional.ofNullable(executionEntity.getProcessDefinitionId())); + if (executionEntity.getProcessDefinition() != null) { + request.setProcessDefinitionKey( + Optional.ofNullable(executionEntity.getProcessDefinition().getKey())); + } + request.setProcessInstanceId(Optional.ofNullable(executionEntity.getProcessInstanceId())); + request.setActivityId(Optional.ofNullable(executionEntity.getActivityId())); + if (executionEntity.getActivity() != null) { + request.setActivityName(Optional.ofNullable(executionEntity.getActivity().getName())); + } + + String processInstanceId = executionEntity.getProcessInstanceId(); + + if (Java8BytecodeBridge.currentContext() == Java8BytecodeBridge.rootContext()) { + System.out.println("No initial span context for process instance " + processInstanceId); + } + + Context parentContext = + getOpentelemetry() + .getPropagators() + .getTextMapPropagator() + .extract( + Java8BytecodeBridge.currentContext(), + executionEntity, + new CamundaExecutionEntityGetter()); + + parentScope = parentContext.makeCurrent(); + + if (getInstumenter().shouldStart(Java8BytecodeBridge.currentContext(), request)) { + context = getInstumenter().start(Java8BytecodeBridge.currentContext(), request); + scope = context.makeCurrent(); + + } else { + System.out.println("Unable to start telemetry for process " + processInstanceId); + } + } + + @Advice.OnMethodExit(onThrowable = Throwable.class, suppress = Throwable.class) + public static void closeTrace( + @Advice.Argument(1) ExecutionEntity executionEntity, + @Advice.Local("request") CamundaCommonRequest request, + @Advice.Local("otelParentScope") Scope parentScope, + @Advice.Local("otelContext") Context context, + @Advice.Local("otelScope") Scope scope, + @Advice.Thrown Throwable throwable) { + + if (context != null && scope != null) { + getInstumenter().end(context, request, "NA", throwable); + scope.close(); + } + + if (parentScope != null) { + parentScope.close(); + } + } + } } diff --git a/instrumentation/camunda/camunda-7.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_0/jobs/CamundaAsyncContinuationJobHandlerModule.java b/instrumentation/camunda/camunda-7.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_0/jobs/CamundaAsyncContinuationJobHandlerModule.java index 0ae39888ac80..6fc6c5cf67fe 100644 --- a/instrumentation/camunda/camunda-7.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_0/jobs/CamundaAsyncContinuationJobHandlerModule.java +++ b/instrumentation/camunda/camunda-7.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_0/jobs/CamundaAsyncContinuationJobHandlerModule.java @@ -1,47 +1,52 @@ +/* + * Copyright The OpenTelemetry Authors + * SPDX-License-Identifier: Apache-2.0 + */ + package io.opentelemetry.javaagent.instrumentation.camunda.v7_0.jobs; import static io.opentelemetry.javaagent.extension.matcher.AgentElementMatchers.hasClassesNamed; -import java.util.Arrays; -import java.util.Collections; -import java.util.List; - import com.google.auto.service.AutoService; - import io.opentelemetry.javaagent.extension.instrumentation.InstrumentationModule; import io.opentelemetry.javaagent.extension.instrumentation.TypeInstrumentation; import io.opentelemetry.sdk.autoconfigure.spi.ConfigProperties; +import java.util.Arrays; +import java.util.Collections; +import java.util.List; import net.bytebuddy.matcher.ElementMatcher; @AutoService(InstrumentationModule.class) public class CamundaAsyncContinuationJobHandlerModule extends InstrumentationModule { - public CamundaAsyncContinuationJobHandlerModule() { - super("camunda", "camunda-job", "camunda-job-7_18"); - } - - @Override - public boolean defaultEnabled(ConfigProperties config) { - return config.getBoolean("otel.instrumentation.common.default-enabled", true); - } - - @Override - public List typeInstrumentations() { - return Collections.singletonList(new CamundaAsyncContinuationJobHandlerInstrumentation()); - } - - @Override - public ElementMatcher.Junction classLoaderMatcher() { - return hasClassesNamed("org.camunda.bpm.engine.impl.jobexecutor.AsyncContinuationJobHandler"); - } - - String[] helperClassnames = { "io.opentelemetry.javaagent.instrumentation.camunda.v7_0.jobs", - "io.opentelemetry.instrumentation.camunda.v7_0.jobs", - "io.opentelemetry.instrumentation.camunda.v7_0.common"}; - - @Override - public boolean isHelperClass(String classname) { - return super.isHelperClass(classname) || Arrays.stream(helperClassnames).anyMatch(c -> classname.startsWith(c)); - } - + public CamundaAsyncContinuationJobHandlerModule() { + super("camunda", "camunda-job", "camunda-job-7_18"); + } + + @Override + public boolean defaultEnabled(ConfigProperties config) { + return config.getBoolean("otel.instrumentation.common.default-enabled", true); + } + + @Override + public List typeInstrumentations() { + return Collections.singletonList(new CamundaAsyncContinuationJobHandlerInstrumentation()); + } + + @Override + public ElementMatcher.Junction classLoaderMatcher() { + return hasClassesNamed("org.camunda.bpm.engine.impl.jobexecutor.AsyncContinuationJobHandler"); + } + + String[] helperClassnames = { + "io.opentelemetry.javaagent.instrumentation.camunda.v7_0.jobs", + "io.opentelemetry.instrumentation.camunda.v7_0.jobs", + "io.opentelemetry.instrumentation.camunda.v7_0.common" + }; + + @Override + public boolean isHelperClass(String classname) { + return super.isHelperClass(classname) + || Arrays.stream(helperClassnames).anyMatch(c -> classname.startsWith(c)); + } } diff --git a/instrumentation/camunda/camunda-7.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_0/jobs/CamundaJobSingletons.java b/instrumentation/camunda/camunda-7.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_0/jobs/CamundaJobSingletons.java index 1c643c5aaa5e..bfb56dd42667 100644 --- a/instrumentation/camunda/camunda-7.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_0/jobs/CamundaJobSingletons.java +++ b/instrumentation/camunda/camunda-7.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_0/jobs/CamundaJobSingletons.java @@ -1,41 +1,40 @@ -package io.opentelemetry.javaagent.instrumentation.camunda.v7_0.jobs; - -import org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity; +/* + * Copyright The OpenTelemetry Authors + * SPDX-License-Identifier: Apache-2.0 + */ -import io.opentelemetry.instrumentation.camunda.v7_0.common.CamundaCommonRequest; -import io.opentelemetry.instrumentation.camunda.v7_0.common.CamundaVariableAttributeExtractor; -import io.opentelemetry.instrumentation.camunda.v7_0.jobs.CamundaJobSpanNameExtractor; +package io.opentelemetry.javaagent.instrumentation.camunda.v7_0.jobs; import io.opentelemetry.api.GlobalOpenTelemetry; import io.opentelemetry.api.OpenTelemetry; import io.opentelemetry.instrumentation.api.instrumenter.Instrumenter; import io.opentelemetry.instrumentation.api.instrumenter.InstrumenterBuilder; +import io.opentelemetry.instrumentation.camunda.v7_0.common.CamundaCommonRequest; +import io.opentelemetry.instrumentation.camunda.v7_0.common.CamundaVariableAttributeExtractor; +import io.opentelemetry.instrumentation.camunda.v7_0.jobs.CamundaJobSpanNameExtractor; public class CamundaJobSingletons { - private static final Instrumenter instrumenter; - - private static final OpenTelemetry opentelemetry; - - static { - - opentelemetry = GlobalOpenTelemetry.get(); + private static final Instrumenter instrumenter; - InstrumenterBuilder builder = Instrumenter - .builder(opentelemetry, "io.opentelemetry.camunda-job", - new CamundaJobSpanNameExtractor()) - .addAttributesExtractor(new CamundaVariableAttributeExtractor()); + private static final OpenTelemetry opentelemetry; - instrumenter = builder.buildInstrumenter(); - } + static { + opentelemetry = GlobalOpenTelemetry.get(); - public static OpenTelemetry getOpentelemetry() { - return opentelemetry; - } + InstrumenterBuilder builder = + Instrumenter.builder( + opentelemetry, "io.opentelemetry.camunda-job", new CamundaJobSpanNameExtractor()) + .addAttributesExtractor(new CamundaVariableAttributeExtractor()); - public static Instrumenter getInstumenter() { - return instrumenter; - } + instrumenter = builder.buildInstrumenter(); + } + public static OpenTelemetry getOpentelemetry() { + return opentelemetry; + } + public static Instrumenter getInstumenter() { + return instrumenter; + } } diff --git a/instrumentation/camunda/camunda-7.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_0/processes/CamundaProcessInstantiationBuilderInstrumentation.java b/instrumentation/camunda/camunda-7.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_0/processes/CamundaProcessInstantiationBuilderInstrumentation.java index f69c9536f0b6..c2a58f257b39 100644 --- a/instrumentation/camunda/camunda-7.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_0/processes/CamundaProcessInstantiationBuilderInstrumentation.java +++ b/instrumentation/camunda/camunda-7.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_0/processes/CamundaProcessInstantiationBuilderInstrumentation.java @@ -1,3 +1,8 @@ +/* + * Copyright The OpenTelemetry Authors + * SPDX-License-Identifier: Apache-2.0 + */ + package io.opentelemetry.javaagent.instrumentation.camunda.v7_0.processes; import static io.opentelemetry.javaagent.extension.matcher.AgentElementMatchers.hasClassesNamed; @@ -5,89 +10,92 @@ import static net.bytebuddy.matcher.ElementMatchers.isMethod; import static net.bytebuddy.matcher.ElementMatchers.named; -import java.util.Optional; - -import io.opentelemetry.instrumentation.camunda.v7_0.common.CamundaCommonRequest; -import io.opentelemetry.instrumentation.camunda.v7_0.processes.CamundaActivityInstantiationBuilderSetter; -import io.opentelemetry.javaagent.instrumentation.camunda.v7_0.processes.CamundaProcessSingletons; - -import org.camunda.bpm.engine.impl.ProcessInstanceModificationBuilderImpl; -import org.camunda.bpm.engine.runtime.ProcessInstance; - import io.opentelemetry.api.trace.SpanContext; import io.opentelemetry.context.Context; import io.opentelemetry.context.Scope; +import io.opentelemetry.instrumentation.camunda.v7_0.common.CamundaCommonRequest; +import io.opentelemetry.instrumentation.camunda.v7_0.processes.CamundaActivityInstantiationBuilderSetter; import io.opentelemetry.javaagent.bootstrap.Java8BytecodeBridge; import io.opentelemetry.javaagent.extension.instrumentation.TypeInstrumentation; import io.opentelemetry.javaagent.extension.instrumentation.TypeTransformer; +import java.util.Optional; import net.bytebuddy.asm.Advice; import net.bytebuddy.description.type.TypeDescription; import net.bytebuddy.matcher.ElementMatcher; +import org.camunda.bpm.engine.impl.ProcessInstanceModificationBuilderImpl; +import org.camunda.bpm.engine.runtime.ProcessInstance; public class CamundaProcessInstantiationBuilderInstrumentation implements TypeInstrumentation { - @Override - public ElementMatcher classLoaderOptimization() { - return hasClassesNamed("org.camunda.bpm.engine.runtime.ProcessInstantiationBuilder"); - } - - @Override - public ElementMatcher typeMatcher() { - return hasSuperType(named("org.camunda.bpm.engine.runtime.ProcessInstantiationBuilder")); - } - - @Override - public void transform(TypeTransformer transformer) { - // comment out for now because it causes duplicate spans - // transformer.applyAdviceToMethod(isMethod().and(named("execute")), - // this.getClass().getName() + - // "$CamundaProcessInstantiationBuilderExecuteAdvice"); - - transformer.applyAdviceToMethod(isMethod().and(named("executeWithVariablesInReturn")), - this.getClass().getName() + "$CamundaProcessInstantiationBuilderExecuteWithVariablesAdvice"); - - } - - public static class CamundaProcessInstantiationBuilderExecuteWithVariablesAdvice { - - @Advice.OnMethodEnter(suppress = Throwable.class) - public static void addTracingEnter( - @Advice.FieldValue("modificationBuilder") ProcessInstanceModificationBuilderImpl modificationBuilder, - @Advice.FieldValue("processDefinitionKey") String processDefinitionKey, - @Advice.FieldValue("businessKey") String businessKey, - @Advice.Local("request") CamundaCommonRequest request, @Advice.Local("otelContext") Context context, - @Advice.Local("otelScope") Scope scope) { - - request = new CamundaCommonRequest(); - request.setProcessDefinitionKey(Optional.ofNullable(processDefinitionKey)); - - Context parentContext = Java8BytecodeBridge.currentContext(); - - if (CamundaProcessSingletons.getInstumenter().shouldStart(parentContext, request)) { - context = CamundaProcessSingletons.getInstumenter().start(parentContext, request); - scope = context.makeCurrent(); - - SpanContext currentSpanContext = Java8BytecodeBridge.spanFromContext(context).getSpanContext(); - if (currentSpanContext.isValid()) { - CamundaProcessSingletons.getOpentelemetry().getPropagators().getTextMapPropagator() - .inject(context, modificationBuilder, new CamundaActivityInstantiationBuilderSetter()); - } - - } - } - - @Advice.OnMethodExit(onThrowable = Throwable.class, suppress = Throwable.class) - public static void closeTrace(@Advice.FieldValue("processDefinitionKey") String processDefinitionKey, - @Advice.Local("request") CamundaCommonRequest request, @Advice.Local("otelContext") Context context, - @Advice.Local("otelScope") Scope scope, @Advice.Thrown Throwable throwable, - @Advice.Return ProcessInstance pi) { - - if (context != null && scope != null) { - CamundaProcessSingletons.getInstumenter().end(context, request, "NA", throwable); - scope.close(); - } - - } - } - + @Override + public ElementMatcher classLoaderOptimization() { + return hasClassesNamed("org.camunda.bpm.engine.runtime.ProcessInstantiationBuilder"); + } + + @Override + public ElementMatcher typeMatcher() { + return hasSuperType(named("org.camunda.bpm.engine.runtime.ProcessInstantiationBuilder")); + } + + @Override + public void transform(TypeTransformer transformer) { + // comment out for now because it causes duplicate spans + // transformer.applyAdviceToMethod(isMethod().and(named("execute")), + // this.getClass().getName() + + // "$CamundaProcessInstantiationBuilderExecuteAdvice"); + + transformer.applyAdviceToMethod( + isMethod().and(named("executeWithVariablesInReturn")), + this.getClass().getName() + + "$CamundaProcessInstantiationBuilderExecuteWithVariablesAdvice"); + } + + public static class CamundaProcessInstantiationBuilderExecuteWithVariablesAdvice { + + @Advice.OnMethodEnter(suppress = Throwable.class) + public static void addTracingEnter( + @Advice.FieldValue("modificationBuilder") + ProcessInstanceModificationBuilderImpl modificationBuilder, + @Advice.FieldValue("processDefinitionKey") String processDefinitionKey, + @Advice.FieldValue("businessKey") String businessKey, + @Advice.Local("request") CamundaCommonRequest request, + @Advice.Local("otelContext") Context context, + @Advice.Local("otelScope") Scope scope) { + + request = new CamundaCommonRequest(); + request.setProcessDefinitionKey(Optional.ofNullable(processDefinitionKey)); + + Context parentContext = Java8BytecodeBridge.currentContext(); + + if (CamundaProcessSingletons.getInstumenter().shouldStart(parentContext, request)) { + context = CamundaProcessSingletons.getInstumenter().start(parentContext, request); + scope = context.makeCurrent(); + + SpanContext currentSpanContext = + Java8BytecodeBridge.spanFromContext(context).getSpanContext(); + if (currentSpanContext.isValid()) { + CamundaProcessSingletons.getOpentelemetry() + .getPropagators() + .getTextMapPropagator() + .inject( + context, modificationBuilder, new CamundaActivityInstantiationBuilderSetter()); + } + } + } + + @Advice.OnMethodExit(onThrowable = Throwable.class, suppress = Throwable.class) + public static void closeTrace( + @Advice.FieldValue("processDefinitionKey") String processDefinitionKey, + @Advice.Local("request") CamundaCommonRequest request, + @Advice.Local("otelContext") Context context, + @Advice.Local("otelScope") Scope scope, + @Advice.Thrown Throwable throwable, + @Advice.Return ProcessInstance pi) { + + if (context != null && scope != null) { + CamundaProcessSingletons.getInstumenter().end(context, request, "NA", throwable); + scope.close(); + } + } + } } diff --git a/instrumentation/camunda/camunda-7.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_0/processes/CamundaProcessInstantiationBuilderModule.java b/instrumentation/camunda/camunda-7.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_0/processes/CamundaProcessInstantiationBuilderModule.java index b8e7c828d787..bb4474647813 100644 --- a/instrumentation/camunda/camunda-7.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_0/processes/CamundaProcessInstantiationBuilderModule.java +++ b/instrumentation/camunda/camunda-7.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_0/processes/CamundaProcessInstantiationBuilderModule.java @@ -1,49 +1,53 @@ +/* + * Copyright The OpenTelemetry Authors + * SPDX-License-Identifier: Apache-2.0 + */ + package io.opentelemetry.javaagent.instrumentation.camunda.v7_0.processes; import static io.opentelemetry.javaagent.extension.matcher.AgentElementMatchers.hasClassesNamed; -import java.util.Arrays; -import java.util.Collections; -import java.util.List; -import java.util.logging.Logger; - import com.google.auto.service.AutoService; - import io.opentelemetry.javaagent.extension.instrumentation.InstrumentationModule; import io.opentelemetry.javaagent.extension.instrumentation.TypeInstrumentation; import io.opentelemetry.sdk.autoconfigure.spi.ConfigProperties; +import java.util.Arrays; +import java.util.Collections; +import java.util.List; import net.bytebuddy.matcher.ElementMatcher; @AutoService(InstrumentationModule.class) public class CamundaProcessInstantiationBuilderModule extends InstrumentationModule { - public CamundaProcessInstantiationBuilderModule() { - super("camunda", "camunda-process", "camunda-process-7_18"); - } - - @Override - public List typeInstrumentations() { - return Collections.singletonList(new CamundaProcessInstantiationBuilderInstrumentation()); - } - - @Override - public boolean defaultEnabled(ConfigProperties config) { - return config.getBoolean("otel.instrumentation.common.default-enabled", true); - } - - @Override - public ElementMatcher.Junction classLoaderMatcher() { - - return hasClassesNamed("org.camunda.bpm.engine.runtime.ProcessInstantiationBuilder"); - } - - String[] helperClassnames = { "io.opentelemetry.javaagent.instrumentation.camunda.v7_0.processes", - "io.opentelemetry.instrumentation.camunda.v7_0.processes", - "io.opentelemetry.instrumentation.camunda.v7_0.common" }; - - @Override - public boolean isHelperClass(String classname) { - return super.isHelperClass(classname) || Arrays.stream(helperClassnames).anyMatch(c -> classname.startsWith(c)); - } - + public CamundaProcessInstantiationBuilderModule() { + super("camunda", "camunda-process", "camunda-process-7_18"); + } + + @Override + public List typeInstrumentations() { + return Collections.singletonList(new CamundaProcessInstantiationBuilderInstrumentation()); + } + + @Override + public boolean defaultEnabled(ConfigProperties config) { + return config.getBoolean("otel.instrumentation.common.default-enabled", true); + } + + @Override + public ElementMatcher.Junction classLoaderMatcher() { + + return hasClassesNamed("org.camunda.bpm.engine.runtime.ProcessInstantiationBuilder"); + } + + String[] helperClassnames = { + "io.opentelemetry.javaagent.instrumentation.camunda.v7_0.processes", + "io.opentelemetry.instrumentation.camunda.v7_0.processes", + "io.opentelemetry.instrumentation.camunda.v7_0.common" + }; + + @Override + public boolean isHelperClass(String classname) { + return super.isHelperClass(classname) + || Arrays.stream(helperClassnames).anyMatch(c -> classname.startsWith(c)); + } } diff --git a/instrumentation/camunda/camunda-7.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_0/processes/CamundaProcessSingletons.java b/instrumentation/camunda/camunda-7.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_0/processes/CamundaProcessSingletons.java index 93c38999391d..2d182d726cb1 100644 --- a/instrumentation/camunda/camunda-7.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_0/processes/CamundaProcessSingletons.java +++ b/instrumentation/camunda/camunda-7.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_0/processes/CamundaProcessSingletons.java @@ -1,41 +1,44 @@ -package io.opentelemetry.javaagent.instrumentation.camunda.v7_0.processes; +/* + * Copyright The OpenTelemetry Authors + * SPDX-License-Identifier: Apache-2.0 + */ -import io.opentelemetry.instrumentation.camunda.v7_0.common.CamundaCommonRequest; -import io.opentelemetry.instrumentation.camunda.v7_0.common.CamundaVariableAttributeExtractor; -import io.opentelemetry.instrumentation.camunda.v7_0.processes.CamundaProcessSpanNameExtractor; +package io.opentelemetry.javaagent.instrumentation.camunda.v7_0.processes; import io.opentelemetry.api.GlobalOpenTelemetry; import io.opentelemetry.api.OpenTelemetry; import io.opentelemetry.instrumentation.api.instrumenter.Instrumenter; import io.opentelemetry.instrumentation.api.instrumenter.InstrumenterBuilder; -import io.opentelemetry.javaagent.bootstrap.internal.InstrumentationConfig; +import io.opentelemetry.instrumentation.camunda.v7_0.common.CamundaCommonRequest; +import io.opentelemetry.instrumentation.camunda.v7_0.common.CamundaVariableAttributeExtractor; +import io.opentelemetry.instrumentation.camunda.v7_0.processes.CamundaProcessSpanNameExtractor; public class CamundaProcessSingletons { - private static final Instrumenter instrumenter; - - private static final OpenTelemetry opentelemetry; - - private static final boolean propagationEnabled; + private static final Instrumenter instrumenter; - static { + private static final OpenTelemetry opentelemetry; - opentelemetry = GlobalOpenTelemetry.get(); + private static final boolean propagationEnabled; - InstrumenterBuilder builder = Instrumenter - .builder(opentelemetry, "io.opentelemetry.camunda-process", - new CamundaProcessSpanNameExtractor()) - .addAttributesExtractor(new CamundaVariableAttributeExtractor()); + static { + opentelemetry = GlobalOpenTelemetry.get(); - instrumenter = builder.buildInstrumenter(); - } + InstrumenterBuilder builder = + Instrumenter.builder( + opentelemetry, + "io.opentelemetry.camunda-process", + new CamundaProcessSpanNameExtractor()) + .addAttributesExtractor(new CamundaVariableAttributeExtractor()); - public static OpenTelemetry getOpentelemetry() { - return opentelemetry; - } + instrumenter = builder.buildInstrumenter(); + } - public static Instrumenter getInstumenter() { - return instrumenter; - } + public static OpenTelemetry getOpentelemetry() { + return opentelemetry; + } + public static Instrumenter getInstumenter() { + return instrumenter; + } } diff --git a/instrumentation/camunda/camunda-7.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_0/task/CamundaTaskSingletons.java b/instrumentation/camunda/camunda-7.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_0/task/CamundaTaskSingletons.java index eec56ed42788..33fd80d96c7f 100644 --- a/instrumentation/camunda/camunda-7.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_0/task/CamundaTaskSingletons.java +++ b/instrumentation/camunda/camunda-7.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_0/task/CamundaTaskSingletons.java @@ -1,38 +1,40 @@ -package io.opentelemetry.javaagent.instrumentation.camunda.v7_0.task; +/* + * Copyright The OpenTelemetry Authors + * SPDX-License-Identifier: Apache-2.0 + */ -import io.opentelemetry.instrumentation.camunda.v7_0.common.CamundaCommonRequest; -import io.opentelemetry.instrumentation.camunda.v7_0.common.CamundaVariableAttributeExtractor; -import io.opentelemetry.instrumentation.camunda.v7_0.task.CamundaTaskSpanNameExtractor; +package io.opentelemetry.javaagent.instrumentation.camunda.v7_0.task; import io.opentelemetry.api.GlobalOpenTelemetry; import io.opentelemetry.api.OpenTelemetry; import io.opentelemetry.instrumentation.api.instrumenter.Instrumenter; import io.opentelemetry.instrumentation.api.instrumenter.InstrumenterBuilder; +import io.opentelemetry.instrumentation.camunda.v7_0.common.CamundaCommonRequest; +import io.opentelemetry.instrumentation.camunda.v7_0.common.CamundaVariableAttributeExtractor; +import io.opentelemetry.instrumentation.camunda.v7_0.task.CamundaTaskSpanNameExtractor; public class CamundaTaskSingletons { - private static final Instrumenter instrumenter; - - private static final OpenTelemetry opentelemetry; - - static { + private static final Instrumenter instrumenter; - opentelemetry = GlobalOpenTelemetry.get(); + private static final OpenTelemetry opentelemetry; - InstrumenterBuilder builder = Instrumenter - .builder(opentelemetry, "io.opentelemetry.camunda-task", - new CamundaTaskSpanNameExtractor()) - .addAttributesExtractor(new CamundaVariableAttributeExtractor()); + static { + opentelemetry = GlobalOpenTelemetry.get(); - instrumenter = builder.buildInstrumenter(); - } + InstrumenterBuilder builder = + Instrumenter.builder( + opentelemetry, "io.opentelemetry.camunda-task", new CamundaTaskSpanNameExtractor()) + .addAttributesExtractor(new CamundaVariableAttributeExtractor()); - public static OpenTelemetry getOpentelemetry() { - return opentelemetry; - } + instrumenter = builder.buildInstrumenter(); + } - public static Instrumenter getInstumenter() { - return instrumenter; - } + public static OpenTelemetry getOpentelemetry() { + return opentelemetry; + } + public static Instrumenter getInstumenter() { + return instrumenter; + } } diff --git a/instrumentation/camunda/camunda-7.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_0/task/CamundaTopicSubscriptionManagerModule.java b/instrumentation/camunda/camunda-7.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_0/task/CamundaTopicSubscriptionManagerModule.java index e364fa36de7e..18534090260e 100644 --- a/instrumentation/camunda/camunda-7.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_0/task/CamundaTopicSubscriptionManagerModule.java +++ b/instrumentation/camunda/camunda-7.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_0/task/CamundaTopicSubscriptionManagerModule.java @@ -1,47 +1,52 @@ +/* + * Copyright The OpenTelemetry Authors + * SPDX-License-Identifier: Apache-2.0 + */ + package io.opentelemetry.javaagent.instrumentation.camunda.v7_0.task; import static io.opentelemetry.javaagent.extension.matcher.AgentElementMatchers.hasClassesNamed; -import java.util.Arrays; -import java.util.Collections; -import java.util.List; - import com.google.auto.service.AutoService; - import io.opentelemetry.javaagent.extension.instrumentation.InstrumentationModule; import io.opentelemetry.javaagent.extension.instrumentation.TypeInstrumentation; import io.opentelemetry.sdk.autoconfigure.spi.ConfigProperties; +import java.util.Arrays; +import java.util.Collections; +import java.util.List; import net.bytebuddy.matcher.ElementMatcher; @AutoService(InstrumentationModule.class) public class CamundaTopicSubscriptionManagerModule extends InstrumentationModule { - public CamundaTopicSubscriptionManagerModule() { - super("camunda", "camunda-task", "camunda-task-7_18"); - } - - @Override - public boolean defaultEnabled(ConfigProperties config) { - return config.getBoolean("otel.instrumentation.common.default-enabled", true); - } - - @Override - public List typeInstrumentations() { - return Collections.singletonList(new CamundaTopicSubscriptionMangerInstrumentation()); - } - - @Override - public ElementMatcher.Junction classLoaderMatcher() { - return hasClassesNamed("org.camunda.bpm.client.topic.impl.TopicSubscriptionManager"); - } - - String[] helperClassnames = { "io.opentelemetry.javaagent.instrumentation.camunda.v7_0.task", - "io.opentelemetry.instrumentation.camunda.v7_0.task", - "io.opentelemetry.instrumentation.camunda.v7_0.common" }; - - @Override - public boolean isHelperClass(String classname) { - return super.isHelperClass(classname) || Arrays.stream(helperClassnames).anyMatch(c -> classname.startsWith(c)); - } - + public CamundaTopicSubscriptionManagerModule() { + super("camunda", "camunda-task", "camunda-task-7_18"); + } + + @Override + public boolean defaultEnabled(ConfigProperties config) { + return config.getBoolean("otel.instrumentation.common.default-enabled", true); + } + + @Override + public List typeInstrumentations() { + return Collections.singletonList(new CamundaTopicSubscriptionMangerInstrumentation()); + } + + @Override + public ElementMatcher.Junction classLoaderMatcher() { + return hasClassesNamed("org.camunda.bpm.client.topic.impl.TopicSubscriptionManager"); + } + + String[] helperClassnames = { + "io.opentelemetry.javaagent.instrumentation.camunda.v7_0.task", + "io.opentelemetry.instrumentation.camunda.v7_0.task", + "io.opentelemetry.instrumentation.camunda.v7_0.common" + }; + + @Override + public boolean isHelperClass(String classname) { + return super.isHelperClass(classname) + || Arrays.stream(helperClassnames).anyMatch(c -> classname.startsWith(c)); + } } diff --git a/instrumentation/camunda/camunda-7.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_0/task/CamundaTopicSubscriptionMangerInstrumentation.java b/instrumentation/camunda/camunda-7.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_0/task/CamundaTopicSubscriptionMangerInstrumentation.java index 95b102a537ef..d9fac16573f3 100644 --- a/instrumentation/camunda/camunda-7.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_0/task/CamundaTopicSubscriptionMangerInstrumentation.java +++ b/instrumentation/camunda/camunda-7.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_0/task/CamundaTopicSubscriptionMangerInstrumentation.java @@ -1,111 +1,122 @@ +/* + * Copyright The OpenTelemetry Authors + * SPDX-License-Identifier: Apache-2.0 + */ + package io.opentelemetry.javaagent.instrumentation.camunda.v7_0.task; +import static io.opentelemetry.javaagent.extension.matcher.AgentElementMatchers.hasClassesNamed; import static io.opentelemetry.javaagent.instrumentationn.camunda.v7_0.task.CamundaTaskSingletons.getInstumenter; import static io.opentelemetry.javaagent.instrumentationn.camunda.v7_0.task.CamundaTaskSingletons.getOpentelemetry; -import static io.opentelemetry.javaagent.extension.matcher.AgentElementMatchers.hasClassesNamed; import static net.bytebuddy.matcher.ElementMatchers.named; -import java.util.Map; -import java.util.Optional; - -import org.camunda.bpm.client.task.ExternalTask; -import org.camunda.bpm.client.task.impl.ExternalTaskImpl; -import org.camunda.bpm.client.variable.impl.TypedValueField; -import org.camunda.bpm.client.variable.impl.TypedValues; -import org.camunda.bpm.client.variable.impl.VariableValue; - -import io.opentelemetry.instrumentation.camunda.v7_0.common.CamundaCommonRequest; -import io.opentelemetry.instrumentation.camunda.v7_0.task.CamundaExternalTaskGetter; - -import io.opentelemetry.api.trace.SpanContext; import io.opentelemetry.context.Context; import io.opentelemetry.context.Scope; +import io.opentelemetry.instrumentation.camunda.v7_0.common.CamundaCommonRequest; +import io.opentelemetry.instrumentation.camunda.v7_0.task.CamundaExternalTaskGetter; import io.opentelemetry.javaagent.bootstrap.Java8BytecodeBridge; import io.opentelemetry.javaagent.extension.instrumentation.TypeInstrumentation; import io.opentelemetry.javaagent.extension.instrumentation.TypeTransformer; +import java.util.Map; +import java.util.Optional; import net.bytebuddy.asm.Advice; import net.bytebuddy.description.type.TypeDescription; import net.bytebuddy.matcher.ElementMatcher; import net.bytebuddy.matcher.ElementMatchers; +import org.camunda.bpm.client.task.ExternalTask; +import org.camunda.bpm.client.task.impl.ExternalTaskImpl; +import org.camunda.bpm.client.variable.impl.TypedValueField; +import org.camunda.bpm.client.variable.impl.TypedValues; +import org.camunda.bpm.client.variable.impl.VariableValue; public class CamundaTopicSubscriptionMangerInstrumentation implements TypeInstrumentation { - @Override - public ElementMatcher classLoaderOptimization() { - return hasClassesNamed("org.camunda.bpm.client.topic.impl.TopicSubscriptionManager"); - } - - @Override - public ElementMatcher typeMatcher() { - return named("org.camunda.bpm.client.topic.impl.TopicSubscriptionManager"); - } - - @Override - public void transform(TypeTransformer transformer) { - transformer.applyAdviceToMethod(ElementMatchers.isMethod().and(named("handleExternalTask")), - this.getClass().getName() + "$CamundaTopicSubscriptionMangerAdvice"); - } - - public static class CamundaTopicSubscriptionMangerAdvice { - - @Advice.OnMethodEnter(suppress = Throwable.class) - public static void addTracingEnter(@Advice.FieldValue("typedValues") TypedValues typedValues, - @Advice.Argument(0) ExternalTask externalTask, @Advice.Local("request") CamundaCommonRequest request, - @Advice.Local("otelParentScope") Scope parentScope, @Advice.Local("otelContext") Context context, - @Advice.Local("otelScope") Scope scope) { - - - if (externalTask == null) { - return; - } - - request = new CamundaCommonRequest(); - request.setProcessDefinitionKey(Optional.ofNullable(externalTask.getProcessDefinitionKey())); - request.setProcessInstanceId(Optional.ofNullable(externalTask.getProcessInstanceId())); - request.setTopicName(Optional.ofNullable(externalTask.getTopicName())); - request.setTopicWorkerId(Optional.ofNullable(externalTask.getWorkerId())); - - String id = externalTask.getTopicName() + " " + externalTask.getWorkerId(); - - if (Java8BytecodeBridge.currentContext() == Java8BytecodeBridge.rootContext()) { - //log - } - - ExternalTaskImpl task = (ExternalTaskImpl) externalTask; - - Map variables = task.getVariables(); - - Map wrappedVariables = typedValues.wrapVariables(externalTask, variables); - - task.setReceivedVariableMap(wrappedVariables); - - Context parentContext = getOpentelemetry().getPropagators().getTextMapPropagator() - .extract(Java8BytecodeBridge.currentContext(), externalTask, new CamundaExternalTaskGetter()); - - parentScope = parentContext.makeCurrent(); - - if (getInstumenter().shouldStart(Java8BytecodeBridge.currentContext(), request)) { - context = getInstumenter().start(Java8BytecodeBridge.currentContext(), request); - scope = context.makeCurrent(); - - } - - } - - @Advice.OnMethodExit(onThrowable = Throwable.class, suppress = Throwable.class) - public static void closeTrace(@Advice.Local("otelParentScope") Scope parentScope, - @Advice.Local("request") CamundaCommonRequest request, @Advice.Local("otelContext") Context context, - @Advice.Local("otelScope") Scope scope, @Advice.Thrown Throwable throwable) { - - if (context != null && scope != null) { - getInstumenter().end(context, request, "NA", throwable); - scope.close(); - } - - if (parentScope != null) { - parentScope.close(); - } - - } - } + @Override + public ElementMatcher classLoaderOptimization() { + return hasClassesNamed("org.camunda.bpm.client.topic.impl.TopicSubscriptionManager"); + } + + @Override + public ElementMatcher typeMatcher() { + return named("org.camunda.bpm.client.topic.impl.TopicSubscriptionManager"); + } + + @Override + public void transform(TypeTransformer transformer) { + transformer.applyAdviceToMethod( + ElementMatchers.isMethod().and(named("handleExternalTask")), + this.getClass().getName() + "$CamundaTopicSubscriptionMangerAdvice"); + } + + public static class CamundaTopicSubscriptionMangerAdvice { + + @Advice.OnMethodEnter(suppress = Throwable.class) + public static void addTracingEnter( + @Advice.FieldValue("typedValues") TypedValues typedValues, + @Advice.Argument(0) ExternalTask externalTask, + @Advice.Local("request") CamundaCommonRequest request, + @Advice.Local("otelParentScope") Scope parentScope, + @Advice.Local("otelContext") Context context, + @Advice.Local("otelScope") Scope scope) { + + if (externalTask == null) { + return; + } + + request = new CamundaCommonRequest(); + request.setProcessDefinitionKey(Optional.ofNullable(externalTask.getProcessDefinitionKey())); + request.setProcessInstanceId(Optional.ofNullable(externalTask.getProcessInstanceId())); + request.setTopicName(Optional.ofNullable(externalTask.getTopicName())); + request.setTopicWorkerId(Optional.ofNullable(externalTask.getWorkerId())); + + String id = externalTask.getTopicName() + " " + externalTask.getWorkerId(); + + if (Java8BytecodeBridge.currentContext() == Java8BytecodeBridge.rootContext()) { + // log + } + + ExternalTaskImpl task = (ExternalTaskImpl) externalTask; + + Map variables = task.getVariables(); + + Map wrappedVariables = + typedValues.wrapVariables(externalTask, variables); + + task.setReceivedVariableMap(wrappedVariables); + + Context parentContext = + getOpentelemetry() + .getPropagators() + .getTextMapPropagator() + .extract( + Java8BytecodeBridge.currentContext(), + externalTask, + new CamundaExternalTaskGetter()); + + parentScope = parentContext.makeCurrent(); + + if (getInstumenter().shouldStart(Java8BytecodeBridge.currentContext(), request)) { + context = getInstumenter().start(Java8BytecodeBridge.currentContext(), request); + scope = context.makeCurrent(); + } + } + + @Advice.OnMethodExit(onThrowable = Throwable.class, suppress = Throwable.class) + public static void closeTrace( + @Advice.Local("otelParentScope") Scope parentScope, + @Advice.Local("request") CamundaCommonRequest request, + @Advice.Local("otelContext") Context context, + @Advice.Local("otelScope") Scope scope, + @Advice.Thrown Throwable throwable) { + + if (context != null && scope != null) { + getInstumenter().end(context, request, "NA", throwable); + scope.close(); + } + + if (parentScope != null) { + parentScope.close(); + } + } + } } From 80b0e676325c20d585b9be5aae0cfb524159f76f Mon Sep 17 00:00:00 2001 From: "Boslet, Cory (cb645j)" Date: Wed, 11 Dec 2024 15:51:36 -0500 Subject: [PATCH 06/23] Fix formatting for lib folder also per spotless --- .../camunda-7.0/library/build.gradle.kts | 8 +- .../CamundaActivityExecutionGetter.java | 27 ++-- .../CamundaActivityExecutionLocalSetter.java | 17 ++- .../CamundaActivityExecutionSetter.java | 17 ++- .../CamundaBehaviorSpanNameExtractor.java | 32 ++--- .../behavior/CamundaVariableMapSetter.java | 17 ++- .../v7_0/common/CamundaCommonRequest.java | 133 +++++++++--------- .../CamundaVariableAttributeExtractor.java | 50 ++++--- .../jobs/CamundaExecutionEntityGetter.java | 27 ++-- .../jobs/CamundaJobSpanNameExtractor.java | 17 ++- ...ndaActivityInstantiationBuilderSetter.java | 23 +-- ...sInstanceModificationBuilderImpSetter.java | 22 +-- .../CamundaProcessSpanNameExtractor.java | 17 ++- .../v7_0/task/CamundaExternalTaskGetter.java | 27 ++-- .../task/CamundaTaskSpanNameExtractor.java | 17 ++- 15 files changed, 251 insertions(+), 200 deletions(-) diff --git a/instrumentation/camunda/camunda-7.0/library/build.gradle.kts b/instrumentation/camunda/camunda-7.0/library/build.gradle.kts index 2494f932a4f9..0b2c676dc081 100644 --- a/instrumentation/camunda/camunda-7.0/library/build.gradle.kts +++ b/instrumentation/camunda/camunda-7.0/library/build.gradle.kts @@ -3,11 +3,11 @@ plugins { } dependencies { - implementation("org.camunda.bpm:camunda-engine:7.18.0") - implementation("org.camunda.bpm:camunda-external-task-client:7.18.0") + implementation("org.camunda.bpm:camunda-engine:7.18.0") + implementation("org.camunda.bpm:camunda-external-task-client:7.18.0") - api("com.google.auto.value:auto-value-annotations:1.6") - annotationProcessor("com.google.auto.value:auto-value:1.6") + api("com.google.auto.value:auto-value-annotations:1.6") + annotationProcessor("com.google.auto.value:auto-value:1.6") } tasks.withType().configureEach { diff --git a/instrumentation/camunda/camunda-7.0/library/src/main/java/io/opentelemetry/instrumentation/camunda/v7_0/behavior/CamundaActivityExecutionGetter.java b/instrumentation/camunda/camunda-7.0/library/src/main/java/io/opentelemetry/instrumentation/camunda/v7_0/behavior/CamundaActivityExecutionGetter.java index 6a67a8e04e95..07215e0ec122 100644 --- a/instrumentation/camunda/camunda-7.0/library/src/main/java/io/opentelemetry/instrumentation/camunda/v7_0/behavior/CamundaActivityExecutionGetter.java +++ b/instrumentation/camunda/camunda-7.0/library/src/main/java/io/opentelemetry/instrumentation/camunda/v7_0/behavior/CamundaActivityExecutionGetter.java @@ -1,20 +1,23 @@ -package io.opentelemetry.instrumentation.camunda.v7_0.behavior; +/* + * Copyright The OpenTelemetry Authors + * SPDX-License-Identifier: Apache-2.0 + */ -import org.camunda.bpm.engine.impl.pvm.delegate.ActivityExecution; +package io.opentelemetry.instrumentation.camunda.v7_0.behavior; import io.opentelemetry.context.propagation.TextMapGetter; +import org.camunda.bpm.engine.impl.pvm.delegate.ActivityExecution; public class CamundaActivityExecutionGetter implements TextMapGetter { - @Override - public Iterable keys(ActivityExecution carrier) { - return carrier.getVariableNames(); - } - - @Override - public String get(ActivityExecution carrier, String key) { - Object variable = carrier.getVariables().get(key); - return variable == null ? null : variable.toString(); - } + @Override + public Iterable keys(ActivityExecution carrier) { + return carrier.getVariableNames(); + } + @Override + public String get(ActivityExecution carrier, String key) { + Object variable = carrier.getVariables().get(key); + return variable == null ? null : variable.toString(); + } } diff --git a/instrumentation/camunda/camunda-7.0/library/src/main/java/io/opentelemetry/instrumentation/camunda/v7_0/behavior/CamundaActivityExecutionLocalSetter.java b/instrumentation/camunda/camunda-7.0/library/src/main/java/io/opentelemetry/instrumentation/camunda/v7_0/behavior/CamundaActivityExecutionLocalSetter.java index 8dd4148aa4bf..5b220abce7e4 100644 --- a/instrumentation/camunda/camunda-7.0/library/src/main/java/io/opentelemetry/instrumentation/camunda/v7_0/behavior/CamundaActivityExecutionLocalSetter.java +++ b/instrumentation/camunda/camunda-7.0/library/src/main/java/io/opentelemetry/instrumentation/camunda/v7_0/behavior/CamundaActivityExecutionLocalSetter.java @@ -1,14 +1,17 @@ -package io.opentelemetry.instrumentation.camunda.v7_0.behavior; +/* + * Copyright The OpenTelemetry Authors + * SPDX-License-Identifier: Apache-2.0 + */ -import org.camunda.bpm.engine.impl.pvm.delegate.ActivityExecution; +package io.opentelemetry.instrumentation.camunda.v7_0.behavior; import io.opentelemetry.context.propagation.TextMapSetter; +import org.camunda.bpm.engine.impl.pvm.delegate.ActivityExecution; public class CamundaActivityExecutionLocalSetter implements TextMapSetter { - @Override - public void set(ActivityExecution carrier, String key, String value) { - carrier.setVariableLocal(key, value); - } - + @Override + public void set(ActivityExecution carrier, String key, String value) { + carrier.setVariableLocal(key, value); + } } diff --git a/instrumentation/camunda/camunda-7.0/library/src/main/java/io/opentelemetry/instrumentation/camunda/v7_0/behavior/CamundaActivityExecutionSetter.java b/instrumentation/camunda/camunda-7.0/library/src/main/java/io/opentelemetry/instrumentation/camunda/v7_0/behavior/CamundaActivityExecutionSetter.java index 6784d3711df2..075a7c7c991f 100644 --- a/instrumentation/camunda/camunda-7.0/library/src/main/java/io/opentelemetry/instrumentation/camunda/v7_0/behavior/CamundaActivityExecutionSetter.java +++ b/instrumentation/camunda/camunda-7.0/library/src/main/java/io/opentelemetry/instrumentation/camunda/v7_0/behavior/CamundaActivityExecutionSetter.java @@ -1,14 +1,17 @@ -package io.opentelemetry.instrumentation.camunda.v7_0.behavior; +/* + * Copyright The OpenTelemetry Authors + * SPDX-License-Identifier: Apache-2.0 + */ -import org.camunda.bpm.engine.impl.pvm.delegate.ActivityExecution; +package io.opentelemetry.instrumentation.camunda.v7_0.behavior; import io.opentelemetry.context.propagation.TextMapSetter; +import org.camunda.bpm.engine.impl.pvm.delegate.ActivityExecution; public class CamundaActivityExecutionSetter implements TextMapSetter { - @Override - public void set(ActivityExecution carrier, String key, String value) { - carrier.setVariable(key, value); - } - + @Override + public void set(ActivityExecution carrier, String key, String value) { + carrier.setVariable(key, value); + } } diff --git a/instrumentation/camunda/camunda-7.0/library/src/main/java/io/opentelemetry/instrumentation/camunda/v7_0/behavior/CamundaBehaviorSpanNameExtractor.java b/instrumentation/camunda/camunda-7.0/library/src/main/java/io/opentelemetry/instrumentation/camunda/v7_0/behavior/CamundaBehaviorSpanNameExtractor.java index d01e2d4c236c..00a5beb8f5e7 100644 --- a/instrumentation/camunda/camunda-7.0/library/src/main/java/io/opentelemetry/instrumentation/camunda/v7_0/behavior/CamundaBehaviorSpanNameExtractor.java +++ b/instrumentation/camunda/camunda-7.0/library/src/main/java/io/opentelemetry/instrumentation/camunda/v7_0/behavior/CamundaBehaviorSpanNameExtractor.java @@ -1,24 +1,24 @@ -package io.opentelemetry.instrumentation.camunda.v7_0.behavior; +/* + * Copyright The OpenTelemetry Authors + * SPDX-License-Identifier: Apache-2.0 + */ -import java.util.Arrays; +package io.opentelemetry.instrumentation.camunda.v7_0.behavior; import io.opentelemetry.camunda.v7_0.common.CamundaCommonRequest; - import io.opentelemetry.instrumentation.api.instrumenter.SpanNameExtractor; +import java.util.Arrays; public class CamundaBehaviorSpanNameExtractor implements SpanNameExtractor { - @Override - public String extract(CamundaCommonRequest request) { - String[] eventTypes = { "Start", "End" }; - String type = "Task"; - if (request.getActivityName().isPresent() - && Arrays.stream(eventTypes).anyMatch(request.getActivityName().get()::equals)) { - type = "Event"; - - } - return String.format("%s %s", request.getActivityName().orElse("Plugin"), type); - - } - + @Override + public String extract(CamundaCommonRequest request) { + String[] eventTypes = {"Start", "End"}; + String type = "Task"; + if (request.getActivityName().isPresent() + && Arrays.stream(eventTypes).anyMatch(request.getActivityName().get()::equals)) { + type = "Event"; + } + return String.format("%s %s", request.getActivityName().orElse("Plugin"), type); + } } diff --git a/instrumentation/camunda/camunda-7.0/library/src/main/java/io/opentelemetry/instrumentation/camunda/v7_0/behavior/CamundaVariableMapSetter.java b/instrumentation/camunda/camunda-7.0/library/src/main/java/io/opentelemetry/instrumentation/camunda/v7_0/behavior/CamundaVariableMapSetter.java index 87fc1472baa3..838dcf9f13f3 100644 --- a/instrumentation/camunda/camunda-7.0/library/src/main/java/io/opentelemetry/instrumentation/camunda/v7_0/behavior/CamundaVariableMapSetter.java +++ b/instrumentation/camunda/camunda-7.0/library/src/main/java/io/opentelemetry/instrumentation/camunda/v7_0/behavior/CamundaVariableMapSetter.java @@ -1,14 +1,17 @@ -package io.opentelemetry.instrumentation.camunda.v7_0.behavior; +/* + * Copyright The OpenTelemetry Authors + * SPDX-License-Identifier: Apache-2.0 + */ -import org.camunda.bpm.engine.variable.VariableMap; +package io.opentelemetry.instrumentation.camunda.v7_0.behavior; import io.opentelemetry.context.propagation.TextMapSetter; +import org.camunda.bpm.engine.variable.VariableMap; public class CamundaVariableMapSetter implements TextMapSetter { - @Override - public void set(VariableMap carrier, String key, String value) { - carrier.put(key, value); - } - + @Override + public void set(VariableMap carrier, String key, String value) { + carrier.put(key, value); + } } diff --git a/instrumentation/camunda/camunda-7.0/library/src/main/java/io/opentelemetry/instrumentation/camunda/v7_0/common/CamundaCommonRequest.java b/instrumentation/camunda/camunda-7.0/library/src/main/java/io/opentelemetry/instrumentation/camunda/v7_0/common/CamundaCommonRequest.java index 154de1c49343..42b345f46e8b 100644 --- a/instrumentation/camunda/camunda-7.0/library/src/main/java/io/opentelemetry/instrumentation/camunda/v7_0/common/CamundaCommonRequest.java +++ b/instrumentation/camunda/camunda-7.0/library/src/main/java/io/opentelemetry/instrumentation/camunda/v7_0/common/CamundaCommonRequest.java @@ -1,72 +1,75 @@ +/* + * Copyright The OpenTelemetry Authors + * SPDX-License-Identifier: Apache-2.0 + */ + package io.opentelemetry.instrumentation.camunda.v7_0.common; import java.util.Optional; public class CamundaCommonRequest { - private Optional processDefinitionId = Optional.empty(); - private Optional processDefinitionKey = Optional.empty(); - private Optional processInstanceId = Optional.empty(); - private Optional activityId = Optional.empty(); - private Optional activityName = Optional.empty(); - private Optional topicName = Optional.empty(); - private Optional topicWorkerId = Optional.empty(); - - public Optional getProcessDefinitionId() { - return processDefinitionId; - } - - public void setProcessDefinitionId(Optional processDefinitionId) { - this.processDefinitionId = processDefinitionId; - } - - public Optional getProcessDefinitionKey() { - return processDefinitionKey; - } - - public void setProcessDefinitionKey(Optional processDefinitionKey) { - this.processDefinitionKey = processDefinitionKey; - } - - public Optional getProcessInstanceId() { - return processInstanceId; - } - - - public void setProcessInstanceId(Optional processInstanceId) { - this.processInstanceId = processInstanceId; - } - - public Optional getActivityId() { - return activityId; - } - - public void setActivityId(Optional activityId) { - this.activityId = activityId; - } - - public Optional getActivityName() { - return activityName; - } - - public void setActivityName(Optional activityName) { - this.activityName = activityName; - } - - public Optional getTopicName() { - return topicName; - } - - public void setTopicName(Optional topicName) { - this.topicName = topicName; - } - - public Optional getTopicWorkerId() { - return topicWorkerId; - } - - public void setTopicWorkerId(Optional topicWorkerId) { - this.topicWorkerId = topicWorkerId; - } - + private Optional processDefinitionId = Optional.empty(); + private Optional processDefinitionKey = Optional.empty(); + private Optional processInstanceId = Optional.empty(); + private Optional activityId = Optional.empty(); + private Optional activityName = Optional.empty(); + private Optional topicName = Optional.empty(); + private Optional topicWorkerId = Optional.empty(); + + public Optional getProcessDefinitionId() { + return processDefinitionId; + } + + public void setProcessDefinitionId(Optional processDefinitionId) { + this.processDefinitionId = processDefinitionId; + } + + public Optional getProcessDefinitionKey() { + return processDefinitionKey; + } + + public void setProcessDefinitionKey(Optional processDefinitionKey) { + this.processDefinitionKey = processDefinitionKey; + } + + public Optional getProcessInstanceId() { + return processInstanceId; + } + + public void setProcessInstanceId(Optional processInstanceId) { + this.processInstanceId = processInstanceId; + } + + public Optional getActivityId() { + return activityId; + } + + public void setActivityId(Optional activityId) { + this.activityId = activityId; + } + + public Optional getActivityName() { + return activityName; + } + + public void setActivityName(Optional activityName) { + this.activityName = activityName; + } + + public Optional getTopicName() { + return topicName; + } + + public void setTopicName(Optional topicName) { + this.topicName = topicName; + } + + public Optional getTopicWorkerId() { + return topicWorkerId; + } + + public void setTopicWorkerId(Optional topicWorkerId) { + this.topicWorkerId = topicWorkerId; + } } diff --git a/instrumentation/camunda/camunda-7.0/library/src/main/java/io/opentelemetry/instrumentation/camunda/v7_0/common/CamundaVariableAttributeExtractor.java b/instrumentation/camunda/camunda-7.0/library/src/main/java/io/opentelemetry/instrumentation/camunda/v7_0/common/CamundaVariableAttributeExtractor.java index e8b30d79e933..441489999084 100644 --- a/instrumentation/camunda/camunda-7.0/library/src/main/java/io/opentelemetry/instrumentation/camunda/v7_0/common/CamundaVariableAttributeExtractor.java +++ b/instrumentation/camunda/camunda-7.0/library/src/main/java/io/opentelemetry/instrumentation/camunda/v7_0/common/CamundaVariableAttributeExtractor.java @@ -1,28 +1,44 @@ +/* + * Copyright The OpenTelemetry Authors + * SPDX-License-Identifier: Apache-2.0 + */ + package io.opentelemetry.instrumentation.camunda.v7_0.common; import io.opentelemetry.api.common.AttributesBuilder; import io.opentelemetry.context.Context; import io.opentelemetry.instrumentation.api.instrumenter.AttributesExtractor; -public class CamundaVariableAttributeExtractor implements AttributesExtractor { - - @Override - public void onStart(AttributesBuilder attributes, Context parentContext, CamundaCommonRequest request) { +public class CamundaVariableAttributeExtractor + implements AttributesExtractor { - request.getProcessDefinitionKey().ifPresent(pdk -> attributes.put("camunda.processdefinitionkey", pdk)); - request.getProcessDefinitionId().ifPresent(pdi -> attributes.put("camunda.processdefinitionid", pdi)); - request.getProcessInstanceId().ifPresent(pid -> attributes.put("camunda.processinstanceid", pid)); - request.getActivityId().ifPresent(aid -> attributes.put("camunda.activityid", aid)); - request.getActivityName().ifPresent(an -> attributes.put("camunda.activityname", an)); - request.getTopicName().ifPresent(tn -> attributes.put("camunda.topicname", tn)); - request.getTopicWorkerId().ifPresent(twi -> attributes.put("camunda.topicworkerid", twi)); - } + @Override + public void onStart( + AttributesBuilder attributes, Context parentContext, CamundaCommonRequest request) { - @Override - public void onEnd(AttributesBuilder attributes, Context context, CamundaCommonRequest request, String response, - Throwable error) { - // TODO Auto-generated method stub + request + .getProcessDefinitionKey() + .ifPresent(pdk -> attributes.put("camunda.processdefinitionkey", pdk)); + request + .getProcessDefinitionId() + .ifPresent(pdi -> attributes.put("camunda.processdefinitionid", pdi)); + request + .getProcessInstanceId() + .ifPresent(pid -> attributes.put("camunda.processinstanceid", pid)); + request.getActivityId().ifPresent(aid -> attributes.put("camunda.activityid", aid)); + request.getActivityName().ifPresent(an -> attributes.put("camunda.activityname", an)); + request.getTopicName().ifPresent(tn -> attributes.put("camunda.topicname", tn)); + request.getTopicWorkerId().ifPresent(twi -> attributes.put("camunda.topicworkerid", twi)); + } - } + @Override + public void onEnd( + AttributesBuilder attributes, + Context context, + CamundaCommonRequest request, + String response, + Throwable error) { + // TODO Auto-generated method stub + } } diff --git a/instrumentation/camunda/camunda-7.0/library/src/main/java/io/opentelemetry/instrumentation/camunda/v7_0/jobs/CamundaExecutionEntityGetter.java b/instrumentation/camunda/camunda-7.0/library/src/main/java/io/opentelemetry/instrumentation/camunda/v7_0/jobs/CamundaExecutionEntityGetter.java index d58cd3f689bc..38ee5fe76d4d 100644 --- a/instrumentation/camunda/camunda-7.0/library/src/main/java/io/opentelemetry/instrumentation/camunda/v7_0/jobs/CamundaExecutionEntityGetter.java +++ b/instrumentation/camunda/camunda-7.0/library/src/main/java/io/opentelemetry/instrumentation/camunda/v7_0/jobs/CamundaExecutionEntityGetter.java @@ -1,20 +1,23 @@ -package io.opentelemetry.instrumentation.camunda.v7_0.jobs; +/* + * Copyright The OpenTelemetry Authors + * SPDX-License-Identifier: Apache-2.0 + */ -import org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity; +package io.opentelemetry.instrumentation.camunda.v7_0.jobs; import io.opentelemetry.context.propagation.TextMapGetter; +import org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity; public class CamundaExecutionEntityGetter implements TextMapGetter { - @Override - public Iterable keys(ExecutionEntity carrier) { - return carrier.getVariableNames(); - } - - @Override - public String get(ExecutionEntity carrier, String key) { - Object variable = carrier.getVariables().get(key); - return variable == null ? null : variable.toString(); - } + @Override + public Iterable keys(ExecutionEntity carrier) { + return carrier.getVariableNames(); + } + @Override + public String get(ExecutionEntity carrier, String key) { + Object variable = carrier.getVariables().get(key); + return variable == null ? null : variable.toString(); + } } diff --git a/instrumentation/camunda/camunda-7.0/library/src/main/java/io/opentelemetry/instrumentation/camunda/v7_0/jobs/CamundaJobSpanNameExtractor.java b/instrumentation/camunda/camunda-7.0/library/src/main/java/io/opentelemetry/instrumentation/camunda/v7_0/jobs/CamundaJobSpanNameExtractor.java index 82568028c635..52ac6055cb0f 100644 --- a/instrumentation/camunda/camunda-7.0/library/src/main/java/io/opentelemetry/instrumentation/camunda/v7_0/jobs/CamundaJobSpanNameExtractor.java +++ b/instrumentation/camunda/camunda-7.0/library/src/main/java/io/opentelemetry/instrumentation/camunda/v7_0/jobs/CamundaJobSpanNameExtractor.java @@ -1,14 +1,17 @@ -package io.opentelemetry.instrumentation.camunda.v7_0.jobs; +/* + * Copyright The OpenTelemetry Authors + * SPDX-License-Identifier: Apache-2.0 + */ -import io.opentelemetry.instrumentation.camunda.v7_0.common.CamundaCommonRequest; +package io.opentelemetry.instrumentation.camunda.v7_0.jobs; import io.opentelemetry.instrumentation.api.instrumenter.SpanNameExtractor; +import io.opentelemetry.instrumentation.camunda.v7_0.common.CamundaCommonRequest; public class CamundaJobSpanNameExtractor implements SpanNameExtractor { - @Override - public String extract(CamundaCommonRequest request) { - return String.format("%s AsyncContinuation", request.getActivityName().get()); - } - + @Override + public String extract(CamundaCommonRequest request) { + return String.format("%s AsyncContinuation", request.getActivityName().get()); + } } diff --git a/instrumentation/camunda/camunda-7.0/library/src/main/java/io/opentelemetry/instrumentation/camunda/v7_0/processes/CamundaActivityInstantiationBuilderSetter.java b/instrumentation/camunda/camunda-7.0/library/src/main/java/io/opentelemetry/instrumentation/camunda/v7_0/processes/CamundaActivityInstantiationBuilderSetter.java index 6c276718cc1a..9999eaca0c7a 100644 --- a/instrumentation/camunda/camunda-7.0/library/src/main/java/io/opentelemetry/instrumentation/camunda/v7_0/processes/CamundaActivityInstantiationBuilderSetter.java +++ b/instrumentation/camunda/camunda-7.0/library/src/main/java/io/opentelemetry/instrumentation/camunda/v7_0/processes/CamundaActivityInstantiationBuilderSetter.java @@ -1,16 +1,19 @@ -package io.opentelemetry.instrumentation.camunda.v7_0.processes; +/* + * Copyright The OpenTelemetry Authors + * SPDX-License-Identifier: Apache-2.0 + */ -import org.camunda.bpm.engine.runtime.ActivityInstantiationBuilder; +package io.opentelemetry.instrumentation.camunda.v7_0.processes; import io.opentelemetry.context.propagation.TextMapSetter; +import org.camunda.bpm.engine.runtime.ActivityInstantiationBuilder; -//TODO Bound it to ProcessInstanceModificationBuilder ?? -public class CamundaActivityInstantiationBuilderSetter implements TextMapSetter> { - - @Override - public void set(ActivityInstantiationBuilder carrier, String key, String value) { - carrier.setVariable(key, value); - - } +// TODO Bound it to ProcessInstanceModificationBuilder ?? +public class CamundaActivityInstantiationBuilderSetter + implements TextMapSetter> { + @Override + public void set(ActivityInstantiationBuilder carrier, String key, String value) { + carrier.setVariable(key, value); + } } diff --git a/instrumentation/camunda/camunda-7.0/library/src/main/java/io/opentelemetry/instrumentation/camunda/v7_0/processes/CamundaProcessInstanceModificationBuilderImpSetter.java b/instrumentation/camunda/camunda-7.0/library/src/main/java/io/opentelemetry/instrumentation/camunda/v7_0/processes/CamundaProcessInstanceModificationBuilderImpSetter.java index 34df4f6bbae2..5f0834858ffc 100644 --- a/instrumentation/camunda/camunda-7.0/library/src/main/java/io/opentelemetry/instrumentation/camunda/v7_0/processes/CamundaProcessInstanceModificationBuilderImpSetter.java +++ b/instrumentation/camunda/camunda-7.0/library/src/main/java/io/opentelemetry/instrumentation/camunda/v7_0/processes/CamundaProcessInstanceModificationBuilderImpSetter.java @@ -1,17 +1,19 @@ -package io.opentelemetry.instrumentation.camunda.v7_0.processes; +/* + * Copyright The OpenTelemetry Authors + * SPDX-License-Identifier: Apache-2.0 + */ -import org.camunda.bpm.engine.impl.ProcessInstanceModificationBuilderImpl; +package io.opentelemetry.instrumentation.camunda.v7_0.processes; import io.opentelemetry.context.propagation.TextMapSetter; +import org.camunda.bpm.engine.impl.ProcessInstanceModificationBuilderImpl; -//TODO use this or activityinstanctiationbuildersetter ?? +// TODO use this or activityinstanctiationbuildersetter ?? public class CamundaProcessInstanceModificationBuilderImpSetter - implements TextMapSetter { - - @Override - public void set(ProcessInstanceModificationBuilderImpl carrier, String key, String value) { - carrier.setVariable(key, value); - - } + implements TextMapSetter { + @Override + public void set(ProcessInstanceModificationBuilderImpl carrier, String key, String value) { + carrier.setVariable(key, value); + } } diff --git a/instrumentation/camunda/camunda-7.0/library/src/main/java/io/opentelemetry/instrumentation/camunda/v7_0/processes/CamundaProcessSpanNameExtractor.java b/instrumentation/camunda/camunda-7.0/library/src/main/java/io/opentelemetry/instrumentation/camunda/v7_0/processes/CamundaProcessSpanNameExtractor.java index e47ae93cf1a6..9fea08620cc3 100644 --- a/instrumentation/camunda/camunda-7.0/library/src/main/java/io/opentelemetry/instrumentation/camunda/v7_0/processes/CamundaProcessSpanNameExtractor.java +++ b/instrumentation/camunda/camunda-7.0/library/src/main/java/io/opentelemetry/instrumentation/camunda/v7_0/processes/CamundaProcessSpanNameExtractor.java @@ -1,14 +1,17 @@ -package io.opentelemetry.instrumentation.camunda.v7_0.processes; +/* + * Copyright The OpenTelemetry Authors + * SPDX-License-Identifier: Apache-2.0 + */ -import io.opentelemetry.instrumentation.camunda.v7_0.common.CamundaCommonRequest; +package io.opentelemetry.instrumentation.camunda.v7_0.processes; import io.opentelemetry.instrumentation.api.instrumenter.SpanNameExtractor; +import io.opentelemetry.instrumentation.camunda.v7_0.common.CamundaCommonRequest; public class CamundaProcessSpanNameExtractor implements SpanNameExtractor { - @Override - public String extract(CamundaCommonRequest request) { - return request.getProcessDefinitionKey().get(); - } - + @Override + public String extract(CamundaCommonRequest request) { + return request.getProcessDefinitionKey().get(); + } } diff --git a/instrumentation/camunda/camunda-7.0/library/src/main/java/io/opentelemetry/instrumentation/camunda/v7_0/task/CamundaExternalTaskGetter.java b/instrumentation/camunda/camunda-7.0/library/src/main/java/io/opentelemetry/instrumentation/camunda/v7_0/task/CamundaExternalTaskGetter.java index 478503c212e6..b3030d6cae41 100644 --- a/instrumentation/camunda/camunda-7.0/library/src/main/java/io/opentelemetry/instrumentation/camunda/v7_0/task/CamundaExternalTaskGetter.java +++ b/instrumentation/camunda/camunda-7.0/library/src/main/java/io/opentelemetry/instrumentation/camunda/v7_0/task/CamundaExternalTaskGetter.java @@ -1,20 +1,23 @@ -package io.opentelemetry.instrumentation.camunda.v7_0.task; +/* + * Copyright The OpenTelemetry Authors + * SPDX-License-Identifier: Apache-2.0 + */ -import org.camunda.bpm.client.task.ExternalTask; +package io.opentelemetry.instrumentation.camunda.v7_0.task; import io.opentelemetry.context.propagation.TextMapGetter; +import org.camunda.bpm.client.task.ExternalTask; public class CamundaExternalTaskGetter implements TextMapGetter { - @Override - public Iterable keys(ExternalTask carrier) { - return carrier.getAllVariables().keySet(); - } - - @Override - public String get(ExternalTask carrier, String key) { - Object variable = carrier.getAllVariables().get(key); - return variable == null ? null : variable.toString(); - } + @Override + public Iterable keys(ExternalTask carrier) { + return carrier.getAllVariables().keySet(); + } + @Override + public String get(ExternalTask carrier, String key) { + Object variable = carrier.getAllVariables().get(key); + return variable == null ? null : variable.toString(); + } } diff --git a/instrumentation/camunda/camunda-7.0/library/src/main/java/io/opentelemetry/instrumentation/camunda/v7_0/task/CamundaTaskSpanNameExtractor.java b/instrumentation/camunda/camunda-7.0/library/src/main/java/io/opentelemetry/instrumentation/camunda/v7_0/task/CamundaTaskSpanNameExtractor.java index d34299ff057a..4f9e53eefeb2 100644 --- a/instrumentation/camunda/camunda-7.0/library/src/main/java/io/opentelemetry/instrumentation/camunda/v7_0/task/CamundaTaskSpanNameExtractor.java +++ b/instrumentation/camunda/camunda-7.0/library/src/main/java/io/opentelemetry/instrumentation/camunda/v7_0/task/CamundaTaskSpanNameExtractor.java @@ -1,14 +1,17 @@ -package io.opentelemetry.instrumentation.camunda.v7_0.task; +/* + * Copyright The OpenTelemetry Authors + * SPDX-License-Identifier: Apache-2.0 + */ -import io.opentelemetry.instrumentation.camunda.v7_0.common.CamundaCommonRequest; +package io.opentelemetry.instrumentation.camunda.v7_0.task; import io.opentelemetry.instrumentation.api.instrumenter.SpanNameExtractor; +import io.opentelemetry.instrumentation.camunda.v7_0.common.CamundaCommonRequest; public class CamundaTaskSpanNameExtractor implements SpanNameExtractor { - @Override - public String extract(CamundaCommonRequest request) { - return String.format("%s Topic", request.getTopicName().get()); - } - + @Override + public String extract(CamundaCommonRequest request) { + return String.format("%s Topic", request.getTopicName().get()); + } } From b2673160e11134225dcb6ad93cb4ebae352ba88d Mon Sep 17 00:00:00 2001 From: "Boslet, Cory (cb645j)" Date: Wed, 11 Dec 2024 16:00:56 -0500 Subject: [PATCH 07/23] fix bad import in span name extractor class --- .../camunda/v7_0/behavior/CamundaBehaviorSpanNameExtractor.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/instrumentation/camunda/camunda-7.0/library/src/main/java/io/opentelemetry/instrumentation/camunda/v7_0/behavior/CamundaBehaviorSpanNameExtractor.java b/instrumentation/camunda/camunda-7.0/library/src/main/java/io/opentelemetry/instrumentation/camunda/v7_0/behavior/CamundaBehaviorSpanNameExtractor.java index 00a5beb8f5e7..f7fb0bd3c8bc 100644 --- a/instrumentation/camunda/camunda-7.0/library/src/main/java/io/opentelemetry/instrumentation/camunda/v7_0/behavior/CamundaBehaviorSpanNameExtractor.java +++ b/instrumentation/camunda/camunda-7.0/library/src/main/java/io/opentelemetry/instrumentation/camunda/v7_0/behavior/CamundaBehaviorSpanNameExtractor.java @@ -5,7 +5,7 @@ package io.opentelemetry.instrumentation.camunda.v7_0.behavior; -import io.opentelemetry.camunda.v7_0.common.CamundaCommonRequest; +import io.opentelemetry.instrumentation.camunda.v7_0.common.CamundaCommonRequest; import io.opentelemetry.instrumentation.api.instrumenter.SpanNameExtractor; import java.util.Arrays; From fb19def9dacbc8c1fa4e39991cade1e320def88f Mon Sep 17 00:00:00 2001 From: "Boslet, Cory (cb645j)" Date: Wed, 11 Dec 2024 17:24:09 -0500 Subject: [PATCH 08/23] Added dependencies to javaagent module, changed library instead of implemenation --- .../camunda/camunda-7.0/javaagent/build.gradle.kts | 3 +++ instrumentation/camunda/camunda-7.0/library/build.gradle.kts | 4 ++-- .../v7_0/behavior/CamundaBehaviorSpanNameExtractor.java | 2 +- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/instrumentation/camunda/camunda-7.0/javaagent/build.gradle.kts b/instrumentation/camunda/camunda-7.0/javaagent/build.gradle.kts index e5261f20fe6d..fcfa64f52771 100644 --- a/instrumentation/camunda/camunda-7.0/javaagent/build.gradle.kts +++ b/instrumentation/camunda/camunda-7.0/javaagent/build.gradle.kts @@ -15,6 +15,9 @@ muzzle { dependencies { implementation(project(":instrumentation:camunda:camunda-7.0:library")) + library("org.camunda.bpm:camunda-engine:7.18.0") + library("org.camunda.bpm:camunda-external-task-client:7.18.0") + api("com.google.auto.value:auto-value-annotations:1.6") annotationProcessor("com.google.auto.value:auto-value:1.6") } diff --git a/instrumentation/camunda/camunda-7.0/library/build.gradle.kts b/instrumentation/camunda/camunda-7.0/library/build.gradle.kts index 0b2c676dc081..28730e9962f0 100644 --- a/instrumentation/camunda/camunda-7.0/library/build.gradle.kts +++ b/instrumentation/camunda/camunda-7.0/library/build.gradle.kts @@ -3,8 +3,8 @@ plugins { } dependencies { - implementation("org.camunda.bpm:camunda-engine:7.18.0") - implementation("org.camunda.bpm:camunda-external-task-client:7.18.0") + library("org.camunda.bpm:camunda-engine:7.18.0") + library("org.camunda.bpm:camunda-external-task-client:7.18.0") api("com.google.auto.value:auto-value-annotations:1.6") annotationProcessor("com.google.auto.value:auto-value:1.6") diff --git a/instrumentation/camunda/camunda-7.0/library/src/main/java/io/opentelemetry/instrumentation/camunda/v7_0/behavior/CamundaBehaviorSpanNameExtractor.java b/instrumentation/camunda/camunda-7.0/library/src/main/java/io/opentelemetry/instrumentation/camunda/v7_0/behavior/CamundaBehaviorSpanNameExtractor.java index f7fb0bd3c8bc..96a530793df3 100644 --- a/instrumentation/camunda/camunda-7.0/library/src/main/java/io/opentelemetry/instrumentation/camunda/v7_0/behavior/CamundaBehaviorSpanNameExtractor.java +++ b/instrumentation/camunda/camunda-7.0/library/src/main/java/io/opentelemetry/instrumentation/camunda/v7_0/behavior/CamundaBehaviorSpanNameExtractor.java @@ -5,8 +5,8 @@ package io.opentelemetry.instrumentation.camunda.v7_0.behavior; -import io.opentelemetry.instrumentation.camunda.v7_0.common.CamundaCommonRequest; import io.opentelemetry.instrumentation.api.instrumenter.SpanNameExtractor; +import io.opentelemetry.instrumentation.camunda.v7_0.common.CamundaCommonRequest; import java.util.Arrays; public class CamundaBehaviorSpanNameExtractor implements SpanNameExtractor { From b44bc9db48d9de34d95b0d76e281bcc0bd3013b9 Mon Sep 17 00:00:00 2001 From: "Boslet, Cory (cb645j)" Date: Thu, 12 Dec 2024 13:14:07 -0500 Subject: [PATCH 09/23] Fix import statements and remove dead code --- .../camunda/v7_0/behavior/CamundaBehaviorSingletons.java | 8 +++----- .../CamundaEndEventActivityBehaviorInstrumentation.java | 4 ++-- ...amundaExternalTaskActivityBehaviorInstrumentation.java | 6 +++--- .../CamundaTaskActivityBehaviorInstrumentation.java | 4 ++-- .../CamundaProcessInstantiationBuilderModule.java | 6 ------ .../v7_0/task/CamundaTopicSubscriptionManagerModule.java | 6 ------ 6 files changed, 10 insertions(+), 24 deletions(-) diff --git a/instrumentation/camunda/camunda-7.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_0/behavior/CamundaBehaviorSingletons.java b/instrumentation/camunda/camunda-7.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_0/behavior/CamundaBehaviorSingletons.java index adde8621625b..49c55daee108 100644 --- a/instrumentation/camunda/camunda-7.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_0/behavior/CamundaBehaviorSingletons.java +++ b/instrumentation/camunda/camunda-7.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_0/behavior/CamundaBehaviorSingletons.java @@ -7,11 +7,11 @@ import io.opentelemetry.api.GlobalOpenTelemetry; import io.opentelemetry.api.OpenTelemetry; -import io.opentelemetry.camunda.v7_0.behavior.CamundaBehaviorSpanNameExtractor; -import io.opentelemetry.camunda.v7_0.common.CamundaCommonRequest; -import io.opentelemetry.camunda.v7_0.common.CamundaVariableAttributeExtractor; import io.opentelemetry.instrumentation.api.instrumenter.Instrumenter; import io.opentelemetry.instrumentation.api.instrumenter.InstrumenterBuilder; +import io.opentelemetry.instrumentation.camunda.v7_0.behavior.CamundaBehaviorSpanNameExtractor; +import io.opentelemetry.instrumentation.camunda.v7_0.common.CamundaCommonRequest; +import io.opentelemetry.instrumentation.camunda.v7_0.common.CamundaVariableAttributeExtractor; public class CamundaBehaviorSingletons { @@ -19,8 +19,6 @@ public class CamundaBehaviorSingletons { private static final OpenTelemetry opentelemetry; - private static final boolean propagationEnabled; - static { opentelemetry = GlobalOpenTelemetry.get(); diff --git a/instrumentation/camunda/camunda-7.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_0/behavior/CamundaEndEventActivityBehaviorInstrumentation.java b/instrumentation/camunda/camunda-7.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_0/behavior/CamundaEndEventActivityBehaviorInstrumentation.java index 74113e2989db..84a8049cb293 100644 --- a/instrumentation/camunda/camunda-7.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_0/behavior/CamundaEndEventActivityBehaviorInstrumentation.java +++ b/instrumentation/camunda/camunda-7.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_0/behavior/CamundaEndEventActivityBehaviorInstrumentation.java @@ -10,10 +10,10 @@ import static io.opentelemetry.javaagent.instrumentation.camunda.v7_0.behavior.CamundaBehaviorSingletons.getOpentelemetry; import static net.bytebuddy.matcher.ElementMatchers.named; -import io.opentelemetry.camunda.v7_0.behavior.CamundaActivityExecutionGetter; -import io.opentelemetry.camunda.v7_0.common.CamundaCommonRequest; import io.opentelemetry.context.Context; import io.opentelemetry.context.Scope; +import io.opentelemetry.instrumentation.camunda.v7_0.behavior.CamundaActivityExecutionGetter; +import io.opentelemetry.instrumentation.camunda.v7_0.common.CamundaCommonRequest; import io.opentelemetry.javaagent.bootstrap.Java8BytecodeBridge; import io.opentelemetry.javaagent.extension.instrumentation.TypeInstrumentation; import io.opentelemetry.javaagent.extension.instrumentation.TypeTransformer; diff --git a/instrumentation/camunda/camunda-7.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_0/behavior/CamundaExternalTaskActivityBehaviorInstrumentation.java b/instrumentation/camunda/camunda-7.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_0/behavior/CamundaExternalTaskActivityBehaviorInstrumentation.java index 55edf964fba9..3b1a889e907e 100644 --- a/instrumentation/camunda/camunda-7.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_0/behavior/CamundaExternalTaskActivityBehaviorInstrumentation.java +++ b/instrumentation/camunda/camunda-7.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_0/behavior/CamundaExternalTaskActivityBehaviorInstrumentation.java @@ -10,11 +10,11 @@ import static io.opentelemetry.javaagent.instrumentation.camunda.v7_0.behavior.CamundaBehaviorSingletons.getOpentelemetry; import static net.bytebuddy.matcher.ElementMatchers.named; -import io.opentelemetry.camunda.v7_0.behavior.CamundaActivityExecutionGetter; -import io.opentelemetry.camunda.v7_0.behavior.CamundaActivityExecutionLocalSetter; -import io.opentelemetry.camunda.v7_0.common.CamundaCommonRequest; import io.opentelemetry.context.Context; import io.opentelemetry.context.Scope; +import io.opentelemetry.instrumentation.camunda.v7_0.behavior.CamundaActivityExecutionGetter; +import io.opentelemetry.instrumentation.camunda.v7_0.behavior.CamundaActivityExecutionLocalSetter; +import io.opentelemetry.instrumentation.camunda.v7_0.common.CamundaCommonRequest; import io.opentelemetry.javaagent.bootstrap.Java8BytecodeBridge; import io.opentelemetry.javaagent.extension.instrumentation.TypeInstrumentation; import io.opentelemetry.javaagent.extension.instrumentation.TypeTransformer; diff --git a/instrumentation/camunda/camunda-7.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_0/behavior/CamundaTaskActivityBehaviorInstrumentation.java b/instrumentation/camunda/camunda-7.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_0/behavior/CamundaTaskActivityBehaviorInstrumentation.java index a77f8eed9b73..de1c31c13300 100644 --- a/instrumentation/camunda/camunda-7.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_0/behavior/CamundaTaskActivityBehaviorInstrumentation.java +++ b/instrumentation/camunda/camunda-7.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_0/behavior/CamundaTaskActivityBehaviorInstrumentation.java @@ -11,10 +11,10 @@ import static io.opentelemetry.javaagent.instrumentation.camunda.v7_0.behavior.CamundaBehaviorSingletons.getOpentelemetry; import static net.bytebuddy.matcher.ElementMatchers.named; -import io.opentelemetry.camunda.v7_0.behavior.CamundaActivityExecutionGetter; -import io.opentelemetry.camunda.v7_0.common.CamundaCommonRequest; import io.opentelemetry.context.Context; import io.opentelemetry.context.Scope; +import io.opentelemetry.instrumentation.camunda.v7_0.behavior.CamundaActivityExecutionGetter; +import io.opentelemetry.instrumentation.camunda.v7_0.common.CamundaCommonRequest; import io.opentelemetry.javaagent.bootstrap.Java8BytecodeBridge; import io.opentelemetry.javaagent.extension.instrumentation.TypeInstrumentation; import io.opentelemetry.javaagent.extension.instrumentation.TypeTransformer; diff --git a/instrumentation/camunda/camunda-7.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_0/processes/CamundaProcessInstantiationBuilderModule.java b/instrumentation/camunda/camunda-7.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_0/processes/CamundaProcessInstantiationBuilderModule.java index bb4474647813..3a96cada2b63 100644 --- a/instrumentation/camunda/camunda-7.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_0/processes/CamundaProcessInstantiationBuilderModule.java +++ b/instrumentation/camunda/camunda-7.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_0/processes/CamundaProcessInstantiationBuilderModule.java @@ -10,7 +10,6 @@ import com.google.auto.service.AutoService; import io.opentelemetry.javaagent.extension.instrumentation.InstrumentationModule; import io.opentelemetry.javaagent.extension.instrumentation.TypeInstrumentation; -import io.opentelemetry.sdk.autoconfigure.spi.ConfigProperties; import java.util.Arrays; import java.util.Collections; import java.util.List; @@ -28,11 +27,6 @@ public List typeInstrumentations() { return Collections.singletonList(new CamundaProcessInstantiationBuilderInstrumentation()); } - @Override - public boolean defaultEnabled(ConfigProperties config) { - return config.getBoolean("otel.instrumentation.common.default-enabled", true); - } - @Override public ElementMatcher.Junction classLoaderMatcher() { diff --git a/instrumentation/camunda/camunda-7.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_0/task/CamundaTopicSubscriptionManagerModule.java b/instrumentation/camunda/camunda-7.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_0/task/CamundaTopicSubscriptionManagerModule.java index 18534090260e..659737ae4a54 100644 --- a/instrumentation/camunda/camunda-7.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_0/task/CamundaTopicSubscriptionManagerModule.java +++ b/instrumentation/camunda/camunda-7.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_0/task/CamundaTopicSubscriptionManagerModule.java @@ -10,7 +10,6 @@ import com.google.auto.service.AutoService; import io.opentelemetry.javaagent.extension.instrumentation.InstrumentationModule; import io.opentelemetry.javaagent.extension.instrumentation.TypeInstrumentation; -import io.opentelemetry.sdk.autoconfigure.spi.ConfigProperties; import java.util.Arrays; import java.util.Collections; import java.util.List; @@ -23,11 +22,6 @@ public CamundaTopicSubscriptionManagerModule() { super("camunda", "camunda-task", "camunda-task-7_18"); } - @Override - public boolean defaultEnabled(ConfigProperties config) { - return config.getBoolean("otel.instrumentation.common.default-enabled", true); - } - @Override public List typeInstrumentations() { return Collections.singletonList(new CamundaTopicSubscriptionMangerInstrumentation()); From 26df3f19edccae88013582ada9c202aeddbb1b91 Mon Sep 17 00:00:00 2001 From: "Boslet, Cory (cb645j)" Date: Thu, 12 Dec 2024 13:42:34 -0500 Subject: [PATCH 10/23] Fix more errors on compile --- ...mundaCallableElementActivityBehaviorInstrumentation.java | 6 +++--- .../v7_0/behavior/CamundaTaskActivityBehaviorModule.java | 6 ------ .../v7_0/jobs/CamundaAsyncContinuationJobHandlerModule.java | 6 ------ .../camunda/v7_0/processes/CamundaProcessSingletons.java | 2 -- .../task/CamundaTopicSubscriptionMangerInstrumentation.java | 4 ++-- 5 files changed, 5 insertions(+), 19 deletions(-) diff --git a/instrumentation/camunda/camunda-7.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_0/behavior/CamundaCallableElementActivityBehaviorInstrumentation.java b/instrumentation/camunda/camunda-7.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_0/behavior/CamundaCallableElementActivityBehaviorInstrumentation.java index d43db2f433f5..7d4fc486c87f 100644 --- a/instrumentation/camunda/camunda-7.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_0/behavior/CamundaCallableElementActivityBehaviorInstrumentation.java +++ b/instrumentation/camunda/camunda-7.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_0/behavior/CamundaCallableElementActivityBehaviorInstrumentation.java @@ -14,10 +14,10 @@ import io.opentelemetry.api.trace.SpanContext; import io.opentelemetry.context.Context; import io.opentelemetry.context.Scope; +import io.opentelemetry.instrumentation.camunda.v7_0.behavior.CamundaActivityExecutionGetter; +import io.opentelemetry.instrumentation.camunda.v7_0.behavior.CamundaVariableMapSetter; +import io.opentelemetry.instrumentation.camunda.v7_0.common.CamundaCommonRequest; import io.opentelemetry.javaagent.bootstrap.Java8BytecodeBridge; -import io.opentelemetry.javaagent.camunda.v7_0.behavior.CamundaActivityExecutionGetter; -import io.opentelemetry.javaagent.camunda.v7_0.behavior.CamundaVariableMapSetter; -import io.opentelemetry.javaagent.camunda.v7_0.common.CamundaCommonRequest; import io.opentelemetry.javaagent.extension.instrumentation.TypeInstrumentation; import io.opentelemetry.javaagent.extension.instrumentation.TypeTransformer; import java.util.Optional; diff --git a/instrumentation/camunda/camunda-7.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_0/behavior/CamundaTaskActivityBehaviorModule.java b/instrumentation/camunda/camunda-7.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_0/behavior/CamundaTaskActivityBehaviorModule.java index 5573874c3e24..d4ec844f7921 100644 --- a/instrumentation/camunda/camunda-7.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_0/behavior/CamundaTaskActivityBehaviorModule.java +++ b/instrumentation/camunda/camunda-7.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_0/behavior/CamundaTaskActivityBehaviorModule.java @@ -10,7 +10,6 @@ import com.google.auto.service.AutoService; import io.opentelemetry.javaagent.extension.instrumentation.InstrumentationModule; import io.opentelemetry.javaagent.extension.instrumentation.TypeInstrumentation; -import io.opentelemetry.sdk.autoconfigure.spi.ConfigProperties; import java.util.Arrays; import java.util.Collections; import java.util.List; @@ -23,11 +22,6 @@ public CamundaTaskActivityBehaviorModule() { super("camunda", "camunda-behavior", "camunda-behavior-7_18"); } - @Override - public boolean defaultEnabled(ConfigProperties config) { - return config.getBoolean("otel.instrumentation.common.default-enabled", true); - } - @Override public List typeInstrumentations() { return Collections.singletonList(new CamundaTaskActivityBehaviorInstrumentation()); diff --git a/instrumentation/camunda/camunda-7.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_0/jobs/CamundaAsyncContinuationJobHandlerModule.java b/instrumentation/camunda/camunda-7.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_0/jobs/CamundaAsyncContinuationJobHandlerModule.java index 6fc6c5cf67fe..6f3f83db7794 100644 --- a/instrumentation/camunda/camunda-7.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_0/jobs/CamundaAsyncContinuationJobHandlerModule.java +++ b/instrumentation/camunda/camunda-7.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_0/jobs/CamundaAsyncContinuationJobHandlerModule.java @@ -10,7 +10,6 @@ import com.google.auto.service.AutoService; import io.opentelemetry.javaagent.extension.instrumentation.InstrumentationModule; import io.opentelemetry.javaagent.extension.instrumentation.TypeInstrumentation; -import io.opentelemetry.sdk.autoconfigure.spi.ConfigProperties; import java.util.Arrays; import java.util.Collections; import java.util.List; @@ -23,11 +22,6 @@ public CamundaAsyncContinuationJobHandlerModule() { super("camunda", "camunda-job", "camunda-job-7_18"); } - @Override - public boolean defaultEnabled(ConfigProperties config) { - return config.getBoolean("otel.instrumentation.common.default-enabled", true); - } - @Override public List typeInstrumentations() { return Collections.singletonList(new CamundaAsyncContinuationJobHandlerInstrumentation()); diff --git a/instrumentation/camunda/camunda-7.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_0/processes/CamundaProcessSingletons.java b/instrumentation/camunda/camunda-7.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_0/processes/CamundaProcessSingletons.java index 2d182d726cb1..02fad4b28696 100644 --- a/instrumentation/camunda/camunda-7.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_0/processes/CamundaProcessSingletons.java +++ b/instrumentation/camunda/camunda-7.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_0/processes/CamundaProcessSingletons.java @@ -19,8 +19,6 @@ public class CamundaProcessSingletons { private static final OpenTelemetry opentelemetry; - private static final boolean propagationEnabled; - static { opentelemetry = GlobalOpenTelemetry.get(); diff --git a/instrumentation/camunda/camunda-7.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_0/task/CamundaTopicSubscriptionMangerInstrumentation.java b/instrumentation/camunda/camunda-7.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_0/task/CamundaTopicSubscriptionMangerInstrumentation.java index d9fac16573f3..a40dced38fad 100644 --- a/instrumentation/camunda/camunda-7.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_0/task/CamundaTopicSubscriptionMangerInstrumentation.java +++ b/instrumentation/camunda/camunda-7.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_0/task/CamundaTopicSubscriptionMangerInstrumentation.java @@ -6,8 +6,8 @@ package io.opentelemetry.javaagent.instrumentation.camunda.v7_0.task; import static io.opentelemetry.javaagent.extension.matcher.AgentElementMatchers.hasClassesNamed; -import static io.opentelemetry.javaagent.instrumentationn.camunda.v7_0.task.CamundaTaskSingletons.getInstumenter; -import static io.opentelemetry.javaagent.instrumentationn.camunda.v7_0.task.CamundaTaskSingletons.getOpentelemetry; +import static io.opentelemetry.javaagent.instrumentation.camunda.v7_0.task.CamundaTaskSingletons.getInstumenter; +import static io.opentelemetry.javaagent.instrumentation.camunda.v7_0.task.CamundaTaskSingletons.getOpentelemetry; import static net.bytebuddy.matcher.ElementMatchers.named; import io.opentelemetry.context.Context; From 9fb1aed31bfc41e0de104aaa8b9690465784adef Mon Sep 17 00:00:00 2001 From: "Boslet, Cory (cb645j)" Date: Thu, 12 Dec 2024 14:32:51 -0500 Subject: [PATCH 11/23] remove unused dependencies and supress warning --- instrumentation/camunda/camunda-7.0/javaagent/build.gradle.kts | 1 - .../v7_0/task/CamundaTopicSubscriptionMangerInstrumentation.java | 1 + instrumentation/camunda/camunda-7.0/library/build.gradle.kts | 1 - 3 files changed, 1 insertion(+), 2 deletions(-) diff --git a/instrumentation/camunda/camunda-7.0/javaagent/build.gradle.kts b/instrumentation/camunda/camunda-7.0/javaagent/build.gradle.kts index fcfa64f52771..51e382995f4d 100644 --- a/instrumentation/camunda/camunda-7.0/javaagent/build.gradle.kts +++ b/instrumentation/camunda/camunda-7.0/javaagent/build.gradle.kts @@ -18,6 +18,5 @@ dependencies { library("org.camunda.bpm:camunda-engine:7.18.0") library("org.camunda.bpm:camunda-external-task-client:7.18.0") - api("com.google.auto.value:auto-value-annotations:1.6") annotationProcessor("com.google.auto.value:auto-value:1.6") } diff --git a/instrumentation/camunda/camunda-7.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_0/task/CamundaTopicSubscriptionMangerInstrumentation.java b/instrumentation/camunda/camunda-7.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_0/task/CamundaTopicSubscriptionMangerInstrumentation.java index a40dced38fad..9056a5ae2ddc 100644 --- a/instrumentation/camunda/camunda-7.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_0/task/CamundaTopicSubscriptionMangerInstrumentation.java +++ b/instrumentation/camunda/camunda-7.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_0/task/CamundaTopicSubscriptionMangerInstrumentation.java @@ -50,6 +50,7 @@ public void transform(TypeTransformer transformer) { public static class CamundaTopicSubscriptionMangerAdvice { + @SuppressWarnings("rawtypes") @Advice.OnMethodEnter(suppress = Throwable.class) public static void addTracingEnter( @Advice.FieldValue("typedValues") TypedValues typedValues, diff --git a/instrumentation/camunda/camunda-7.0/library/build.gradle.kts b/instrumentation/camunda/camunda-7.0/library/build.gradle.kts index 28730e9962f0..8ac3e9ba95e4 100644 --- a/instrumentation/camunda/camunda-7.0/library/build.gradle.kts +++ b/instrumentation/camunda/camunda-7.0/library/build.gradle.kts @@ -6,7 +6,6 @@ dependencies { library("org.camunda.bpm:camunda-engine:7.18.0") library("org.camunda.bpm:camunda-external-task-client:7.18.0") - api("com.google.auto.value:auto-value-annotations:1.6") annotationProcessor("com.google.auto.value:auto-value:1.6") } From d7f179f67c3e07bb9dff5b629f21e05926250e22 Mon Sep 17 00:00:00 2001 From: "Boslet, Cory (cb645j)" Date: Thu, 12 Dec 2024 14:53:14 -0500 Subject: [PATCH 12/23] Add private constructor for singletons --- .../camunda/v7_0/behavior/CamundaBehaviorSingletons.java | 2 ++ .../instrumentation/camunda/v7_0/jobs/CamundaJobSingletons.java | 2 ++ .../camunda/v7_0/processes/CamundaProcessSingletons.java | 2 ++ .../camunda/v7_0/task/CamundaTaskSingletons.java | 2 ++ 4 files changed, 8 insertions(+) diff --git a/instrumentation/camunda/camunda-7.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_0/behavior/CamundaBehaviorSingletons.java b/instrumentation/camunda/camunda-7.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_0/behavior/CamundaBehaviorSingletons.java index 49c55daee108..2f2f04db16b1 100644 --- a/instrumentation/camunda/camunda-7.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_0/behavior/CamundaBehaviorSingletons.java +++ b/instrumentation/camunda/camunda-7.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_0/behavior/CamundaBehaviorSingletons.java @@ -39,4 +39,6 @@ public static OpenTelemetry getOpentelemetry() { public static Instrumenter getInstumenter() { return instrumenter; } + + private CamundaBehaviorSingletons() {} } diff --git a/instrumentation/camunda/camunda-7.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_0/jobs/CamundaJobSingletons.java b/instrumentation/camunda/camunda-7.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_0/jobs/CamundaJobSingletons.java index bfb56dd42667..1dcb81c74f0b 100644 --- a/instrumentation/camunda/camunda-7.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_0/jobs/CamundaJobSingletons.java +++ b/instrumentation/camunda/camunda-7.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_0/jobs/CamundaJobSingletons.java @@ -37,4 +37,6 @@ public static OpenTelemetry getOpentelemetry() { public static Instrumenter getInstumenter() { return instrumenter; } + + private CamundaJobSingletons() {} } diff --git a/instrumentation/camunda/camunda-7.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_0/processes/CamundaProcessSingletons.java b/instrumentation/camunda/camunda-7.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_0/processes/CamundaProcessSingletons.java index 02fad4b28696..e8437e0d9640 100644 --- a/instrumentation/camunda/camunda-7.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_0/processes/CamundaProcessSingletons.java +++ b/instrumentation/camunda/camunda-7.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_0/processes/CamundaProcessSingletons.java @@ -39,4 +39,6 @@ public static OpenTelemetry getOpentelemetry() { public static Instrumenter getInstumenter() { return instrumenter; } + + private CamundaProcessSingletons() {} } diff --git a/instrumentation/camunda/camunda-7.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_0/task/CamundaTaskSingletons.java b/instrumentation/camunda/camunda-7.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_0/task/CamundaTaskSingletons.java index 33fd80d96c7f..4cb4b76777b2 100644 --- a/instrumentation/camunda/camunda-7.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_0/task/CamundaTaskSingletons.java +++ b/instrumentation/camunda/camunda-7.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_0/task/CamundaTaskSingletons.java @@ -37,4 +37,6 @@ public static OpenTelemetry getOpentelemetry() { public static Instrumenter getInstumenter() { return instrumenter; } + + private CamundaTaskSingletons() {} } From 308f6a82bd7229b746c9b1479c4d6a7254f95a63 Mon Sep 17 00:00:00 2001 From: "Boslet, Cory (cb645j)" Date: Thu, 12 Dec 2024 15:47:32 -0500 Subject: [PATCH 13/23] Removed javadocs with no description and unused fields --- ...CallableElementActivityBehaviorInstrumentation.java | 2 -- ...CamundaEndEventActivityBehaviorInstrumentation.java | 2 -- ...ndaExternalTaskActivityBehaviorInstrumentation.java | 10 ---------- .../CamundaTaskActivityBehaviorInstrumentation.java | 2 -- ...undaAsyncContinuationJobHandlerInstrumentation.java | 4 +--- 5 files changed, 1 insertion(+), 19 deletions(-) diff --git a/instrumentation/camunda/camunda-7.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_0/behavior/CamundaCallableElementActivityBehaviorInstrumentation.java b/instrumentation/camunda/camunda-7.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_0/behavior/CamundaCallableElementActivityBehaviorInstrumentation.java index 7d4fc486c87f..b031eeee664e 100644 --- a/instrumentation/camunda/camunda-7.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_0/behavior/CamundaCallableElementActivityBehaviorInstrumentation.java +++ b/instrumentation/camunda/camunda-7.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_0/behavior/CamundaCallableElementActivityBehaviorInstrumentation.java @@ -71,8 +71,6 @@ public static void addTracingEnter( request.setActivityId(Optional.ofNullable(execution.getCurrentActivityId())); request.setActivityName(Optional.ofNullable(execution.getCurrentActivityName())); - String processInstanceId = execution.getProcessInstanceId(); - if (Java8BytecodeBridge.currentContext() == Java8BytecodeBridge.rootContext()) { // log } diff --git a/instrumentation/camunda/camunda-7.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_0/behavior/CamundaEndEventActivityBehaviorInstrumentation.java b/instrumentation/camunda/camunda-7.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_0/behavior/CamundaEndEventActivityBehaviorInstrumentation.java index 84a8049cb293..881df74b4d6b 100644 --- a/instrumentation/camunda/camunda-7.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_0/behavior/CamundaEndEventActivityBehaviorInstrumentation.java +++ b/instrumentation/camunda/camunda-7.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_0/behavior/CamundaEndEventActivityBehaviorInstrumentation.java @@ -93,8 +93,6 @@ public static void addTracingEnter( } } - String processInstanceId = execution.getProcessInstanceId(); - Context parentContext = getOpentelemetry() .getPropagators() diff --git a/instrumentation/camunda/camunda-7.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_0/behavior/CamundaExternalTaskActivityBehaviorInstrumentation.java b/instrumentation/camunda/camunda-7.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_0/behavior/CamundaExternalTaskActivityBehaviorInstrumentation.java index 3b1a889e907e..0b8a4b770be8 100644 --- a/instrumentation/camunda/camunda-7.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_0/behavior/CamundaExternalTaskActivityBehaviorInstrumentation.java +++ b/instrumentation/camunda/camunda-7.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_0/behavior/CamundaExternalTaskActivityBehaviorInstrumentation.java @@ -50,19 +50,11 @@ public static class CamundaExternalTaskActivityBehaviorAdvice { /** * Sets parent context to process instance. Creates new context and span. propagates current * context to variable set for topic to retrieve. - * - * @param execution - * @param request - * @param parentScope - * @param parentContext - * @param context - * @param scope */ @Advice.OnMethodEnter(suppress = Throwable.class) public static void addTracingEnter( @Advice.Argument(0) ActivityExecution execution, @Advice.Local("request") CamundaCommonRequest request, - @Advice.Local("otelParentScope") Scope parentScope, @Advice.Local("otelParentContext") Context parentContext, @Advice.Local("otelContext") Context context, @Advice.Local("otelScope") Scope scope) { @@ -77,8 +69,6 @@ public static void addTracingEnter( request.setActivityId(Optional.ofNullable(execution.getCurrentActivityId())); request.setActivityName(Optional.ofNullable(execution.getCurrentActivityName())); - String processInstanceId = execution.getProcessInstanceId(); - if (Java8BytecodeBridge.currentContext() == Java8BytecodeBridge.rootContext()) {} parentContext = diff --git a/instrumentation/camunda/camunda-7.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_0/behavior/CamundaTaskActivityBehaviorInstrumentation.java b/instrumentation/camunda/camunda-7.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_0/behavior/CamundaTaskActivityBehaviorInstrumentation.java index de1c31c13300..4a6db2d62877 100644 --- a/instrumentation/camunda/camunda-7.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_0/behavior/CamundaTaskActivityBehaviorInstrumentation.java +++ b/instrumentation/camunda/camunda-7.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_0/behavior/CamundaTaskActivityBehaviorInstrumentation.java @@ -64,8 +64,6 @@ public static void addTracingEnter( request.setActivityId(Optional.ofNullable(execution.getCurrentActivityId())); request.setActivityName(Optional.ofNullable(execution.getCurrentActivityName())); - String processInstanceId = execution.getProcessInstanceId(); - if (Java8BytecodeBridge.currentContext() == Java8BytecodeBridge.rootContext()) {} Context parentContext = diff --git a/instrumentation/camunda/camunda-7.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_0/jobs/CamundaAsyncContinuationJobHandlerInstrumentation.java b/instrumentation/camunda/camunda-7.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_0/jobs/CamundaAsyncContinuationJobHandlerInstrumentation.java index 59873c4e409a..2451752e55d0 100644 --- a/instrumentation/camunda/camunda-7.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_0/jobs/CamundaAsyncContinuationJobHandlerInstrumentation.java +++ b/instrumentation/camunda/camunda-7.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_0/jobs/CamundaAsyncContinuationJobHandlerInstrumentation.java @@ -74,10 +74,8 @@ public static void addTracingEnter( request.setActivityName(Optional.ofNullable(executionEntity.getActivity().getName())); } - String processInstanceId = executionEntity.getProcessInstanceId(); - if (Java8BytecodeBridge.currentContext() == Java8BytecodeBridge.rootContext()) { - System.out.println("No initial span context for process instance " + processInstanceId); + // log } Context parentContext = From fd44b57dc3d25ffc56c0ffd71075bcb0970b3355 Mon Sep 17 00:00:00 2001 From: "Boslet, Cory (cb645j)" Date: Thu, 12 Dec 2024 16:14:41 -0500 Subject: [PATCH 14/23] remove print line and fix scope --- .../CamundaExternalTaskActivityBehaviorInstrumentation.java | 1 + .../CamundaAsyncContinuationJobHandlerInstrumentation.java | 3 --- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/instrumentation/camunda/camunda-7.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_0/behavior/CamundaExternalTaskActivityBehaviorInstrumentation.java b/instrumentation/camunda/camunda-7.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_0/behavior/CamundaExternalTaskActivityBehaviorInstrumentation.java index 0b8a4b770be8..f8a6a713d355 100644 --- a/instrumentation/camunda/camunda-7.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_0/behavior/CamundaExternalTaskActivityBehaviorInstrumentation.java +++ b/instrumentation/camunda/camunda-7.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_0/behavior/CamundaExternalTaskActivityBehaviorInstrumentation.java @@ -55,6 +55,7 @@ public static class CamundaExternalTaskActivityBehaviorAdvice { public static void addTracingEnter( @Advice.Argument(0) ActivityExecution execution, @Advice.Local("request") CamundaCommonRequest request, + @Advice.Local("otelParentScope") Scope parentScope, @Advice.Local("otelParentContext") Context parentContext, @Advice.Local("otelContext") Context context, @Advice.Local("otelScope") Scope scope) { diff --git a/instrumentation/camunda/camunda-7.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_0/jobs/CamundaAsyncContinuationJobHandlerInstrumentation.java b/instrumentation/camunda/camunda-7.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_0/jobs/CamundaAsyncContinuationJobHandlerInstrumentation.java index 2451752e55d0..ba9c5ff493cf 100644 --- a/instrumentation/camunda/camunda-7.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_0/jobs/CamundaAsyncContinuationJobHandlerInstrumentation.java +++ b/instrumentation/camunda/camunda-7.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_0/jobs/CamundaAsyncContinuationJobHandlerInstrumentation.java @@ -92,9 +92,6 @@ public static void addTracingEnter( if (getInstumenter().shouldStart(Java8BytecodeBridge.currentContext(), request)) { context = getInstumenter().start(Java8BytecodeBridge.currentContext(), request); scope = context.makeCurrent(); - - } else { - System.out.println("Unable to start telemetry for process " + processInstanceId); } } From bdd9ea1fcf89e8ebf79c0421157d244190cf9905 Mon Sep 17 00:00:00 2001 From: "Boslet, Cory (cb645j)" Date: Fri, 13 Dec 2024 12:46:26 -0500 Subject: [PATCH 15/23] Surpress unused warning in instrumentation --- .../CamundaExternalTaskActivityBehaviorInstrumentation.java | 1 + 1 file changed, 1 insertion(+) diff --git a/instrumentation/camunda/camunda-7.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_0/behavior/CamundaExternalTaskActivityBehaviorInstrumentation.java b/instrumentation/camunda/camunda-7.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_0/behavior/CamundaExternalTaskActivityBehaviorInstrumentation.java index f8a6a713d355..1fa07fac7ea4 100644 --- a/instrumentation/camunda/camunda-7.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_0/behavior/CamundaExternalTaskActivityBehaviorInstrumentation.java +++ b/instrumentation/camunda/camunda-7.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_0/behavior/CamundaExternalTaskActivityBehaviorInstrumentation.java @@ -45,6 +45,7 @@ public void transform(TypeTransformer transformer) { this.getClass().getName() + "$CamundaExternalTaskActivityBehaviorAdvice"); } + @SuppressWarnings("unused") public static class CamundaExternalTaskActivityBehaviorAdvice { /** From 628d839eb672a7f834f387c766998cb943d0b09c Mon Sep 17 00:00:00 2001 From: "Boslet, Cory (cb645j)" Date: Fri, 13 Dec 2024 13:05:32 -0500 Subject: [PATCH 16/23] Surpress false warnings so build doesnt fail --- .../CamundaCallableElementActivityBehaviorInstrumentation.java | 1 + .../behavior/CamundaEndEventActivityBehaviorInstrumentation.java | 1 + .../behavior/CamundaTaskActivityBehaviorInstrumentation.java | 1 + .../jobs/CamundaAsyncContinuationJobHandlerInstrumentation.java | 1 + .../CamundaProcessInstantiationBuilderInstrumentation.java | 1 + .../v7_0/task/CamundaTopicSubscriptionMangerInstrumentation.java | 1 + 6 files changed, 6 insertions(+) diff --git a/instrumentation/camunda/camunda-7.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_0/behavior/CamundaCallableElementActivityBehaviorInstrumentation.java b/instrumentation/camunda/camunda-7.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_0/behavior/CamundaCallableElementActivityBehaviorInstrumentation.java index b031eeee664e..9b52cdd6a56f 100644 --- a/instrumentation/camunda/camunda-7.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_0/behavior/CamundaCallableElementActivityBehaviorInstrumentation.java +++ b/instrumentation/camunda/camunda-7.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_0/behavior/CamundaCallableElementActivityBehaviorInstrumentation.java @@ -49,6 +49,7 @@ public void transform(TypeTransformer transformer) { this.getClass().getName() + "$CamundaCallableElementActivityBehaviorAdvice"); } + @SuppressWarnings("unused") public static class CamundaCallableElementActivityBehaviorAdvice { @Advice.OnMethodEnter(suppress = Throwable.class) diff --git a/instrumentation/camunda/camunda-7.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_0/behavior/CamundaEndEventActivityBehaviorInstrumentation.java b/instrumentation/camunda/camunda-7.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_0/behavior/CamundaEndEventActivityBehaviorInstrumentation.java index 881df74b4d6b..ace0cee4157c 100644 --- a/instrumentation/camunda/camunda-7.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_0/behavior/CamundaEndEventActivityBehaviorInstrumentation.java +++ b/instrumentation/camunda/camunda-7.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_0/behavior/CamundaEndEventActivityBehaviorInstrumentation.java @@ -54,6 +54,7 @@ public void transform(TypeTransformer transformer) { this.getClass().getName() + "$CamundaEndEventActivityBehaviorAdvice"); } + @SuppressWarnings("unused") public static class CamundaEndEventActivityBehaviorAdvice { @Advice.OnMethodEnter(suppress = Throwable.class) diff --git a/instrumentation/camunda/camunda-7.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_0/behavior/CamundaTaskActivityBehaviorInstrumentation.java b/instrumentation/camunda/camunda-7.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_0/behavior/CamundaTaskActivityBehaviorInstrumentation.java index 4a6db2d62877..ba7c1267ae80 100644 --- a/instrumentation/camunda/camunda-7.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_0/behavior/CamundaTaskActivityBehaviorInstrumentation.java +++ b/instrumentation/camunda/camunda-7.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_0/behavior/CamundaTaskActivityBehaviorInstrumentation.java @@ -44,6 +44,7 @@ public void transform(TypeTransformer transformer) { this.getClass().getName() + "$CamundaTaskActivityBehaviorAdvice"); } + @SuppressWarnings("unused") public static class CamundaTaskActivityBehaviorAdvice { @Advice.OnMethodEnter(suppress = Throwable.class) diff --git a/instrumentation/camunda/camunda-7.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_0/jobs/CamundaAsyncContinuationJobHandlerInstrumentation.java b/instrumentation/camunda/camunda-7.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_0/jobs/CamundaAsyncContinuationJobHandlerInstrumentation.java index ba9c5ff493cf..f89d74402b86 100644 --- a/instrumentation/camunda/camunda-7.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_0/jobs/CamundaAsyncContinuationJobHandlerInstrumentation.java +++ b/instrumentation/camunda/camunda-7.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_0/jobs/CamundaAsyncContinuationJobHandlerInstrumentation.java @@ -49,6 +49,7 @@ public void transform(TypeTransformer transformer) { this.getClass().getName() + "$CamundaAsyncContinuationJobHandlerAdvice"); } + @SuppressWarnings("unused") public static class CamundaAsyncContinuationJobHandlerAdvice { @Advice.OnMethodEnter(suppress = Throwable.class) public static void addTracingEnter( diff --git a/instrumentation/camunda/camunda-7.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_0/processes/CamundaProcessInstantiationBuilderInstrumentation.java b/instrumentation/camunda/camunda-7.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_0/processes/CamundaProcessInstantiationBuilderInstrumentation.java index c2a58f257b39..bff245476d99 100644 --- a/instrumentation/camunda/camunda-7.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_0/processes/CamundaProcessInstantiationBuilderInstrumentation.java +++ b/instrumentation/camunda/camunda-7.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_0/processes/CamundaProcessInstantiationBuilderInstrumentation.java @@ -50,6 +50,7 @@ public void transform(TypeTransformer transformer) { + "$CamundaProcessInstantiationBuilderExecuteWithVariablesAdvice"); } + @SuppressWarnings("unused") public static class CamundaProcessInstantiationBuilderExecuteWithVariablesAdvice { @Advice.OnMethodEnter(suppress = Throwable.class) diff --git a/instrumentation/camunda/camunda-7.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_0/task/CamundaTopicSubscriptionMangerInstrumentation.java b/instrumentation/camunda/camunda-7.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_0/task/CamundaTopicSubscriptionMangerInstrumentation.java index 9056a5ae2ddc..044a466365f0 100644 --- a/instrumentation/camunda/camunda-7.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_0/task/CamundaTopicSubscriptionMangerInstrumentation.java +++ b/instrumentation/camunda/camunda-7.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_0/task/CamundaTopicSubscriptionMangerInstrumentation.java @@ -50,6 +50,7 @@ public void transform(TypeTransformer transformer) { public static class CamundaTopicSubscriptionMangerAdvice { + @SuppressWarnings("unused") @SuppressWarnings("rawtypes") @Advice.OnMethodEnter(suppress = Throwable.class) public static void addTracingEnter( From 75f3fdc0f2265d1940a8d0da9930ed242195dcef Mon Sep 17 00:00:00 2001 From: "Boslet, Cory (cb645j)" Date: Mon, 16 Dec 2024 11:48:05 -0500 Subject: [PATCH 17/23] Combine supress warnings into one --- .../task/CamundaTopicSubscriptionMangerInstrumentation.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/instrumentation/camunda/camunda-7.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_0/task/CamundaTopicSubscriptionMangerInstrumentation.java b/instrumentation/camunda/camunda-7.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_0/task/CamundaTopicSubscriptionMangerInstrumentation.java index 044a466365f0..e58c19e793b3 100644 --- a/instrumentation/camunda/camunda-7.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_0/task/CamundaTopicSubscriptionMangerInstrumentation.java +++ b/instrumentation/camunda/camunda-7.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_0/task/CamundaTopicSubscriptionMangerInstrumentation.java @@ -50,8 +50,7 @@ public void transform(TypeTransformer transformer) { public static class CamundaTopicSubscriptionMangerAdvice { - @SuppressWarnings("unused") - @SuppressWarnings("rawtypes") + @SuppressWarnings({"rawtypes", "unused"}) @Advice.OnMethodEnter(suppress = Throwable.class) public static void addTracingEnter( @Advice.FieldValue("typedValues") TypedValues typedValues, From 0cd31853807fdbbe3baab90cfb27afcf98cfaf0d Mon Sep 17 00:00:00 2001 From: "Boslet, Cory (cb645j)" Date: Mon, 16 Dec 2024 12:34:38 -0500 Subject: [PATCH 18/23] remove empty if blocks from the code --- .../CamundaExternalTaskActivityBehaviorInstrumentation.java | 2 -- .../behavior/CamundaTaskActivityBehaviorInstrumentation.java | 2 -- 2 files changed, 4 deletions(-) diff --git a/instrumentation/camunda/camunda-7.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_0/behavior/CamundaExternalTaskActivityBehaviorInstrumentation.java b/instrumentation/camunda/camunda-7.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_0/behavior/CamundaExternalTaskActivityBehaviorInstrumentation.java index 1fa07fac7ea4..43c66652fa30 100644 --- a/instrumentation/camunda/camunda-7.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_0/behavior/CamundaExternalTaskActivityBehaviorInstrumentation.java +++ b/instrumentation/camunda/camunda-7.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_0/behavior/CamundaExternalTaskActivityBehaviorInstrumentation.java @@ -71,8 +71,6 @@ public static void addTracingEnter( request.setActivityId(Optional.ofNullable(execution.getCurrentActivityId())); request.setActivityName(Optional.ofNullable(execution.getCurrentActivityName())); - if (Java8BytecodeBridge.currentContext() == Java8BytecodeBridge.rootContext()) {} - parentContext = getOpentelemetry() .getPropagators() diff --git a/instrumentation/camunda/camunda-7.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_0/behavior/CamundaTaskActivityBehaviorInstrumentation.java b/instrumentation/camunda/camunda-7.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_0/behavior/CamundaTaskActivityBehaviorInstrumentation.java index ba7c1267ae80..a8842ead3ef6 100644 --- a/instrumentation/camunda/camunda-7.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_0/behavior/CamundaTaskActivityBehaviorInstrumentation.java +++ b/instrumentation/camunda/camunda-7.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_0/behavior/CamundaTaskActivityBehaviorInstrumentation.java @@ -65,8 +65,6 @@ public static void addTracingEnter( request.setActivityId(Optional.ofNullable(execution.getCurrentActivityId())); request.setActivityName(Optional.ofNullable(execution.getCurrentActivityName())); - if (Java8BytecodeBridge.currentContext() == Java8BytecodeBridge.rootContext()) {} - Context parentContext = getOpentelemetry() .getPropagators() From 3f9833ab51387d5703d2b6117690e3082e49e4f7 Mon Sep 17 00:00:00 2001 From: "Boslet, Cory (cb645j)" Date: Mon, 16 Dec 2024 13:36:31 -0500 Subject: [PATCH 19/23] Add extra dependency for muzzle check --- instrumentation/camunda/camunda-7.0/javaagent/build.gradle.kts | 1 + 1 file changed, 1 insertion(+) diff --git a/instrumentation/camunda/camunda-7.0/javaagent/build.gradle.kts b/instrumentation/camunda/camunda-7.0/javaagent/build.gradle.kts index 51e382995f4d..566beb300d0f 100644 --- a/instrumentation/camunda/camunda-7.0/javaagent/build.gradle.kts +++ b/instrumentation/camunda/camunda-7.0/javaagent/build.gradle.kts @@ -9,6 +9,7 @@ muzzle { // have not tested with versions prior to 7.18.0 versions.set("[7.18.0,)") + extraDependency("org.camunda.bpm:camunda-external-task-client:7.18.0") } } From 38ff7f076ffeb3243b6d842280085423bf5aea6d Mon Sep 17 00:00:00 2001 From: "Boslet, Cory (cb645j)" Date: Mon, 16 Dec 2024 14:09:06 -0500 Subject: [PATCH 20/23] Consolidated similiar type instrumentations into single module --- ...CamundaCommonBehaviorInstrumentation.java} | 63 +++++++-- ....java => CamundaCommonBehaviorModule.java} | 8 +- ...dEventActivityBehaviorInstrumentation.java | 132 ------------------ ...CamundaEndEventActivityBehaviorModule.java | 55 -------- ...alTaskActivityBehaviorInstrumentation.java | 115 --------------- ...ndaExternalTaskActivityBehaviorModule.java | 53 ------- 6 files changed, 58 insertions(+), 368 deletions(-) rename instrumentation/camunda/camunda-7.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_0/behavior/{CamundaTaskActivityBehaviorInstrumentation.java => CamundaCommonBehaviorInstrumentation.java} (57%) rename instrumentation/camunda/camunda-7.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_0/behavior/{CamundaTaskActivityBehaviorModule.java => CamundaCommonBehaviorModule.java} (76%) delete mode 100644 instrumentation/camunda/camunda-7.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_0/behavior/CamundaEndEventActivityBehaviorInstrumentation.java delete mode 100644 instrumentation/camunda/camunda-7.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_0/behavior/CamundaEndEventActivityBehaviorModule.java delete mode 100644 instrumentation/camunda/camunda-7.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_0/behavior/CamundaExternalTaskActivityBehaviorInstrumentation.java delete mode 100644 instrumentation/camunda/camunda-7.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_0/behavior/CamundaExternalTaskActivityBehaviorModule.java diff --git a/instrumentation/camunda/camunda-7.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_0/behavior/CamundaTaskActivityBehaviorInstrumentation.java b/instrumentation/camunda/camunda-7.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_0/behavior/CamundaCommonBehaviorInstrumentation.java similarity index 57% rename from instrumentation/camunda/camunda-7.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_0/behavior/CamundaTaskActivityBehaviorInstrumentation.java rename to instrumentation/camunda/camunda-7.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_0/behavior/CamundaCommonBehaviorInstrumentation.java index a8842ead3ef6..d349ef4132bc 100644 --- a/instrumentation/camunda/camunda-7.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_0/behavior/CamundaTaskActivityBehaviorInstrumentation.java +++ b/instrumentation/camunda/camunda-7.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_0/behavior/CamundaCommonBehaviorInstrumentation.java @@ -25,27 +25,36 @@ import net.bytebuddy.matcher.ElementMatchers; import org.camunda.bpm.engine.impl.pvm.delegate.ActivityExecution; -public class CamundaTaskActivityBehaviorInstrumentation implements TypeInstrumentation { +public class CamundaCommonBehaviorInstrumentation implements TypeInstrumentation { @Override public ElementMatcher classLoaderOptimization() { return hasClassesNamed("org.camunda.bpm.engine.impl.bpmn.behavior.TaskActivityBehavior"); } - @Override - public ElementMatcher typeMatcher() { - return hasSuperType(named("org.camunda.bpm.engine.impl.bpmn.behavior.TaskActivityBehavior")); - } + @Override + public ElementMatcher typeMatcher() { + return hasSuperType(named("org.camunda.bpm.engine.impl.bpmn.behavior.TaskActivityBehavior")) + .or(named("org.camunda.bpm.engine.impl.bpmn.behavior.ExternalTaskActivityBehavior")) + .or(named("org.camunda.bpm.engine.impl.bpmn.behavior.TerminateEndEventActivityBehavior")) + .or(named("org.camunda.bpm.engine.impl.bpmn.behavior.NoneEndEventActivityBehavior")) + .or(named("org.camunda.bpm.engine.impl.bpmn.behavior.ErrorEndEventActivityBehavior")); + // elements that have been tested with instrumentation, eventually this can be + // replaced by the supertype AbstractBpmnActivityBehavior, once all elements + // instrumentations have been certified and instrumented, but will need to make + // sure its not callable element as the instrumentation should remain separate + // due to logic + } @Override public void transform(TypeTransformer transformer) { transformer.applyAdviceToMethod( - ElementMatchers.isMethod().and(ElementMatchers.named("performExecution")), - this.getClass().getName() + "$CamundaTaskActivityBehaviorAdvice"); + ElementMatchers.isMethod().and(ElementMatchers.named("execute")), + this.getClass().getName() + "$CamundaCommonBehaviorAdvice"); } @SuppressWarnings("unused") - public static class CamundaTaskActivityBehaviorAdvice { + public static class CamundaCommonBehaviorAdvice { @Advice.OnMethodEnter(suppress = Throwable.class) public static void addTracingEnter( @@ -63,7 +72,35 @@ public static void addTracingEnter( request.setProcessDefinitionId(Optional.ofNullable(execution.getProcessDefinitionId())); request.setProcessInstanceId(Optional.ofNullable(execution.getProcessInstanceId())); request.setActivityId(Optional.ofNullable(execution.getCurrentActivityId())); - request.setActivityName(Optional.ofNullable(execution.getCurrentActivityName())); + + name: { + if (execution.getBpmnModelElementInstance() != null) { + // TODO lambda does not work due to access modifier + if (execution.getBpmnModelElementInstance() instanceof EndEvent) { + getLogger().info("instance of EndEvent"); + EndEvent e = (EndEvent) execution.getBpmnModelElementInstance(); + + if (e.getEventDefinitions() == null || e.getEventDefinitions().isEmpty()) { + request.setActivityName(Optional.of("End")); + } + for (EventDefinition ed : e.getEventDefinitions()) { + if (ed instanceof TerminateEventDefinition) { + request.setActivityName(Optional.of("End")); + } else if (ed instanceof ErrorEventDefinition) { + request.setActivityName(Optional.of("Error End")); + } else if (ed instanceof CompensateEventDefinition) { + request.setActivityName(Optional.of("Compensation End")); + } else { + request.setActivityName(Optional.of("End")); + } + } + break name; + } else if (execution.getBpmnModelElementInstance() instanceof Gateway) { + // TODO + } + } + request.setActivityName(Optional.ofNullable(execution.getCurrentActivityName())); + } Context parentContext = getOpentelemetry() @@ -79,12 +116,18 @@ public static void addTracingEnter( if (getInstumenter().shouldStart(Java8BytecodeBridge.currentContext(), request)) { context = getInstumenter().start(Java8BytecodeBridge.currentContext(), request); scope = context.makeCurrent(); + + if (target.getClass() == org.camunda.bpm.engine.impl.bpmn.behavior.ExternalTaskActivityBehavior.class) { + + getOpentelemetry().getPropagators().getTextMapPropagator().inject(context, execution, + new CamundaActivityExecutionLocalSetter()); + } } } @Advice.OnMethodExit(onThrowable = Throwable.class, suppress = Throwable.class) public static void closeTrace( - @Advice.Local("request") CamundaCommonRequest request, + @Advice.Local("request") CamundaCommonRequest request, @Advice.This Object target, @Advice.Local("otelParentScope") Scope parentScope, @Advice.Local("otelContext") Context context, @Advice.Local("otelScope") Scope scope, diff --git a/instrumentation/camunda/camunda-7.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_0/behavior/CamundaTaskActivityBehaviorModule.java b/instrumentation/camunda/camunda-7.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_0/behavior/CamundaCommonBehaviorModule.java similarity index 76% rename from instrumentation/camunda/camunda-7.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_0/behavior/CamundaTaskActivityBehaviorModule.java rename to instrumentation/camunda/camunda-7.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_0/behavior/CamundaCommonBehaviorModule.java index d4ec844f7921..990f5eff5a15 100644 --- a/instrumentation/camunda/camunda-7.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_0/behavior/CamundaTaskActivityBehaviorModule.java +++ b/instrumentation/camunda/camunda-7.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_0/behavior/CamundaCommonBehaviorModule.java @@ -16,7 +16,7 @@ import net.bytebuddy.matcher.ElementMatcher; @AutoService(InstrumentationModule.class) -public class CamundaTaskActivityBehaviorModule extends InstrumentationModule { +public class CamundaCommonBehaviorModule extends InstrumentationModule { public CamundaTaskActivityBehaviorModule() { super("camunda", "camunda-behavior", "camunda-behavior-7_18"); @@ -24,12 +24,14 @@ public CamundaTaskActivityBehaviorModule() { @Override public List typeInstrumentations() { - return Collections.singletonList(new CamundaTaskActivityBehaviorInstrumentation()); + return Collections.singletonList(new CamundaCommonBehaviorInstrumentation()); } @Override public ElementMatcher.Junction classLoaderMatcher() { - return hasClassesNamed("org.camunda.bpm.engine.impl.bpmn.behavior.TaskActivityBehavior"); + return hasClassesNamed("org.camunda.bpm.engine.impl.bpmn.behavior.TaskActivityBehavior", + "org.camunda.bpm.engine.impl.bpmn.behavior.NoneEndEventActivityBehavior", + "org.camunda.bpm.engine.impl.bpmn.behavior.ErrorEndEventActivityBehavior"); } String[] helperClassnames = { diff --git a/instrumentation/camunda/camunda-7.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_0/behavior/CamundaEndEventActivityBehaviorInstrumentation.java b/instrumentation/camunda/camunda-7.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_0/behavior/CamundaEndEventActivityBehaviorInstrumentation.java deleted file mode 100644 index ace0cee4157c..000000000000 --- a/instrumentation/camunda/camunda-7.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_0/behavior/CamundaEndEventActivityBehaviorInstrumentation.java +++ /dev/null @@ -1,132 +0,0 @@ -/* - * Copyright The OpenTelemetry Authors - * SPDX-License-Identifier: Apache-2.0 - */ - -package io.opentelemetry.javaagent.instrumentation.camunda.v7_0.behavior; - -import static io.opentelemetry.javaagent.extension.matcher.AgentElementMatchers.hasClassesNamed; -import static io.opentelemetry.javaagent.instrumentation.camunda.v7_0.behavior.CamundaBehaviorSingletons.getInstumenter; -import static io.opentelemetry.javaagent.instrumentation.camunda.v7_0.behavior.CamundaBehaviorSingletons.getOpentelemetry; -import static net.bytebuddy.matcher.ElementMatchers.named; - -import io.opentelemetry.context.Context; -import io.opentelemetry.context.Scope; -import io.opentelemetry.instrumentation.camunda.v7_0.behavior.CamundaActivityExecutionGetter; -import io.opentelemetry.instrumentation.camunda.v7_0.common.CamundaCommonRequest; -import io.opentelemetry.javaagent.bootstrap.Java8BytecodeBridge; -import io.opentelemetry.javaagent.extension.instrumentation.TypeInstrumentation; -import io.opentelemetry.javaagent.extension.instrumentation.TypeTransformer; -import java.util.Optional; -import net.bytebuddy.asm.Advice; -import net.bytebuddy.description.type.TypeDescription; -import net.bytebuddy.matcher.ElementMatcher; -import net.bytebuddy.matcher.ElementMatchers; -import org.camunda.bpm.engine.impl.pvm.delegate.ActivityExecution; -import org.camunda.bpm.model.bpmn.instance.CompensateEventDefinition; -import org.camunda.bpm.model.bpmn.instance.EndEvent; -import org.camunda.bpm.model.bpmn.instance.ErrorEventDefinition; -import org.camunda.bpm.model.bpmn.instance.EventDefinition; -import org.camunda.bpm.model.bpmn.instance.TerminateEventDefinition; - -public class CamundaEndEventActivityBehaviorInstrumentation implements TypeInstrumentation { - - @Override - public ElementMatcher classLoaderOptimization() { - return hasClassesNamed( - "org.camunda.bpm.engine.impl.bpmn.behavior.TerminateEndEventActivityBehavior"); - } - - @Override - public ElementMatcher typeMatcher() { - return named("org.camunda.bpm.engine.impl.bpmn.behavior.TerminateEndEventActivityBehavior") - .or( - named("org.camunda.bpm.engine.impl.bpmn.behavior.NoneEndEventActivityBehavior") - .or( - named( - "org.camunda.bpm.engine.impl.bpmn.behavior.ErrorEndEventActivityBehavior"))); - } - - @Override - public void transform(TypeTransformer transformer) { - transformer.applyAdviceToMethod( - ElementMatchers.isMethod().and(ElementMatchers.named("execute")), - this.getClass().getName() + "$CamundaEndEventActivityBehaviorAdvice"); - } - - @SuppressWarnings("unused") - public static class CamundaEndEventActivityBehaviorAdvice { - - @Advice.OnMethodEnter(suppress = Throwable.class) - public static void addTracingEnter( - @Advice.Argument(0) ActivityExecution execution, - @Advice.Local("request") CamundaCommonRequest request, - @Advice.Local("otelParentScope") Scope parentScope, - @Advice.Local("otelContext") Context context, - @Advice.Local("otelScope") Scope scope) { - - if (execution == null) { - return; - } - - request = new CamundaCommonRequest(); - request.setProcessDefinitionId(Optional.ofNullable(execution.getProcessDefinitionId())); - request.setProcessInstanceId(Optional.ofNullable(execution.getProcessInstanceId())); - request.setActivityId(Optional.ofNullable(execution.getCurrentActivityId())); - - if (execution.getBpmnModelElementInstance() != null) { - // TODO lambda does not work due to access modifier - - // TODO add other events execution.getBpmnModelElementInstance() instanceof - // EndEvent - EndEvent e = (EndEvent) execution.getBpmnModelElementInstance(); - - for (EventDefinition ed : e.getEventDefinitions()) { - if (ed instanceof TerminateEventDefinition) { - request.setActivityName(Optional.of("End")); - } else if (ed instanceof ErrorEventDefinition) { - request.setActivityName(Optional.of("Error End")); - } else if (ed instanceof CompensateEventDefinition) { - request.setActivityName(Optional.of("Compensation End")); - } else { - request.setActivityName(Optional.of("End")); - } - } - } - - Context parentContext = - getOpentelemetry() - .getPropagators() - .getTextMapPropagator() - .extract( - Java8BytecodeBridge.currentContext(), - execution, - new CamundaActivityExecutionGetter()); - - parentScope = parentContext.makeCurrent(); - - if (getInstumenter().shouldStart(Java8BytecodeBridge.currentContext(), request)) { - context = getInstumenter().start(Java8BytecodeBridge.currentContext(), request); - scope = context.makeCurrent(); - } - } - - @Advice.OnMethodExit(onThrowable = Throwable.class, suppress = Throwable.class) - public static void closeSpan( - @Advice.Local("request") CamundaCommonRequest request, - @Advice.Local("otelParentScope") Scope parentScope, - @Advice.Local("otelContext") Context context, - @Advice.Local("otelScope") Scope scope, - @Advice.Thrown Throwable throwable) { - - if (context != null && scope != null) { - getInstumenter().end(context, request, "NA", throwable); - scope.close(); - } - - if (parentScope != null) { - parentScope.close(); - } - } - } -} diff --git a/instrumentation/camunda/camunda-7.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_0/behavior/CamundaEndEventActivityBehaviorModule.java b/instrumentation/camunda/camunda-7.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_0/behavior/CamundaEndEventActivityBehaviorModule.java deleted file mode 100644 index 0d75b6fee130..000000000000 --- a/instrumentation/camunda/camunda-7.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_0/behavior/CamundaEndEventActivityBehaviorModule.java +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Copyright The OpenTelemetry Authors - * SPDX-License-Identifier: Apache-2.0 - */ - -package io.opentelemetry.javaagent.instrumentation.camunda.v7_0.behavior; - -import static io.opentelemetry.javaagent.extension.matcher.AgentElementMatchers.hasClassesNamed; - -import com.google.auto.service.AutoService; -import io.opentelemetry.javaagent.extension.instrumentation.InstrumentationModule; -import io.opentelemetry.javaagent.extension.instrumentation.TypeInstrumentation; -import io.opentelemetry.sdk.autoconfigure.spi.ConfigProperties; -import java.util.Arrays; -import java.util.Collections; -import java.util.List; -import net.bytebuddy.matcher.ElementMatcher; - -@AutoService(InstrumentationModule.class) -public class CamundaEndEventActivityBehaviorModule extends InstrumentationModule { - - public CamundaEndEventActivityBehaviorModule() { - super("camunda", "camunda-behavior", "camunda-behavior-7_18"); - } - - @Override - public boolean defaultEnabled(ConfigProperties config) { - return config.getBoolean("otel.instrumentation.common.default-enabled", true); - } - - @Override - public List typeInstrumentations() { - return Collections.singletonList(new CamundaEndEventActivityBehaviorInstrumentation()); - } - - @Override - public ElementMatcher.Junction classLoaderMatcher() { - return hasClassesNamed( - "org.camunda.bpm.engine.impl.bpmn.behavior.TerminateEndEventActivityBehavior", - "org.camunda.bpm.engine.impl.bpmn.behavior.NoneEndEventActivityBehavior", - "org.camunda.bpm.engine.impl.bpmn.behavior.ErrorEndEventActivityBehavior"); - } - - String[] helperClassnames = { - "io.opentelemetry.javaagent.instrumentation.camunda.v7_0.behavior", - "io.opentelemetry.instrumentation.camunda.v7_0.behavior", - "io.opentelemetry.instrumentation.camunda.v7_0.common" - }; - - @Override - public boolean isHelperClass(String classname) { - return super.isHelperClass(classname) - || Arrays.stream(helperClassnames).anyMatch(c -> classname.startsWith(c)); - } -} diff --git a/instrumentation/camunda/camunda-7.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_0/behavior/CamundaExternalTaskActivityBehaviorInstrumentation.java b/instrumentation/camunda/camunda-7.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_0/behavior/CamundaExternalTaskActivityBehaviorInstrumentation.java deleted file mode 100644 index 43c66652fa30..000000000000 --- a/instrumentation/camunda/camunda-7.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_0/behavior/CamundaExternalTaskActivityBehaviorInstrumentation.java +++ /dev/null @@ -1,115 +0,0 @@ -/* - * Copyright The OpenTelemetry Authors - * SPDX-License-Identifier: Apache-2.0 - */ - -package io.opentelemetry.javaagent.instrumentation.camunda.v7_0.behavior; - -import static io.opentelemetry.javaagent.extension.matcher.AgentElementMatchers.hasClassesNamed; -import static io.opentelemetry.javaagent.instrumentation.camunda.v7_0.behavior.CamundaBehaviorSingletons.getInstumenter; -import static io.opentelemetry.javaagent.instrumentation.camunda.v7_0.behavior.CamundaBehaviorSingletons.getOpentelemetry; -import static net.bytebuddy.matcher.ElementMatchers.named; - -import io.opentelemetry.context.Context; -import io.opentelemetry.context.Scope; -import io.opentelemetry.instrumentation.camunda.v7_0.behavior.CamundaActivityExecutionGetter; -import io.opentelemetry.instrumentation.camunda.v7_0.behavior.CamundaActivityExecutionLocalSetter; -import io.opentelemetry.instrumentation.camunda.v7_0.common.CamundaCommonRequest; -import io.opentelemetry.javaagent.bootstrap.Java8BytecodeBridge; -import io.opentelemetry.javaagent.extension.instrumentation.TypeInstrumentation; -import io.opentelemetry.javaagent.extension.instrumentation.TypeTransformer; -import java.util.Optional; -import net.bytebuddy.asm.Advice; -import net.bytebuddy.description.type.TypeDescription; -import net.bytebuddy.matcher.ElementMatcher; -import net.bytebuddy.matcher.ElementMatchers; -import org.camunda.bpm.engine.impl.pvm.delegate.ActivityExecution; - -public class CamundaExternalTaskActivityBehaviorInstrumentation implements TypeInstrumentation { - - @Override - public ElementMatcher classLoaderOptimization() { - return hasClassesNamed( - "org.camunda.bpm.engine.impl.bpmn.behavior.ExternalTaskActivityBehavior"); - } - - @Override - public ElementMatcher typeMatcher() { - return named("org.camunda.bpm.engine.impl.bpmn.behavior.ExternalTaskActivityBehavior"); - } - - @Override - public void transform(TypeTransformer transformer) { - transformer.applyAdviceToMethod( - ElementMatchers.isMethod().and(ElementMatchers.named("execute")), - this.getClass().getName() + "$CamundaExternalTaskActivityBehaviorAdvice"); - } - - @SuppressWarnings("unused") - public static class CamundaExternalTaskActivityBehaviorAdvice { - - /** - * Sets parent context to process instance. Creates new context and span. propagates current - * context to variable set for topic to retrieve. - */ - @Advice.OnMethodEnter(suppress = Throwable.class) - public static void addTracingEnter( - @Advice.Argument(0) ActivityExecution execution, - @Advice.Local("request") CamundaCommonRequest request, - @Advice.Local("otelParentScope") Scope parentScope, - @Advice.Local("otelParentContext") Context parentContext, - @Advice.Local("otelContext") Context context, - @Advice.Local("otelScope") Scope scope) { - - if (execution == null) { - return; - } - - request = new CamundaCommonRequest(); - request.setProcessDefinitionId(Optional.ofNullable(execution.getProcessDefinitionId())); - request.setProcessInstanceId(Optional.ofNullable(execution.getProcessInstanceId())); - request.setActivityId(Optional.ofNullable(execution.getCurrentActivityId())); - request.setActivityName(Optional.ofNullable(execution.getCurrentActivityName())); - - parentContext = - getOpentelemetry() - .getPropagators() - .getTextMapPropagator() - .extract( - Java8BytecodeBridge.currentContext(), - execution, - new CamundaActivityExecutionGetter()); - - parentScope = parentContext.makeCurrent(); - - if (getInstumenter().shouldStart(Java8BytecodeBridge.currentContext(), request)) { - context = getInstumenter().start(Java8BytecodeBridge.currentContext(), request); - scope = context.makeCurrent(); - - getOpentelemetry() - .getPropagators() - .getTextMapPropagator() - .inject(context, execution, new CamundaActivityExecutionLocalSetter()); - } - } - - @Advice.OnMethodExit(onThrowable = Throwable.class, suppress = Throwable.class) - public static void closeTrace( - @Advice.Local("request") CamundaCommonRequest request, - @Advice.Local("otelParentScope") Scope parentScope, - @Advice.Local("otelParentContext") Context parentContext, - @Advice.Local("otelContext") Context context, - @Advice.Local("otelScope") Scope scope, - @Advice.Thrown Throwable throwable) { - - if (context != null && scope != null) { - getInstumenter().end(context, request, "NA", throwable); - scope.close(); - } - - if (parentScope != null) { - parentScope.close(); - } - } - } -} diff --git a/instrumentation/camunda/camunda-7.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_0/behavior/CamundaExternalTaskActivityBehaviorModule.java b/instrumentation/camunda/camunda-7.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_0/behavior/CamundaExternalTaskActivityBehaviorModule.java deleted file mode 100644 index a7022fb241f1..000000000000 --- a/instrumentation/camunda/camunda-7.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_0/behavior/CamundaExternalTaskActivityBehaviorModule.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Copyright The OpenTelemetry Authors - * SPDX-License-Identifier: Apache-2.0 - */ - -package io.opentelemetry.javaagent.instrumentation.camunda.v7_0.behavior; - -import static io.opentelemetry.javaagent.extension.matcher.AgentElementMatchers.hasClassesNamed; - -import com.google.auto.service.AutoService; -import io.opentelemetry.javaagent.extension.instrumentation.InstrumentationModule; -import io.opentelemetry.javaagent.extension.instrumentation.TypeInstrumentation; -import io.opentelemetry.sdk.autoconfigure.spi.ConfigProperties; -import java.util.Arrays; -import java.util.Collections; -import java.util.List; -import net.bytebuddy.matcher.ElementMatcher; - -@AutoService(InstrumentationModule.class) -public class CamundaExternalTaskActivityBehaviorModule extends InstrumentationModule { - - public CamundaExternalTaskActivityBehaviorModule() { - super("camunda", "camunda-behavior", "camunda-behavior-7_18"); - } - - @Override - public boolean defaultEnabled(ConfigProperties config) { - return config.getBoolean("otel.instrumentation.common.default-enabled", true); - } - - @Override - public List typeInstrumentations() { - return Collections.singletonList(new CamundaExternalTaskActivityBehaviorInstrumentation()); - } - - @Override - public ElementMatcher.Junction classLoaderMatcher() { - return hasClassesNamed( - "org.camunda.bpm.engine.impl.bpmn.behavior.ExternalTaskActivityBehavior"); - } - - String[] helperClassnames = { - "io.opentelemetry.javaagent.instrumentation.camunda.v7_0.behavior", - "io.opentelemetry.instrumentation.camunda.v7_0.behavior", - "io.opentelemetry.instrumentation.camunda.v7_0.common" - }; - - @Override - public boolean isHelperClass(String classname) { - return super.isHelperClass(classname) - || Arrays.stream(helperClassnames).anyMatch(c -> classname.startsWith(c)); - } -} From 7fcfa7d6c351c1ecb5adc56bcb1283e77d2c31dd Mon Sep 17 00:00:00 2001 From: "Boslet, Cory (cb645j)" Date: Mon, 16 Dec 2024 14:29:02 -0500 Subject: [PATCH 21/23] fix spotless java format --- .../CamundaCommonBehaviorInstrumentation.java | 103 ++++++++++-------- .../behavior/CamundaCommonBehaviorModule.java | 7 +- 2 files changed, 61 insertions(+), 49 deletions(-) diff --git a/instrumentation/camunda/camunda-7.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_0/behavior/CamundaCommonBehaviorInstrumentation.java b/instrumentation/camunda/camunda-7.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_0/behavior/CamundaCommonBehaviorInstrumentation.java index d349ef4132bc..fd6967531ed5 100644 --- a/instrumentation/camunda/camunda-7.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_0/behavior/CamundaCommonBehaviorInstrumentation.java +++ b/instrumentation/camunda/camunda-7.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_0/behavior/CamundaCommonBehaviorInstrumentation.java @@ -14,6 +14,7 @@ import io.opentelemetry.context.Context; import io.opentelemetry.context.Scope; import io.opentelemetry.instrumentation.camunda.v7_0.behavior.CamundaActivityExecutionGetter; +import io.opentelemetry.instrumentation.camunda.v7_0.behavior.CamundaActivityExecutionLocalSetter; import io.opentelemetry.instrumentation.camunda.v7_0.common.CamundaCommonRequest; import io.opentelemetry.javaagent.bootstrap.Java8BytecodeBridge; import io.opentelemetry.javaagent.extension.instrumentation.TypeInstrumentation; @@ -24,6 +25,12 @@ import net.bytebuddy.matcher.ElementMatcher; import net.bytebuddy.matcher.ElementMatchers; import org.camunda.bpm.engine.impl.pvm.delegate.ActivityExecution; +import org.camunda.bpm.model.bpmn.instance.CompensateEventDefinition; +import org.camunda.bpm.model.bpmn.instance.EndEvent; +import org.camunda.bpm.model.bpmn.instance.ErrorEventDefinition; +import org.camunda.bpm.model.bpmn.instance.EventDefinition; +import org.camunda.bpm.model.bpmn.instance.Gateway; +import org.camunda.bpm.model.bpmn.instance.TerminateEventDefinition; public class CamundaCommonBehaviorInstrumentation implements TypeInstrumentation { @@ -32,19 +39,19 @@ public ElementMatcher classLoaderOptimization() { return hasClassesNamed("org.camunda.bpm.engine.impl.bpmn.behavior.TaskActivityBehavior"); } - @Override - public ElementMatcher typeMatcher() { - return hasSuperType(named("org.camunda.bpm.engine.impl.bpmn.behavior.TaskActivityBehavior")) - .or(named("org.camunda.bpm.engine.impl.bpmn.behavior.ExternalTaskActivityBehavior")) - .or(named("org.camunda.bpm.engine.impl.bpmn.behavior.TerminateEndEventActivityBehavior")) - .or(named("org.camunda.bpm.engine.impl.bpmn.behavior.NoneEndEventActivityBehavior")) - .or(named("org.camunda.bpm.engine.impl.bpmn.behavior.ErrorEndEventActivityBehavior")); - // elements that have been tested with instrumentation, eventually this can be - // replaced by the supertype AbstractBpmnActivityBehavior, once all elements - // instrumentations have been certified and instrumented, but will need to make - // sure its not callable element as the instrumentation should remain separate - // due to logic - } + @Override + public ElementMatcher typeMatcher() { + return hasSuperType(named("org.camunda.bpm.engine.impl.bpmn.behavior.TaskActivityBehavior")) + .or(named("org.camunda.bpm.engine.impl.bpmn.behavior.ExternalTaskActivityBehavior")) + .or(named("org.camunda.bpm.engine.impl.bpmn.behavior.TerminateEndEventActivityBehavior")) + .or(named("org.camunda.bpm.engine.impl.bpmn.behavior.NoneEndEventActivityBehavior")) + .or(named("org.camunda.bpm.engine.impl.bpmn.behavior.ErrorEndEventActivityBehavior")); + // elements that have been tested with instrumentation, eventually this can be + // replaced by the supertype AbstractBpmnActivityBehavior, once all elements + // instrumentations have been certified and instrumented, but will need to make + // sure its not callable element as the instrumentation should remain separate + // due to logic + } @Override public void transform(TypeTransformer transformer) { @@ -73,34 +80,34 @@ public static void addTracingEnter( request.setProcessInstanceId(Optional.ofNullable(execution.getProcessInstanceId())); request.setActivityId(Optional.ofNullable(execution.getCurrentActivityId())); - name: { - if (execution.getBpmnModelElementInstance() != null) { - // TODO lambda does not work due to access modifier - if (execution.getBpmnModelElementInstance() instanceof EndEvent) { - getLogger().info("instance of EndEvent"); - EndEvent e = (EndEvent) execution.getBpmnModelElementInstance(); - - if (e.getEventDefinitions() == null || e.getEventDefinitions().isEmpty()) { - request.setActivityName(Optional.of("End")); - } - for (EventDefinition ed : e.getEventDefinitions()) { - if (ed instanceof TerminateEventDefinition) { - request.setActivityName(Optional.of("End")); - } else if (ed instanceof ErrorEventDefinition) { - request.setActivityName(Optional.of("Error End")); - } else if (ed instanceof CompensateEventDefinition) { - request.setActivityName(Optional.of("Compensation End")); - } else { - request.setActivityName(Optional.of("End")); - } - } - break name; - } else if (execution.getBpmnModelElementInstance() instanceof Gateway) { - // TODO - } - } - request.setActivityName(Optional.ofNullable(execution.getCurrentActivityName())); - } + name: + { + if (execution.getBpmnModelElementInstance() != null) { + // TODO lambda does not work due to access modifier + if (execution.getBpmnModelElementInstance() instanceof EndEvent) { + EndEvent e = (EndEvent) execution.getBpmnModelElementInstance(); + + if (e.getEventDefinitions() == null || e.getEventDefinitions().isEmpty()) { + request.setActivityName(Optional.of("End")); + } + for (EventDefinition ed : e.getEventDefinitions()) { + if (ed instanceof TerminateEventDefinition) { + request.setActivityName(Optional.of("End")); + } else if (ed instanceof ErrorEventDefinition) { + request.setActivityName(Optional.of("Error End")); + } else if (ed instanceof CompensateEventDefinition) { + request.setActivityName(Optional.of("Compensation End")); + } else { + request.setActivityName(Optional.of("End")); + } + } + break name; + } else if (execution.getBpmnModelElementInstance() instanceof Gateway) { + // TODO + } + } + request.setActivityName(Optional.ofNullable(execution.getCurrentActivityName())); + } Context parentContext = getOpentelemetry() @@ -117,17 +124,21 @@ public static void addTracingEnter( context = getInstumenter().start(Java8BytecodeBridge.currentContext(), request); scope = context.makeCurrent(); - if (target.getClass() == org.camunda.bpm.engine.impl.bpmn.behavior.ExternalTaskActivityBehavior.class) { + if (target.getClass() + == org.camunda.bpm.engine.impl.bpmn.behavior.ExternalTaskActivityBehavior.class) { - getOpentelemetry().getPropagators().getTextMapPropagator().inject(context, execution, - new CamundaActivityExecutionLocalSetter()); - } + getOpentelemetry() + .getPropagators() + .getTextMapPropagator() + .inject(context, execution, new CamundaActivityExecutionLocalSetter()); + } } } @Advice.OnMethodExit(onThrowable = Throwable.class, suppress = Throwable.class) public static void closeTrace( - @Advice.Local("request") CamundaCommonRequest request, @Advice.This Object target, + @Advice.Local("request") CamundaCommonRequest request, + @Advice.This Object target, @Advice.Local("otelParentScope") Scope parentScope, @Advice.Local("otelContext") Context context, @Advice.Local("otelScope") Scope scope, diff --git a/instrumentation/camunda/camunda-7.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_0/behavior/CamundaCommonBehaviorModule.java b/instrumentation/camunda/camunda-7.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_0/behavior/CamundaCommonBehaviorModule.java index 990f5eff5a15..0ceca27f850b 100644 --- a/instrumentation/camunda/camunda-7.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_0/behavior/CamundaCommonBehaviorModule.java +++ b/instrumentation/camunda/camunda-7.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_0/behavior/CamundaCommonBehaviorModule.java @@ -29,9 +29,10 @@ public List typeInstrumentations() { @Override public ElementMatcher.Junction classLoaderMatcher() { - return hasClassesNamed("org.camunda.bpm.engine.impl.bpmn.behavior.TaskActivityBehavior", - "org.camunda.bpm.engine.impl.bpmn.behavior.NoneEndEventActivityBehavior", - "org.camunda.bpm.engine.impl.bpmn.behavior.ErrorEndEventActivityBehavior"); + return hasClassesNamed( + "org.camunda.bpm.engine.impl.bpmn.behavior.TaskActivityBehavior", + "org.camunda.bpm.engine.impl.bpmn.behavior.NoneEndEventActivityBehavior", + "org.camunda.bpm.engine.impl.bpmn.behavior.ErrorEndEventActivityBehavior"); } String[] helperClassnames = { From da9e8512655d9b9f64178c8fe825942bfe46a1fb Mon Sep 17 00:00:00 2001 From: "Boslet, Cory (cb645j)" Date: Mon, 16 Dec 2024 14:40:52 -0500 Subject: [PATCH 22/23] Fix typos and compilation errors --- ...daCallableElementActivityBehaviorInstrumentation.java | 1 + .../behavior/CamundaCommonBehaviorInstrumentation.java | 2 ++ .../v7_0/behavior/CamundaCommonBehaviorModule.java | 2 +- .../camunda/v7_0/common/CamundaCommonRequest.java | 9 +++++++++ 4 files changed, 13 insertions(+), 1 deletion(-) diff --git a/instrumentation/camunda/camunda-7.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_0/behavior/CamundaCallableElementActivityBehaviorInstrumentation.java b/instrumentation/camunda/camunda-7.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_0/behavior/CamundaCallableElementActivityBehaviorInstrumentation.java index 9b52cdd6a56f..7756fafd796f 100644 --- a/instrumentation/camunda/camunda-7.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_0/behavior/CamundaCallableElementActivityBehaviorInstrumentation.java +++ b/instrumentation/camunda/camunda-7.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_0/behavior/CamundaCallableElementActivityBehaviorInstrumentation.java @@ -71,6 +71,7 @@ public static void addTracingEnter( request.setProcessInstanceId(Optional.ofNullable(execution.getProcessInstanceId())); request.setActivityId(Optional.ofNullable(execution.getCurrentActivityId())); request.setActivityName(Optional.ofNullable(execution.getCurrentActivityName())); + request.setBusinessKey(Optional.ofNullable(execution.getProcessBusinessKey())); if (Java8BytecodeBridge.currentContext() == Java8BytecodeBridge.rootContext()) { // log diff --git a/instrumentation/camunda/camunda-7.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_0/behavior/CamundaCommonBehaviorInstrumentation.java b/instrumentation/camunda/camunda-7.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_0/behavior/CamundaCommonBehaviorInstrumentation.java index fd6967531ed5..1027dea97d3c 100644 --- a/instrumentation/camunda/camunda-7.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_0/behavior/CamundaCommonBehaviorInstrumentation.java +++ b/instrumentation/camunda/camunda-7.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_0/behavior/CamundaCommonBehaviorInstrumentation.java @@ -66,6 +66,7 @@ public static class CamundaCommonBehaviorAdvice { @Advice.OnMethodEnter(suppress = Throwable.class) public static void addTracingEnter( @Advice.Argument(0) ActivityExecution execution, + @Advice.This Object target, @Advice.Local("request") CamundaCommonRequest request, @Advice.Local("otelParentScope") Scope parentScope, @Advice.Local("otelContext") Context context, @@ -79,6 +80,7 @@ public static void addTracingEnter( request.setProcessDefinitionId(Optional.ofNullable(execution.getProcessDefinitionId())); request.setProcessInstanceId(Optional.ofNullable(execution.getProcessInstanceId())); request.setActivityId(Optional.ofNullable(execution.getCurrentActivityId())); + request.setBusinessKey(Optional.ofNullable(execution.getProcessBusinessKey())); name: { diff --git a/instrumentation/camunda/camunda-7.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_0/behavior/CamundaCommonBehaviorModule.java b/instrumentation/camunda/camunda-7.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_0/behavior/CamundaCommonBehaviorModule.java index 0ceca27f850b..aaed45e34f60 100644 --- a/instrumentation/camunda/camunda-7.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_0/behavior/CamundaCommonBehaviorModule.java +++ b/instrumentation/camunda/camunda-7.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_0/behavior/CamundaCommonBehaviorModule.java @@ -18,7 +18,7 @@ @AutoService(InstrumentationModule.class) public class CamundaCommonBehaviorModule extends InstrumentationModule { - public CamundaTaskActivityBehaviorModule() { + public CamundaCommonBehaviorModule() { super("camunda", "camunda-behavior", "camunda-behavior-7_18"); } diff --git a/instrumentation/camunda/camunda-7.0/library/src/main/java/io/opentelemetry/instrumentation/camunda/v7_0/common/CamundaCommonRequest.java b/instrumentation/camunda/camunda-7.0/library/src/main/java/io/opentelemetry/instrumentation/camunda/v7_0/common/CamundaCommonRequest.java index 42b345f46e8b..e5265dd672fc 100644 --- a/instrumentation/camunda/camunda-7.0/library/src/main/java/io/opentelemetry/instrumentation/camunda/v7_0/common/CamundaCommonRequest.java +++ b/instrumentation/camunda/camunda-7.0/library/src/main/java/io/opentelemetry/instrumentation/camunda/v7_0/common/CamundaCommonRequest.java @@ -12,6 +12,7 @@ public class CamundaCommonRequest { private Optional processDefinitionId = Optional.empty(); private Optional processDefinitionKey = Optional.empty(); private Optional processInstanceId = Optional.empty(); + private Optional businessKey = Optional.empty(); private Optional activityId = Optional.empty(); private Optional activityName = Optional.empty(); private Optional topicName = Optional.empty(); @@ -41,6 +42,14 @@ public void setProcessInstanceId(Optional processInstanceId) { this.processInstanceId = processInstanceId; } + public Optional getBusinessKey() { + return businessKey; + } + + public void setBusinessKey(Optional businessKey) { + this.businessKey = businessKey; + } + public Optional getActivityId() { return activityId; } From 4355c63d4d8efadd1a60b858b321b86042a61a63 Mon Sep 17 00:00:00 2001 From: "Boslet, Cory (cb645j)" Date: Mon, 16 Dec 2024 14:50:05 -0500 Subject: [PATCH 23/23] remove the label from method --- .../CamundaCommonBehaviorInstrumentation.java | 43 +++++++++---------- 1 file changed, 21 insertions(+), 22 deletions(-) diff --git a/instrumentation/camunda/camunda-7.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_0/behavior/CamundaCommonBehaviorInstrumentation.java b/instrumentation/camunda/camunda-7.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_0/behavior/CamundaCommonBehaviorInstrumentation.java index 1027dea97d3c..39eabce31583 100644 --- a/instrumentation/camunda/camunda-7.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_0/behavior/CamundaCommonBehaviorInstrumentation.java +++ b/instrumentation/camunda/camunda-7.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_0/behavior/CamundaCommonBehaviorInstrumentation.java @@ -82,32 +82,31 @@ public static void addTracingEnter( request.setActivityId(Optional.ofNullable(execution.getCurrentActivityId())); request.setBusinessKey(Optional.ofNullable(execution.getProcessBusinessKey())); - name: - { - if (execution.getBpmnModelElementInstance() != null) { - // TODO lambda does not work due to access modifier - if (execution.getBpmnModelElementInstance() instanceof EndEvent) { - EndEvent e = (EndEvent) execution.getBpmnModelElementInstance(); - - if (e.getEventDefinitions() == null || e.getEventDefinitions().isEmpty()) { + if (execution.getBpmnModelElementInstance() != null) { + // TODO lambda does not work due to access modifier + if (execution.getBpmnModelElementInstance() instanceof EndEvent) { + EndEvent e = (EndEvent) execution.getBpmnModelElementInstance(); + + if (e.getEventDefinitions() == null || e.getEventDefinitions().isEmpty()) { + request.setActivityName(Optional.of("End")); + } + for (EventDefinition ed : e.getEventDefinitions()) { + if (ed instanceof TerminateEventDefinition) { + request.setActivityName(Optional.of("End")); + } else if (ed instanceof ErrorEventDefinition) { + request.setActivityName(Optional.of("Error End")); + } else if (ed instanceof CompensateEventDefinition) { + request.setActivityName(Optional.of("Compensation End")); + } else { request.setActivityName(Optional.of("End")); } - for (EventDefinition ed : e.getEventDefinitions()) { - if (ed instanceof TerminateEventDefinition) { - request.setActivityName(Optional.of("End")); - } else if (ed instanceof ErrorEventDefinition) { - request.setActivityName(Optional.of("Error End")); - } else if (ed instanceof CompensateEventDefinition) { - request.setActivityName(Optional.of("Compensation End")); - } else { - request.setActivityName(Optional.of("End")); - } - } - break name; - } else if (execution.getBpmnModelElementInstance() instanceof Gateway) { - // TODO } + } else if (execution.getBpmnModelElementInstance() instanceof Gateway) { + // TODO + } else { + request.setActivityName(Optional.ofNullable(execution.getCurrentActivityName())); } + } else { request.setActivityName(Optional.ofNullable(execution.getCurrentActivityName())); }