You've already forked opentelemetry-go
mirror of
https://github.com/open-telemetry/opentelemetry-go.git
synced 2025-07-15 01:04:25 +02:00
Separate InstrumentationLibrary from metric.Descriptor (#2197)
* factor instrumentation library out of the instrument descriptor * SDK tests pass * checkpoint work * otlp and opencensus tests passing * prometheus * tests pass, working on lint * lint applied: MetricReader->Reader * comments * Changelog * Apply suggestions from code review Co-authored-by: alrex <alrex.boten@gmail.com> * remove an interdependency * fix build * re-indent one * Apply suggestions from code review Co-authored-by: Tyler Yahn <MrAlias@users.noreply.github.com> * Lint&feedback * update after rename * comment fix * style fix for meter options * remove libraryReader, let Controller implement the reader API directly * rename 'impl' field to 'provider' * remove a type assertion * move metric/registry into internal; move registry.MeterProvider into metric controller * add test for controller registry function * CheckpointSet->Reader everywhere * lint * remove two unnecessary accessor methods; Controller implements MeterProvider and InstrumentationLibraryReader directly, no need to get these * use a sync.Map * ensure the initOnce is always called; handle multiple errors * Apply suggestions from code review Co-authored-by: Anthony Mirabella <a9@aneurysm9.com> * cleanup locking in metrictest * Revert "ensure the initOnce is always called; handle multiple errors" This reverts commit3356eb5ed0
. * Revert "use a sync.Map" This reverts commitea7bc599bd
. * restore the TODO about sync.Map Co-authored-by: alrex <alrex.boten@gmail.com> Co-authored-by: Tyler Yahn <MrAlias@users.noreply.github.com> Co-authored-by: Anthony Mirabella <a9@aneurysm9.com>
This commit is contained in:
@ -34,7 +34,7 @@ import (
|
||||
|
||||
func TestPullNoCollect(t *testing.T) {
|
||||
puller := controller.New(
|
||||
processor.New(
|
||||
processor.NewFactory(
|
||||
processortest.AggregatorSelector(),
|
||||
export.CumulativeExportKindSelector(),
|
||||
processor.WithMemory(true),
|
||||
@ -44,14 +44,14 @@ func TestPullNoCollect(t *testing.T) {
|
||||
)
|
||||
|
||||
ctx := context.Background()
|
||||
meter := puller.MeterProvider().Meter("nocache")
|
||||
meter := puller.Meter("nocache")
|
||||
counter := metric.Must(meter).NewInt64Counter("counter.sum")
|
||||
|
||||
counter.Add(ctx, 10, attribute.String("A", "B"))
|
||||
|
||||
require.NoError(t, puller.Collect(ctx))
|
||||
records := processortest.NewOutput(attribute.DefaultEncoder())
|
||||
require.NoError(t, puller.ForEach(export.CumulativeExportKindSelector(), records.AddRecord))
|
||||
require.NoError(t, controllertest.ReadAll(puller, export.CumulativeExportKindSelector(), records.AddInstrumentationLibraryRecord))
|
||||
|
||||
require.EqualValues(t, map[string]float64{
|
||||
"counter.sum/A=B/": 10,
|
||||
@ -61,7 +61,7 @@ func TestPullNoCollect(t *testing.T) {
|
||||
|
||||
require.NoError(t, puller.Collect(ctx))
|
||||
records = processortest.NewOutput(attribute.DefaultEncoder())
|
||||
require.NoError(t, puller.ForEach(export.CumulativeExportKindSelector(), records.AddRecord))
|
||||
require.NoError(t, controllertest.ReadAll(puller, export.CumulativeExportKindSelector(), records.AddInstrumentationLibraryRecord))
|
||||
|
||||
require.EqualValues(t, map[string]float64{
|
||||
"counter.sum/A=B/": 20,
|
||||
@ -70,7 +70,7 @@ func TestPullNoCollect(t *testing.T) {
|
||||
|
||||
func TestPullWithCollect(t *testing.T) {
|
||||
puller := controller.New(
|
||||
processor.New(
|
||||
processor.NewFactory(
|
||||
processortest.AggregatorSelector(),
|
||||
export.CumulativeExportKindSelector(),
|
||||
processor.WithMemory(true),
|
||||
@ -82,14 +82,14 @@ func TestPullWithCollect(t *testing.T) {
|
||||
puller.SetClock(mock)
|
||||
|
||||
ctx := context.Background()
|
||||
meter := puller.MeterProvider().Meter("nocache")
|
||||
meter := puller.Meter("nocache")
|
||||
counter := metric.Must(meter).NewInt64Counter("counter.sum")
|
||||
|
||||
counter.Add(ctx, 10, attribute.String("A", "B"))
|
||||
|
||||
require.NoError(t, puller.Collect(ctx))
|
||||
records := processortest.NewOutput(attribute.DefaultEncoder())
|
||||
require.NoError(t, puller.ForEach(export.CumulativeExportKindSelector(), records.AddRecord))
|
||||
require.NoError(t, controllertest.ReadAll(puller, export.CumulativeExportKindSelector(), records.AddInstrumentationLibraryRecord))
|
||||
|
||||
require.EqualValues(t, map[string]float64{
|
||||
"counter.sum/A=B/": 10,
|
||||
@ -100,7 +100,7 @@ func TestPullWithCollect(t *testing.T) {
|
||||
// Cached value!
|
||||
require.NoError(t, puller.Collect(ctx))
|
||||
records = processortest.NewOutput(attribute.DefaultEncoder())
|
||||
require.NoError(t, puller.ForEach(export.CumulativeExportKindSelector(), records.AddRecord))
|
||||
require.NoError(t, controllertest.ReadAll(puller, export.CumulativeExportKindSelector(), records.AddInstrumentationLibraryRecord))
|
||||
|
||||
require.EqualValues(t, map[string]float64{
|
||||
"counter.sum/A=B/": 10,
|
||||
@ -112,7 +112,7 @@ func TestPullWithCollect(t *testing.T) {
|
||||
// Re-computed value!
|
||||
require.NoError(t, puller.Collect(ctx))
|
||||
records = processortest.NewOutput(attribute.DefaultEncoder())
|
||||
require.NoError(t, puller.ForEach(export.CumulativeExportKindSelector(), records.AddRecord))
|
||||
require.NoError(t, controllertest.ReadAll(puller, export.CumulativeExportKindSelector(), records.AddInstrumentationLibraryRecord))
|
||||
|
||||
require.EqualValues(t, map[string]float64{
|
||||
"counter.sum/A=B/": 20,
|
||||
|
Reference in New Issue
Block a user