Skip to content
This repository has been archived by the owner on Jun 11, 2024. It is now read-only.

Commit

Permalink
Updated to agent 1.17.0
Browse files Browse the repository at this point in the history
  • Loading branch information
user1 committed Jul 13, 2020
1 parent 65e59d0 commit a821855
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 1 deletion.
2 changes: 2 additions & 0 deletions mule4-agent/.classpath
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,13 @@
<attributes>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
<attribute name="test" value="true"/>
</attributes>
</classpathentry>
<classpathentry excluding="**" kind="src" output="target/test-classes" path="src/test/resources">
<attributes>
<attribute name="maven.pomderived" value="true"/>
<attribute name="test" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8">
Expand Down
3 changes: 2 additions & 1 deletion mule4-agent/.gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/target/
$*
.mule/
.mule/
.settings
3 changes: 3 additions & 0 deletions mule4-agent/.settings/org.eclipse.jdt.core.prefs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
org.eclipse.jdt.core.compiler.compliance=1.8
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=ignore
org.eclipse.jdt.core.compiler.release=disabled
org.eclipse.jdt.core.compiler.source=1.8
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import org.mule.runtime.api.event.Event;
import org.mule.runtime.api.notification.PipelineMessageNotification;
import org.mule.runtime.core.api.event.CoreEvent;
import org.slf4j.MDC;

import co.elastic.apm.api.ElasticApm;
import co.elastic.apm.api.Transaction;
Expand All @@ -15,6 +16,9 @@
*/
public class TransactionUtils {

private static final String TRANSACTION_ID = "transaction.id";
private static final String TRACE_ID = "trace.id";

/*
* Is this notification related to newly started flow, i.e. there is no
* transaction yet in the transactionStore?
Expand Down Expand Up @@ -42,6 +46,10 @@ public static void startTransaction(TransactionStore transactionStore, PipelineM
// Once created, store the transaction in the store.
transactionStore.storeTransaction(getTransactionId(notification).get(),
populateTransactionDetails(transaction, notification));

// Populate MDC for logs correlation
MDC.put(TRACE_ID, transaction.getTraceId());
MDC.put(TRANSACTION_ID, transaction.getId());
}

/*
Expand Down Expand Up @@ -142,6 +150,10 @@ public static void endTransaction(TransactionStore transactionStore, PipelineMes
populateFinalTransactionDetails(transaction, notification);

transaction.end();

// Clean MDC
MDC.remove(TRACE_ID);
MDC.remove(TRANSACTION_ID);
}

private static boolean isEndOfTopFlow(TransactionStore transactionStore, PipelineMessageNotification notification) {
Expand Down

0 comments on commit a821855

Please sign in to comment.