本文整理匯總了Golang中github.com/telemetryapp/gotelemetry.Flow.TableData方法的典型用法代碼示例。如果您正苦於以下問題:Golang Flow.TableData方法的具體用法?Golang Flow.TableData怎麽用?Golang Flow.TableData使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/telemetryapp/gotelemetry.Flow
的用法示例。
在下文中一共展示了Flow.TableData方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: DailyMostFrequentCrashes
func (p *CrittercismPlugin) DailyMostFrequentCrashes(job *job.Job, f *gotelemetry.Flow) {
data, found := f.TableData()
if !found {
job.ReportError(gotelemetry.NewError(400, "Cannot extract table data from flow"+f.Tag))
}
crashes, err := p.api.FetchCrashStatus()
if err != nil {
job.ReportError(err)
return
}
crashes = crashes.Aggregate()
cells := [][]gotelemetry.TableCell{}
var count = 8
for _, crash := range crashes {
name := ""
if crash.Reason != "" {
name = crash.Reason
} else if crash.DisplayReason != nil {
name = *crash.DisplayReason
} else if crash.Name != nil {
name = *crash.Name
} else {
name = "N/A (" + crash.Reason + ")"
}
if len(name) > tableDataLength {
name = name[:tableDataLength-1]
}
cells = append(
cells,
[]gotelemetry.TableCell{
gotelemetry.TableCell{Value: name},
gotelemetry.TableCell{Value: crash.SessionCount},
},
)
count -= 1
if count == 0 {
break
}
}
for count > 0 {
cells = append(
cells,
[]gotelemetry.TableCell{
gotelemetry.TableCell{Value: ""},
gotelemetry.TableCell{Value: ""},
},
)
count -= 1
}
data.Cells = cells
job.PostFlowUpdate(f)
job.Logf("Updated flow %s", f.Tag)
}