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

Unified Diff: logdog/client/butler/butler.go

Issue 2595993002: Add Butler global tags. (Closed)
Patch Set: Mutate existing map. Created 4 years 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 | « no previous file | logdog/client/cmd/logdog_butler/main.go » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: logdog/client/butler/butler.go
diff --git a/logdog/client/butler/butler.go b/logdog/client/butler/butler.go
index 80b0d04cf94be17b921e34e2b8811c5a6f89f7b5..f8a1d134fcd77ffbb5410fb03018a9b478255ef7 100644
--- a/logdog/client/butler/butler.go
+++ b/logdog/client/butler/butler.go
@@ -25,6 +25,7 @@ import (
"github.com/luci/luci-go/logdog/client/butler/streamserver"
"github.com/luci/luci-go/logdog/client/butlerlib/streamproto"
"github.com/luci/luci-go/logdog/common/types"
+
"golang.org/x/net/context"
)
@@ -56,6 +57,11 @@ type Config struct {
// Prefix is the log stream common prefix value.
Prefix types.StreamName
+ // GlobalTags are a set of global log stream tags to apply to individual
+ // streams on registration. Individual stream tags will override tags with
+ // the same key.
+ GlobalTags streamproto.TagMap
+
// BufferLogs, if true, instructs the butler to buffer collected log data
// before sending it to Output.
BufferLogs bool
@@ -398,6 +404,17 @@ func (b *Butler) AddStream(rc io.ReadCloser, p *streamproto.Properties) error {
return err
}
+ // Build per-stream tag map.
+ if l := len(b.c.GlobalTags); l > 0 {
+ for k, v := range b.c.GlobalTags {
+ // Add only global flags that aren't already present (overridden) in
+ // stream tags.
+ if _, ok := p.Tags[k]; !ok {
+ p.Tags[k] = v
+ }
+ }
+ }
+
if p.Timeout > 0 {
if rts, ok := rc.(iotools.ReadTimeoutSetter); ok {
if err := rts.SetReadTimeout(p.Timeout); err != nil {
« no previous file with comments | « no previous file | logdog/client/cmd/logdog_butler/main.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698