Skip to content

Commit

Permalink
Merge branch 'main' into fix_set_data_race
Browse files Browse the repository at this point in the history
  • Loading branch information
rogercoll authored Aug 30, 2024
2 parents cac5723 + 499cfd8 commit dc39494
Show file tree
Hide file tree
Showing 205 changed files with 1,293 additions and 1,069 deletions.
27 changes: 27 additions & 0 deletions .chloggen/ottl-remove-tracing.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Use this changelog template to create an entry for release notes.

# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix'
change_type: breaking

# The name of the component, or a single word describing the area of concern, (e.g. filelogreceiver)
component: ottl

# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
note: Remove tracing from OTTL due to performance concerns

# Mandatory: One or more tracking issues related to the change. You can use the PR number here if no issue exists.
issues: [34910]

# (Optional) One or more lines of additional information to render under the primary note.
# These lines will be padded with 2 spaces and then inserted directly into the document.
# Use pipe (|) for multiline entries.
subtext:

# If your change doesn't affect end users or the exported elements of any package,
# you should instead start your pull request title with [chore] or use the "Skip Changelog" label.
# Optional: The change log or logs in which this entry should be included.
# e.g. '[user]' or '[user, api]'
# Include 'user' if the change is relevant to end users.
# Include 'api' if there is a change to a library API.
# Default: '[user]'
change_logs: []
27 changes: 27 additions & 0 deletions .chloggen/redaction-add-metrics-and-logs.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Use this changelog template to create an entry for release notes.

# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix'
change_type: enhancement

# The name of the component, or a single word describing the area of concern, (e.g. filelogreceiver)
component: redactionprocessor

# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
note: Add support for logs and metrics

# Mandatory: One or more tracking issues related to the change. You can use the PR number here if no issue exists.
issues: [34479]

# (Optional) One or more lines of additional information to render under the primary note.
# These lines will be padded with 2 spaces and then inserted directly into the document.
# Use pipe (|) for multiline entries.
subtext:

# If your change doesn't affect end users or the exported elements of any package,
# you should instead start your pull request title with [chore] or use the "Skip Changelog" label.
# Optional: The change log or logs in which this entry should be included.
# e.g. '[user]' or '[user, api]'
# Include 'user' if the change is relevant to end users.
# Include 'api' if there is a change to a library API.
# Default: '[user]'
change_logs: []
17 changes: 17 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,22 @@ linters-settings:
predeclared:
ignore: copy

testifylint:
disable:
- compares
- empty
- error-is-as
- error-nil
- expected-actual
- float-compare
- go-require
- negative-positive
- nil-compare
- require-error
- suite-dont-use-pkg
- useless-assert
enable-all: true

linters:
enable:
- decorder
Expand All @@ -152,6 +168,7 @@ linters:
- revive
- staticcheck
- tenv
- testifylint
- unconvert
- unparam
- unused
Expand Down
6 changes: 3 additions & 3 deletions cmd/telemetrygen/internal/traces/worker_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ func TestSpansWithNoAttrs(t *testing.T) {
assert.Len(t, syncer.spans, 4) // each trace has two spans
for _, span := range syncer.spans {
attributes := span.Attributes()
assert.Equal(t, 2, len(attributes), "it shouldn't have more than 2 fixed attributes")
assert.Len(t, attributes, 2, "it shouldn't have more than 2 fixed attributes")
}
}

Expand All @@ -284,7 +284,7 @@ func TestSpansWithOneAttrs(t *testing.T) {
assert.Len(t, syncer.spans, 4) // each trace has two spans
for _, span := range syncer.spans {
attributes := span.Attributes()
assert.Equal(t, 3, len(attributes), "it should have more than 3 attributes")
assert.Len(t, attributes, 3, "it should have more than 3 attributes")
}
}

Expand All @@ -306,7 +306,7 @@ func TestSpansWithMultipleAttrs(t *testing.T) {
assert.Len(t, syncer.spans, 4) // each trace has two spans
for _, span := range syncer.spans {
attributes := span.Attributes()
assert.Equal(t, 4, len(attributes), "it should have more than 4 attributes")
assert.Len(t, attributes, 4, "it should have more than 4 attributes")
}
}

