Source:
public final void onStarted(final Run run, final TaskListener listener) { String jobName = run.getParent().getFullName(); logger.fine(String.format("onStarted() called with jobName: %s", jobName)); Map<String,String> tags = new HashMap<String,String>(); if ( DatadogUtilities.isJobTracked(jobName) ) { logger.fine("Started build!"); tags.putAll(DatadogUtilities.getRegexJobTags(jobName)); Queue.Item item = queue.getItem(run.getQueueId()); JSONObject builddata = new JSONObject(); Map<String,String> extraTags = DatadogUtilities.buildExtraTags(run, listener); extraTags.putAll(tags); builddata.put("job", DatadogUtilities.normalizeFullDisplayName(jobName)); builddata.put("number", run.number); builddata.put("result", null); builddata.put("duration", null); long starttime = run.getStartTimeInMillis() / DatadogBuildListener.THOUSAND_LONG; builddata.put("timestamp", starttime); try { EnvVars envVars = run.getEnvironment(listener); tags.putAll(DatadogUtilities.parseTagList(run, listener)); builddata.put("hostname", DatadogUtilities.getHostname(envVars)); builddata.put("buildurl", envVars.get("BUILD_URL")); builddata.put("node", envVars.get("NODE_NAME")); } catch (IOException e) { logger.severe(e.getMessage()); } catch (InterruptedException e) { logger.severe(e.getMessage()); } BuildStartedEventImpl evt = new BuildStartedEventImpl(builddata, tags); DatadogHttpRequests.sendEvent(evt); try { builddata.put("waiting", (System.currentTimeMillis() - item.getInQueueSince()) / DatadogBuildListener.THOUSAND_LONG); gauge("jenkins.job.waiting", builddata, "waiting", extraTags); } catch (NullPointerException e) { logger.severe(e.getMessage()); } logger.fine("Finished onStarted()"); } }

Target:
public final void onStarted(final Run run, final TaskListener listener) { String jobName = run.getParent().getFullName(); logger.fine(String.format("onStarted() called with jobName: %s", jobName)); Map<String,String> tags = new HashMap<String,String>(); if ( DatadogUtilities.isJobTracked(jobName) ) { logger.fine("Started build!"); tags.putAll(DatadogUtilities.getRegexJobTags(jobName)); Queue.Item item = queue.getItem(run.getQueueId()); JSONObject builddata = new JSONObject(); Map<String,String> extraTags = DatadogUtilities.buildExtraTags(run, listener); extraTags.putAll(tags); builddata.put("job", DatadogUtilities.normalizeFullDisplayName(jobName)); builddata.put("number", run.number); builddata.put("result", null); builddata.put("duration", null); long starttime = run.getStartTimeInMillis() / DatadogBuildListener.THOUSAND_LONG; builddata.put("timestamp", starttime); try { EnvVars envVars = run.getEnvironment(listener); tags.putAll(DatadogUtilities.parseTagList(run, listener)); builddata.put("hostname", DatadogUtilities.getHostname(envVars)); builddata.put("buildurl", envVars.get("BUILD_URL")); builddata.put("node", envVars.get("NODE_NAME")); } catch (IOException e) { logger.severe(e.getMessage()); } catch (InterruptedException e) { logger.severe(e.getMessage()); } BuildStartedEventImpl evt = new BuildStartedEventImpl(builddata, tags); DatadogHttpRequests.sendEvent(evt); try { builddata.put("waiting", (System.currentTimeMillis() - item.getInQueueSince()) / DatadogBuildListener.THOUSAND_LONG); gauge("jenkins.job.waiting", builddata, "waiting", extraTags); } catch (NullPointerException e) { logger.warning("Unable to compute 'waiting' metric. item.getInQueueSince() unavailable, possibly due to worker instance provisioning"); } logger.fine("Finished onStarted()"); } }