Merge pull request #2774 from weaveworks/2607-historic-reports-capability

rename 'report_persistence' capability to 'historic_reports'
This commit is contained in:
Matthias Radestock
2017-07-31 14:22:55 +01:00
committed by GitHub
4 changed files with 21 additions and 4 deletions

View File

@@ -29,6 +29,7 @@ const reportQuantisationInterval = 3 * time.Second
// interface for parts of the app, and several experimental components.
type Reporter interface {
Report(context.Context, time.Time) (report.Report, error)
HasHistoricReports() bool
WaitOn(context.Context, chan struct{})
UnWait(context.Context, chan struct{})
}
@@ -139,6 +140,12 @@ func (c *collector) Report(_ context.Context, timestamp time.Time) (report.Repor
return rpt, nil
}
// HasHistoricReports indicates whether the collector contains reports
// older than now-app.window.
func (c *collector) HasHistoricReports() bool {
return false
}
// remove reports older than the app.window
func (c *collector) clean() {
var (
@@ -195,6 +202,12 @@ func (c StaticCollector) Report(context.Context, time.Time) (report.Report, erro
return report.Report(c), nil
}
// HasHistoricReports indicates whether the collector contains reports
// older than now-app.window.
func (c StaticCollector) HasHistoricReports() bool {
return false
}
// Add adds a report to the collector's internal state. It implements Adder.
func (c StaticCollector) Add(context.Context, report.Report, []byte) error { return nil }

View File

@@ -340,6 +340,10 @@ func (c *awsCollector) Report(ctx context.Context, timestamp time.Time) (report.
return c.merger.Merge(reports).Upgrade(), nil
}
func (c *awsCollector) HasHistoricReports() bool {
return true
}
// calculateDynamoKeys generates the row & column keys for Dynamo.
func calculateDynamoKeys(userid string, now time.Time) (string, string) {
rowKey := fmt.Sprintf("%s-%s", userid, strconv.FormatInt(now.UnixNano()/time.Hour.Nanoseconds(), 10))

View File

@@ -14,9 +14,9 @@ const (
ScopeProbeVersionHeader = "X-Scope-Probe-Version"
)
// ReportPersistenceCapability indicates whether probe reports end up in a
// long-term storage and can be retrieved.
const ReportPersistenceCapability = "report_persistence"
// HistoricReportsCapability indicates whether reports older than the
// current time (-app.window) can be retrieved.
const HistoricReportsCapability = "historic_reports"
// Details are some generic details that can be fetched from /api
type Details struct {

View File

@@ -295,7 +295,7 @@ func appMain(flags appFlags) {
}
capabilities := map[string]bool{
xfer.ReportPersistenceCapability: flags.s3URL != "local",
xfer.HistoricReportsCapability: collector.HasHistoricReports(),
}
handler := router(collector, controlRouter, pipeRouter, flags.externalUI, capabilities)
if flags.logHTTP {