github.com/jeffalder/nr.yml/v3@v3.0.1-0.20200721182236-9572b92f5925/nr_yml/infinite_tracing_test.go (about) 1 // Copyright 2020, Jeff Alder 2 // 3 // Licensed under the Apache License, Version 2.0 (the "License"); 4 // you may not use this file except in compliance with the License. 5 // You may obtain a copy of the License at 6 // 7 // http://www.apache.org/licenses/LICENSE-2.0 8 // 9 // Unless required by applicable law or agreed to in writing, software 10 // distributed under the License is distributed on an "AS IS" BASIS, 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 // See the License for the specific language governing permissions and 13 // limitations under the License. 14 package nr_yml 15 16 import ( 17 "github.com/newrelic/go-agent/v3/newrelic" 18 "github.com/stretchr/testify/assert" 19 "testing" 20 ) 21 22 func TestHostAndQueueSize(t *testing.T) { 23 withContents(` 24 production: 25 infinite_tracing: 26 trace_observer: 27 host: my-trace-observer 28 span_events: 29 queue_size: 340382 30 `, t, func(filename string, t *testing.T) { 31 cfg := new(newrelic.Config) 32 ConfigFromYamlFile(filename)(cfg) 33 assert.NoError(t, cfg.Error) 34 assert.Equal(t, "my-trace-observer", cfg.InfiniteTracing.TraceObserver.Host) 35 assert.Equal(t, 340382, cfg.InfiniteTracing.SpanEvents.QueueSize) 36 }) 37 } 38 39 func TestPort(t *testing.T) { 40 withContents(` 41 production: 42 infinite_tracing: 43 trace_observer: 44 port: 3402 45 `, t, func(filename string, t *testing.T) { 46 cfg := new(newrelic.Config) 47 ConfigFromYamlFile(filename)(cfg) 48 assert.NoError(t, cfg.Error) 49 assert.Equal(t, 3402, cfg.InfiniteTracing.TraceObserver.Port) 50 }) 51 } 52 53 func TestTraceObserverHostNoOverwrite(t *testing.T) { 54 withContents(` 55 production: 56 infinite_tracing: 57 trace_observer: 58 `, t, func(filename string, t *testing.T) { 59 cfg := new(newrelic.Config) 60 cfg.InfiniteTracing.TraceObserver.Host = "previous-host" 61 ConfigFromYamlFile(filename)(cfg) 62 assert.NoError(t, cfg.Error) 63 assert.Equal(t, "previous-host", cfg.InfiniteTracing.TraceObserver.Host) 64 }) 65 } 66 67 func TestSpanEventsNoOverwrite(t *testing.T) { 68 withContents(` 69 production: 70 infinite_tracing: 71 span_events: 72 `, t, func(filename string, t *testing.T) { 73 cfg := new(newrelic.Config) 74 cfg.InfiniteTracing.SpanEvents.QueueSize = 340382 75 ConfigFromYamlFile(filename)(cfg) 76 assert.NoError(t, cfg.Error) 77 assert.Equal(t, 340382, cfg.InfiniteTracing.SpanEvents.QueueSize) 78 }) 79 }