Skip to content

Instantly share code, notes, and snippets.

@bennadel
Created February 1, 2020 12:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bennadel/9f79c4d2ac5fb32dd8603c03dea404c7 to your computer and use it in GitHub Desktop.
Save bennadel/9f79c4d2ac5fb32dd8603c03dea404c7 to your computer and use it in GitHub Desktop.
Sending FusionReactor Tracked Transaction Metrics To The Cloud Dashboard With Lucee CFML 5.2.9.40
<cfscript>
// Get the running FusionReactor API (FRAPI) instance from the FRAPI factory class.
// --
// Java Docs: https://www.fusion-reactor.com/frapi/8_0_0/com/intergral/fusionreactor/api/FRAPI.html
frapi = createObject( "java", "com.intergral.fusionreactor.api.FRAPI" )
.getInstance()
;
// ------------------------------------------------------------------------------- //
// ------------------------------------------------------------------------------- //
// By default, FusionReactor will use the name of the application as defined in the
// Application.cfc ColdFusion framework component. However, we can set the name
// programmatically.
frapi.setTransactionApplicationName( "FRAPI-Testing" );
// By default, FusionReactor will calculate the transaction name based on the request
// context. It actually "understands" the fact that we're using Framework One (FW/1)
// in production and uses the "action" value as the transaction name. That's the
// beauty of using an APM product that is embedded within the ColdFusion and CFML
// community. That said, we can set the transaction name programmatically.
// --
// See Framework Support: https://www.fusion-reactor.com/support/kb/frs-431/
frapi.setTransactionName( "testing-cloud-transaction-metrics" );
// ------------------------------------------------------------------------------- //
// ------------------------------------------------------------------------------- //
try {
// Let's explicitly wrap a segment of our code in a custom, tracked transaction.
// This way, we can see how this code executes in the context of parent request.
subtransaction = frapi.createTrackedTransaction( "demo-segment" );
// When a custom Transaction is explicitly created in the ColdFusion code,
// FusionReactor sends the Transaction data to the CLOUD dashboard; however, by
// default, it doesn't send the METRICS about that Transaction to the CLOUD
// dashboard. This means that we can see the Transaction in the Tracing and the
// data-tables; but, we can't graph it in our custom graphs. In order to do this,
// we have to explicitly set the Transaction-related metrics to be cloud-enabled.
frapi.enableCloudMetric( "/transit/txntracker/demo-segment/active/activity" );
frapi.enableCloudMetric( "/transit/txntracker/demo-segment/active/time" );
frapi.enableCloudMetric( "/transit/txntracker/demo-segment/history/activity" );
frapi.enableCloudMetric( "/transit/txntracker/demo-segment/history/time" );
// frapi.enableCloudMetric( "/transit/txntracker/demo-segment/error/activity" );
// frapi.enableCloudMetric( "/transit/txntracker/demo-segment/error/time" );
sleep( randRange( 500, 1500 ) );
} finally {
subtransaction.close();
}
</cfscript>
<!--- ------------------------------------------------------------------------------ --->
<!--- ------------------------------------------------------------------------------ --->
<script>
// Simulate regular throughput / traffic to this endpoint by refreshing.
setTimeout(
function() {
window.location.reload();
},
1000
);
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment