Skip to content

Commit

Permalink
turn off spotbugs of a method
Browse files Browse the repository at this point in the history
  • Loading branch information
amarziali committed Jun 14, 2024
1 parent dcc575d commit f3e50b9
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import datadog.trace.agent.tooling.bytebuddy.matcher.NameMatchers;
import datadog.trace.bootstrap.InstrumentationContext;
import datadog.trace.bootstrap.instrumentation.api.AgentSpan;
import edu.umd.cs.findbugs.annotations.SuppressWarnings;
import java.util.HashMap;
import java.util.Map;
import net.bytebuddy.asm.Advice;
Expand All @@ -35,6 +36,7 @@ public void methodAdvice(MethodTransformer transformer) {
}

public static class JobStartAdvice {
@SuppressWarnings("UC_USELESS_OBJECT")
@Advice.OnMethodEnter(suppress = Throwable.class)
public static void after(@Advice.Argument(value = 0) ProcessContext processContext) {
final Workflow workflow = DDJobMate.getJobWorkflow(processContext);
Expand All @@ -47,9 +49,10 @@ public static void after(@Advice.Argument(value = 0) ProcessContext processConte
if (suffixIdx > 0) {
workflowName = workflowName.substring(0, suffixIdx);
}
HashMap<String, AgentSpan> map = new HashMap<>();
AgentSpan span = startSpan(TIBCO_PROCESS_OPERATION);
DECORATE.afterStart(span);
DECORATE.onProcessStart(span, workflowName);
Map<String, AgentSpan> map = new HashMap<>();
map.put(wId, span);
InstrumentationContext.get(ProcessContext.class, Map.class).put(processContext, map);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,9 @@ public static boolean before(
if (span == null) {
AgentSpan parent = map.getOrDefault(ddActivityInfo.parent, activeSpan());
span = startSpan(TIBCO_ACTIVITY_OPERATION, parent != null ? parent.context() : null);
map.put(ddActivityInfo.id, span);
DECORATE.afterStart(span);
DECORATE.onActivityStart(span, ddActivityInfo.name);
map.put(ddActivityInfo.id, span);
}
if (ddActivityInfo.trace) {
ddScope = activateSpan(span);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public Map<String, String> contextStore() {
@Override
public String[] helperClassNames() {
return new String[] {
packageName + ".TibcoDecorator",
packageName + ".TibcoDecorator", packageName + ".IgnoreHelper",
};
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,6 @@
import static net.bytebuddy.matcher.ElementMatchers.takesArgument;

import com.google.auto.service.AutoService;
import com.tibco.bx.core.behaviors.activity.BxEmptyBehavior;
import com.tibco.bx.core.behaviors.activity.BxFlowBehavior;
import com.tibco.bx.core.behaviors.activity.BxScopeBehavior;
import com.tibco.pvm.api.PmProcessInstance;
import com.tibco.pvm.api.PmTask;
import com.tibco.pvm.api.PmWorkUnit;
Expand Down Expand Up @@ -87,9 +84,7 @@ public static AgentScope activityBegin(
if (parentSpan == null) {
parentSpan = contextStore.get(pmTask.getProcess(pmContext));
}
if (self instanceof BxFlowBehavior
|| self instanceof BxScopeBehavior
|| self instanceof BxEmptyBehavior) {
if (IgnoreHelper.notTracing(self)) {
// record the parent but do not trace scope or flows
contextStore.put(pmTask, parentSpan);
return null;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package datadog.trace.instrumentation.tibcobw6;

import com.tibco.bx.core.behaviors.activity.BxEmptyBehavior;
import com.tibco.bx.core.behaviors.activity.BxFlowBehavior;
import com.tibco.bx.core.behaviors.activity.BxPickBehavior;
import com.tibco.bx.core.behaviors.activity.BxScopeBehavior;
import java.util.HashSet;
import java.util.Set;
import javax.annotation.Nonnull;

public class IgnoreHelper {
private static final Set<Class<?>> IGNORED_TRACE_CLASSES = init();

private static Set<Class<?>> init() {
HashSet<Class<?>> ret = new HashSet<>();
ret.add(BxFlowBehavior.class);
ret.add(BxScopeBehavior.class);
ret.add(BxEmptyBehavior.class);
ret.add(BxPickBehavior.class);
return ret;
}

public static boolean notTracing(@Nonnull final Object o) {
return IGNORED_TRACE_CLASSES.contains(o.getClass());
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
package com.tibco.bx.core.behaviors.activity;

public class BxPickBehavior {}

0 comments on commit f3e50b9

Please sign in to comment.