Skip to content

Commit

Permalink
resolving comments
Browse files Browse the repository at this point in the history
  • Loading branch information
Paramadon committed Dec 16, 2024
1 parent c223485 commit 5dcbb54
Show file tree
Hide file tree
Showing 9 changed files with 19 additions and 17 deletions.
2 changes: 1 addition & 1 deletion cmd/otelcontribcol/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,7 @@ require (
github.com/alecthomas/participle/v2 v2.1.1 // indirect
github.com/alecthomas/units v0.0.0-20231202071711-9a357b53e9c9 // indirect
github.com/aliyun/aliyun-log-go-sdk v0.1.76 // indirect
github.com/amazon-contributing/opentelemetry-collector-contrib/extension/awsmiddleware v0.0.0-20241204155332-be45e31638de // indirect
github.com/amazon-contributing/opentelemetry-collector-contrib/extension/awsmiddleware v0.0.0-20240419190856-2f880467f335 // indirect
github.com/amazon-contributing/opentelemetry-collector-contrib/override/aws v0.0.0-20240415183253-230331014d2c // indirect
github.com/andybalholm/brotli v1.1.0 // indirect
github.com/apache/arrow/go/v15 v15.0.0 // indirect
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,7 @@ require (
github.com/alecthomas/participle/v2 v2.1.1 // indirect
github.com/alecthomas/units v0.0.0-20231202071711-9a357b53e9c9 // indirect
github.com/aliyun/aliyun-log-go-sdk v0.1.76 // indirect
github.com/amazon-contributing/opentelemetry-collector-contrib/extension/awsmiddleware v0.0.0-20241204155332-be45e31638de // indirect
github.com/amazon-contributing/opentelemetry-collector-contrib/extension/awsmiddleware v0.0.0-20240419190856-2f880467f335 // indirect
github.com/amazon-contributing/opentelemetry-collector-contrib/override/aws v0.0.0-20240415183253-230331014d2c // indirect
github.com/andybalholm/brotli v1.1.0 // indirect
github.com/apache/arrow/go/v15 v15.0.0 // indirect
Expand Down
4 changes: 2 additions & 2 deletions internal/metadataproviders/aws/ec2/metadata.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import (

type Provider interface {
Get(ctx context.Context) (ec2metadata.EC2InstanceIdentityDocument, error)
GetHandlers(ctx context.Context) *request.Handlers
GetHandlers() *request.Handlers
Hostname(ctx context.Context) (string, error)
InstanceID(ctx context.Context) (string, error)
}
Expand Down Expand Up @@ -62,6 +62,6 @@ func (c *metadataClient) Get(_ context.Context) (ec2metadata.EC2InstanceIdentity
return c.metadataFallbackEnable.GetInstanceIdentityDocument()
}

func (c *metadataClient) GetHandlers(_ context.Context) *request.Handlers {
func (c *metadataClient) GetHandlers() *request.Handlers {
return &c.metadata.Handlers
}
4 changes: 3 additions & 1 deletion processor/resourcedetectionprocessor/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ go 1.22.5
require (
cloud.google.com/go/compute/metadata v0.3.0
github.com/GoogleCloudPlatform/opentelemetry-operations-go/detectors/gcp v1.23.0
github.com/amazon-contributing/opentelemetry-collector-contrib/extension/awsmiddleware v0.0.0-20241204155332-be45e31638de
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/google/go-cmp v0.6.0
github.com/hashicorp/consul/api v1.29.1
Expand Down Expand Up @@ -171,3 +171,5 @@ replace github.com/open-telemetry/opentelemetry-collector-contrib/internal/k8sco
replace github.com/openshift/api v3.9.0+incompatible => github.com/openshift/api v0.0.0-20180801171038-322a19404e37

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

replace github.com/amazon-contributing/opentelemetry-collector-contrib/extension/awsmiddleware => ../../extension/awsmiddleware
1 change: 1 addition & 0 deletions processor/resourcedetectionprocessor/go.sum

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

4 changes: 2 additions & 2 deletions processor/resourcedetectionprocessor/internal/aws/ec2/ec2.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,8 @@ func (d *Detector) Detect(ctx context.Context) (resource pcommon.Resource, schem
return res, conventions.SchemaURL, nil
}

func (d *Detector) ExposeHandlers(ctx context.Context) (handlers *request.Handlers) {
return d.metadataProvider.GetHandlers(ctx)
func (d *Detector) ExposeHandlers() (handlers *request.Handlers) {
return d.metadataProvider.GetHandlers()
}

func getClientConfig(ctx context.Context, logger *zap.Logger) *http.Client {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,8 @@ type Detector interface {
Detect(ctx context.Context) (resource pcommon.Resource, schemaURL string, err error)
}

type ExposeHandlerDetector interface {
Detector // Embed the existing Detector interface
ExposeHandlers(ctx context.Context) *request.Handlers
type HandlerProvider interface {
ExposeHandlers() *request.Handlers
}
type DetectorConfig any

Expand Down Expand Up @@ -126,8 +125,8 @@ func (p *ResourceProvider) Get(ctx context.Context, client *http.Client) (resour

func (p *ResourceProvider) ConfigureHandlers(ctx context.Context, host component.Host, middlewareId component.ID) {
for _, detector := range p.detectors {
if handlerDetector, ok := detector.(ExposeHandlerDetector); ok {
awsmiddleware.TryConfigure(p.logger, host, middlewareId, awsmiddleware.SDKv1(handlerDetector.ExposeHandlers(ctx)))
if handlerDetector, ok := detector.(HandlerProvider); ok {
awsmiddleware.TryConfigure(p.logger, host, middlewareId, awsmiddleware.SDKv1(handlerDetector.ExposeHandlers()))
}
}
}
Expand Down Expand Up @@ -212,4 +211,3 @@ func MergeResource(to, from pcommon.Resource, overrideTo bool) {
func IsEmptyResource(res pcommon.Resource) bool {
return res.Attributes().Len() == 0
}

Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,7 @@ func TestFilterAttributes_NoAttributes(t *testing.T) {
assert.Equal(t, len(droppedAttributes), 0)
}

// mockDetectorWithHandler is a mock detector that implements ExposeHandlerDetector
// mockDetectorWithHandler is a mock detector that implements HandlerProvider
type mockDetectorWithHandler struct {
handlersCalled bool
}
Expand All @@ -329,7 +329,7 @@ func (m *mockDetectorWithHandler) Detect(ctx context.Context) (resource pcommon.
return pcommon.NewResource(), "", nil
}

func (m *mockDetectorWithHandler) ExposeHandlers(ctx context.Context) *request.Handlers {
func (m *mockDetectorWithHandler) ExposeHandlers() *request.Handlers {
m.handlersCalled = true
return &request.Handlers{}
}
Expand All @@ -352,7 +352,7 @@ type mockHost struct {
extensions map[component.ID]component.Component
}

// mockDetector is a basic detector that doesn't implement ExposeHandlerDetector
// mockDetector is a basic detector that doesn't implement HandlerProvider
type mockDetector struct{}

func (m *mockDetector) Detect(ctx context.Context) (resource pcommon.Resource, schemaURL string, err error) {
Expand Down
3 changes: 2 additions & 1 deletion receiver/awscontainerinsightreceiver/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ go 1.22.5

require (
github.com/Microsoft/hcsshim v0.12.0-rc.3
github.com/amazon-contributing/opentelemetry-collector-contrib/extension/awsmiddleware v0.0.0-20241204155332-be45e31638de
github.com/amazon-contributing/opentelemetry-collector-contrib/extension/awsmiddleware v0.0.0-20240419190856-2f880467f335
github.com/amazon-contributing/opentelemetry-collector-contrib/override/aws v0.0.0-00010101000000-000000000000
github.com/aws/aws-sdk-go v1.53.11
github.com/go-kit/log v0.2.1
Expand Down Expand Up @@ -275,3 +275,4 @@ replace github.com/open-telemetry/opentelemetry-collector-contrib/internal/corei
replace github.com/open-telemetry/opentelemetry-collector-contrib/pkg/pdatatest => ../../pkg/pdatatest

replace github.com/open-telemetry/opentelemetry-collector-contrib/pkg/golden => ../../pkg/golden
replace github.com/amazon-contributing/opentelemetry-collector-contrib/extension/awsmiddleware => ../../extension/awsmiddleware

0 comments on commit 5dcbb54

Please sign in to comment.