Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
21 changes: 11 additions & 10 deletions .github/workflows/build-and-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: "1.22.5"
go-version: "1.23.6"
cache: false
- name: Cache Go
id: go-cache
Expand Down Expand Up @@ -77,7 +77,7 @@ jobs:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: "1.22.5"
go-version: "1.23.6"
cache: false
- name: Cache Go
id: go-cache
Expand Down Expand Up @@ -131,7 +131,7 @@ jobs:
- name: Setup Go
uses: actions/setup-go@v5
with:
go-version: "1.22.5"
go-version: "1.23.6"
cache: false
- name: Cache Go
id: go-cache
Expand All @@ -154,7 +154,7 @@ jobs:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: "1.22.5"
go-version: "1.23.6"
cache: false
- name: Cache Go
id: go-cache
Expand All @@ -164,6 +164,7 @@ jobs:
path: |
~/go/bin
~/go/pkg/mod
./.tools
key: go-cache-${{ runner.os }}-${{ hashFiles('**/go.sum') }}
- name: Install dependencies
if: steps.go-cache.outputs.cache-hit != 'true'
Expand Down Expand Up @@ -224,7 +225,7 @@ jobs:
strategy:
fail-fast: false
matrix:
go-version: ["1.22.5", "1.21.11"] # 1.20 is interpreted as 1.2 without quotes
go-version: ["1.23.6"] # 1.20 is interpreted as 1.2 without quotes
runner: [ubuntu-latest]
group:
- ocb-collector
Expand Down Expand Up @@ -309,7 +310,7 @@ jobs:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: "1.22.5"
go-version: "1.23.6"
cache: false
- name: Cache Go
id: go-cache
Expand Down Expand Up @@ -347,7 +348,7 @@ jobs:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: "1.22.5"
go-version: "1.23.6"
cache: false
- name: Cache Go
id: go-cache
Expand All @@ -373,7 +374,7 @@ jobs:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: "1.22.5"
go-version: "1.23.6"
cache: false
- name: Cache Go
id: go-cache
Expand Down Expand Up @@ -443,7 +444,7 @@ jobs:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: "1.22.5"
go-version: "1.23.6"
cache: false
- name: Cache Go
id: go-cache
Expand Down Expand Up @@ -544,7 +545,7 @@ jobs:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: "1.22.5"
go-version: "1.23.6"
cache: false
- name: Mkdir bin and dist
run: |
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: "1.22.5"
go-version: "1.23.6"
cache: false

# Initializes the CodeQL tools for scanning.
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/e2e-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ jobs:
uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: "1.22.5"
go-version: "1.23.6"
cache: false
- name: Cache Go
id: go-cache
Expand Down Expand Up @@ -55,7 +55,7 @@ jobs:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: "1.22.5"
go-version: "1.23.6"
cache: false
- name: Cache Go
id: go-cache
Expand Down Expand Up @@ -87,7 +87,7 @@ jobs:
uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: "1.22.5"
go-version: "1.23.6"
cache: false
- name: Cache Go
id: go-cache
Expand Down Expand Up @@ -133,7 +133,7 @@ jobs:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: "1.22.5"
go-version: "1.23.6"
cache: false
- name: Cache Go
id: go-cache
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/prepare-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ jobs:
path: opentelemetry-collector-contrib
- uses: actions/setup-go@v5
with:
go-version: "1.22.5"
go-version: "1.23.6"
cache: false
- name: Prepare release for contrib
working-directory: opentelemetry-collector-contrib
Expand Down
4 changes: 3 additions & 1 deletion .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,6 @@ linters:
- depguard
- errcheck
- errorlint
- exportloopref
- exhaustive
- gci
- gocritic
Expand Down Expand Up @@ -167,3 +166,6 @@ issues:
- text: "G402:"
linters:
- gosec
- text: "G115:"
linters:
- gosec
20 changes: 15 additions & 5 deletions cmd/checkapi/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,12 @@ func run(folder string, allowlistFilePath string) error {
return nil
}

func isTestFunction(fnName string) bool {
return strings.HasPrefix(fnName, "Test") ||
strings.HasPrefix(fnName, "Benchmark") ||
strings.HasPrefix(fnName, "Fuzz")
}

func handleFile(f *ast.File, result *api) {
for _, d := range f.Decls {
if str, isStr := d.(*ast.GenDecl); isStr {
Expand All @@ -99,7 +105,6 @@ func handleFile(f *ast.File, result *api) {
result.Structs = append(result.Structs, t.Name.String())
}
}

}
}
if fn, isFn := d.(*ast.FuncDecl); isFn {
Expand All @@ -108,11 +113,10 @@ func handleFile(f *ast.File, result *api) {
}
exported := false
receiver := ""
if fn.Recv.NumFields() == 0 && !strings.HasPrefix(fn.Name.String(), "Test") && !strings.HasPrefix(fn.Name.String(), "Benchmark") {
if fn.Recv.NumFields() == 0 && !isTestFunction(fn.Name.String()) {
exported = true
}
if fn.Recv.NumFields() > 0 {

for _, t := range fn.Recv.List {
for _, n := range t.Names {
exported = exported || n.IsExported()
Expand Down Expand Up @@ -179,8 +183,14 @@ func walkFolder(folder string, componentType string) error {
if len(result.Functions) > 1 {
return fmt.Errorf("%s has more than one function: %q", folder, strings.Join(fnNames, ","))
}
if err := checkFactoryFunction(result.Functions[0], folder, componentType); err != nil {
return err
}
return nil
}

newFactoryFn := result.Functions[0]
// check the only exported function of the module is NewFactory, matching the signature of the factory expected by the collector builder.
func checkFactoryFunction(newFactoryFn *function, folder string, componentType string) error {
if newFactoryFn.Name != "NewFactory" {
return fmt.Errorf("%s does not define a NewFactory function", folder)
}
Expand Down Expand Up @@ -245,4 +255,4 @@ func exprToString(expr ast.Expr) string {
default:
panic(fmt.Sprintf("Unsupported expr type: %#v", expr))
}
}
}
2 changes: 1 addition & 1 deletion cmd/otelcontribcol/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

module github.com/open-telemetry/opentelemetry-collector-contrib/cmd/otelcontribcol

go 1.22.5
go 1.23.0

require (
github.com/amazon-contributing/opentelemetry-collector-contrib/processor/awsapplicationsignalsprocessor v0.103.0
Expand Down
2 changes: 1 addition & 1 deletion exporter/awscloudwatchlogsexporter/go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/open-telemetry/opentelemetry-collector-contrib/exporter/awscloudwatchlogsexporter

go 1.22.5
go 1.23.0

require (
github.com/aws/aws-sdk-go v1.53.11
Expand Down
78 changes: 10 additions & 68 deletions exporter/awsemfexporter/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import (
"github.com/stretchr/testify/require"
"go.opentelemetry.io/collector/component"
"go.opentelemetry.io/collector/confmap/confmaptest"
"go.opentelemetry.io/collector/confmap/xconfmap"
"go.opentelemetry.io/collector/featuregate"
"go.uber.org/zap"

Expand Down Expand Up @@ -104,50 +105,6 @@ func TestLoadConfig(t *testing.T) {
logger: zap.NewNop(),
},
},
{
id: component.NewIDWithName(metadata.Type, "disable_metric_extraction"),
expected: &Config{
AWSSessionSettings: awsutil.AWSSessionSettings{
NumberOfWorkers: 8,
Endpoint: "",
RequestTimeoutSeconds: 30,
MaxRetries: 2,
NoVerifySSL: false,
ProxyAddress: "",
Region: "",
RoleARN: "",
},
LogGroupName: "",
LogStreamName: "",
DimensionRollupOption: "ZeroAndSingleDimensionRollup",
OutputDestination: "cloudwatch",
Version: "1",
DisableMetricExtraction: true,
logger: zap.NewNop(),
},
},
{
id: component.NewIDWithName(metadata.Type, "enhanced_container_insights"),
expected: &Config{
AWSSessionSettings: awsutil.AWSSessionSettings{
NumberOfWorkers: 8,
Endpoint: "",
RequestTimeoutSeconds: 30,
MaxRetries: 2,
NoVerifySSL: false,
ProxyAddress: "",
Region: "",
RoleARN: "",
},
LogGroupName: "",
LogStreamName: "",
DimensionRollupOption: "ZeroAndSingleDimensionRollup",
OutputDestination: "cloudwatch",
Version: "1",
EnhancedContainerInsights: true,
logger: zap.NewNop(),
},
},
}

for _, tt := range tests {
Expand All @@ -159,7 +116,7 @@ func TestLoadConfig(t *testing.T) {
require.NoError(t, err)
require.NoError(t, sub.Unmarshal(cfg))

assert.NoError(t, component.ValidateConfig(cfg))
assert.NoError(t, xconfmap.Validate(cfg))
assert.Equal(t, tt.expected, cfg)
})
}
Expand All @@ -182,9 +139,9 @@ func TestConfigValidate(t *testing.T) {
MetricDescriptors: incorrectDescriptor,
logger: zap.NewNop(),
}
assert.NoError(t, component.ValidateConfig(cfg))
assert.NoError(t, xconfmap.Validate(cfg))

assert.Equal(t, 2, len(cfg.MetricDescriptors))
assert.Len(t, cfg.MetricDescriptors, 2)
assert.Equal(t, []MetricDescriptor{
{Unit: "Count", MetricName: "apiserver_total", Overwrite: true},
{Unit: "Megabytes", MetricName: "memory_usage"},
Expand All @@ -202,8 +159,7 @@ func TestRetentionValidateCorrect(t *testing.T) {
ResourceToTelemetrySettings: resourcetotelemetry.Settings{Enabled: true},
logger: zap.NewNop(),
}
assert.NoError(t, component.ValidateConfig(cfg))

assert.NoError(t, xconfmap.Validate(cfg))
}

func TestRetentionValidateWrong(t *testing.T) {
Expand All @@ -217,8 +173,7 @@ func TestRetentionValidateWrong(t *testing.T) {
ResourceToTelemetrySettings: resourcetotelemetry.Settings{Enabled: true},
logger: zap.NewNop(),
}
assert.Error(t, component.ValidateConfig(wrongcfg))

assert.Error(t, xconfmap.Validate(wrongcfg))
}

func TestValidateTags(t *testing.T) {
Expand Down Expand Up @@ -298,10 +253,10 @@ func TestValidateTags(t *testing.T) {
logger: zap.NewNop(),
}
if tt.errorMessage != "" {
assert.EqualError(t, component.ValidateConfig(cfg), tt.errorMessage)
assert.ErrorContains(t, xconfmap.Validate(cfg), tt.errorMessage)
return
}
assert.NoError(t, component.ValidateConfig(cfg))
assert.NoError(t, xconfmap.Validate(cfg))
})
}
}
Expand All @@ -311,23 +266,10 @@ func TestNoDimensionRollupFeatureGate(t *testing.T) {
require.NoError(t, err)
cfg := createDefaultConfig()

assert.Equal(t, cfg.(*Config).DimensionRollupOption, "NoDimensionRollup")
assert.Equal(t, "NoDimensionRollup", cfg.(*Config).DimensionRollupOption)
_ = featuregate.GlobalRegistry().Set("awsemf.nodimrollupdefault", false)
}

func TestIsEnhancedContainerInsights(t *testing.T) {
factory := NewFactory()
cfg := factory.CreateDefaultConfig().(*Config)
cfg.EnhancedContainerInsights = true
cfg.DisableMetricExtraction = false
assert.True(t, cfg.IsEnhancedContainerInsights())
cfg.EnhancedContainerInsights = false
assert.False(t, cfg.IsEnhancedContainerInsights())
cfg.EnhancedContainerInsights = true
cfg.DisableMetricExtraction = true
assert.False(t, cfg.IsEnhancedContainerInsights())
}

func TestIsApplicationSignalsEnabled(t *testing.T) {
tests := []struct {
name string
Expand Down Expand Up @@ -377,7 +319,7 @@ func TestIsApplicationSignalsEnabled(t *testing.T) {
cfg.LogGroupName = tc.logGroupName
}

assert.Equal(t, cfg.IsAppSignalsEnabled(), tc.expectedResult)
assert.Equal(t, tc.expectedResult, cfg.IsAppSignalsEnabled())
})
}
}
Loading
Loading