From 7fcfa7d6c351c1ecb5adc56bcb1283e77d2c31dd Mon Sep 17 00:00:00 2001 From: "Boslet, Cory (cb645j)" Date: Mon, 16 Dec 2024 14:29:02 -0500 Subject: [PATCH] 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 = {