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

Add an --interface-names flag #342

Merged
merged 2 commits into from
Nov 2, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
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
21 changes: 17 additions & 4 deletions cmd/refinery/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,11 @@ var BuildID string
var version string

type Options struct {
ConfigFile string `short:"c" long:"config" description:"Path to config file" default:"/etc/refinery/refinery.toml"`
RulesFile string `short:"r" long:"rules_config" description:"Path to rules config file" default:"/etc/refinery/rules.toml"`
Version bool `short:"v" long:"version" description:"Print version number and exit"`
Debug bool `short:"d" long:"debug" description:"If enabled, runs debug service (runs on the first open port between localhost:6060 and :6069 by default)"`
ConfigFile string `short:"c" long:"config" description:"Path to config file" default:"/etc/refinery/refinery.toml"`
RulesFile string `short:"r" long:"rules_config" description:"Path to rules config file" default:"/etc/refinery/rules.toml"`
Version bool `short:"v" long:"version" description:"Print version number and exit"`
Debug bool `short:"d" long:"debug" description:"If enabled, runs debug service (runs on the first open port between localhost:6060 and :6069 by default)"`
InterfaceNames bool `long:"interface-names" description:"If set, print system's network interface names and exit."`
}

func main() {
Expand All @@ -58,6 +59,18 @@ func main() {
os.Exit(0)
}

if opts.InterfaceNames {
ifaces, err := net.Interfaces()
if err != nil {
fmt.Printf("Error: %s\n", err)
os.Exit(1)
}
for _, i := range ifaces {
fmt.Println(i.Name)
}
os.Exit(0)
}

a := app.App{
Version: version,
}
Expand Down
10 changes: 5 additions & 5 deletions collect/collect_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -320,14 +320,14 @@ func TestCacheSizeReload(t *testing.T) {
coll.AddSpan(&types.Span{TraceID: "2", Event: event})

expectedEvents := 1
wait := 2 * time.Millisecond
wait := 1 * time.Second
check := func() bool {
transmission.Mux.RLock()
defer transmission.Mux.RUnlock()

return len(transmission.Events) == expectedEvents
}
assert.Eventually(t, check, 10*wait, wait, "expected one trace evicted and sent")
assert.Eventually(t, check, 60*wait, wait, "expected one trace evicted and sent")

conf.Mux.Lock()
conf.GetInMemoryCollectorCacheCapacityVal.CacheCapacity = 2
Expand All @@ -339,7 +339,7 @@ func TestCacheSizeReload(t *testing.T) {
defer coll.mutex.RUnlock()

return coll.cache.(*cache.DefaultInMemCache).GetCacheSize() == 2
}, 10*wait, wait, "cache size to change")
}, 60*wait, wait, "cache size to change")

coll.AddSpan(&types.Span{TraceID: "3", Event: event})
time.Sleep(5 * conf.SendTickerVal)
Expand All @@ -351,7 +351,7 @@ func TestCacheSizeReload(t *testing.T) {
conf.ReloadConfig()

expectedEvents = 2
assert.Eventually(t, check, 10*wait, wait, "expected another trace evicted and sent")
assert.Eventually(t, check, 60*wait, wait, "expected another trace evicted and sent")
}

func TestSampleConfigReload(t *testing.T) {
Expand All @@ -361,7 +361,7 @@ func TestSampleConfigReload(t *testing.T) {

conf := &config.MockConfig{
GetSendDelayVal: 0,
GetTraceTimeoutVal: 10 * time.Millisecond,
GetTraceTimeoutVal: 60 * time.Second,
GetSamplerTypeVal: &config.DeterministicSamplerConfig{SampleRate: 1},
SendTickerVal: 2 * time.Millisecond,
GetInMemoryCollectorCacheCapacityVal: config.InMemoryCollectorCacheCapacity{CacheCapacity: 10},
Expand Down