Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Session report collection and report templates #981

Merged
merged 13 commits into from
Jun 27, 2021
Merged

Conversation

piksel
Copy link
Member

@piksel piksel commented Jun 6, 2021

PoC for collecting a report containing session stats. Updated to not replace the current notification templates, but instead make the report-based notifications an opt-in (using the --notification-report flag)


This will generate the following report for each session:

type Report interface {
Scanned() []ContainerReport
Updated() []ContainerReport
Failed() []ContainerReport
Skipped() []ContainerReport
Stale() []ContainerReport
Fresh() []ContainerReport
}

where each ContainerReport contains
type ContainerReport interface {
ID() string
Name() string
OldImageID() string
NewImageID() string
ImageName() string
Error() string
State() string
}

This report is passed to the template together with the log entries (the old template data):

type Data struct {
Entries []*log.Entry
Report t.Report
}

This makes it possible to send notifications like these instead of the full logs:

3 Scanned, 1 Updated
 - /baz (alpine:latest): Updated
 - /bar (nginx:latest): Fresh
 - /bar (redis:latest): Stale
Found new alpine:latest image (5de788243aca)
Stopping /baz (a9faebf599b0) with SIGTERM
Creating /baz

...using template:

{{with .Report -}}
  {{len .Scanned}} Scanned, {{len .Updated}} Updated
  {{range .Scanned}}
     - {{.Name}} ({{.ImageName}}): {{.State}}
  {{end}}
{{- end}}
{{range .Entries}}
  {{- .Message -}}
{{end}}

Note that the above still contains the old "log" notifications at the bottom as well, but the point is that you don't have to include them.

Report container classifications:

image

@codecov
Copy link

codecov bot commented Jun 11, 2021

Codecov Report

Merging #981 (71251ea) into main (145fe6d) will increase coverage by 2.51%.
The diff coverage is 62.60%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #981      +/-   ##
==========================================
+ Coverage   57.11%   59.63%   +2.51%     
==========================================
  Files          25       22       -3     
  Lines        1476     1412      -64     
==========================================
- Hits          843      842       -1     
+ Misses        564      500      -64     
- Partials       69       70       +1     
Impacted Files Coverage Δ
pkg/notifications/email.go 90.69% <ø> (-0.22%) ⬇️
pkg/notifications/gotify.go 66.66% <ø> (-1.08%) ⬇️
pkg/notifications/msteams.go 66.66% <ø> (-1.76%) ⬇️
pkg/notifications/slack.go 100.00% <ø> (ø)
pkg/container/client.go 14.28% <8.33%> (-0.19%) ⬇️
pkg/container/container.go 45.36% <20.00%> (-1.45%) ⬇️
pkg/notifications/shoutrrr.go 75.38% <70.27%> (+1.94%) ⬆️
pkg/notifications/notifier.go 69.56% <84.61%> (+36.75%) ⬆️
internal/actions/update.go 63.55% <86.66%> (-0.24%) ⬇️
internal/flags/flags.go 88.65% <100.00%> (ø)
... and 1 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 145fe6d...71251ea. Read the comment docs.

pkg/container/interface.go.go Outdated Show resolved Hide resolved
@piksel piksel marked this pull request as ready for review June 11, 2021 17:19
@piksel piksel requested a review from simskij as a code owner June 11, 2021 17:19
@piksel piksel changed the title wip: session stats Session report collection and report templates Jun 11, 2021
@piksel piksel self-assigned this Jun 24, 2021
@simskij simskij merged commit e3dd8d6 into main Jun 27, 2021
@simskij simskij deleted the feat/notification-stats branch June 27, 2021 07:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants