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

[chore] make update-otel #14702

Merged
merged 5 commits into from
Oct 5, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
more clone
  • Loading branch information
Alex Boten committed Oct 5, 2022
commit 0dff757758f5db0e26e424a19afaf02d9ad76102
24 changes: 16 additions & 8 deletions pkg/batchperresourceattr/batchperresourceattr_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,8 @@ func TestSplitTracesSameResource(t *testing.T) {
fillResourceSpans(inBatch.ResourceSpans().AppendEmpty(), "same_attr_val", "1")
fillResourceSpans(inBatch.ResourceSpans().AppendEmpty(), "same_attr_val", "1")
fillResourceSpans(inBatch.ResourceSpans().AppendEmpty(), "same_attr_val", "1")
expected := inBatch.Clone()
expected := ptrace.NewTraces()
inBatch.CopyTo(expected)

sink := new(consumertest.TracesSink)
bpr := NewBatchPerResourceTraces("same_attr_val", sink)
Expand All @@ -80,7 +81,8 @@ func TestSplitTracesIntoDifferentBatches(t *testing.T) {
fillResourceSpans(inBatch.ResourceSpans().AppendEmpty(), "attr_key", "3")
fillResourceSpans(inBatch.ResourceSpans().AppendEmpty(), "attr_key", "4")
fillResourceSpans(inBatch.ResourceSpans().AppendEmpty(), "diff_attr_key", "1")
expected := inBatch.Clone()
expected := ptrace.NewTraces()
inBatch.CopyTo(expected)

sink := new(consumertest.TracesSink)
bpr := NewBatchPerResourceTraces("attr_key", sink)
Expand All @@ -98,7 +100,8 @@ func TestSplitTracesIntoDifferentBatches(t *testing.T) {
func TestSplitMetricsOneResourceMetrics(t *testing.T) {
inBatch := pmetric.NewMetrics()
fillResourceMetrics(inBatch.ResourceMetrics().AppendEmpty(), "attr_key", "1")
expected := inBatch.Clone()
expected := pmetric.NewMetrics()
inBatch.CopyTo(expected)

sink := new(consumertest.MetricsSink)
bpr := NewBatchPerResourceMetrics("attr_key", sink)
Expand All @@ -124,7 +127,8 @@ func TestSplitMetricsSameResource(t *testing.T) {
fillResourceMetrics(inBatch.ResourceMetrics().AppendEmpty(), "same_attr_val", "1")
fillResourceMetrics(inBatch.ResourceMetrics().AppendEmpty(), "same_attr_val", "1")
fillResourceMetrics(inBatch.ResourceMetrics().AppendEmpty(), "same_attr_val", "1")
expected := inBatch.Clone()
expected := pmetric.NewMetrics()
inBatch.CopyTo(expected)

sink := new(consumertest.MetricsSink)
bpr := NewBatchPerResourceMetrics("same_attr_val", sink)
Expand All @@ -145,7 +149,8 @@ func TestSplitMetricsIntoDifferentBatches(t *testing.T) {
fillResourceMetrics(inBatch.ResourceMetrics().AppendEmpty(), "attr_key", "3")
fillResourceMetrics(inBatch.ResourceMetrics().AppendEmpty(), "attr_key", "4")
fillResourceMetrics(inBatch.ResourceMetrics().AppendEmpty(), "diff_attr_key", "1")
expected := inBatch.Clone()
expected := pmetric.NewMetrics()
inBatch.CopyTo(expected)

sink := new(consumertest.MetricsSink)
bpr := NewBatchPerResourceMetrics("attr_key", sink)
Expand All @@ -163,7 +168,8 @@ func TestSplitMetricsIntoDifferentBatches(t *testing.T) {
func TestSplitLogsOneResourceLogs(t *testing.T) {
inBatch := plog.NewLogs()
fillResourceLogs(inBatch.ResourceLogs().AppendEmpty(), "attr_key", "1")
expected := inBatch.Clone()
expected := plog.NewLogs()
inBatch.CopyTo(expected)

sink := new(consumertest.LogsSink)
bpr := NewBatchPerResourceLogs("attr_key", sink)
Expand All @@ -189,7 +195,8 @@ func TestSplitLogsSameResource(t *testing.T) {
fillResourceLogs(inBatch.ResourceLogs().AppendEmpty(), "same_attr_val", "1")
fillResourceLogs(inBatch.ResourceLogs().AppendEmpty(), "same_attr_val", "1")
fillResourceLogs(inBatch.ResourceLogs().AppendEmpty(), "same_attr_val", "1")
expected := inBatch.Clone()
expected := plog.NewLogs()
inBatch.CopyTo(expected)

sink := new(consumertest.LogsSink)
bpr := NewBatchPerResourceLogs("same_attr_val", sink)
Expand All @@ -210,7 +217,8 @@ func TestSplitLogsIntoDifferentBatches(t *testing.T) {
fillResourceLogs(inBatch.ResourceLogs().AppendEmpty(), "attr_key", "3")
fillResourceLogs(inBatch.ResourceLogs().AppendEmpty(), "attr_key", "4")
fillResourceLogs(inBatch.ResourceLogs().AppendEmpty(), "diff_attr_key", "1")
expected := inBatch.Clone()
expected := plog.NewLogs()
inBatch.CopyTo(expected)

sink := new(consumertest.LogsSink)
bpr := NewBatchPerResourceLogs("attr_key", sink)
Expand Down
6 changes: 4 additions & 2 deletions pkg/translator/opencensus/oc_to_metrics_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,8 @@ func TestOCToMetrics(t *testing.T) {

func TestOCToMetrics_ResourceInMetric(t *testing.T) {
internal := testdata.GenerateMetricsOneMetric()
want := internal.Clone()
want := pmetric.NewMetrics()
internal.CopyTo(want)
want.ResourceMetrics().At(0).CopyTo(want.ResourceMetrics().AppendEmpty())
want.ResourceMetrics().At(1).Resource().Attributes().PutString("resource-attr", "another-value")
oc := generateOCTestDataMetricsOneMetric()
Expand All @@ -153,7 +154,8 @@ func TestOCToMetrics_ResourceInMetric(t *testing.T) {

func TestOCToMetrics_ResourceInMetricOnly(t *testing.T) {
internal := testdata.GenerateMetricsOneMetric()
want := internal.Clone()
want := pmetric.NewMetrics()
internal.CopyTo(want)
oc := generateOCTestDataMetricsOneMetric()
// Move resource to metric level.
// We shouldn't have a "combined" resource after conversion
Expand Down