Tidying up the new Metrics implementations (#1974)
* Unit tests to check tagging and aggregation of Prometheus metrics * Removing the logger output routing (because it doesn't actually work in the logger implementation) * Emitting values with the logging reporter Co-authored-by: chris <chris@Profanity.local>
This commit is contained in:
		| @@ -1,11 +1,9 @@ | ||||
| package logging | ||||
|  | ||||
| import ( | ||||
| 	"bytes" | ||||
| 	"testing" | ||||
| 	"time" | ||||
|  | ||||
| 	log "github.com/micro/go-micro/v3/logger" | ||||
| 	"github.com/micro/go-micro/v3/metrics" | ||||
|  | ||||
| 	"github.com/stretchr/testify/assert" | ||||
| @@ -20,10 +18,6 @@ func TestLoggingReporter(t *testing.T) { | ||||
| 	assert.Equal(t, ":9000", reporter.options.Address) | ||||
| 	assert.Equal(t, "/prometheus", reporter.options.Path) | ||||
|  | ||||
| 	// Make a log buffer and create a new logger to use it: | ||||
| 	logBuffer := new(bytes.Buffer) | ||||
| 	reporter.logger = log.NewLogger(log.WithLevel(log.TraceLevel), log.WithOutput(logBuffer), log.WithFields(convertTags(reporter.options.DefaultTags))) | ||||
|  | ||||
| 	// Check that our implementation is valid: | ||||
| 	assert.Implements(t, new(metrics.Reporter), reporter) | ||||
|  | ||||
| @@ -45,7 +39,4 @@ func TestLoggingReporter(t *testing.T) { | ||||
| 	assert.NoError(t, reporter.Gauge("test.gauge.1", 98, tags)) | ||||
| 	assert.NoError(t, reporter.Timing("test.timing.1", time.Second, tags)) | ||||
| 	assert.NoError(t, reporter.Timing("test.timing.2", time.Minute, tags)) | ||||
|  | ||||
| 	// Test reading back the metrics from the logbuffer (doesn't seem to work because the output still goes to StdOut): | ||||
| 	// assert.Contains(t, logBuffer.String(), "level=debug service=prometheus-test Count metric: map[tag1:false tag2:true]") | ||||
| } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user