Update anonymize/collect

This commit is contained in:
Jean-Baptiste Doumenjou 2019-03-14 19:32:03 +01:00 committed by Traefiker Bot
parent 03d5a95bde
commit bd4c822670
7 changed files with 214 additions and 18 deletions

View file

@ -7,11 +7,19 @@ import (
"github.com/containous/flaeg/parse"
"github.com/containous/traefik/config/static"
"github.com/containous/traefik/ping"
"github.com/containous/traefik/provider"
"github.com/containous/traefik/provider/acme"
acmeprovider "github.com/containous/traefik/provider/acme"
"github.com/containous/traefik/provider/docker"
"github.com/containous/traefik/provider/file"
"github.com/containous/traefik/provider/kubernetes/crd"
"github.com/containous/traefik/provider/kubernetes/ingress"
traefiktls "github.com/containous/traefik/tls"
"github.com/containous/traefik/tracing/datadog"
"github.com/containous/traefik/tracing/instana"
"github.com/containous/traefik/tracing/jaeger"
"github.com/containous/traefik/tracing/zipkin"
"github.com/containous/traefik/types"
assetfs "github.com/elazarl/go-bindata-assetfs"
)
@ -20,20 +28,42 @@ func TestDo_globalConfiguration(t *testing.T) {
config := &static.Configuration{}
sendAnonymousUsage := true
config.Global = &static.Global{
Debug: true,
CheckNewVersion: true,
SendAnonymousUsage: true,
SendAnonymousUsage: &sendAnonymousUsage,
}
config.AccessLog = &types.AccessLog{
FilePath: "AccessLog FilePath",
Format: "AccessLog Format",
Filters: &types.AccessLogFilters{
StatusCodes: types.StatusCodes{"200", "500"},
RetryAttempts: true,
MinDuration: 10,
},
Fields: &types.AccessLogFields{
DefaultMode: "drop",
Names: types.FieldNames{
"RequestHost": "keep",
},
Headers: &types.FieldHeaders{
DefaultMode: "drop",
Names: types.FieldHeaderNames{
"Referer": "keep",
},
},
},
BufferingSize: 4,
}
config.Log = &types.TraefikLog{
LogLevel: "LogLevel",
FilePath: "/foo/path",
Format: "json",
}
config.EntryPoints = static.EntryPoints{
"foo": {
Address: "foo Address",
@ -63,19 +93,24 @@ func TestDo_globalConfiguration(t *testing.T) {
},
}
config.ACME = &acme.Configuration{
Email: "acme Email",
Email: "acme Email",
ACMELogging: true,
CAServer: "CAServer",
Storage: "Storage",
EntryPoint: "EntryPoint",
KeyType: "MyKeyType",
OnHostRule: true,
DNSChallenge: &acmeprovider.DNSChallenge{Provider: "DNSProvider"},
HTTPChallenge: &acmeprovider.HTTPChallenge{
EntryPoint: "MyEntryPoint",
},
TLSChallenge: &acmeprovider.TLSChallenge{},
Domains: []types.Domain{
{
Main: "Domains Main",
SANs: []string{"Domains acme SANs 1", "Domains acme SANs 2", "Domains acme SANs 3"},
},
},
Storage: "Storage",
OnHostRule: true,
CAServer: "CAServer",
EntryPoint: "EntryPoint",
DNSChallenge: &acmeprovider.DNSChallenge{Provider: "DNSProvider"},
ACMELogging: true,
}
config.Providers = &static.Providers{
ProvidersThrottleDuration: parse.Duration(111 * time.Second),
@ -134,8 +169,159 @@ func TestDo_globalConfiguration(t *testing.T) {
Directory: "file Directory",
}
config.Providers.Docker = &docker.Provider{
BaseProvider: provider.BaseProvider{
Watch: true,
Filename: "myfilename",
Constraints: nil,
Trace: true,
DebugLogGeneratedTemplate: true,
},
Endpoint: "MyEndPoint",
DefaultRule: "PathPrefix(`/`)",
TLS: &types.ClientTLS{
CA: "myCa",
CAOptional: true,
Cert: "mycert.pem",
Key: "mycert.key",
InsecureSkipVerify: true,
},
ExposedByDefault: true,
UseBindPortIP: true,
SwarmMode: true,
Network: "MyNetwork",
SwarmModeRefreshSeconds: 42,
}
config.Providers.Kubernetes = &ingress.Provider{
BaseProvider: provider.BaseProvider{
Watch: true,
Filename: "myFileName",
Constraints: types.Constraints{
{
Key: "k8s Constraints Key 1",
Regex: "k8s Constraints Regex 2",
MustMatch: true,
},
{
Key: "k8s Constraints Key 1",
Regex: "k8s Constraints Regex 2",
MustMatch: true,
},
},
Trace: true,
DebugLogGeneratedTemplate: true,
},
Endpoint: "MyEndpoint",
Token: "MyToken",
CertAuthFilePath: "MyCertAuthPath",
DisablePassHostHeaders: true,
EnablePassTLSCert: true,
Namespaces: []string{"a", "b"},
LabelSelector: "myLabelSelector",
IngressClass: "MyIngressClass",
}
config.Providers.KubernetesCRD = &crd.Provider{
BaseProvider: provider.BaseProvider{
Watch: true,
Filename: "myFileName",
Constraints: types.Constraints{
{
Key: "k8s Constraints Key 1",
Regex: "k8s Constraints Regex 2",
MustMatch: true,
},
{
Key: "k8s Constraints Key 1",
Regex: "k8s Constraints Regex 2",
MustMatch: true,
},
},
Trace: true,
DebugLogGeneratedTemplate: true,
},
Endpoint: "MyEndpoint",
Token: "MyToken",
CertAuthFilePath: "MyCertAuthPath",
DisablePassHostHeaders: true,
EnablePassTLSCert: true,
Namespaces: []string{"a", "b"},
LabelSelector: "myLabelSelector",
IngressClass: "MyIngressClass",
}
// FIXME Test the other providers once they are migrated
config.Metrics = &types.Metrics{
Prometheus: &types.Prometheus{
Buckets: types.Buckets{0.1, 0.3, 1.2, 5},
EntryPoint: "MyEntryPoint",
Middlewares: []string{"m1", "m2"},
},
Datadog: &types.Datadog{
Address: "localhost:8181",
PushInterval: "12",
},
StatsD: &types.Statsd{
Address: "localhost:8182",
PushInterval: "42",
},
InfluxDB: &types.InfluxDB{
Address: "localhost:8183",
Protocol: "http",
PushInterval: "22",
Database: "myDB",
RetentionPolicy: "12",
Username: "a",
Password: "aaaa",
},
}
config.Ping = &ping.Handler{
EntryPoint: "MyEntryPoint",
Middlewares: []string{"m1", "m2", "m3"},
}
config.Tracing = &static.Tracing{
Backend: "myBackend",
ServiceName: "myServiceName",
SpanNameLimit: 3,
Jaeger: &jaeger.Config{
SamplingServerURL: "aaa",
SamplingType: "bbb",
SamplingParam: 43,
LocalAgentHostPort: "ccc",
Gen128Bit: true,
Propagation: "ddd",
TraceContextHeaderName: "eee",
},
Zipkin: &zipkin.Config{
HTTPEndpoint: "fff",
SameSpan: true,
ID128Bit: true,
Debug: true,
SampleRate: 53,
},
DataDog: &datadog.Config{
LocalAgentHostPort: "ggg",
GlobalTag: "eee",
Debug: true,
PrioritySampling: true,
},
Instana: &instana.Config{
LocalAgentHost: "fff",
LocalAgentPort: 32,
LogLevel: "ggg",
},
}
config.HostResolver = &types.HostResolverConfig{
CnameFlattening: true,
ResolvConfig: "aaa",
ResolvDepth: 3,
}
cleanJSON, err := Do(config, true)
if err != nil {
t.Fatal(err, cleanJSON)

View file

@ -42,8 +42,7 @@ func NewTraefikConfiguration() *TraefikConfiguration {
return &TraefikConfiguration{
Configuration: static.Configuration{
Global: &static.Global{
CheckNewVersion: true,
SendAnonymousUsage: false,
CheckNewVersion: true,
},
EntryPoints: make(static.EntryPoints),
Providers: &static.Providers{

View file

@ -383,7 +383,15 @@ func checkNewVersion() {
}
func stats(staticConfiguration *static.Configuration) {
if staticConfiguration.Global.SendAnonymousUsage {
if staticConfiguration.Global.SendAnonymousUsage == nil {
log.WithoutContext().Error(`
You haven't specify the sendAnonymousUsage option, it will be enable by default.
`)
sendAnonymousUsage := true
staticConfiguration.Global.SendAnonymousUsage = &sendAnonymousUsage
}
if *staticConfiguration.Global.SendAnonymousUsage {
log.WithoutContext().Info(`
Stats collection is enabled.
Many thanks for contributing to Traefik's improvement by allowing us to receive anonymous information from your configuration.

View file

@ -18,7 +18,7 @@ import (
)
// collectorURL URL where the stats are send
const collectorURL = "https://collect.traefik.io/619df80498b60f985d766ce62f912b7c"
const collectorURL = "https://collect.traefik.io/9vxmmkcdmalbdi635d4jgc5p5rx0h7h8"
// Collected data
type data struct {

View file

@ -75,9 +75,9 @@ type Configuration struct {
// Global holds the global configuration.
type Global struct {
Debug bool `short:"d" description:"Enable debug mode" export:"true"`
CheckNewVersion bool `description:"Periodically check if a new version has been released" export:"true"`
SendAnonymousUsage bool `description:"send periodically anonymous usage statistics" export:"true"`
Debug bool `short:"d" description:"Enable debug mode" export:"true"`
CheckNewVersion bool `description:"Periodically check if a new version has been released" export:"true"`
SendAnonymousUsage *bool `description:"send periodically anonymous usage statistics" export:"true"`
}
// ServersTransport options to configure communication between Traefik and the servers

View file

@ -5,15 +5,17 @@ Understanding How Traefik is Being Used
## Configuration Example
**By default, this feature is disabled;** but to allow us understand better how you use Traefik, please enable the data collection option.
Understanding how you use Traefik is very important to us: it helps us improve the solution in many different ways.
For this very reason, the sendAnonymousUsage option is mandatory: we want you to take time to consider whether or not you wish to share anonymous data with us so we can benefit from your experience and use cases.
!!! warning
During the alpha stage only, leaving this option unset will not prevent Traefik from running but will generate an error log indicating that it enables data collection by default.
??? example "Enabling Data Collection with TOML"
```toml
[Global]
# Send anonymous usage data
# Default: false
#
sendAnonymousUsage = true
```

View file

@ -4,6 +4,7 @@ filePath = "traefik.log"
[global]
checkNewVersion = false
sendAnonymousUsage = false
[accessLog]
filePath = "access.log"