Skip to content
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

[cassandra] Blacklisting/Whitelisting Tags for Indexing #1904

Merged
merged 23 commits into from
Nov 9, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Added configuration and CLI support
Signed-off-by: Joe Elliott <number101010@gmail.com>
  • Loading branch information
joe-elliott committed Nov 6, 2019
commit 3fdbae6dfd606aeefc944426b42a431b0cf33cb6
2 changes: 2 additions & 0 deletions pkg/cassandra/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ type Configuration struct {
DisableAutoDiscovery bool `yaml:"disable_auto_discovery"`
EnableDependenciesV2 bool `yaml:"enable_dependencies_v2"`
TLS TLS
TagIndexWhitelist []string `yaml:"tag-index-whitelist"`
TagIndexBlacklist []string `yaml:"tag-index-blacklist"`
joe-elliott marked this conversation as resolved.
Show resolved Hide resolved
}

// Authenticator holds the authentication properties needed to connect to a Cassandra cluster
Expand Down
32 changes: 28 additions & 4 deletions plugin/storage/cassandra/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ const (
suffixServerName = ".tls.server-name"
suffixVerifyHost = ".tls.verify-host"
suffixEnableDependenciesV2 = ".enable-dependencies-v2"
suffixTagIndexBlacklist = ".tag-index-blacklist"
suffixTagIndexWhitelist = ".tag-index-whitelist"

// common storage settings
suffixSpanStoreWriteCacheTTL = ".span-store-write-cache-ttl"
Expand All @@ -69,10 +71,12 @@ type Options struct {
// preparing the actual config.Configuration.
type namespaceConfig struct {
config.Configuration
servers string
namespace string
primary bool
Enabled bool
servers string
tagIndexBlacklist string
tagIndexWhitelist string
namespace string
primary bool
Enabled bool
}

// NewOptions creates a new Options struct.
Expand Down Expand Up @@ -213,6 +217,14 @@ func addFlags(flagSet *flag.FlagSet, nsConfig *namespaceConfig) {
nsConfig.namespace+suffixEnableDependenciesV2,
nsConfig.EnableDependenciesV2,
"(deprecated) Jaeger will automatically detect the version of the dependencies table")
flagSet.String(
nsConfig.namespace+suffixTagIndexBlacklist,
nsConfig.tagIndexWhitelist,
"The comma-separated list of tags to blacklist")
flagSet.String(
nsConfig.namespace+suffixTagIndexWhitelist,
nsConfig.tagIndexBlacklist,
"The comma-separated list of tags to whitelist")
}

// InitFromViper initializes Options with properties from viper
Expand Down Expand Up @@ -250,11 +262,15 @@ func (cfg *namespaceConfig) initFromViper(v *viper.Viper) {
cfg.TLS.EnableHostVerification = v.GetBool(cfg.namespace + suffixVerifyHost)
cfg.EnableDependenciesV2 = v.GetBool(cfg.namespace + suffixEnableDependenciesV2)
cfg.DisableCompression = v.GetBool(cfg.namespace + suffixDisableCompression)
cfg.tagIndexBlacklist = stripWhiteSpace(v.GetString(cfg.namespace + suffixTagIndexBlacklist))
cfg.tagIndexWhitelist = stripWhiteSpace(v.GetString(cfg.namespace + suffixTagIndexWhitelist))
}

// GetPrimary returns primary configuration.
func (opt *Options) GetPrimary() *config.Configuration {
opt.primary.Servers = strings.Split(opt.primary.servers, ",")
opt.primary.TagIndexBlacklist = strings.Split(opt.primary.tagIndexBlacklist, ",")
opt.primary.TagIndexWhitelist = strings.Split(opt.primary.tagIndexWhitelist, ",")
return &opt.primary.Configuration
}

Expand All @@ -273,6 +289,14 @@ func (opt *Options) Get(namespace string) *config.Configuration {
nsCfg.servers = opt.primary.servers
}
nsCfg.Servers = strings.Split(nsCfg.servers, ",")
if nsCfg.tagIndexBlacklist == "" {
nsCfg.tagIndexBlacklist = opt.primary.tagIndexBlacklist
}
nsCfg.TagIndexBlacklist = strings.Split(nsCfg.tagIndexBlacklist, ",")
if nsCfg.tagIndexWhitelist == "" {
nsCfg.tagIndexWhitelist = opt.primary.tagIndexWhitelist
}
nsCfg.TagIndexWhitelist = strings.Split(nsCfg.tagIndexWhitelist, ",")
return &nsCfg.Configuration
}

Expand Down
9 changes: 9 additions & 0 deletions plugin/storage/cassandra/options_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ func TestOptions(t *testing.T) {
assert.Equal(t, primary.Servers, aux.Servers)
assert.Equal(t, primary.ConnectionsPerHost, aux.ConnectionsPerHost)
assert.Equal(t, primary.ReconnectInterval, aux.ReconnectInterval)
assert.Equal(t, primary.TagIndexBlacklist, aux.TagIndexBlacklist)
assert.Equal(t, primary.TagIndexWhitelist, aux.TagIndexWhitelist)
}

func TestOptionsWithFlags(t *testing.T) {
Expand All @@ -60,11 +62,14 @@ func TestOptionsWithFlags(t *testing.T) {
"--cas.consistency=ONE",
"--cas.proto-version=3",
"--cas.socket-keep-alive=42s",
"--cas.tag-index-blacklist=blerg, blarg,blorg ",
"--cas.tag-index-whitelist=blerg, blarg,blorg ",
// enable aux with a couple overrides
"--cas-aux.enabled=true",
"--cas-aux.keyspace=jaeger-archive",
"--cas-aux.servers=3.3.3.3, 4.4.4.4",
"--cas-aux.enable-dependencies-v2=true",
"--cas-aux.tag-index-whitelist=foo,bar",
joe-elliott marked this conversation as resolved.
Show resolved Hide resolved
})
opts.InitFromViper(v)

Expand All @@ -74,6 +79,8 @@ func TestOptionsWithFlags(t *testing.T) {
assert.Equal(t, []string{"1.1.1.1", "2.2.2.2"}, primary.Servers)
assert.Equal(t, "ONE", primary.Consistency)
assert.Equal(t, false, primary.EnableDependenciesV2)
assert.Equal(t, []string{"blerg", "blarg", "blorg"}, primary.TagIndexBlacklist)
assert.Equal(t, []string{"blerg", "blarg", "blorg"}, primary.TagIndexWhitelist)

aux := opts.Get("cas-aux")
require.NotNil(t, aux)
Expand All @@ -88,4 +95,6 @@ func TestOptionsWithFlags(t *testing.T) {
assert.Equal(t, 3, aux.ProtoVersion)
assert.Equal(t, 42*time.Second, aux.SocketKeepAlive)
assert.Equal(t, true, aux.EnableDependenciesV2)
assert.Equal(t, []string{"blerg", "blarg", "blorg"}, aux.TagIndexBlacklist)
assert.Equal(t, []string{"foo", "bar"}, aux.TagIndexWhitelist)
}