Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

otlpmetric with slice-valued attributes not merge #2573

Closed
forsaken628 opened this issue Jan 30, 2022 · 2 comments
Closed

otlpmetric with slice-valued attributes not merge #2573

forsaken628 opened this issue Jan 30, 2022 · 2 comments
Labels
bug Something isn't working

Comments

@forsaken628
Copy link

forsaken628 commented Jan 30, 2022

Description

otlpmetric with slice-valued attributes not merge

Environment

go.opentelemetry.io/otel v1.3.0
go.opentelemetry.io/otel/exporters/stdout/stdoutmetric v0.26.0
go.opentelemetry.io/otel/metric v0.26.0
go.opentelemetry.io/otel/sdk v1.3.0
go.opentelemetry.io/otel/sdk/export/metric v0.26.0
go.opentelemetry.io/otel/sdk/metric v0.26.0
go.opentelemetry.io/otel/trace v1.3.0

Steps To Reproduce

package example

import (
	"context"
	"math/rand"
	"testing"
	"time"

	"github.com/stretchr/testify/require"
	"go.opentelemetry.io/otel/attribute"
	"go.opentelemetry.io/otel/exporters/stdout/stdoutmetric"
	controller "go.opentelemetry.io/otel/sdk/metric/controller/basic"
	processor "go.opentelemetry.io/otel/sdk/metric/processor/basic"
	"go.opentelemetry.io/otel/sdk/metric/selector/simple"
)

func TestIssue(t *testing.T) {
	t.Run("attribute", func(t *testing.T) {
		set0 := attribute.NewSet(attribute.StringSlice("a", []string{"a"}))
		set1 := attribute.NewSet(attribute.StringSlice("a", []string{"a"}))
		t.Log(set0.Equals(&set1)) // false
	})

	exp, err := stdoutmetric.New(stdoutmetric.WithPrettyPrint())
	require.NoError(t, err)

	pusher := controller.New(
		processor.NewFactory(
			simple.NewWithHistogramDistribution(),
			exp,
		),
		controller.WithExporter(exp),
		controller.WithCollectPeriod(time.Second),
	)
	_ = pusher.Start(context.Background())

	histogram, err := pusher.Meter("test").NewInt64Histogram("test")
	require.NoError(t, err)

	for {
		time.Sleep(time.Millisecond * 100)
		histogram.Record(context.Background(), 1, attribute.StringSlice("a", []string{"a"}))
		histogram.Record(context.Background(), int64(rand.Intn(10)), attribute.String("b", "b"))
	}
}
// [
//	{
//		"Name": "test{service.name=unknown_service:xxx,telemetry.sdk.language=go,telemetry.sdk.name=opentelemetry,telemetry.sdk.version=1.3.0,instrumentation.name=test,b=b}",
//		"Sum": 44
//	},
//	{
//		"Name": "test{service.name=unknown_service:xxx,telemetry.sdk.language=go,telemetry.sdk.name=opentelemetry,telemetry.sdk.version=1.3.0,instrumentation.name=test,a=[a]}",
//		"Sum": 1
//	},
//	{
//		"Name": "test{service.name=unknown_service:xxx,telemetry.sdk.language=go,telemetry.sdk.name=opentelemetry,telemetry.sdk.version=1.3.0,instrumentation.name=test,a=[a]}",
//		"Sum": 1
//	},
//  ...
// ]

Expected behavior

Aggregator should merge by dimension?

link #2223

Expected output

[
	{
		"Name": "test{service.name=unknown_service:xxx,telemetry.sdk.language=go,telemetry.sdk.name=opentelemetry,telemetry.sdk.version=1.3.0,instrumentation.name=test,b=b}",
		"Sum": 44
	},
	{
		"Name": "test{service.name=unknown_service:xxx,telemetry.sdk.language=go,telemetry.sdk.name=opentelemetry,telemetry.sdk.version=1.3.0,instrumentation.name=test,a=[a]}",
		"Sum": 2
	},	
	...
 ]
@forsaken628 forsaken628 added the bug Something isn't working label Jan 30, 2022
@drichards188
Copy link

Hello, could you expand more on the behavior you are expecting vs the behavior you received? That might help a more senior person come by and help.

@MrAlias
Copy link
Contributor

MrAlias commented May 3, 2022

This issues relates to the current metric SDK. The metric SDK redesign project includes changes to the SDK design that will make this issue obsolete. I'm closing so no wasted work is performed to address this.

When the new SDK is released, please re-evaluate the issue and reopen this issue, or a new more fitting one, if necessary.

@MrAlias MrAlias closed this as completed May 3, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants