1// Copyright (c) 2017 Uber Technologies, Inc. 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 15package jaeger 16 17import ( 18 "testing" 19 20 "github.com/stretchr/testify/require" 21 "github.com/uber/jaeger-lib/metrics/metricstest" 22) 23 24func TestNewMetrics(t *testing.T) { 25 factory := metricstest.NewFactory(0) 26 m := NewMetrics(factory, map[string]string{"lib": "jaeger"}) 27 28 require.NotNil(t, m.SpansStartedSampled, "counter not initialized") 29 require.NotNil(t, m.ReporterQueueLength, "gauge not initialized") 30 31 m.SpansStartedSampled.Inc(1) 32 m.ReporterQueueLength.Update(11) 33 factory.AssertCounterMetrics(t, 34 metricstest.ExpectedMetric{ 35 Name: "jaeger.tracer.started_spans", 36 Tags: map[string]string{"lib": "jaeger", "sampled": "y"}, 37 Value: 1, 38 }, 39 ) 40 factory.AssertGaugeMetrics(t, 41 metricstest.ExpectedMetric{ 42 Name: "jaeger.tracer.reporter_queue_length", 43 Tags: map[string]string{"lib": "jaeger"}, 44 Value: 11, 45 }, 46 ) 47} 48