Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(7)

Unified Diff: client/cmd/isolate/isolate_event_logger.go

Issue 2922153002: Log uses of isolate archive and exparchive when 'chromium' build tag is set.
Patch Set: use build tags to enable autologging Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « client/cmd/isolate/exp_archive.go ('k') | client/cmd/isolate/no_build_chromium.go » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..1d424dc45fd71bf852096580bfb3041cdf2deaaf 100644
--- a/client/cmd/isolate/isolate_event_logger.go
+++ b/client/cmd/isolate/isolate_event_logger.go
@@ -13,8 +13,31 @@ 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"
)
+// eventlogEndpoint returns a destination URL for eventlogs, based on the contents of
+// the endpointFlag.
+func eventlogEndpoint(ctx context.Context, endpointFlag string) string {
+ switch endpointFlag {
+ case "auto":
+ if autoEventlog() {
+ 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 +53,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 +86,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.
« no previous file with comments | « client/cmd/isolate/exp_archive.go ('k') | client/cmd/isolate/no_build_chromium.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698