Skip to content

Commit 7fcfa7d

Browse files
committed
fix spotless java format
1 parent 38ff7f0 commit 7fcfa7d

File tree

2 files changed

+61
-49
lines changed

2 files changed

+61
-49
lines changed

instrumentation/camunda/camunda-7.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_0/behavior/CamundaCommonBehaviorInstrumentation.java

Lines changed: 57 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
import io.opentelemetry.context.Context;
1515
import io.opentelemetry.context.Scope;
1616
import io.opentelemetry.instrumentation.camunda.v7_0.behavior.CamundaActivityExecutionGetter;
17+
import io.opentelemetry.instrumentation.camunda.v7_0.behavior.CamundaActivityExecutionLocalSetter;
1718
import io.opentelemetry.instrumentation.camunda.v7_0.common.CamundaCommonRequest;
1819
import io.opentelemetry.javaagent.bootstrap.Java8BytecodeBridge;
1920
import io.opentelemetry.javaagent.extension.instrumentation.TypeInstrumentation;
@@ -24,6 +25,12 @@
2425
import net.bytebuddy.matcher.ElementMatcher;
2526
import net.bytebuddy.matcher.ElementMatchers;
2627
import org.camunda.bpm.engine.impl.pvm.delegate.ActivityExecution;
28+
import org.camunda.bpm.model.bpmn.instance.CompensateEventDefinition;
29+
import org.camunda.bpm.model.bpmn.instance.EndEvent;
30+
import org.camunda.bpm.model.bpmn.instance.ErrorEventDefinition;
31+
import org.camunda.bpm.model.bpmn.instance.EventDefinition;
32+
import org.camunda.bpm.model.bpmn.instance.Gateway;
33+
import org.camunda.bpm.model.bpmn.instance.TerminateEventDefinition;
2734

