-
Notifications
You must be signed in to change notification settings - Fork 5.1k
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
Stats collection. #2447
Stats collection. #2447
Conversation
c1f2e4e
to
6116f62
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 👏 👍
6116f62
to
8ad23d0
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 👼
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 👏
8ad23d0
to
b264b07
Compare
b264b07
to
3b8509d
Compare
cmd/traefik/traefik.go
Outdated
func collect(globalConfiguration *configuration.GlobalConfiguration) { | ||
ticker := time.NewTicker(24 * time.Hour) | ||
safe.Go(func() { | ||
time.Sleep(10 * time.Minute) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure understand why this first call of Collect
is required 👼 I guess you want the first one after 10min and then each and every day, right.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
exactly, we wait 10 min for eliminate some quick restart.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we document the delay in basics.md
as well?
"strconv" | ||
"time" | ||
|
||
"github.com/containous/traefik/cmd/traefik/anonymize" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🤔 why anonymize
is under cmd/traefik
package ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(or why collector
is in a different parent package that anonimize
?)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because before this PR it was use only by traefik bug
command.
I can move the package anonymize
at the root of the project.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
collector/collector.go
Outdated
"github.com/mitchellh/hashstructure" | ||
) | ||
|
||
const containousURL = "https://collect.traefik.io" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is probably fine, but we might want this overridable for testing, and to allow people to post the stats to their own endpoint if they want. This would also improve public perception, as they can see EXACTLY what is being sent by posting to their own endpoint.
collector/collector.go
Outdated
buf := new(bytes.Buffer) | ||
json.NewEncoder(buf).Encode(data) | ||
|
||
_, err = makeHTTPClient().Post(containousURL, "application/json; charset=utf-8", buf) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This might be a dumb question, but do we want this to retry/or log the data on failure? rather than just the error?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's not critical for the application, we think the retry/log response is not needed in this case.
|
||
```bash | ||
./traefik --sendAnonymousUsage=true | ||
``` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Might want to note that in the future, that this will be enabled by default.
4ecad76
to
ddcd87e
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @ldez for this great PR. Few comments though ;)
collector/collector.go
Outdated
BuildDate: version.BuildDate, | ||
Hash: strconv.FormatUint(hashConf, 10), | ||
Configuration: base64.StdEncoding.EncodeToString([]byte(anonConfig)), | ||
EmitDate: time.Now().Format(time.RFC3339), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is-it needed ?
collector/collector.go
Outdated
} | ||
|
||
buf := new(bytes.Buffer) | ||
json.NewEncoder(buf).Encode(data) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
error is shadowed here
docs/basics.md
Outdated
Once a day, we collect: | ||
- the Træfik version | ||
- a hash of the configuration | ||
- an **obfuscated and anonymous version** of the static configuration: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
s/obfuscated and anonymous version/anonymous version
docs/basics.md
Outdated
|
||
By default we anonymize all configuration fields, except fields tagged with `export=true`. | ||
|
||
You can check all fields in the [godoc](https://godoc.org/github.com/containous/traefik). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe we should give a this link instead https://godoc.org/github.com/containous/traefik/configuration#GlobalConfiguration
ddcd87e
to
ba322d7
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 👏
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, I only left two very small nit-picks :)
docs/basics.md
Outdated
- an **anonymous version** of the static configuration: | ||
- token, user name, password, URL, IP, domain, email, etc, are removed | ||
|
||
!!! warning |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is rather another note than a warning.
cmd/traefik/traefik.go
Outdated
log.Debug(err) | ||
} | ||
for { | ||
select { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You don't really need the select
case here, because <-ticker.C
will block anyway.
ba322d7
to
4e7500f
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd call out the typo fixes as mandatory, everything else as recommended / points of discussion.
cmd/traefik/traefik.go
Outdated
if globalConfiguration.SendAnonymousUsage { | ||
log.Info(` | ||
Stats collection is enabled. | ||
Many thanks to contribute to Traefik improvement by allowing us to receive anonymous information from your configuration. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it must say (emphasis by me)
Many thanks for contributing to Traefik's improvement [...]
cmd/traefik/traefik.go
Outdated
} | ||
|
||
func collect(globalConfiguration *configuration.GlobalConfiguration) { | ||
ticker := time.NewTicker(24 * time.Hour) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd make it explicit that we want a never-ending ticker (we never call ticker.Stop()
) by invoking time.Tick()
here.
collector/collector.go
Outdated
"github.com/mitchellh/hashstructure" | ||
) | ||
|
||
const containousURL = "https://collect.traefik.io/619df80498b60f985d766ce62f912b7c" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we have a more expressive name to indicate what's happening behind this URL (like collectorURL
), possibly even a GoDoc?
collector/collector.go
Outdated
return err | ||
} | ||
|
||
log.Infof("Stats sent on %s: %s", containousURL, anonConfig) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
s/on/to/
collector/collector.go
Outdated
return err | ||
} | ||
|
||
log.Infof("Stats sent on %s: %s", containousURL, anonConfig) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd write Anonymous stats sent to [...].
(Emphasis by me.)
cmd/traefik/traefik.go
Outdated
func collect(globalConfiguration *configuration.GlobalConfiguration) { | ||
ticker := time.NewTicker(24 * time.Hour) | ||
safe.Go(func() { | ||
time.Sleep(10 * time.Minute) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we document the delay in basics.md
as well?
cmd/traefik/traefik.go
Outdated
for range ticker.C { | ||
err := collector.Collect(globalConfiguration) | ||
if err != nil { | ||
log.Debug(err) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is possible to have just one call to Collect
like this (slightly adopted from here):
for time.Sleep(10 * time.Minute); ; <-ticker.C {
if err := collector.Collect(globalConfiguration); err != nil {
log.Debug(err)
}
}
@timoreimann I have take account of all your remarks. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 👏
f4000db
to
8d13309
Compare
What does this PR do?
#2369
This feature is disabled by default.
In the future, as discussed in the proposal, this may be enabled by default.
Motivation
#2369
More