Expand Down
6 changes: 3 additions & 3 deletions connector/countconnector/connector_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ func TestTracesToMetrics(t *testing.T) {
assert.NoError(t, conn.ConsumeTraces(context.Background(), testSpans))

allMetrics := sink.AllMetrics()
assert.Equal(t, 1, len(allMetrics))
assert.Len(t, allMetrics, 1)

// golden.WriteMetrics(t, filepath.Join("testdata", "traces", tc.name+".yaml"), allMetrics[0])
expected, err := golden.ReadMetrics(filepath.Join("testdata", "traces", tc.name+".yaml"))
Expand Down Expand Up @@ -507,7 +507,7 @@ func TestMetricsToMetrics(t *testing.T) {
assert.NoError(t, conn.ConsumeMetrics(context.Background(), testMetrics))

allMetrics := sink.AllMetrics()
assert.Equal(t, 1, len(allMetrics))
assert.Len(t, allMetrics, 1)

// golden.WriteMetrics(t, filepath.Join("testdata", "metrics", tc.name+".yaml"), allMetrics[0])
expected, err := golden.ReadMetrics(filepath.Join("testdata", "metrics", tc.name+".yaml"))
Expand Down Expand Up @@ -679,7 +679,7 @@ func TestLogsToMetrics(t *testing.T) {
assert.NoError(t, conn.ConsumeLogs(context.Background(), testLogs))

allMetrics := sink.AllMetrics()
assert.Equal(t, 1, len(allMetrics))
assert.Len(t, allMetrics, 1)

// golden.WriteMetrics(t, filepath.Join("testdata", "logs", tc.name+".yaml"), allMetrics[0])
expected, err := golden.ReadMetrics(filepath.Join("testdata", "logs", tc.name+".yaml"))
Expand Down
6 changes: 3 additions & 3 deletions connector/datadogconnector/connector_native_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ func TestContainerTagsNative(t *testing.T) {

// check if the container tags are added to the metrics
metrics := metricsSink.AllMetrics()
assert.Equal(t, 1, len(metrics))
assert.Len(t, metrics, 1)

ch := make(chan []byte, 100)
tr := newTranslatorWithStatsChannel(t, zap.NewNop(), ch)
Expand All @@ -117,7 +117,7 @@ func TestContainerTagsNative(t *testing.T) {
require.NoError(t, err)

tags := sp.Stats[0].Tags
assert.Equal(t, 3, len(tags))
assert.Len(t, tags, 3)
assert.ElementsMatch(t, []string{"region:my-region", "zone:my-zone", "az:my-az"}, tags)
}

Expand Down Expand Up @@ -187,7 +187,7 @@ func TestMeasuredAndClientKindNative(t *testing.T) {
}

metrics := metricsSink.AllMetrics()
require.Equal(t, 1, len(metrics))
require.Len(t, metrics, 1)

ch := make(chan []byte, 100)
tr := newTranslatorWithStatsChannel(t, zap.NewNop(), ch)
Expand Down
6 changes: 3 additions & 3 deletions connector/datadogconnector/connector_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ func TestContainerTags(t *testing.T) {
err = connector.ConsumeTraces(context.Background(), trace2)
assert.NoError(t, err)
// check if the container tags are added to the cache
assert.Equal(t, 1, len(connector.containerTagCache.Items()))
assert.Len(t, connector.containerTagCache.Items(), 1)
count := 0
connector.containerTagCache.Items()["my-container-id"].Object.(*sync.Map).Range(func(_, _ any) bool {
count++
Expand All @@ -175,7 +175,7 @@ func TestContainerTags(t *testing.T) {

// check if the container tags are added to the metrics
metrics := metricsSink.AllMetrics()
assert.Equal(t, 1, len(metrics))
assert.Len(t, metrics, 1)

ch := make(chan []byte, 100)
tr := newTranslatorWithStatsChannel(t, zap.NewNop(), ch)
Expand All @@ -188,7 +188,7 @@ func TestContainerTags(t *testing.T) {
require.NoError(t, err)

tags := sp.Stats[0].Tags
assert.Equal(t, 3, len(tags))
assert.Len(t, tags, 3)
assert.ElementsMatch(t, []string{"region:my-region", "zone:my-zone", "az:my-az"}, tags)
}

Expand Down
36 changes: 18 additions & 18 deletions connector/roundrobinconnector/connector_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,17 +50,17 @@ func TestLogsRoundRobin(t *testing.T) {
assert.NoError(t, logs.ConsumeLogs(ctx, plog.NewLogs()))
assert.NoError(t, logs.ConsumeLogs(ctx, plog.NewLogs()))

assert.Equal(t, 1, len(sink1.AllLogs()))
assert.Equal(t, 1, len(sink2.AllLogs()))
assert.Equal(t, 1, len(sink3.AllLogs()))
assert.Len(t, sink1.AllLogs(), 1)
assert.Len(t, sink2.AllLogs(), 1)
assert.Len(t, sink3.AllLogs(), 1)

assert.NoError(t, logs.ConsumeLogs(ctx, plog.NewLogs()))
assert.NoError(t, logs.ConsumeLogs(ctx, plog.NewLogs()))
assert.NoError(t, logs.ConsumeLogs(ctx, plog.NewLogs()))

assert.Equal(t, 2, len(sink1.AllLogs()))
assert.Equal(t, 2, len(sink2.AllLogs()))
assert.Equal(t, 2, len(sink3.AllLogs()))
assert.Len(t, sink1.AllLogs(), 2)
assert.Len(t, sink2.AllLogs(), 2)
assert.Len(t, sink3.AllLogs(), 2)

assert.NoError(t, logs.Shutdown(ctx))
}
Expand All @@ -87,17 +87,17 @@ func TestMetricsRoundRobin(t *testing.T) {
assert.NoError(t, metrics.ConsumeMetrics(ctx, pmetric.NewMetrics()))
assert.NoError(t, metrics.ConsumeMetrics(ctx, pmetric.NewMetrics()))

assert.Equal(t, 1, len(sink1.AllMetrics()))
assert.Equal(t, 1, len(sink2.AllMetrics()))
assert.Equal(t, 1, len(sink3.AllMetrics()))
assert.Len(t, sink1.AllMetrics(), 1)
assert.Len(t, sink2.AllMetrics(), 1)
assert.Len(t, sink3.AllMetrics(), 1)

assert.NoError(t, metrics.ConsumeMetrics(ctx, pmetric.NewMetrics()))
assert.NoError(t, metrics.ConsumeMetrics(ctx, pmetric.NewMetrics()))
assert.NoError(t, metrics.ConsumeMetrics(ctx, pmetric.NewMetrics()))

assert.Equal(t, 2, len(sink1.AllMetrics()))
assert.Equal(t, 2, len(sink2.AllMetrics()))
assert.Equal(t, 2, len(sink3.AllMetrics()))
assert.Len(t, sink1.AllMetrics(), 2)
assert.Len(t, sink2.AllMetrics(), 2)
assert.Len(t, sink3.AllMetrics(), 2)

assert.NoError(t, metrics.Shutdown(ctx))
}
Expand All @@ -124,17 +124,17 @@ func TestTracesRoundRobin(t *testing.T) {
assert.NoError(t, traces.ConsumeTraces(ctx, ptrace.NewTraces()))
assert.NoError(t, traces.ConsumeTraces(ctx, ptrace.NewTraces()))

assert.Equal(t, 1, len(sink1.AllTraces()))
assert.Equal(t, 1, len(sink2.AllTraces()))
assert.Equal(t, 1, len(sink3.AllTraces()))
assert.Len(t, sink1.AllTraces(), 1)
assert.Len(t, sink2.AllTraces(), 1)
assert.Len(t, sink3.AllTraces(), 1)

assert.NoError(t, traces.ConsumeTraces(ctx, ptrace.NewTraces()))
assert.NoError(t, traces.ConsumeTraces(ctx, ptrace.NewTraces()))
assert.NoError(t, traces.ConsumeTraces(ctx, ptrace.NewTraces()))

assert.Equal(t, 2, len(sink1.AllTraces()))
assert.Equal(t, 2, len(sink2.AllTraces()))
assert.Equal(t, 2, len(sink3.AllTraces()))
assert.Len(t, sink1.AllTraces(), 2)
assert.Len(t, sink2.AllTraces(), 2)
assert.Len(t, sink3.AllTraces(), 2)

assert.NoError(t, traces.Shutdown(ctx))
}
2 changes: 1 addition & 1 deletion connector/routingconnector/logs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -463,5 +463,5 @@ func TestLogsConnectorCapabilities(t *testing.T) {
)

require.NoError(t, err)
assert.Equal(t, false, conn.Capabilities().MutatesData)
assert.False(t, conn.Capabilities().MutatesData)
}
2 changes: 1 addition & 1 deletion connector/routingconnector/metrics_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -493,5 +493,5 @@ func TestMetricsConnectorCapabilities(t *testing.T) {
)

require.NoError(t, err)
assert.Equal(t, false, conn.Capabilities().MutatesData)
assert.False(t, conn.Capabilities().MutatesData)
}
2 changes: 1 addition & 1 deletion connector/routingconnector/traces_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -417,5 +417,5 @@ func TestTraceConnectorCapabilities(t *testing.T) {
)

require.NoError(t, err)
assert.Equal(t, false, conn.Capabilities().MutatesData)
assert.False(t, conn.Capabilities().MutatesData)
}
12 changes: 6 additions & 6 deletions connector/servicegraphconnector/connector_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -480,7 +480,7 @@ func TestStaleSeriesCleanup(t *testing.T) {
p.keyToMetric[key] = metric
}
p.cleanCache()
assert.Equal(t, 0, len(p.keyToMetric))
assert.Len(t, p.keyToMetric, 0)

// ConsumeTraces with a trace with different attribute value
td = buildSampleTrace(t, "second")
Expand Down Expand Up @@ -526,8 +526,8 @@ func TestMapsAreConsistentDuringCleanup(t *testing.T) {
go p.cleanCache()

// Since everything is locked, nothing has happened, so both should still have length 1
assert.Equal(t, 1, len(p.reqTotal))
assert.Equal(t, 1, len(p.keyToMetric))
assert.Len(t, p.reqTotal, 1)
assert.Len(t, p.keyToMetric, 1)

// Now we pretend that we have stopped collecting metrics, by unlocking seriesMutex
p.seriesMutex.Unlock()
Expand All @@ -540,8 +540,8 @@ func TestMapsAreConsistentDuringCleanup(t *testing.T) {
// for dimensions from that series. It's important that it happens this way around,
// instead of deleting it from `keyToMetric`, otherwise the metrics collector will try
// and fail to find dimensions for a series that is about to be removed.
assert.Equal(t, 0, len(p.reqTotal))
assert.Equal(t, 1, len(p.keyToMetric))
assert.Len(t, p.reqTotal, 0)
assert.Len(t, p.keyToMetric, 1)

p.metricMutex.RUnlock()
p.seriesMutex.Unlock()
Expand Down Expand Up @@ -575,7 +575,7 @@ func TestValidateOwnTelemetry(t *testing.T) {
p.keyToMetric[key] = metric
}
p.cleanCache()
assert.Equal(t, 0, len(p.keyToMetric))
assert.Len(t, p.keyToMetric, 0)

// ConsumeTraces with a trace with different attribute value
td = buildSampleTrace(t, "second")
Expand Down
12 changes: 6 additions & 6 deletions connector/servicegraphconnector/internal/store/store_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ func TestStoreUpsertEdge(t *testing.T) {
e.ClientService = clientService
})
require.NoError(t, err)
require.Equal(t, true, isNew)
require.True(t, isNew)
assert.Equal(t, 1, s.Len())

// Nothing should be evicted as TTL is set to 1h
Expand All @@ -44,7 +44,7 @@ func TestStoreUpsertEdge(t *testing.T) {
e.ServerService = "server"
})
require.NoError(t, err)
require.Equal(t, false, isNew)
require.False(t, isNew)
// Edge is complete and should have been removed
assert.Equal(t, 0, s.Len())

Expand All @@ -57,7 +57,7 @@ func TestStoreUpsertEdge(t *testing.T) {
e.expiration = time.UnixMicro(0)
})
require.NoError(t, err)
require.Equal(t, true, isNew)
require.True(t, isNew)
assert.Equal(t, 1, s.Len())
assert.Equal(t, 1, onCompletedCount)
assert.Equal(t, 0, onExpireCount)
Expand All @@ -80,7 +80,7 @@ func TestStoreUpsertEdge_errTooManyItems(t *testing.T) {
e.ClientService = clientService
})
require.NoError(t, err)
require.Equal(t, true, isNew)
require.True(t, isNew)
assert.Equal(t, 1, s.Len())

_, err = s.UpsertEdge(key2, func(e *Edge) {
Expand All @@ -93,7 +93,7 @@ func TestStoreUpsertEdge_errTooManyItems(t *testing.T) {
e.ClientService = clientService
})
require.NoError(t, err)
require.Equal(t, false, isNew)
require.False(t, isNew)
assert.Equal(t, 1, s.Len())

assert.Equal(t, 0, onCallbackCounter)
Expand All @@ -120,7 +120,7 @@ func TestStoreExpire(t *testing.T) {
for key := range keys {
isNew, err := s.UpsertEdge(key, noopCallback)
require.NoError(t, err)
require.Equal(t, true, isNew)
require.True(t, isNew)
}

s.Expire()
Expand Down
2 changes: 1 addition & 1 deletion connector/spanmetricsconnector/connector_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -692,7 +692,7 @@ func TestConnectorCapabilities(t *testing.T) {

// Verify
assert.NotNil(t, c)
assert.Equal(t, false, caps.MutatesData)
assert.False(t, caps.MutatesData)
}

type errConsumer struct {
Expand Down
Loading

0 comments on commit dc39494

Please sign in to comment.