Chromium Code Reviews| Index: client/cmd/isolate/isolate_event_logger.go |
| diff --git a/client/cmd/isolate/isolate_event_logger.go b/client/cmd/isolate/isolate_event_logger.go |
| index 4878f1d4ac7894d542bd00c29f5b8856b5e1cbd9..1a68933607c37bac27909ea4fa0a2330cc84fc68 100644 |
| --- a/client/cmd/isolate/isolate_event_logger.go |
| +++ b/client/cmd/isolate/isolate_event_logger.go |
| @@ -13,8 +13,35 @@ import ( |
| "github.com/golang/protobuf/proto" |
| "github.com/luci/luci-go/common/eventlog" |
| logpb "github.com/luci/luci-go/common/eventlog/proto" |
| + "github.com/luci/luci-go/common/logging" |
| ) |
| +// When --eventlog-endpoint=auto, we decide to send eventlogs based on whether --isolate-server matches prodIsolateServer |
|
M-A Ruel
2017/06/08 14:06:05
I don't understand why we don't want to log everyw
mcgreevy
2017/06/08 23:19:01
The reason is that luci-go is an open source proje
|
| +const prodIsolateServer = "https://isolateserver.appspot.com" |
| + |
| +// eventlogEndpoint returns a destination URL for eventlogs, based on the contents of |
| +// the endpointFlag and isolateServerFlag. |
| +func eventlogEndpoint(ctx context.Context, endpointFlag string, isolateServerFlag string) string { |
| + switch endpointFlag { |
| + case "auto": |
| + if isolateServerFlag == prodIsolateServer { |
| + // If we are uploading to the prod server, we log this activity. |
| + msg := "Automatically logging usage statistics to %s. If this is not desired, then set --eventlog-endpoint=none" |
| + logging.Infof(ctx, msg, eventlog.ProdEndpoint) |
| + return eventlog.ProdEndpoint |
| + } |
| + return "" |
| + case "test": |
| + return eventlog.TestEndpoint |
| + case "prod": |
| + return eventlog.ProdEndpoint |
| + case "none": |
| + return "" |
| + default: |
| + return endpointFlag |
| + } |
| +} |
| + |
| type syncLogger interface { |
| LogSync(ctx context.Context, events ...*eventlog.ChromeInfraLogEvent) error |
| NewLogEvent(ctx context.Context, eventTime eventlog.TypedTime) *eventlog.ChromeInfraLogEvent |
| @@ -30,10 +57,11 @@ type IsolateEventLogger struct { |
| } |
| // NewLogger returns an IsolateEventLogger which logs to the specified endpoint. |
| +// endpoint is the URL to which logs will be sent. |
| func NewLogger(ctx context.Context, endpoint string) *IsolateEventLogger { |
| l := &IsolateEventLogger{} |
| - if host := eventlogEndpoint(endpoint); host != "" { |
| - l.client = eventlog.NewClient(ctx, host) |
| + if endpoint != "" { |
| + l.client = eventlog.NewClient(ctx, endpoint) |
| } |
| return l |
| } |
| @@ -62,17 +90,6 @@ func (l *IsolateEventLogger) logStats(ctx context.Context, op *logpb.IsolateClie |
| return l.client.LogSync(ctx, event) |
| } |
| -func eventlogEndpoint(endpointFlag string) string { |
| - switch endpointFlag { |
| - case "test": |
| - return eventlog.TestEndpoint |
| - case "prod": |
| - return eventlog.ProdEndpoint |
| - default: |
| - return endpointFlag |
| - } |
| -} |
| - |
| // buildbotInfo contains information about the build in which this command was run. |
| type buildbotInfo struct { |
| // Variables which are not present in the environment are nil. |