2835
public class CamundaCommonBehaviorInstrumentation implements TypeInstrumentation {
2936

@@ -32,19 +39,19 @@ public ElementMatcher<ClassLoader> classLoaderOptimization() {
3239
return hasClassesNamed("org.camunda.bpm.engine.impl.bpmn.behavior.TaskActivityBehavior");
3340
}
3441

35-
@Override
36-
public ElementMatcher<TypeDescription> typeMatcher() {
37-
return hasSuperType(named("org.camunda.bpm.engine.impl.bpmn.behavior.TaskActivityBehavior"))
38-
.or(named("org.camunda.bpm.engine.impl.bpmn.behavior.ExternalTaskActivityBehavior"))
39-
.or(named("org.camunda.bpm.engine.impl.bpmn.behavior.TerminateEndEventActivityBehavior"))
40-
.or(named("org.camunda.bpm.engine.impl.bpmn.behavior.NoneEndEventActivityBehavior"))
41-
.or(named("org.camunda.bpm.engine.impl.bpmn.behavior.ErrorEndEventActivityBehavior"));
42-
// elements that have been tested with instrumentation, eventually this can be
43-
// replaced by the supertype AbstractBpmnActivityBehavior, once all elements
44-
// instrumentations have been certified and instrumented, but will need to make
45-
// sure its not callable element as the instrumentation should remain separate
46-
// due to logic
47-
}
42+
@Override
43+
public ElementMatcher<TypeDescription> typeMatcher() {
44+
return hasSuperType(named("org.camunda.bpm.engine.impl.bpmn.behavior.TaskActivityBehavior"))
45+
.or(named("org.camunda.bpm.engine.impl.bpmn.behavior.ExternalTaskActivityBehavior"))
46+
.or(named("org.camunda.bpm.engine.impl.bpmn.behavior.TerminateEndEventActivityBehavior"))
47+
.or(named("org.camunda.bpm.engine.impl.bpmn.behavior.NoneEndEventActivityBehavior"))
48+
.or(named("org.camunda.bpm.engine.impl.bpmn.behavior.ErrorEndEventActivityBehavior"));
49+
// elements that have been tested with instrumentation, eventually this can be
50+
// replaced by the supertype AbstractBpmnActivityBehavior, once all elements
51+
// instrumentations have been certified and instrumented, but will need to make
52+
// sure its not callable element as the instrumentation should remain separate
53+
// due to logic
54+
}
4855

4956
@Override
5057
public void transform(TypeTransformer transformer) {
@@ -73,34 +80,34 @@ public static void addTracingEnter(
7380
request.setProcessInstanceId(Optional.ofNullable(execution.getProcessInstanceId()));
7481
request.setActivityId(Optional.ofNullable(execution.getCurrentActivityId()));
7582

76-
name: {
77-
if (execution.getBpmnModelElementInstance() != null) {
78-
// TODO lambda does not work due to access modifier
79-
if (execution.getBpmnModelElementInstance() instanceof EndEvent) {
80-
getLogger().info("instance of EndEvent");
81-
EndEvent e = (EndEvent) execution.getBpmnModelElementInstance();
82-
83-
if (e.getEventDefinitions() == null || e.getEventDefinitions().isEmpty()) {
84-
request.setActivityName(Optional.of("End"));
85-
}
86-
for (EventDefinition ed : e.getEventDefinitions()) {
87-
if (ed instanceof TerminateEventDefinition) {
88-
request.setActivityName(Optional.of("End"));
89-
} else if (ed instanceof ErrorEventDefinition) {
90-
request.setActivityName(Optional.of("Error End"));
91-
} else if (ed instanceof CompensateEventDefinition) {
92-
request.setActivityName(Optional.of("Compensation End"));
93-
} else {
94-
request.setActivityName(Optional.of("End"));
95-
}
96-
}
97-
break name;
98-
} else if (execution.getBpmnModelElementInstance() instanceof Gateway) {
99-
// TODO
100-
}
101-
}
102-
request.setActivityName(Optional.ofNullable(execution.getCurrentActivityName()));
103-
}
83+
name:
84+
{
85+
if (execution.getBpmnModelElementInstance() != null) {
86+
// TODO lambda does not work due to access modifier
87+
if (execution.getBpmnModelElementInstance() instanceof EndEvent) {
88+
EndEvent e = (EndEvent) execution.getBpmnModelElementInstance();
89+
90+
if (e.getEventDefinitions() == null || e.getEventDefinitions().isEmpty()) {
91+
request.setActivityName(Optional.of("End"));
92+
}
93+
for (EventDefinition ed : e.getEventDefinitions()) {
94+
if (ed instanceof TerminateEventDefinition) {
95+
request.setActivityName(Optional.of("End"));
96+
} else if (ed instanceof ErrorEventDefinition) {
97+
request.setActivityName(Optional.of("Error End"));
98+
} else if (ed instanceof CompensateEventDefinition) {
99+
request.setActivityName(Optional.of("Compensation End"));
100+
} else {
101+
request.setActivityName(Optional.of("End"));
102+
}
103+
}
104+
break name;
105+
} else if (execution.getBpmnModelElementInstance() instanceof Gateway) {
106+
// TODO
107+
}
108+
}
109+
request.setActivityName(Optional.ofNullable(execution.getCurrentActivityName()));
110+
}
104111

105112
Context parentContext =
106113
getOpentelemetry()
@@ -117,17 +124,21 @@ public static void addTracingEnter(
117124
context = getInstumenter().start(Java8BytecodeBridge.currentContext(), request);
118125
scope = context.makeCurrent();
119126

120-
if (target.getClass() == org.camunda.bpm.engine.impl.bpmn.behavior.ExternalTaskActivityBehavior.class) {
127+
if (target.getClass()
128+
== org.camunda.bpm.engine.impl.bpmn.behavior.ExternalTaskActivityBehavior.class) {
121129

122-
getOpentelemetry().getPropagators().getTextMapPropagator().inject(context, execution,
123-
new CamundaActivityExecutionLocalSetter());
124-
}
130+
getOpentelemetry()
131+
.getPropagators()
132+
.getTextMapPropagator()
133+
.inject(context, execution, new CamundaActivityExecutionLocalSetter());
134+
}
125135
}
126136
}
127137

128138
@Advice.OnMethodExit(onThrowable = Throwable.class, suppress = Throwable.class)
129139
public static void closeTrace(
130-
@Advice.Local("request") CamundaCommonRequest request, @Advice.This Object target,
140+
@Advice.Local("request") CamundaCommonRequest request,
141+
@Advice.This Object target,
131142
@Advice.Local("otelParentScope") Scope parentScope,
132143
@Advice.Local("otelContext") Context context,
133144
@Advice.Local("otelScope") Scope scope,

instrumentation/camunda/camunda-7.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camunda/v7_0/behavior/CamundaCommonBehaviorModule.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,10 @@ public List<TypeInstrumentation> typeInstrumentations() {
2929

3030
@Override
3131
public ElementMatcher.Junction<ClassLoader> classLoaderMatcher() {
32-
return hasClassesNamed("org.camunda.bpm.engine.impl.bpmn.behavior.TaskActivityBehavior",
33-
"org.camunda.bpm.engine.impl.bpmn.behavior.NoneEndEventActivityBehavior",
34-
"org.camunda.bpm.engine.impl.bpmn.behavior.ErrorEndEventActivityBehavior");
32+
return hasClassesNamed(
33+
"org.camunda.bpm.engine.impl.bpmn.behavior.TaskActivityBehavior",
34+
"org.camunda.bpm.engine.impl.bpmn.behavior.NoneEndEventActivityBehavior",
35+
"org.camunda.bpm.engine.impl.bpmn.behavior.ErrorEndEventActivityBehavior");
3536
}
3637

3738
String[] helperClassnames = {

0 commit comments

Comments
 (0)