Skip to content

Commit 2027b93

Browse files
committed
Added a trace connection help popup.
It gives you the "-javaagent..." command that you have to add to the traced app's command line in order to trace. The path is slightly auto-generated, assuming the user is running CodePulse from the packaged+embedded version, and that they haven't moved the agent jar around.
1 parent 0210615 commit 2027b93

File tree

4 files changed

+70
-0
lines changed

4 files changed

+70
-0
lines changed

codepulse/src/main/resources/toserve/pages/traces/trace-recording-controls.css

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,35 @@
212212
background-color: #DEDEDE;
213213
}
214214

215+
#connection-help-link {
216+
display: block;
217+
font-size: small;
218+
}
219+
220+
#connection-help-popup {
221+
position: fixed;
222+
top: 59px;
223+
right: 240px;
224+
width: 450px;
225+
226+
background-color: lightgray;
227+
border: 1px solid;
228+
padding: 1em 1em .5em;
229+
}
230+
231+
#connection-help-popup code {
232+
display: block;
233+
padding: .5em;
234+
overflow-x: scroll;
235+
}
236+
237+
#connection-help-popup .dismissal {
238+
display: block;
239+
margin-top: 5px;
240+
text-align: right;
241+
font-size: small;
242+
cursor: pointer;
243+
}
215244

216245
/****************************\
217246
| Recording "Coverage" Badge |

codepulse/src/main/resources/toserve/pages/traces/trace-recording-controls.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -523,6 +523,15 @@
523523
TraceAPI.requestEnd()
524524
})
525525

526+
// Set up the connection help link
527+
var connectionHelpPopup = $('#connection-help-popup')
528+
$('#connection-help-link').click(function(){
529+
connectionHelpPopup.show()
530+
})
531+
connectionHelpPopup.find('.dismissal').click(function(){
532+
connectionHelpPopup.hide()
533+
})
534+
526535
})
527536

528537
}(this));

codepulse/src/main/scala/com/secdec/codepulse/tracer/snippet/TraceWidgetry.scala

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ import java.text.SimpleDateFormat
2828
import java.util.Date
2929
import com.secdec.codepulse.tracer
3030
import com.secdec.codepulse.tracer.TraceManager
31+
import java.io.File
3132

3233
class TraceWidgetry(manager: TraceManager, target: TracingTarget) extends DispatchSnippet {
3334

@@ -77,6 +78,20 @@ class TraceWidgetry(manager: TraceManager, target: TracingTarget) extends Dispat
7778
"exportlink" -> { (xml: NodeSeq) =>
7879
val href = tracer.traceAPIServer.Paths.Export.toHref(target)
7980
<a data-downloader={ href } data-filename={ s"${data.metadata.name}.pulse" }>{ runBinding(xml) }</a>
81+
},
82+
"agentcommand" -> { (xml: NodeSeq) =>
83+
// embedded versions will be running in "some/install/dir/backend", and
84+
// the agent jar will be located at "some/install/dir/agent.jar"
85+
val agentPath = new File("../agent.jar").getCanonicalPath
86+
87+
val hqAddress = "localhost"
88+
val hqPort = com.secdec.codepulse.userSettings.tracePort
89+
90+
val cmd = s"-javaagent:$agentPath=$hqAddress:$hqPort"
91+
92+
// if `cmd` has spaces, wrap it in "quotes"
93+
val cmdWrapped = if (cmd.contains(" ")) '"' + cmd + '"' else cmd
94+
Text(cmdWrapped)
8095
})
8196

8297
cometTemplate +: runBinding(template)

codepulse/src/main/webapp/templates-hidden/trace-recording-controls.html

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,12 +59,29 @@
5959
</div>
6060
<div class="control-button" data-role="connection-waiting">
6161
Waiting for a trace connection...
62+
63+
<a id="connection-help-link">
64+
<i class="fa fa-question-circle"></i>
65+
How do I make a trace connection?
66+
</a>
6267
</div>
6368
<div class="control-button big" data-role="end-trace">
6469
End Trace
6570
</div>
6671
</div>
6772

73+
<div id="connection-help-popup" style="display: none;">
74+
<p>
75+
To make a new trace connection, run your Java-based program with the following addition
76+
to the Java command line:
77+
</p>
78+
<code class="lift:TraceWidgetry">
79+
<trace:agentcommand></trace:agentcommand>
80+
<!-- -javaagent:bytefrog-tracer.jar=localhost:8765 -->
81+
</code>
82+
<a class="dismissal">dismiss</a>
83+
</div>
84+
6885
<h1>Treemap Legend</h1>
6986
<div class="recordingsLegend">
7087
<div class="legend-entry clearfix">

0 commit comments

Comments
 (0)