1212// See the License for the specific language governing permissions and
1313// limitations under the License.
1414
15- package prometheus
15+ package prometheus_test
1616
1717import (
1818 "testing"
@@ -24,17 +24,22 @@ import (
2424 "github.com/stretchr/testify/require"
2525
2626 "github.com/uber/jaeger-lib/metrics"
27+ . "github.com/uber/jaeger-lib/metrics/prometheus"
2728)
2829
2930var _ metrics.Factory = new (Factory )
3031
32+ func TestOptions (t * testing.T ) {
33+ f1 := New ()
34+ assert .NotNil (t , f1 )
35+ }
36+
3137func TestCounter (t * testing.T ) {
3238 registry := prometheus .NewPedanticRegistry ()
33- f1 := New (registry , nil )
39+ f1 := New (WithRegisterer ( registry ) )
3440 fDummy := f1 .Namespace ("" , nil )
3541 f2 := fDummy .Namespace ("bender" , map [string ]string {"a" : "b" })
3642 f3 := f2 .Namespace ("" , nil )
37- assert .Equal (t , "bender" , f3 .(* Factory ).scope )
3843
3944 c1 := f2 .Counter ("rodriguez" , map [string ]string {"x" : "y" })
4045 c2 := f2 .Counter ("rodriguez" , map [string ]string {"x" : "z" })
@@ -56,7 +61,7 @@ func TestCounter(t *testing.T) {
5661
5762func TestGauge (t * testing.T ) {
5863 registry := prometheus .NewPedanticRegistry ()
59- f1 := New (registry , nil )
64+ f1 := New (WithRegisterer ( registry ) )
6065 f2 := f1 .Namespace ("bender" , map [string ]string {"a" : "b" })
6166 f3 := f2 .Namespace ("" , map [string ]string {"a" : "b" }) // essentially same as f2
6267 g1 := f2 .Gauge ("rodriguez" , map [string ]string {"x" : "y" })
@@ -79,7 +84,7 @@ func TestGauge(t *testing.T) {
7984
8085func TestTimer (t * testing.T ) {
8186 registry := prometheus .NewPedanticRegistry ()
82- f1 := New (registry , nil )
87+ f1 := New (WithRegisterer ( registry ) )
8388 f2 := f1 .Namespace ("bender" , map [string ]string {"a" : "b" })
8489 f3 := f2 .Namespace ("" , map [string ]string {"a" : "b" }) // essentially same as f2
8590 t1 := f2 .Timer ("rodriguez" , map [string ]string {"x" : "y" })
@@ -122,7 +127,7 @@ func TestTimer(t *testing.T) {
122127
123128func TestTimerCustomBuckets (t * testing.T ) {
124129 registry := prometheus .NewPedanticRegistry ()
125- f1 := New (registry , []float64 {1.5 })
130+ f1 := New (WithRegisterer ( registry ), WithBuckets ( []float64 {1.5 }) )
126131 // dot and dash in the metric name will be replaced with underscore
127132 t1 := f1 .Timer ("bender.bending-rodriguez" , map [string ]string {"x" : "y" })
128133 t1 .Record (1 * time .Second )
0 commit comments