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

upgrade to v0.113.0 #9

Closed
wants to merge 6 commits into from
Closed
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
9 changes: 5 additions & 4 deletions .github/workflows/build-and-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -212,10 +212,11 @@ jobs:
run: |
make -j2 goporto
git diff --exit-code || (echo 'Porto links are out of date, please run "make goporto" and commit the changes in this PR.' && exit 1)
- name: crosslink
run: |
make crosslink
git diff --exit-code || (echo 'Replace statements are out of date, please run "make crosslink" and commit the changes in this PR.' && exit 1)
# Disable crosslink as some of the "replace" statements are removed to reduce conflicts as OCB components may depend on different OTel dependency versions
# - name: crosslink
# run: |
# make crosslink
# git diff --exit-code || (echo 'Replace statements are out of date, please run "make crosslink" and commit the changes in this PR.' && exit 1)
- name: Check for go mod dependency changes
run: |
make gotidy
Expand Down
2 changes: 2 additions & 0 deletions Makefile.Common
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,8 @@ fmt: $(GOIMPORTS)

.PHONY: lint
lint: $(LINT) checklicense misspell
echo "hi"
echo "$(CURDIR)"
$(LINT) run --allow-parallel-runners --verbose --build-tags integration --timeout=30m --path-prefix $(shell basename "$(CURDIR)")

