Skip to content

Commit 84a6c5d

Browse files
committed
* Ability to open CFCs that are profiled by the WireBox Collector in any Code Editor.
* Ability to open the Handler events that are profiled by the Request Collector in any Code Editor.
1 parent ce5b439 commit 84a6c5d

File tree

7 files changed

+49
-31
lines changed

7 files changed

+49
-31
lines changed

aspects/ObjectProfiler.cfc

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@ component implements="coldbox.system.aop.MethodInterceptor" accessors="true" {
2424
*/
2525
any function invokeMethod( required invocation ) output=false{
2626
// default tx name
27-
var txName = "[Object Profiler] #arguments.invocation.getTargetName()#.#arguments.invocation.getMethod()#()";
27+
var txName = "[Object Profiler] #arguments.invocation.getTargetName()#.#arguments.invocation.getMethod()#()";
28+
var targetMapping = arguments.invocation.getTargetMapping();
2829

2930
// check metadata for tx name if they desire to influence the label
3031
var methodMD = arguments.invocation.getMethodMetadata();
@@ -33,7 +34,16 @@ component implements="coldbox.system.aop.MethodInterceptor" accessors="true" {
3334
}
3435

3536
// create with method name
36-
variables.timerService.start( txName );
37+
variables.timerService.start(
38+
label : txName,
39+
metadata: {
40+
path : targetMapping.getObjectMetadata()?.path ?: targetMapping.getPath(),
41+
name : targetMapping.getName(),
42+
type : targetMapping.getType(),
43+
line : methodMD.keyExists( "position" ) ? methodMD.position.start : 1
44+
},
45+
type: "object-profiler"
46+
);
3747

3848
// proceed invocation
3949
var results = arguments.invocation.proceed();

changelog.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1515
* Ability to open views and layouts from the execution timers in any Code Editor
1616
* New WireBoxCollector which is only used if enabled. This greatly accelerates the performance of the request collector since before they where in the same collector.
1717
* Ability to open CFCs that are profiled by the WireBox Collector in any Code Editor.
18+
* Ability to open the Handler events that are profiled by the Request Collector in any Code Editor.
1819

1920
### Fixed
2021

interceptors/RequestCollector.cfc

Lines changed: 26 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,26 @@ component extends="coldbox.system.Interceptor" {
139139
* Listen to end of ColdBox events
140140
*/
141141
function postEvent( event, interceptData, rc, prc ){
142-
variables.timerService.stop( "[runEvent] #arguments.interceptData.processedEvent#" );
142+
// new coldbox tracking of events
143+
if ( arguments.interceptData.keyExists( "ehBean" ) ) {
144+
var handlerMD = interceptData.ehBean.getHandlerMetadata();
145+
var position = handlerMD.functions
146+
.filter( function( thisItem ){
147+
return thisItem.name == interceptData.ehBean.getMethod();
148+
} )
149+
.reduce( function( result, thisItem ){
150+
return thisItem.keyExists( "position" ) ? thisItem.position.start : result;
151+
}, 1 );
152+
variables.timerService.stop(
153+
label : "[runEvent] #arguments.interceptData.processedEvent#",
154+
metadata: { path : handlerMD.path, line : position }
155+
);
156+
} else {
157+
variables.timerService.stop(
158+
label : "[runEvent] #arguments.interceptData.processedEvent#",
159+
metadata: { path : "", line : 1 }
160+
);
161+
}
143162
}
144163

145164
/**
@@ -171,7 +190,8 @@ component extends="coldbox.system.Interceptor" {
171190
"cacheLastAccessTimeout" : arguments.interceptData.cacheLastAccessTimeout,
172191
"cacheSuffix" : arguments.interceptData.cacheSuffix,
173192
"cacheProvider" : arguments.interceptData.cacheProvider,
174-
"viewPath" : ""
193+
"path" : "",
194+
"line" : 1
175195
},
176196
type: "view-render"
177197
);
@@ -184,7 +204,7 @@ component extends="coldbox.system.Interceptor" {
184204
variables.timerService.stop(
185205
label: "[renderView] #arguments.interceptData.view#" &
186206
( len( arguments.interceptData.module ) ? "@#arguments.interceptData.module#" : "" ),
187-
metadata: { viewPath : arguments.interceptData.viewPath ?: "" }
207+
metadata: { path : expandPath( arguments.interceptData.viewPath ) & ".cfm" }
188208
);
189209
}
190210

@@ -200,7 +220,8 @@ component extends="coldbox.system.Interceptor" {
200220
"module" : arguments.interceptData.module,
201221
"view" : arguments.interceptData.view,
202222
"viewModule" : arguments.interceptData.viewModule,
203-
"viewPath" : ""
223+
"path" : "",
224+
"line" : 1
204225
},
205226
type: "layout-render"
206227
);
@@ -213,7 +234,7 @@ component extends="coldbox.system.Interceptor" {
213234
variables.timerService.stop(
214235
label: "[renderLayout] #arguments.interceptData.layout#" &
215236
( len( arguments.interceptData.module ) ? "@#arguments.interceptData.module#" : "" ),
216-
metadata: { viewPath : arguments.interceptData.viewPath ?: "" }
237+
metadata: { path : expandPath( arguments.interceptData.viewPath ) & ".cfm" }
217238
);
218239
}
219240

interceptors/WireBoxCollector.cfc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,8 @@ component extends="coldbox.system.Interceptor" {
2727
metadata: {
2828
path : "",
2929
name : arguments.interceptData.mapping.getName(),
30-
type : arguments.interceptData.mapping.getType()
30+
type : arguments.interceptData.mapping.getType(),
31+
line : 1
3132
},
3233
type: "wirebox-creation"
3334
);

test-harness/Application.cfc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,8 @@ component {
7474
skipcfcWithError : false
7575
};
7676

77+
//applicationStop();abort;
78+
7779
// application start
7880
public boolean function onApplicationStart(){
7981
application.cbBootstrap = new coldbox.system.Bootstrap(

test-harness/config/Coldbox.cfc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,9 +86,9 @@
8686
// How many tracking profilers to keep in stack: Default is to monitor the last 20 requests
8787
maxProfilers : 25,
8888
// If enabled, the debugger will monitor the creation time of CFC objects via WireBox
89-
profileWireBoxObjectCreation : true,
89+
profileWireBoxObjectCreation : false,
9090
// Profile model objects annotated with the `profile` annotation
91-
profileObjects : false,
91+
profileObjects : true,
9292
// If enabled, will trace the results of any methods that are being profiled
9393
traceObjectResults : false,
9494
// Profile Custom or Core interception points

views/main/panels/requestTracker/debugTimersPanel.cfm

Lines changed: 4 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@
5353

5454
<!--- Show Timers if any are found --->
5555
<cfif structCount( args.timers )>
56-
<cfloop collection="#args.timers#" index="timerKey">
56+
<cfloop collection="#args.timers#" item="timerKey">
5757
<cfset thisTimer = args.timers[ timerKey ]>
5858

5959
<cfif findnocase( "[render", thisTimer.method )>
@@ -98,28 +98,11 @@
9898
<!--- Open --->
9999
<td align="center" >
100100
<!--- View Render --->
101-
<cfif listContains( "view-render,layout-render", thisTimer.type ) and len( thisTimer.metadata?.viewPath )>
101+
<cfif len( thisTimer.metadata?.path )>
102102
<a
103103
href="#args.debuggerService.openInEditorURL( event, {
104-
template : expandPath( thisTimer.metadata.viewPath ) & ".cfm",
105-
line : 1
106-
} )#"
107-
title="Open in Editor"
108-
class="cbd-button"
109-
target="_self"
110-
rel="noreferrer noopener"
111-
>
112-
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke="currentColor">
113-
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M10 20l4-16m4 4l4 4-4 4M6 16l-4-4 4-4" />
114-
</svg>
115-
</a>
116-
117-
<!--- Open Wirebox Creation Objects --->
118-
<cfelseif thisTimer.type eq "wirebox-creation" && isSimpleValue( thisTimer.metadata.path ) && len( thisTimer.metadata.path ) >
119-
<a
120-
href="#args.debuggerService.openInEditorURL( event, {
121-
template : expandPath( thisTimer.metadata.path ),
122-
line : 1
104+
template : thisTimer.metadata.path,
105+
line : thisTimer.metadata.line
123106
} )#"
124107
title="Open in Editor"
125108
class="cbd-button"

0 commit comments

Comments
 (0)