1
0
mirror of https://github.com/open-telemetry/opentelemetry-go.git synced 2025-11-25 22:41:46 +02:00

chore: enable gocritic linter (#7095)

#### Description

Enable and fixes several rules from
[gocritic](https://golangci-lint.run/usage/linters/#gocritic) linter

---------

Signed-off-by: Matthieu MOREL <matthieu.morel35@gmail.com>
Co-authored-by: Tyler Yahn <MrAlias@users.noreply.github.com>
This commit is contained in:
Matthieu MOREL
2025-07-29 18:20:32 +02:00
committed by GitHub
parent 8955578fef
commit 982391315f
37 changed files with 158 additions and 146 deletions

View File

@@ -653,32 +653,31 @@ func TestPipelineProduceErrors(t *testing.T) {
var shouldReturnError bool // When true, the third callback returns an error
var callbackCounts [3]int
// Callback 1: cancels the context during execution but continues to populate data
pipe.callbacks = append(pipe.callbacks, func(ctx context.Context) error {
callbackCounts[0]++
for _, m := range pipe.int64Measures[testObsID] {
m(ctx, 123, *attribute.EmptySet())
}
return nil
})
// Callback 2: populates int64 observable data
pipe.callbacks = append(pipe.callbacks, func(ctx context.Context) error {
callbackCounts[1]++
if shouldCancelContext {
cancelCtx()
}
return nil
})
// Callback 3: return an error
pipe.callbacks = append(pipe.callbacks, func(ctx context.Context) error {
callbackCounts[2]++
if shouldReturnError {
return fmt.Errorf("test callback error")
}
return nil
})
pipe.callbacks = append(pipe.callbacks,
// Callback 1: cancels the context during execution but continues to populate data
func(ctx context.Context) error {
callbackCounts[0]++
for _, m := range pipe.int64Measures[testObsID] {
m(ctx, 123, *attribute.EmptySet())
}
return nil
},
// Callback 2: populates int64 observable data
func(ctx context.Context) error {
callbackCounts[1]++
if shouldCancelContext {
cancelCtx()
}
return nil
},
// Callback 3: return an error
func(ctx context.Context) error {
callbackCounts[2]++
if shouldReturnError {
return fmt.Errorf("test callback error")
}
return nil
})
assertMetrics := func(rm *metricdata.ResourceMetrics, expectVal int64) {
require.Len(t, rm.ScopeMetrics, 1)