Skip to content

Commit

Permalink
[chore][connector/routing] Migrate traces test to concise format (#36165
Browse files Browse the repository at this point in the history
)
  • Loading branch information
djaglowski authored Nov 5, 2024
1 parent ba20b05 commit 740d9aa
Show file tree
Hide file tree
Showing 44 changed files with 355 additions and 2,529 deletions.
1 change: 0 additions & 1 deletion connector/routingconnector/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ module github.com/open-telemetry/opentelemetry-collector-contrib/connector/routi
go 1.22.0

require (
github.com/open-telemetry/opentelemetry-collector-contrib/pkg/golden v0.112.0
github.com/open-telemetry/opentelemetry-collector-contrib/pkg/ottl v0.112.0
github.com/open-telemetry/opentelemetry-collector-contrib/pkg/pdatatest v0.112.0
github.com/stretchr/testify v1.9.0
Expand Down
20 changes: 10 additions & 10 deletions connector/routingconnector/internal/plogutiltest/logs.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,17 @@ import "go.opentelemetry.io/collector/pdata/plog"
// each with log1, log2, log3, log4
//
// Each byte in the input string is a unique ID for the corresponding element.
func NewLogs(rIDs, sIDs, lIDs string) plog.Logs {
func NewLogs(resourceIDs, scopeIDs, logRecordIDs string) plog.Logs {
ld := plog.NewLogs()
for ri := 0; ri < len(rIDs); ri++ {
r := ld.ResourceLogs().AppendEmpty()
r.Resource().Attributes().PutStr("resourceName", "resource"+string(rIDs[ri]))
for si := 0; si < len(sIDs); si++ {
s := r.ScopeLogs().AppendEmpty()
s.Scope().SetName("scope" + string(sIDs[si]))
for li := 0; li < len(lIDs); li++ {
m := s.LogRecords().AppendEmpty()
m.Body().SetStr("log" + string(lIDs[li]))
for resourceN := 0; resourceN < len(resourceIDs); resourceN++ {
rl := ld.ResourceLogs().AppendEmpty()
rl.Resource().Attributes().PutStr("resourceName", "resource"+string(resourceIDs[resourceN]))
for scopeN := 0; scopeN < len(scopeIDs); scopeN++ {
sl := rl.ScopeLogs().AppendEmpty()
sl.Scope().SetName("scope" + string(scopeIDs[scopeN]))
for logRecordN := 0; logRecordN < len(logRecordIDs); logRecordN++ {
lr := sl.LogRecords().AppendEmpty()
lr.Body().SetStr("log" + string(logRecordIDs[logRecordN]))
}
}
}
Expand Down
24 changes: 12 additions & 12 deletions connector/routingconnector/internal/pmetricutiltest/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,21 +22,21 @@ import "go.opentelemetry.io/collector/pdata/pmetric"
// each with dp1, dp2, dp3, dp4
//
// Each byte in the input string is a unique ID for the corresponding element.
func NewMetrics(rIDs, sIDs, mIDs, dpIDs string) pmetric.Metrics {
func NewMetrics(resourceIDs, scopeIDs, metricIDs, dataPointIDs string) pmetric.Metrics {
md := pmetric.NewMetrics()
for ri := 0; ri < len(rIDs); ri++ {
r := md.ResourceMetrics().AppendEmpty()
r.Resource().Attributes().PutStr("resourceName", "resource"+string(rIDs[ri]))
for si := 0; si < len(sIDs); si++ {
s := r.ScopeMetrics().AppendEmpty()
s.Scope().SetName("scope" + string(sIDs[si]))
for mi := 0; mi < len(mIDs); mi++ {
m := s.Metrics().AppendEmpty()
m.SetName("metric" + string(mIDs[mi]))
for resourceN := 0; resourceN < len(resourceIDs); resourceN++ {
rm := md.ResourceMetrics().AppendEmpty()
rm.Resource().Attributes().PutStr("resourceName", "resource"+string(resourceIDs[resourceN]))
for scopeN := 0; scopeN < len(scopeIDs); scopeN++ {
sm := rm.ScopeMetrics().AppendEmpty()
sm.Scope().SetName("scope" + string(scopeIDs[scopeN]))
for metricN := 0; metricN < len(metricIDs); metricN++ {
m := sm.Metrics().AppendEmpty()
m.SetName("metric" + string(metricIDs[metricN]))
dps := m.SetEmptyGauge()
for di := 0; di < len(dpIDs); di++ {
for dataPointN := 0; dataPointN < len(dataPointIDs); dataPointN++ {
dp := dps.DataPoints().AppendEmpty()
dp.Attributes().PutStr("dpName", "dp"+string(dpIDs[di]))
dp.Attributes().PutStr("dpName", "dp"+string(dataPointIDs[dataPointN]))
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ func TestNewMetrics(t *testing.T) {
m.SetName("metricD") // resourceB.scopeC.metricD
dps = m.SetEmptyGauge()
dp = dps.DataPoints().AppendEmpty()
dp.Attributes().PutStr("dpName", "dpE") // resource.scopeC.metricD.dpE
dp.Attributes().PutStr("dpName", "dpE") // resourceB.scopeC.metricD.dpE
return md
}()
assert.NoError(t, pmetrictest.CompareMetrics(expected, pmetricutiltest.NewMetrics("AB", "C", "D", "E")))
Expand Down

This file was deleted.

Empty file.
Empty file.

This file was deleted.

Loading

0 comments on commit 740d9aa

Please sign in to comment.