Skip to content

Commit c7727d6

Browse files
committed
* Migration to java random id's for speed
1 parent d50ac43 commit c7727d6

File tree

7 files changed

+48
-6
lines changed

7 files changed

+48
-6
lines changed

changelog.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
2727
* `timeIt()` helper was not passing the closure correctly
2828
* If doing a fwreinit on the visualizer, the current profiler was still being show even thought it was empty. Add an empty check to avoid the big bang!
2929
* Empty response codes for Adobe, due to their incredibly weird Response object nesting.
30+
* Migration to java random id's for speed
3031

3132
### Changed
3233

handlers/Main.cfc

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ component extends="coldbox.system.RestHandler" {
5050
*/
5151
function renderDebugger( event, rc, prc ){
5252
// are we in visualizer mode?
53-
var isVisualizer = event.getCurrentEvent() eq "cbdebugger:main.index";
53+
var isVisualizer = event.getCurrentEvent() eq "cbdebugger:main.index";
5454
setting showdebugoutput=false;
5555
// Return the debugger layout+view
5656
// We pass in all the variables needed, to avoid prc/rc conflicts
@@ -171,7 +171,14 @@ component extends="coldbox.system.RestHandler" {
171171
}
172172

173173
/**
174-
* Unload a modules
174+
* Export a profiler report as json
175+
*/
176+
function exportProfilerReport( event, rc, prc ){
177+
return variables.debuggerService.getProfilerById( rc.id );
178+
}
179+
180+
/**
181+
* Unload a module
175182
*/
176183
function unloadModule( event, rc, prc ){
177184
event.paramValue( "module", "" );

interceptors/RequestCollector.cfc

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,13 +142,20 @@ component extends="coldbox.system.Interceptor" {
142142
// new coldbox tracking of events
143143
if ( arguments.interceptData.keyExists( "ehBean" ) ) {
144144
var handlerMD = interceptData.ehBean.getHandlerMetadata();
145-
var position = handlerMD.functions
145+
146+
// params in case it's an invalid event
147+
param handlerMD.functions = [];
148+
param handlerMD.path = "";
149+
150+
var position = handlerMD.functions
146151
.filter( function( thisItem ){
147152
return thisItem.name == interceptData.ehBean.getMethod();
148153
} )
149154
.reduce( function( result, thisItem ){
150155
return thisItem.keyExists( "position" ) ? thisItem.position.start : result;
151156
}, 1 );
157+
158+
// stop timer
152159
variables.timerService.stop(
153160
label : "[runEvent] #arguments.interceptData.processedEvent#",
154161
metadata: { path : handlerMD.path, line : position }

models/DebuggerService.cfc

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -129,12 +129,19 @@ component
129129
current debugPassword and a random salt. The salt also protects against someone being able to
130130
reverse engineer the orignal password from an intercepted cookie value.
131131
*/
132-
var salt = variables.uuid.randomUUID();
132+
var salt = randomUUID();
133133
variables.secretKey =
134134
hash( variables.controller.getAppHash() & variables.debugPassword & salt, "SHA-256" );
135135
return this;
136136
}
137137

138+
/**
139+
* Generate a new java random id
140+
*/
141+
string function randomUUID(){
142+
return variables.uuid.randomUUID().toString();
143+
}
144+
138145
/**
139146
* Get the debug mode marker
140147
*/
@@ -193,7 +200,7 @@ component
193200
"fullUrl" : arguments.event.getFullUrl(),
194201
"httpHost" : cgi.HTTP_HOST,
195202
"httpReferer" : cgi.HTTP_REFERER,
196-
"id" : variables.uuid.randomUUID(),
203+
"id" : variables.uuid.randomUUID().toString(),
197204
"inetHost" : discoverInetHost(),
198205
"ip" : getRealIP(),
199206
"localIp" : getServerIp(),

models/Timer.cfc

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@
77
*/
88
component accessors="true" singleton threadsafe {
99

10+
// DI
11+
property name="debuggerService" inject="debuggerService@cbdebugger";
12+
1013
/**
1114
* Constructor
1215
*/
@@ -31,7 +34,7 @@ component accessors="true" singleton threadsafe {
3134
type = "timer",
3235
parent = ""
3336
){
34-
var timerId = createUUID();
37+
var timerId = variables.debuggerService.randomUUID();
3538
getTimers().insert(
3639
arguments.label,
3740
{

resources/assets/js/components/RequestTrackerPanel.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ export default ( isExpanded, refreshFrequency, hasReinitPassword, isVisualizer )
2121
this.$refs.reinitLoader.classList.remove( "cbd-spinner" );
2222
} );
2323
},
24+
2425
loadProfilerReport( id ){
2526
this.stopDebuggerMonitor();
2627
fetch( `${this.appUrl}cbDebugger/renderProfilerReport`, {
@@ -38,10 +39,12 @@ export default ( isExpanded, refreshFrequency, hasReinitPassword, isVisualizer )
3839
coldboxDebugger.scrollTo( "cbd-request-tracker" );
3940
} );
4041
},
42+
4143
clearState(){
4244
history.pushState( {}, null, "#" );
4345
this.currentProfileId = "";
4446
},
47+
4548
refreshProfilers(){
4649
this.$refs.refreshLoader.classList.add( "cbd-spinner" );
4750
fetch( `${this.appUrl}cbDebugger/renderProfilers`, { headers: { "x-Requested-With": "XMLHttpRequest" } } )
@@ -52,6 +55,7 @@ export default ( isExpanded, refreshFrequency, hasReinitPassword, isVisualizer )
5255
this.$refs.refreshLoader.classList.remove( "cbd-spinner" );
5356
} );
5457
},
58+
5559
clearProfilers(){
5660
this.$refs.clearLoader.classList.add( "cbd-spinner" );
5761
fetch( `${this.appUrl}cbDebugger/clearProfilers`, { headers: { "x-Requested-With": "XMLHttpRequest" } } )
@@ -66,6 +70,7 @@ export default ( isExpanded, refreshFrequency, hasReinitPassword, isVisualizer )
6670
this.$refs.clearLoader.classList.remove( "cbd-spinner" );
6771
} );
6872
},
73+
6974
stopDebuggerMonitor(){
7075
// stop only if loaded
7176
if ( this.refreshMonitor != null ){
@@ -74,6 +79,7 @@ export default ( isExpanded, refreshFrequency, hasReinitPassword, isVisualizer )
7479
console.info( "Stopped ColdBox Debugger Profiler Refresh" );
7580
}
7681
},
82+
7783
startDebuggerMonitor( frequency ){
7884
// Ensure monitor is stopped just in case we are switching frequencies
7985
this.stopDebuggerMonitor();
@@ -84,6 +90,7 @@ export default ( isExpanded, refreshFrequency, hasReinitPassword, isVisualizer )
8490
this.refreshMonitor = setInterval( () => this.refreshProfilers(), this.refreshFrequency * 1000 );
8591
console.info( "Started ColdBox Debugger Profiler Refresh using " + this.refreshFrequency + " seconds" );
8692
},
93+
8794
init(){
8895
window.addEventListener( "popstate", e => {
8996
if ( e.state && e.state.profileId ){

views/main/partials/profilers.cfm

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,8 @@
214214

215215
<!--- ACTIONS --->
216216
<td align="center">
217+
218+
<!--- Open Request Profiler --->
217219
<button
218220
title="Show Request"
219221
class="pt5 pb5 cbd-rounded"
@@ -227,6 +229,14 @@
227229
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M10 21h7a2 2 0 002-2V9.414a1 1 0 00-.293-.707l-5.414-5.414A1 1 0 0012.586 3H7a2 2 0 00-2 2v11m0 5l4.879-4.879m0 0a3 3 0 104.243-4.242 3 3 0 00-4.243 4.242z" />
228230
</svg>
229231
</button>
232+
233+
<!--- Export Profiler as JSON --->
234+
<a
235+
href="#event.buildLink( 'cbdebugger:exportProfilerReport', { id : thisProfiler.id } )#"
236+
target="_blank"
237+
>
238+
<svg class="w-6 h-6" fill="none" stroke="currentColor" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M7 16a4 4 0 01-.88-7.903A5 5 0 1115.9 6L16 6a5 5 0 011 9.9M9 19l3 3m0 0l3-3m-3 3V10"></path></svg>
239+
</a>
230240
</td>
231241
</tr>
232242
</cfloop>

0 commit comments

Comments
 (0)