.PHONY: govulncheck
Expand Down
10 changes: 6 additions & 4 deletions cmd/otelcontribcol/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -551,7 +551,6 @@ require (
github.com/jcmturner/goidentity/v6 v6.0.1 // indirect
github.com/jcmturner/gokrb5/v8 v8.4.4 // indirect
github.com/jcmturner/rpc/v2 v2.0.3 // indirect
github.com/jellydator/ttlcache/v3 v3.2.0 // indirect
github.com/jmespath/go-jmespath v0.4.0 // indirect
github.com/joeshaw/multierror v0.0.0-20140124173710-69b34d4ec901 // indirect
github.com/josharian/intern v1.0.0 // indirect
Expand Down Expand Up @@ -832,7 +831,8 @@ replace github.com/open-telemetry/opentelemetry-collector-contrib/extension/stor

replace github.com/open-telemetry/opentelemetry-collector-contrib/pkg/batchpersignal => ../../pkg/batchpersignal

replace github.com/open-telemetry/opentelemetry-collector-contrib/internal/aws/cwlogs => ../../internal/aws/cwlogs
// Do not use replace for OCB components that may have conflicting OTel Collector dependencies
// replace github.com/open-telemetry/opentelemetry-collector-contrib/internal/aws/cwlogs => ../../internal/aws/cwlogs

replace github.com/open-telemetry/opentelemetry-collector-contrib/internal/common => ../../internal/common

Expand Down Expand Up @@ -870,7 +870,8 @@ replace github.com/open-telemetry/opentelemetry-collector-contrib/receiver/recei

replace github.com/open-telemetry/opentelemetry-collector-contrib/processor/k8sattributesprocessor => ../../processor/k8sattributesprocessor

replace github.com/open-telemetry/opentelemetry-collector-contrib/exporter/awsemfexporter => ../../exporter/awsemfexporter
// Do not use replace for OCB components that may have conflicting OTel Collector dependencies
// replace github.com/open-telemetry/opentelemetry-collector-contrib/exporter/awsemfexporter => ../../exporter/awsemfexporter

replace github.com/open-telemetry/opentelemetry-collector-contrib/receiver/opencensusreceiver => ../../receiver/opencensusreceiver

Expand Down Expand Up @@ -1034,7 +1035,8 @@ replace github.com/open-telemetry/opentelemetry-collector-contrib/processor/metr

replace github.com/open-telemetry/opentelemetry-collector-contrib/processor/attributesprocessor => ../../processor/attributesprocessor

replace github.com/amazon-contributing/opentelemetry-collector-contrib/processor/awsapplicationsignalsprocessor => ../../processor/awsapplicationsignalsprocessor
// Do not use replace for OCB components that may have conflicting OTel Collector dependencies
// replace github.com/amazon-contributing/opentelemetry-collector-contrib/processor/awsapplicationsignalsprocessor => ../../processor/awsapplicationsignalsprocessor

replace github.com/open-telemetry/opentelemetry-collector-contrib/receiver/sqlqueryreceiver => ../../receiver/sqlqueryreceiver

Expand Down
8 changes: 6 additions & 2 deletions cmd/otelcontribcol/go.sum

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

23 changes: 14 additions & 9 deletions exporter/awscloudwatchlogsexporter/exporter.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (
"fmt"
"time"

"github.com/amazon-contributing/opentelemetry-collector-contrib/extension/awsmiddleware"
// "github.com/amazon-contributing/opentelemetry-collector-contrib/extension/awsmiddleware"
"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/service/cloudwatchlogs"
"github.com/google/uuid"
Expand All @@ -23,6 +23,7 @@ import (
"go.opentelemetry.io/collector/pdata/plog"
"go.uber.org/zap"

"github.com/open-telemetry/opentelemetry-collector-contrib/exporter/awscloudwatchlogsexporter/internal/metadata"
"github.com/open-telemetry/opentelemetry-collector-contrib/internal/aws/awsutil"
"github.com/open-telemetry/opentelemetry-collector-contrib/internal/aws/cwlogs"
)
Expand Down Expand Up @@ -59,7 +60,7 @@ func newCwLogsPusher(expConfig *Config, params exp.Settings) (*cwlExporter, erro
}

// create CWLogs client with aws session config
svcStructuredLog := cwlogs.NewClient(params.Logger, awsConfig, params.BuildInfo, expConfig.LogGroupName, expConfig.LogRetention, expConfig.Tags, session)
svcStructuredLog := cwlogs.NewClient(params.Logger, awsConfig, params.BuildInfo, expConfig.LogGroupName, expConfig.LogRetention, expConfig.Tags, session, metadata.Type.String())
collectorIdentifier, err := uuid.NewRandom()
if err != nil {
return nil, err
Expand Down Expand Up @@ -93,7 +94,6 @@ func newCwLogsExporter(config component.Config, params exp.Settings) (exp.Logs,
exporterhelper.WithQueue(expConfig.QueueSettings),
exporterhelper.WithRetry(expConfig.BackOffConfig),
exporterhelper.WithCapabilities(consumer.Capabilities{MutatesData: false}),
exporterhelper.WithStart(logsPusher.start),
exporterhelper.WithShutdown(logsPusher.shutdown),
)
}
Expand All @@ -117,12 +117,17 @@ func (e *cwlExporter) consumeLogs(_ context.Context, ld plog.Logs) error {
return errs
}

func (e *cwlExporter) start(_ context.Context, host component.Host) error {
if e.Config.MiddlewareID != nil {
awsmiddleware.TryConfigure(e.logger, host, *e.Config.MiddlewareID, awsmiddleware.SDKv1(e.svcStructuredLog.Handlers()))
}
return nil
}
// In OCB branch, "aws/cwlogs" is not replaced by the forked "aws/cwlogs", and relies on upstream "aws/cwlogs".
// However, upstream "aws/cwlogs" does not have method "Handlers" in type type *cwlogs.Client, causing conflicts
// Upstream also does not implement "start()" in awscloudwatchlogsexporter. It is only implemented in the fork.
// This method is removed to avoid issues with the GitHub workflows for components unrelated to OCB components
// (such as "awscloudwatchlogsexporter")
// func (e *cwlExporter) start(_ context.Context, host component.Host) error {
// if e.Config.MiddlewareID != nil {
// awsmiddleware.TryConfigure(e.logger, host, *e.Config.MiddlewareID, awsmiddleware.SDKv1(e.svcStructuredLog.Handlers()))
// }
// return nil
// }

func (e *cwlExporter) shutdown(_ context.Context) error {
return nil
Expand Down
79 changes: 40 additions & 39 deletions exporter/awscloudwatchlogsexporter/exporter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,11 @@ import (
"testing"
"time"

"github.com/amazon-contributing/opentelemetry-collector-contrib/extension/awsmiddleware"
"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/service/cloudwatchlogs"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/mock"
"github.com/stretchr/testify/require"
"go.opentelemetry.io/collector/component"
"go.opentelemetry.io/collector/exporter/exportertest"
"go.opentelemetry.io/collector/pdata/pcommon"
"go.opentelemetry.io/collector/pdata/plog"
Expand Down Expand Up @@ -467,43 +465,46 @@ func TestConsumeLogs(t *testing.T) {
}
}

func TestMiddleware(t *testing.T) {
testType, _ := component.NewType("test")
id := component.NewID(testType)
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
factory := NewFactory()
expCfg := factory.CreateDefaultConfig().(*Config)
expCfg.Region = "us-west-2"
expCfg.LogGroupName = "testGroup"
expCfg.LogStreamName = "testStream"
expCfg.MaxRetries = 0
expCfg.MiddlewareID = &id
handler := new(awsmiddleware.MockHandler)
handler.On("ID").Return("test")
handler.On("Position").Return(awsmiddleware.After)
handler.On("HandleRequest", mock.Anything, mock.Anything)
handler.On("HandleResponse", mock.Anything, mock.Anything)
middleware := new(awsmiddleware.MockMiddlewareExtension)
middleware.On("Handlers").Return([]awsmiddleware.RequestHandler{handler}, []awsmiddleware.ResponseHandler{handler})
extensions := map[component.ID]component.Component{id: middleware}
exp, err := newCwLogsPusher(expCfg, exportertest.NewNopSettings())
assert.Nil(t, err)
assert.NotNil(t, exp)
host := new(awsmiddleware.MockExtensionsHost)
host.On("GetExtensions").Return(extensions)
assert.NoError(t, exp.start(ctx, host))
ld := plog.NewLogs()
r := ld.ResourceLogs().AppendEmpty()
r.Resource().Attributes().PutStr("hello", "test")
logRecords := r.ScopeLogs().AppendEmpty().LogRecords()
logRecords.EnsureCapacity(5)
logRecords.AppendEmpty()
require.Error(t, exp.consumeLogs(ctx, ld))
require.NoError(t, exp.shutdown(ctx))
handler.AssertCalled(t, "HandleRequest", mock.Anything, mock.Anything)
handler.AssertCalled(t, "HandleResponse", mock.Anything, mock.Anything)
}
// Remove the following test in OCB branch as upstream "internal/aws/cwlogs" is depended on
// as opposed to the forked version. This means the "exp.start(ctx, host)" method that was added
// in the fork is not available to test in the OCB branch.
// func TestMiddleware(t *testing.T) {
// testType, _ := component.NewType("test")
// id := component.NewID(testType)
// ctx, cancel := context.WithCancel(context.Background())
// defer cancel()
// factory := NewFactory()
// expCfg := factory.CreateDefaultConfig().(*Config)
// expCfg.Region = "us-west-2"
// expCfg.LogGroupName = "testGroup"
// expCfg.LogStreamName = "testStream"
// expCfg.MaxRetries = 0
// expCfg.MiddlewareID = &id
// handler := new(awsmiddleware.MockHandler)
// handler.On("ID").Return("test")
// handler.On("Position").Return(awsmiddleware.After)
// handler.On("HandleRequest", mock.Anything, mock.Anything)
// handler.On("HandleResponse", mock.Anything, mock.Anything)
// middleware := new(awsmiddleware.MockMiddlewareExtension)
// middleware.On("Handlers").Return([]awsmiddleware.RequestHandler{handler}, []awsmiddleware.ResponseHandler{handler})
// extensions := map[component.ID]component.Component{id: middleware}
// exp, err := newCwLogsPusher(expCfg, exportertest.NewNopSettings())
// assert.Nil(t, err)
// assert.NotNil(t, exp)
// host := new(awsmiddleware.MockExtensionsHost)
// host.On("GetExtensions").Return(extensions)
// assert.NoError(t, exp.start(ctx, host))
// ld := plog.NewLogs()
// r := ld.ResourceLogs().AppendEmpty()
// r.Resource().Attributes().PutStr("hello", "test")
// logRecords := r.ScopeLogs().AppendEmpty().LogRecords()
// logRecords.EnsureCapacity(5)
// logRecords.AppendEmpty()
// require.Error(t, exp.consumeLogs(ctx, ld))
// require.NoError(t, exp.shutdown(ctx))
// handler.AssertCalled(t, "HandleRequest", mock.Anything, mock.Anything)
// handler.AssertCalled(t, "HandleResponse", mock.Anything, mock.Anything)
// }

func TestNewExporterWithoutRegionErr(t *testing.T) {
factory := NewFactory()
Expand Down
6 changes: 2 additions & 4 deletions exporter/awscloudwatchlogsexporter/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/exporter/awsclo
go 1.22.5

require (
github.com/amazon-contributing/opentelemetry-collector-contrib/extension/awsmiddleware v0.0.0-20240419190856-2f880467f335
github.com/aws/aws-sdk-go v1.53.11
github.com/cenkalti/backoff/v4 v4.3.0
github.com/google/uuid v1.6.0
Expand All @@ -25,8 +24,6 @@ require (

require (
github.com/amazon-contributing/opentelemetry-collector-contrib/override/aws v0.0.0-20241107200025-113eee2da3ff // indirect
github.com/aws/aws-sdk-go-v2 v1.22.2 // indirect
github.com/aws/smithy-go v1.16.0 // indirect
github.com/beorn7/perks v1.0.1 // indirect
github.com/cespare/xxhash/v2 v2.3.0 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
Expand Down Expand Up @@ -70,7 +67,8 @@ require (

replace github.com/open-telemetry/opentelemetry-collector-contrib/internal/aws/awsutil => ../../internal/aws/awsutil

replace github.com/open-telemetry/opentelemetry-collector-contrib/internal/aws/cwlogs => ../../internal/aws/cwlogs
// Do not use replace for OCB components that may have conflicting OTel Collector dependencies
// replace github.com/open-telemetry/opentelemetry-collector-contrib/internal/aws/cwlogs => ../../internal/aws/cwlogs

replace github.com/amazon-contributing/opentelemetry-collector-contrib/override/aws => ../../override/aws

Expand Down
24 changes: 2 additions & 22 deletions exporter/awscloudwatchlogsexporter/go.sum

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion exporter/awsemfexporter/factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ func createMetricsExporter(ctx context.Context, params exporter.Settings, config
return nil, err
}

exporter, err := exporterhelper.NewMetricsExporter(
exporter, err := exporterhelper.NewMetrics(
ctx,
params,
config,
Expand Down
Loading
Loading