本文整理汇总了Java中com.squareup.pagerduty.incidents.Trigger类的典型用法代码示例。如果您正苦于以下问题:Java Trigger类的具体用法?Java Trigger怎么用?Java Trigger使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Trigger类属于com.squareup.pagerduty.incidents包,在下文中一共展示了Trigger类的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: alertAboutStatusTrigger
import com.squareup.pagerduty.incidents.Trigger; //导入依赖的package包/类
private void alertAboutStatusTrigger(RunningUnit runningUnit, StatusSnapshot.Measurement measurement) {
try {
Trigger trigger = new Trigger
.Builder(String.format("%s - the measurement '%s' is in status %s.", createHumanReadableName(runningUnit), measurement.getKey(), measurement.getStatus()))
.withIncidentKey(createIncidentKey(runningUnit, measurement))
.addDetails("measurement-numeric", String.valueOf(measurement.getNumericValue()))
.addDetails("measurement-value", measurement.getDisplayValue())
.addDetails("measurement-status", measurement.getStatus())
.addDetails("measurement-key", measurement.getKey())
.addDetails("server", runningUnit.getServer())
.addDetails("component", runningUnit.getComponent())
.addDetails("system", runningUnit.getSystem())
.addDetails("environment", runningUnit.getEnvironment())
.build();
pagerduty.notify(trigger);
} catch (IOException e) {
LOG.warn("Error when calling pagerduty to trigger measurement", e);
}
}
示例2: indicateFewerRunningUnits
import com.squareup.pagerduty.incidents.Trigger; //导入依赖的package包/类
public void indicateFewerRunningUnits(MissingRunningUnitsAlerter.Component c, int serversLastTime, int serversNow) {
if (!shouldAlert(c.getEnvironment())) {
return;
}
try {
Trigger trigger = new Trigger
.Builder(String.format("%s - number of servers running the app has decreased from %s to %s.", createHumanReadableName(c), serversLastTime, serversNow))
.withIncidentKey(createIncidentKey(c))
.addDetails("component", c.getComponent())
.addDetails("system", c.getSystem())
.addDetails("environment", c.getEnvironment())
.build();
pagerduty.notify(trigger);
} catch (IOException e) {
LOG.warn("Error when calling pagerduty to trigger missing running unit", e);
}
}
示例3: handle
import com.squareup.pagerduty.incidents.Trigger; //导入依赖的package包/类
public void handle(GoNotificationMessage message) throws Exception {
String pipelineStage = message.getPipelineName() + "-" + message.getStageName();
PagerDuty pd;
// Create an incident when matching pipelines fail
if (pipelineApiKeys.containsKey(message.getPipelineName()) && statusesToAlertOn.contains(message.getStageState())) {
// TODO: Should we create a new incident for each failure or assume that if we've already created one that we're good?
// If we create multiple incidents it will be more challenging to resolve them after a pass, obviously.
// If we don't already have an open incident for this pipeline/stage
if (!currentIncidentKeys.containsKey(pipelineStage)){
pd = newPagerDuty(pipelineApiKeys.get(message.getPipelineName()));
String goUrl = getGoCDURL(message);
Trigger trigger = new Trigger.Builder(String.format("Failed Build: %s build %s on %s", message.fullyQualifiedJobName(), message.getStageState(), hostname))
.client("GoCD")
.clientUrl(goUrl)
.build();
NotifyResult result = pd.notify(trigger);
currentIncidentKeys.put(pipelineStage, result.incidentKey());
}
} else if (currentIncidentKeys.containsKey(pipelineStage) && "Passed".equals(message.getStageResult())) {
// If that pipeline + stage passes, clear the incident
pd = newPagerDuty(pipelineApiKeys.get(message.getPipelineName()));
Resolution resolution = new Resolution.Builder(currentIncidentKeys.get(pipelineStage))
.withDescription(String.format("%s build %s on %s", message.fullyQualifiedJobName(), message.getStageState(), hostname))
.build();
pd.notify(resolution);
currentIncidentKeys.remove(pipelineStage);
}
}
示例4: trigger
import com.squareup.pagerduty.incidents.Trigger; //导入依赖的package包/类
@Override
public void trigger(@Nonnull String alert, @Nonnull String description, @Nonnull Map<String, String> details) {
checkNotNull(alert);
checkNotNull(description);
checkNotNull(details);
notify(new Trigger.Builder(description).withIncidentKey(alert).addDetails(details).build());
}