From dcc01deec2b6f27a5af3e5e3ecbb7f93f5fb0f8a Mon Sep 17 00:00:00 2001 From: bhautikpip Date: Thu, 4 Feb 2021 16:21:40 -0800 Subject: [PATCH 01/18] added failure scenario when getting container fails --- detectors/aws/ecs/ecs.go | 7 ++++++- detectors/aws/ecs/ecs_test.go | 17 +++++++++++++++++ 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/detectors/aws/ecs/ecs.go b/detectors/aws/ecs/ecs.go index dcc11955b91..82eb201f142 100644 --- a/detectors/aws/ecs/ecs.go +++ b/detectors/aws/ecs/ecs.go @@ -37,6 +37,7 @@ const ( var ( empty = resource.Empty() errCannotReadContainerID = errors.New("failed to read container ID from cGroupFile") + errCannotReadContainerName = errors.New("failed to read hostname") errCannotReadCGroupFile = errors.New("ECS resource detector failed to read cGroupFile") errNotOnECS = errors.New("process is not on ECS, cannot detect environment variables from ECS") ) @@ -102,5 +103,9 @@ func (ecsUtils ecsDetectorUtils) getContainerID() (string, error) { // returns host name reported by the kernel func (ecsUtils ecsDetectorUtils) getContainerName() (string, error) { - return os.Hostname() + hostName, err := os.Hostname() + if err != nil { + return "", errCannotReadContainerName + } + return hostName, nil } diff --git a/detectors/aws/ecs/ecs_test.go b/detectors/aws/ecs/ecs_test.go index 85cbb131288..7d667c35f3b 100644 --- a/detectors/aws/ecs/ecs_test.go +++ b/detectors/aws/ecs/ecs_test.go @@ -81,6 +81,23 @@ func TestDetectCannotReadContainerID(t *testing.T) { assert.Equal(t, 0, len(resource.Attributes())) } +//returns empty resource when detector cannot read container Name +func TestDetectCannotReadContainerName(t *testing.T) { + os.Clearenv() + os.Setenv(metadataV3EnvVar, "3") + os.Setenv(metadataV4EnvVar, "4") + detectorUtils := new(MockDetectorUtils) + + detectorUtils.On("getContainerName").Return("", errCannotReadContainerName) + detectorUtils.On("getContainerID").Return("0123456789A", nil) + + detector := ResourceDetector{detectorUtils} + resource, err := detector.Detect(context.Background()) + + assert.Equal(t, errCannotReadContainerName, err) + assert.Equal(t, 0, len(resource.Attributes())) +} + //returns empty resource when process is not running ECS func TestReturnsIfNoEnvVars(t *testing.T) { os.Clearenv() From 1dd54d977a8dce0027f0ff4a79afa1aa9c49eaaf Mon Sep 17 00:00:00 2001 From: bhautikpip Date: Thu, 4 Feb 2021 16:57:07 -0800 Subject: [PATCH 02/18] fix test case failure --- detectors/aws/ecs/ecs.go | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/detectors/aws/ecs/ecs.go b/detectors/aws/ecs/ecs.go index 82eb201f142..1bf477345d1 100644 --- a/detectors/aws/ecs/ecs.go +++ b/detectors/aws/ecs/ecs.go @@ -35,11 +35,11 @@ const ( ) var ( - empty = resource.Empty() - errCannotReadContainerID = errors.New("failed to read container ID from cGroupFile") - errCannotReadContainerName = errors.New("failed to read hostname") - errCannotReadCGroupFile = errors.New("ECS resource detector failed to read cGroupFile") - errNotOnECS = errors.New("process is not on ECS, cannot detect environment variables from ECS") + empty = resource.Empty() + errCannotReadContainerID = errors.New("failed to read container ID from cGroupFile") + errCannotReadContainerName = errors.New("failed to read hostname") + errCannotReadCGroupFile = errors.New("ECS resource detector failed to read cGroupFile") + errNotOnECS = errors.New("process is not on ECS, cannot detect environment variables from ECS") ) // Create interface for methods needing to be mocked From 03f6fb4f99601c371279378a4c005dc4bf78867e Mon Sep 17 00:00:00 2001 From: bhautikpip Date: Fri, 5 Feb 2021 10:45:07 -0800 Subject: [PATCH 03/18] add changelog --- CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 91b685de7d9..39bba122bb9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,10 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm ## [Unreleased] +### Fixed + +- Added failure message for AWS ECS resource detector for better debugging (#568) + ## [0.16.0] - 2021-01-13 ### Fixed From e1ff7d0404815b18be13c39521405cc7d731bfe1 Mon Sep 17 00:00:00 2001 From: bhautikpip Date: Sat, 6 Feb 2021 17:04:11 -0800 Subject: [PATCH 04/18] fix ecs resource detector bug --- detectors/aws/ecs/ecs.go | 18 ++++++------------ detectors/aws/ecs/ecs_test.go | 28 ++++++++++++++-------------- 2 files changed, 20 insertions(+), 26 deletions(-) diff --git a/detectors/aws/ecs/ecs.go b/detectors/aws/ecs/ecs.go index 1bf477345d1..02c2718d78a 100644 --- a/detectors/aws/ecs/ecs.go +++ b/detectors/aws/ecs/ecs.go @@ -49,19 +49,13 @@ type detectorUtils interface { } // struct implements detectorUtils interface -type ecsDetectorUtils struct{} +type EcsDetectorUtils struct{} // resource detector collects resource information from Elastic Container Service environment type ResourceDetector struct { - utils detectorUtils + Utils detectorUtils } -// compile time assertion that ecsDetectorUtils implements detectorUtils interface -var _ detectorUtils = (*ecsDetectorUtils)(nil) - -// compile time assertion that resource detector implements the resource.Detector interface. -var _ resource.Detector = (*ResourceDetector)(nil) - // Detect finds associated resources when running on ECS environment. func (detector *ResourceDetector) Detect(ctx context.Context) (*resource.Resource, error) { metadataURIV3 := os.Getenv(metadataV3EnvVar) @@ -70,11 +64,11 @@ func (detector *ResourceDetector) Detect(ctx context.Context) (*resource.Resourc if len(metadataURIV3) == 0 && len(metadataURIV4) == 0 { return empty, errNotOnECS } - hostName, err := detector.utils.getContainerName() + hostName, err := detector.Utils.getContainerName() if err != nil { return empty, err } - containerID, err := detector.utils.getContainerID() + containerID, err := detector.Utils.getContainerID() if err != nil { return empty, err } @@ -87,7 +81,7 @@ func (detector *ResourceDetector) Detect(ctx context.Context) (*resource.Resourc } // returns docker container ID from default c group path -func (ecsUtils ecsDetectorUtils) getContainerID() (string, error) { +func (ecsUtils EcsDetectorUtils) getContainerID() (string, error) { fileData, err := ioutil.ReadFile(defaultCgroupPath) if err != nil { return "", errCannotReadCGroupFile @@ -102,7 +96,7 @@ func (ecsUtils ecsDetectorUtils) getContainerID() (string, error) { } // returns host name reported by the kernel -func (ecsUtils ecsDetectorUtils) getContainerName() (string, error) { +func (ecsUtils EcsDetectorUtils) getContainerName() (string, error) { hostName, err := os.Hostname() if err != nil { return "", errCannotReadContainerName diff --git a/detectors/aws/ecs/ecs_test.go b/detectors/aws/ecs/ecs_test.go index 7d667c35f3b..045648ea035 100644 --- a/detectors/aws/ecs/ecs_test.go +++ b/detectors/aws/ecs/ecs_test.go @@ -45,8 +45,8 @@ func (detectorUtils *MockDetectorUtils) getContainerName() (string, error) { //succesfully return resource when process is running on Amazon ECS environment func TestDetect(t *testing.T) { os.Clearenv() - os.Setenv(metadataV3EnvVar, "3") - os.Setenv(metadataV4EnvVar, "4") + _ = os.Setenv(metadataV3EnvVar, "3") + _ = os.Setenv(metadataV4EnvVar, "4") detectorUtils := new(MockDetectorUtils) @@ -59,51 +59,51 @@ func TestDetect(t *testing.T) { } expectedResource := resource.NewWithAttributes(labels...) detector := ResourceDetector{detectorUtils} - resource, _ := detector.Detect(context.Background()) + res, _ := detector.Detect(context.Background()) - assert.Equal(t, resource, expectedResource, "Resource returned is incorrect") + assert.Equal(t, res, expectedResource, "Resource returned is incorrect") } //returns empty resource when detector cannot read container ID func TestDetectCannotReadContainerID(t *testing.T) { os.Clearenv() - os.Setenv(metadataV3EnvVar, "3") - os.Setenv(metadataV4EnvVar, "4") + _ = os.Setenv(metadataV3EnvVar, "3") + _ = os.Setenv(metadataV4EnvVar, "4") detectorUtils := new(MockDetectorUtils) detectorUtils.On("getContainerName").Return("container-Name", nil) detectorUtils.On("getContainerID").Return("", errCannotReadContainerID) detector := ResourceDetector{detectorUtils} - resource, err := detector.Detect(context.Background()) + res, err := detector.Detect(context.Background()) assert.Equal(t, errCannotReadContainerID, err) - assert.Equal(t, 0, len(resource.Attributes())) + assert.Equal(t, 0, len(res.Attributes())) } //returns empty resource when detector cannot read container Name func TestDetectCannotReadContainerName(t *testing.T) { os.Clearenv() - os.Setenv(metadataV3EnvVar, "3") - os.Setenv(metadataV4EnvVar, "4") + _ = os.Setenv(metadataV3EnvVar, "3") + _ = os.Setenv(metadataV4EnvVar, "4") detectorUtils := new(MockDetectorUtils) detectorUtils.On("getContainerName").Return("", errCannotReadContainerName) detectorUtils.On("getContainerID").Return("0123456789A", nil) detector := ResourceDetector{detectorUtils} - resource, err := detector.Detect(context.Background()) + res, err := detector.Detect(context.Background()) assert.Equal(t, errCannotReadContainerName, err) - assert.Equal(t, 0, len(resource.Attributes())) + assert.Equal(t, 0, len(res.Attributes())) } //returns empty resource when process is not running ECS func TestReturnsIfNoEnvVars(t *testing.T) { os.Clearenv() detector := ResourceDetector{} - resource, err := detector.Detect(context.Background()) + res, err := detector.Detect(context.Background()) assert.Equal(t, errNotOnECS, err) - assert.Equal(t, 0, len(resource.Attributes())) + assert.Equal(t, 0, len(res.Attributes())) } From e12a4b185593413d0d459ffcd5507b20362c4819 Mon Sep 17 00:00:00 2001 From: bhautikpip Date: Sat, 6 Feb 2021 17:17:55 -0800 Subject: [PATCH 05/18] fix struct name as per golint suggestion --- detectors/aws/ecs/ecs.go | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/detectors/aws/ecs/ecs.go b/detectors/aws/ecs/ecs.go index 02c2718d78a..a319454e72b 100644 --- a/detectors/aws/ecs/ecs.go +++ b/detectors/aws/ecs/ecs.go @@ -43,17 +43,17 @@ var ( ) // Create interface for methods needing to be mocked -type detectorUtils interface { +type detectorUtilsResources interface { getContainerName() (string, error) getContainerID() (string, error) } // struct implements detectorUtils interface -type EcsDetectorUtils struct{} +type DetectorUtils struct{} // resource detector collects resource information from Elastic Container Service environment type ResourceDetector struct { - Utils detectorUtils + Utils detectorUtilsResources } // Detect finds associated resources when running on ECS environment. @@ -81,7 +81,7 @@ func (detector *ResourceDetector) Detect(ctx context.Context) (*resource.Resourc } // returns docker container ID from default c group path -func (ecsUtils EcsDetectorUtils) getContainerID() (string, error) { +func (ecsUtils DetectorUtils) getContainerID() (string, error) { fileData, err := ioutil.ReadFile(defaultCgroupPath) if err != nil { return "", errCannotReadCGroupFile @@ -96,7 +96,7 @@ func (ecsUtils EcsDetectorUtils) getContainerID() (string, error) { } // returns host name reported by the kernel -func (ecsUtils EcsDetectorUtils) getContainerName() (string, error) { +func (ecsUtils DetectorUtils) getContainerName() (string, error) { hostName, err := os.Hostname() if err != nil { return "", errCannotReadContainerName From 86c04d1b71f1fcb56703afac36148503098553ec Mon Sep 17 00:00:00 2001 From: bhautikpip Date: Sat, 6 Feb 2021 17:22:49 -0800 Subject: [PATCH 06/18] minor changes --- detectors/aws/ecs/ecs.go | 2 +- detectors/aws/ecs/ecs_test.go | 17 ----------------- 2 files changed, 1 insertion(+), 18 deletions(-) diff --git a/detectors/aws/ecs/ecs.go b/detectors/aws/ecs/ecs.go index a319454e72b..f6237a19f14 100644 --- a/detectors/aws/ecs/ecs.go +++ b/detectors/aws/ecs/ecs.go @@ -48,7 +48,7 @@ type detectorUtilsResources interface { getContainerID() (string, error) } -// struct implements detectorUtils interface +// struct implements detectorUtilsResources interface type DetectorUtils struct{} // resource detector collects resource information from Elastic Container Service environment diff --git a/detectors/aws/ecs/ecs_test.go b/detectors/aws/ecs/ecs_test.go index 86239f61a81..045648ea035 100644 --- a/detectors/aws/ecs/ecs_test.go +++ b/detectors/aws/ecs/ecs_test.go @@ -98,23 +98,6 @@ func TestDetectCannotReadContainerName(t *testing.T) { assert.Equal(t, 0, len(res.Attributes())) } -//returns empty resource when detector cannot read container Name -func TestDetectCannotReadContainerName(t *testing.T) { - os.Clearenv() - os.Setenv(metadataV3EnvVar, "3") - os.Setenv(metadataV4EnvVar, "4") - detectorUtils := new(MockDetectorUtils) - - detectorUtils.On("getContainerName").Return("", errCannotReadContainerName) - detectorUtils.On("getContainerID").Return("0123456789A", nil) - - detector := ResourceDetector{detectorUtils} - resource, err := detector.Detect(context.Background()) - - assert.Equal(t, errCannotReadContainerName, err) - assert.Equal(t, 0, len(resource.Attributes())) -} - //returns empty resource when process is not running ECS func TestReturnsIfNoEnvVars(t *testing.T) { os.Clearenv() From 047f5d0c663a283163d8d9154cff2c292bd76b0f Mon Sep 17 00:00:00 2001 From: bhautikpip Date: Tue, 9 Feb 2021 09:58:45 -0800 Subject: [PATCH 07/18] added NewResourceDetector func and interface assertions --- detectors/aws/ecs/ecs.go | 21 ++++++++++++++++----- detectors/aws/ecs/ecs_test.go | 8 ++++---- 2 files changed, 20 insertions(+), 9 deletions(-) diff --git a/detectors/aws/ecs/ecs.go b/detectors/aws/ecs/ecs.go index f6237a19f14..5978b1476f7 100644 --- a/detectors/aws/ecs/ecs.go +++ b/detectors/aws/ecs/ecs.go @@ -52,23 +52,34 @@ type detectorUtilsResources interface { type DetectorUtils struct{} // resource detector collects resource information from Elastic Container Service environment -type ResourceDetector struct { - Utils detectorUtilsResources +type resourceDetector struct { + utils detectorUtilsResources +} + +// compile time assertion that ecsDetectorUtils implements detectorUtilsResources interface +var _ detectorUtilsResources = (*DetectorUtils)(nil) + +// compile time assertion that resource detector implements the resource.Detector interface. +var _ resource.Detector = (*resourceDetector)(nil) + +// returns resource detector struct +func NewResourceDetector(detectorUtils detectorUtilsResources) resourceDetector{ + return resourceDetector{utils: detectorUtils} } // Detect finds associated resources when running on ECS environment. -func (detector *ResourceDetector) Detect(ctx context.Context) (*resource.Resource, error) { +func (detector *resourceDetector) Detect(ctx context.Context) (*resource.Resource, error) { metadataURIV3 := os.Getenv(metadataV3EnvVar) metadataURIV4 := os.Getenv(metadataV4EnvVar) if len(metadataURIV3) == 0 && len(metadataURIV4) == 0 { return empty, errNotOnECS } - hostName, err := detector.Utils.getContainerName() + hostName, err := detector.utils.getContainerName() if err != nil { return empty, err } - containerID, err := detector.Utils.getContainerID() + containerID, err := detector.utils.getContainerID() if err != nil { return empty, err } diff --git a/detectors/aws/ecs/ecs_test.go b/detectors/aws/ecs/ecs_test.go index 045648ea035..fda1d4ba210 100644 --- a/detectors/aws/ecs/ecs_test.go +++ b/detectors/aws/ecs/ecs_test.go @@ -58,7 +58,7 @@ func TestDetect(t *testing.T) { semconv.ContainerIDKey.String("0123456789A"), } expectedResource := resource.NewWithAttributes(labels...) - detector := ResourceDetector{detectorUtils} + detector := NewResourceDetector(detectorUtils) res, _ := detector.Detect(context.Background()) assert.Equal(t, res, expectedResource, "Resource returned is incorrect") @@ -74,7 +74,7 @@ func TestDetectCannotReadContainerID(t *testing.T) { detectorUtils.On("getContainerName").Return("container-Name", nil) detectorUtils.On("getContainerID").Return("", errCannotReadContainerID) - detector := ResourceDetector{detectorUtils} + detector := NewResourceDetector(detectorUtils) res, err := detector.Detect(context.Background()) assert.Equal(t, errCannotReadContainerID, err) @@ -91,7 +91,7 @@ func TestDetectCannotReadContainerName(t *testing.T) { detectorUtils.On("getContainerName").Return("", errCannotReadContainerName) detectorUtils.On("getContainerID").Return("0123456789A", nil) - detector := ResourceDetector{detectorUtils} + detector := NewResourceDetector(detectorUtils) res, err := detector.Detect(context.Background()) assert.Equal(t, errCannotReadContainerName, err) @@ -101,7 +101,7 @@ func TestDetectCannotReadContainerName(t *testing.T) { //returns empty resource when process is not running ECS func TestReturnsIfNoEnvVars(t *testing.T) { os.Clearenv() - detector := ResourceDetector{} + detector := NewResourceDetector(nil) res, err := detector.Detect(context.Background()) assert.Equal(t, errNotOnECS, err) From 21db8fabc829a60110299e36658c1f9039b704b7 Mon Sep 17 00:00:00 2001 From: bhautikpip Date: Tue, 9 Feb 2021 14:42:29 -0800 Subject: [PATCH 08/18] fix golint failure --- detectors/aws/ecs/ecs.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/detectors/aws/ecs/ecs.go b/detectors/aws/ecs/ecs.go index 5978b1476f7..57376e876e9 100644 --- a/detectors/aws/ecs/ecs.go +++ b/detectors/aws/ecs/ecs.go @@ -63,8 +63,8 @@ var _ detectorUtilsResources = (*DetectorUtils)(nil) var _ resource.Detector = (*resourceDetector)(nil) // returns resource detector struct -func NewResourceDetector(detectorUtils detectorUtilsResources) resourceDetector{ - return resourceDetector{utils: detectorUtils} +func NewResourceDetector(detectorUtils detectorUtilsResources) resource.Detector { + return &resourceDetector{utils: detectorUtils} } // Detect finds associated resources when running on ECS environment. From 5204d27fd5ab645060c5f07d746404b6b8ca54df Mon Sep 17 00:00:00 2001 From: bhautikpip Date: Tue, 9 Feb 2021 17:24:15 -0800 Subject: [PATCH 09/18] minor changes to address review comments --- detectors/aws/ecs/ecs.go | 22 +++++++++++----------- detectors/aws/ecs/ecs_test.go | 8 ++++---- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/detectors/aws/ecs/ecs.go b/detectors/aws/ecs/ecs.go index 57376e876e9..2e21bb080b0 100644 --- a/detectors/aws/ecs/ecs.go +++ b/detectors/aws/ecs/ecs.go @@ -43,28 +43,28 @@ var ( ) // Create interface for methods needing to be mocked -type detectorUtilsResources interface { +type detectorUtils interface { getContainerName() (string, error) getContainerID() (string, error) } -// struct implements detectorUtilsResources interface -type DetectorUtils struct{} +// struct implements detectorUtils interface +type ecsDetectorUtils struct{} // resource detector collects resource information from Elastic Container Service environment type resourceDetector struct { - utils detectorUtilsResources + utils detectorUtils } -// compile time assertion that ecsDetectorUtils implements detectorUtilsResources interface -var _ detectorUtilsResources = (*DetectorUtils)(nil) +// compile time assertion that ecsDetectorUtils implements detectorUtils interface +var _ detectorUtils = (*ecsDetectorUtils)(nil) // compile time assertion that resource detector implements the resource.Detector interface. var _ resource.Detector = (*resourceDetector)(nil) -// returns resource detector struct -func NewResourceDetector(detectorUtils detectorUtilsResources) resource.Detector { - return &resourceDetector{utils: detectorUtils} +// NewResourceDetector returns a resource detector that will detect AWS ECS resources. +func NewResourceDetector() resource.Detector { + return &resourceDetector{utils: ecsDetectorUtils{}} } // Detect finds associated resources when running on ECS environment. @@ -92,7 +92,7 @@ func (detector *resourceDetector) Detect(ctx context.Context) (*resource.Resourc } // returns docker container ID from default c group path -func (ecsUtils DetectorUtils) getContainerID() (string, error) { +func (ecsUtils ecsDetectorUtils) getContainerID() (string, error) { fileData, err := ioutil.ReadFile(defaultCgroupPath) if err != nil { return "", errCannotReadCGroupFile @@ -107,7 +107,7 @@ func (ecsUtils DetectorUtils) getContainerID() (string, error) { } // returns host name reported by the kernel -func (ecsUtils DetectorUtils) getContainerName() (string, error) { +func (ecsUtils ecsDetectorUtils) getContainerName() (string, error) { hostName, err := os.Hostname() if err != nil { return "", errCannotReadContainerName diff --git a/detectors/aws/ecs/ecs_test.go b/detectors/aws/ecs/ecs_test.go index fda1d4ba210..c7719102818 100644 --- a/detectors/aws/ecs/ecs_test.go +++ b/detectors/aws/ecs/ecs_test.go @@ -58,7 +58,7 @@ func TestDetect(t *testing.T) { semconv.ContainerIDKey.String("0123456789A"), } expectedResource := resource.NewWithAttributes(labels...) - detector := NewResourceDetector(detectorUtils) + detector := &resourceDetector{utils: detectorUtils} res, _ := detector.Detect(context.Background()) assert.Equal(t, res, expectedResource, "Resource returned is incorrect") @@ -74,7 +74,7 @@ func TestDetectCannotReadContainerID(t *testing.T) { detectorUtils.On("getContainerName").Return("container-Name", nil) detectorUtils.On("getContainerID").Return("", errCannotReadContainerID) - detector := NewResourceDetector(detectorUtils) + detector := &resourceDetector{utils: detectorUtils} res, err := detector.Detect(context.Background()) assert.Equal(t, errCannotReadContainerID, err) @@ -91,7 +91,7 @@ func TestDetectCannotReadContainerName(t *testing.T) { detectorUtils.On("getContainerName").Return("", errCannotReadContainerName) detectorUtils.On("getContainerID").Return("0123456789A", nil) - detector := NewResourceDetector(detectorUtils) + detector := &resourceDetector{utils: detectorUtils} res, err := detector.Detect(context.Background()) assert.Equal(t, errCannotReadContainerName, err) @@ -101,7 +101,7 @@ func TestDetectCannotReadContainerName(t *testing.T) { //returns empty resource when process is not running ECS func TestReturnsIfNoEnvVars(t *testing.T) { os.Clearenv() - detector := NewResourceDetector(nil) + detector := &resourceDetector{utils: nil} res, err := detector.Detect(context.Background()) assert.Equal(t, errNotOnECS, err) From f30b844e6507b72e926c4c9b21217a984d493c87 Mon Sep 17 00:00:00 2001 From: bhautikpip Date: Mon, 8 Nov 2021 11:50:04 -0800 Subject: [PATCH 10/18] lambda go instrumentation enhancements --- .../aws/aws-lambda-go/otellambda/config.go | 17 ++++- .../otellambda/xrayconfig/README.md | 12 ++-- .../otellambda/xrayconfig/xrayconfig.go | 67 +++++++------------ .../otellambda/xrayconfig/xrayconfig_test.go | 5 +- 4 files changed, 51 insertions(+), 50 deletions(-) diff --git a/instrumentation/github.com/aws/aws-lambda-go/otellambda/config.go b/instrumentation/github.com/aws/aws-lambda-go/otellambda/config.go index fc4309379d1..c11ce9799bc 100644 --- a/instrumentation/github.com/aws/aws-lambda-go/otellambda/config.go +++ b/instrumentation/github.com/aws/aws-lambda-go/otellambda/config.go @@ -16,6 +16,7 @@ package otellambda import ( "context" + "runtime" "go.opentelemetry.io/otel/propagation" "go.opentelemetry.io/otel/trace" @@ -38,6 +39,20 @@ func (*noopFlusher) ForceFlush(context.Context) error { return nil } // Compile time check our noopFlusher implements Flusher var _ Flusher = &noopFlusher{} +type asyncSafeFlusher struct { + flusher Flusher +} + +func (f asyncSafeFlusher) ForceFlush(ctx context.Context) error { + // yield processor to attempt to ensure all spans have + // been consumed and are ready to be flushed + // - see https://github.com/open-telemetry/opentelemetry-go/issues/2080 + // to be removed upon resolution of above issue + runtime.Gosched() + + return f.flusher.ForceFlush(ctx) +} + // An EventToCarrier function defines how the instrumentation should // prepare a TextMapCarrier for the configured propagator to read from. This // extra step is necessary because Lambda does not have HTTP headers to read @@ -100,7 +115,7 @@ func WithTracerProvider(tracerProvider trace.TracerProvider) Option { func WithFlusher(flusher Flusher) Option { return optionFunc(func(c *config) { - c.Flusher = flusher + c.Flusher = asyncSafeFlusher{flusher: flusher} }) } diff --git a/instrumentation/github.com/aws/aws-lambda-go/otellambda/xrayconfig/README.md b/instrumentation/github.com/aws/aws-lambda-go/otellambda/xrayconfig/README.md index 83b06212cc7..fdebfa34ef8 100644 --- a/instrumentation/github.com/aws/aws-lambda-go/otellambda/xrayconfig/README.md +++ b/instrumentation/github.com/aws/aws-lambda-go/otellambda/xrayconfig/README.md @@ -34,7 +34,7 @@ func HandleRequest(ctx context.Context, name MyEvent) (string, error) { } func main() { - lambda.Start(otellambda.WrapHandlerFunction(HandleRequest)) + lambda.Start(otellambda.InstrumentHandler(HandleRequest)) } ``` @@ -46,17 +46,17 @@ import "go.opentelemetry.io/contrib/instrumentation/github.com/aws/aws-lambda-go // add options to WrapHandlerFunction call func main() { - lambda.Start(otellambda.WrapHandlerFunction(HandleRequest, xrayconfig.AllRecommendedOptions()...)) + lambda.Start(otellambda.InstrumentHandler(HandleRequest, xrayconfig.RecommendedOptions()...)) } ``` ## Recommended AWS Lambda Instrumentation Options | Instrumentation Option | Recommended Value | Exported As | | --- | --- | --- | -| `WithTracerProvider` | An `sdktrace.TracerProvider` configured to export in batches to an OTel Collector running locally in Lambda | Not individually exported. Can only be used via `AllRecommendedOptions()` -| `WithFlusher` | An `otellambda.Flusher` which yields before calling ForceFlush on the configured `sdktrace.TracerProvider`. Yielding mitigates data delays caused by asynchronous nature of batching TracerProvider when in Lambda | Not individually exported. Can only be used via `AllRecommendedOptions()` -| `WithEventToCarrier` | Function which reads X-Ray TraceID from Lambda environment and inserts it into a `propagtation.TextMapCarrier` | Individually exported as `EventToCarrier()`, also included in `AllRecommendedOptions()` -| `WithPropagator` | An `xray.propagator` | Individually exported as `EventToCarrier()`, also included in `AllRecommendedOptions()` +| `WithTracerProvider` | An `sdktrace.TracerProvider` configured to export in batches to an OTel Collector running locally in Lambda | Not individually exported. Can only be used via `RecommendedOptions()` +| `WithFlusher` | An `otellambda.Flusher` which yields before calling ForceFlush on the configured `sdktrace.TracerProvider`. Yielding mitigates data delays caused by asynchronous nature of batching TracerProvider when in Lambda | Not individually exported. Can only be used via `RecommendedOptions()` +| `WithEventToCarrier` | Function which reads X-Ray TraceID from Lambda environment and inserts it into a `propagtation.TextMapCarrier` | Individually exported as `EventToCarrier()`, also included in `RecommendedOptions()` +| `WithPropagator` | An `xray.propagator` | Individually exported as `Propagator()`, also included in `RecommendedOptions()` ## Useful links diff --git a/instrumentation/github.com/aws/aws-lambda-go/otellambda/xrayconfig/xrayconfig.go b/instrumentation/github.com/aws/aws-lambda-go/otellambda/xrayconfig/xrayconfig.go index ad80eacfc64..07fdf4989c4 100644 --- a/instrumentation/github.com/aws/aws-lambda-go/otellambda/xrayconfig/xrayconfig.go +++ b/instrumentation/github.com/aws/aws-lambda-go/otellambda/xrayconfig/xrayconfig.go @@ -18,7 +18,6 @@ import ( "context" "log" "os" - "runtime" lambdadetector "go.opentelemetry.io/contrib/detectors/aws/lambda" "go.opentelemetry.io/contrib/instrumentation/github.com/aws/aws-lambda-go/otellambda" @@ -35,48 +34,39 @@ func xrayEventToCarrier([]byte) propagation.TextMapCarrier { return propagation.HeaderCarrier{"X-Amzn-Trace-Id": []string{xrayTraceID}} } -type asyncSafeFlusher struct { - tp *sdktrace.TracerProvider -} - -func (f asyncSafeFlusher) ForceFlush(ctx context.Context) error { - // yield processor to attempt to ensure all spans have - // been consumed and are ready to be flushed - // - see https://github.com/open-telemetry/opentelemetry-go/issues/2080 - // to be removed upon resolution of above issue - runtime.Gosched() - - return f.tp.ForceFlush(ctx) -} - -// tracerProviderAndFlusher returns a list of otellambda.Option(s) to -// enable using a TracerProvider configured for AWS XRay via a collector -// and an otellambda.Flusher to flush this TracerProvider. -// tracerProviderAndFlusher is not exported because it should not be used -// without the provided EventToCarrier function and XRay Propagator -func tracerProviderAndFlusher() ([]otellambda.Option, error) { - ctx := context.Background() - - // Do not need transport security in Lambda because collector - // runs locally in Lambda execution environment +// NewTracerProvider returns a TracerProvider configured with exporter, +// id generator and lambda resource detector to send trace data to AWS X-Ray via Collector +func NewTracerProvider(ctx context.Context) (*sdktrace.TracerProvider, error) { exp, err := otlptracegrpc.New(ctx, otlptracegrpc.WithInsecure()) if err != nil { - return []otellambda.Option{}, err + errorLogger.Println("failed to create exporter: ", err) + return nil, err } detector := lambdadetector.NewResourceDetector() - res, err := detector.Detect(ctx) + resource, err := detector.Detect(ctx) if err != nil { - return []otellambda.Option{}, err + errorLogger.Println("failed to detect lambda resources: ", err) + return nil, err } - tp := sdktrace.NewTracerProvider( + return sdktrace.NewTracerProvider( sdktrace.WithBatcher(exp), sdktrace.WithIDGenerator(xray.NewIDGenerator()), - sdktrace.WithResource(res), - ) + sdktrace.WithResource(resource), + ), nil +} + +// TracerProvider returns an otellambda.Option(s) to +// enable using a TracerProvider configured for AWS XRay via a collector +func TracerProvider(tp *sdktrace.TracerProvider) otellambda.Option { + return otellambda.WithTracerProvider(tp) +} - return []otellambda.Option{otellambda.WithTracerProvider(tp), otellambda.WithFlusher(asyncSafeFlusher{tp: tp})}, nil +// Flusher returns an otellambda.Option(s) to +// enable flushing any unexported spans during lambda invocation +func Flusher(tp *sdktrace.TracerProvider) otellambda.Option { + return otellambda.WithFlusher(tp) } // EventToCarrier returns an otellambda.Option to enable @@ -89,18 +79,11 @@ func EventToCarrier() otellambda.Option { // Propagator returns an otellambda.Option to enable the xray.Propagator func Propagator() otellambda.Option { - return otellambda.WithPropagator(xray.Propagator{}) } -// AllRecommendedOptions returns a list of all otellambda.Option(s) +// RecommendedOptions returns a list of all otellambda.Option(s) // recommended for the otellambda package when using AWS XRay -func AllRecommendedOptions() []otellambda.Option { - options, err := tracerProviderAndFlusher() - if err != nil { - // should we fail to create the TracerProvider, do not alter otellambda's default configuration - errorLogger.Println("failed to create recommended configuration: ", err) - return []otellambda.Option{} - } - return append(options, []otellambda.Option{EventToCarrier(), Propagator()}...) +func RecommendedOptions(tp *sdktrace.TracerProvider) []otellambda.Option { + return []otellambda.Option{EventToCarrier(), Propagator(), TracerProvider(tp), Flusher(tp)} } diff --git a/instrumentation/github.com/aws/aws-lambda-go/otellambda/xrayconfig/xrayconfig_test.go b/instrumentation/github.com/aws/aws-lambda-go/otellambda/xrayconfig/xrayconfig_test.go index 1a5d4e446bf..7706292aa45 100644 --- a/instrumentation/github.com/aws/aws-lambda-go/otellambda/xrayconfig/xrayconfig_test.go +++ b/instrumentation/github.com/aws/aws-lambda-go/otellambda/xrayconfig/xrayconfig_test.go @@ -154,6 +154,9 @@ func assertSpanEqualsIgnoreTimeAndSpanID(t *testing.T, expected *v1trace.Resourc func TestWrapEndToEnd(t *testing.T) { setEnvVars() + ctx := context.Background() + tp, _ := NewTracerProvider(ctx) + customerHandler := func() (string, error) { return "hello world", nil } @@ -163,7 +166,7 @@ func TestWrapEndToEnd(t *testing.T) { }() <-time.After(5 * time.Millisecond) - wrapped := otellambda.InstrumentHandler(customerHandler, AllRecommendedOptions()...) + wrapped := otellambda.InstrumentHandler(customerHandler, RecommendedOptions(tp)...) wrappedCallable := reflect.ValueOf(wrapped) resp := wrappedCallable.Call([]reflect.Value{reflect.ValueOf(mockContext)}) assert.Len(t, resp, 2) From 7cf0c34d398cda929835f0dd0487d3cf1c46fb61 Mon Sep 17 00:00:00 2001 From: bhautikpip Date: Mon, 8 Nov 2021 16:18:25 -0800 Subject: [PATCH 11/18] minor changes to address review comments --- .../aws/aws-lambda-go/otellambda/config.go | 17 +---------------- .../aws/aws-lambda-go/otellambda/go.mod | 1 + .../aws/aws-lambda-go/otellambda/go.sum | 4 ++++ .../aws/aws-lambda-go/otellambda/lambda.go | 4 ++++ .../otellambda/xrayconfig/README.md | 2 +- .../otellambda/xrayconfig/xrayconfig.go | 5 +++-- 6 files changed, 14 insertions(+), 19 deletions(-) diff --git a/instrumentation/github.com/aws/aws-lambda-go/otellambda/config.go b/instrumentation/github.com/aws/aws-lambda-go/otellambda/config.go index c11ce9799bc..fc4309379d1 100644 --- a/instrumentation/github.com/aws/aws-lambda-go/otellambda/config.go +++ b/instrumentation/github.com/aws/aws-lambda-go/otellambda/config.go @@ -16,7 +16,6 @@ package otellambda import ( "context" - "runtime" "go.opentelemetry.io/otel/propagation" "go.opentelemetry.io/otel/trace" @@ -39,20 +38,6 @@ func (*noopFlusher) ForceFlush(context.Context) error { return nil } // Compile time check our noopFlusher implements Flusher var _ Flusher = &noopFlusher{} -type asyncSafeFlusher struct { - flusher Flusher -} - -func (f asyncSafeFlusher) ForceFlush(ctx context.Context) error { - // yield processor to attempt to ensure all spans have - // been consumed and are ready to be flushed - // - see https://github.com/open-telemetry/opentelemetry-go/issues/2080 - // to be removed upon resolution of above issue - runtime.Gosched() - - return f.flusher.ForceFlush(ctx) -} - // An EventToCarrier function defines how the instrumentation should // prepare a TextMapCarrier for the configured propagator to read from. This // extra step is necessary because Lambda does not have HTTP headers to read @@ -115,7 +100,7 @@ func WithTracerProvider(tracerProvider trace.TracerProvider) Option { func WithFlusher(flusher Flusher) Option { return optionFunc(func(c *config) { - c.Flusher = asyncSafeFlusher{flusher: flusher} + c.Flusher = flusher }) } diff --git a/instrumentation/github.com/aws/aws-lambda-go/otellambda/go.mod b/instrumentation/github.com/aws/aws-lambda-go/otellambda/go.mod index 30b6e138b24..a554619ecea 100644 --- a/instrumentation/github.com/aws/aws-lambda-go/otellambda/go.mod +++ b/instrumentation/github.com/aws/aws-lambda-go/otellambda/go.mod @@ -8,5 +8,6 @@ require ( github.com/aws/aws-lambda-go v1.27.0 github.com/stretchr/testify v1.7.0 go.opentelemetry.io/otel v1.1.0 + go.opentelemetry.io/otel/sdk v1.1.0 go.opentelemetry.io/otel/trace v1.1.0 ) diff --git a/instrumentation/github.com/aws/aws-lambda-go/otellambda/go.sum b/instrumentation/github.com/aws/aws-lambda-go/otellambda/go.sum index 30dddb54b80..e3f85e18d7b 100644 --- a/instrumentation/github.com/aws/aws-lambda-go/otellambda/go.sum +++ b/instrumentation/github.com/aws/aws-lambda-go/otellambda/go.sum @@ -19,8 +19,12 @@ github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/ github.com/urfave/cli/v2 v2.2.0/go.mod h1:SE9GqnLQmjVa0iPEY0f1w3ygNIYcIJ0OKPMoW2caLfQ= go.opentelemetry.io/otel v1.1.0 h1:8p0uMLcyyIx0KHNTgO8o3CW8A1aA+dJZJW6PvnMz0Wc= go.opentelemetry.io/otel v1.1.0/go.mod h1:7cww0OW51jQ8IaZChIEdqLwgh+44+7uiTdWsAL0wQpA= +go.opentelemetry.io/otel/sdk v1.1.0 h1:j/1PngUJIDOddkCILQYTevrTIbWd494djgGkSsMit+U= +go.opentelemetry.io/otel/sdk v1.1.0/go.mod h1:3aQvM6uLm6C4wJpHtT8Od3vNzeZ34Pqc6bps8MywWzo= go.opentelemetry.io/otel/trace v1.1.0 h1:N25T9qCL0+7IpOT8RrRy0WYlL7y6U0WiUJzXcVdXY/o= go.opentelemetry.io/otel/trace v1.1.0/go.mod h1:i47XtdcBQiktu5IsrPqOHe8w+sBmnLwwHt8wiUsWGTI= +golang.org/x/sys v0.0.0-20210423185535-09eb48e85fd7 h1:iGu644GcxtEcrInvDsQRCwJjtCIOlT2V7IRt6ah2Whw= +golang.org/x/sys v0.0.0-20210423185535-09eb48e85fd7/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= diff --git a/instrumentation/github.com/aws/aws-lambda-go/otellambda/lambda.go b/instrumentation/github.com/aws/aws-lambda-go/otellambda/lambda.go index b1287bbada7..b621ecd0398 100644 --- a/instrumentation/github.com/aws/aws-lambda-go/otellambda/lambda.go +++ b/instrumentation/github.com/aws/aws-lambda-go/otellambda/lambda.go @@ -24,6 +24,10 @@ import ( "go.opentelemetry.io/otel" "go.opentelemetry.io/otel/attribute" + + // import to call ForceFlush method of batch_span_processor.go + //https://github.com/open-telemetry/opentelemetry-go/blob/main/sdk/trace/batch_span_processor.go#L167 + _ "go.opentelemetry.io/otel/sdk/trace" semconv "go.opentelemetry.io/otel/semconv/v1.7.0" "go.opentelemetry.io/otel/trace" ) diff --git a/instrumentation/github.com/aws/aws-lambda-go/otellambda/xrayconfig/README.md b/instrumentation/github.com/aws/aws-lambda-go/otellambda/xrayconfig/README.md index fdebfa34ef8..a5e60ea709f 100644 --- a/instrumentation/github.com/aws/aws-lambda-go/otellambda/xrayconfig/README.md +++ b/instrumentation/github.com/aws/aws-lambda-go/otellambda/xrayconfig/README.md @@ -44,7 +44,7 @@ Now configure the instrumentation with the provided options to export traces to // Add import import "go.opentelemetry.io/contrib/instrumentation/github.com/aws/aws-lambda-go/otellambda/xrayconfig" -// add options to WrapHandlerFunction call +// add options to InstrumentHandler call func main() { lambda.Start(otellambda.InstrumentHandler(HandleRequest, xrayconfig.RecommendedOptions()...)) } diff --git a/instrumentation/github.com/aws/aws-lambda-go/otellambda/xrayconfig/xrayconfig.go b/instrumentation/github.com/aws/aws-lambda-go/otellambda/xrayconfig/xrayconfig.go index 07fdf4989c4..91e04d44c43 100644 --- a/instrumentation/github.com/aws/aws-lambda-go/otellambda/xrayconfig/xrayconfig.go +++ b/instrumentation/github.com/aws/aws-lambda-go/otellambda/xrayconfig/xrayconfig.go @@ -34,8 +34,9 @@ func xrayEventToCarrier([]byte) propagation.TextMapCarrier { return propagation.HeaderCarrier{"X-Amzn-Trace-Id": []string{xrayTraceID}} } -// NewTracerProvider returns a TracerProvider configured with exporter, -// id generator and lambda resource detector to send trace data to AWS X-Ray via Collector +// NewTracerProvider returns a TracerProvider configured with an exporter, +// ID generator, and lambda resource detector to send trace data to AWS X-Ray +// via a Collector instance listening on localhost func NewTracerProvider(ctx context.Context) (*sdktrace.TracerProvider, error) { exp, err := otlptracegrpc.New(ctx, otlptracegrpc.WithInsecure()) if err != nil { From 2696b3508575282848c4c36de8939ce993f0de40 Mon Sep 17 00:00:00 2001 From: bhautikpip Date: Mon, 8 Nov 2021 16:56:38 -0800 Subject: [PATCH 12/18] update go.mod --- .../github.com/aws/aws-lambda-go/otellambda/example/go.mod | 3 ++- .../github.com/aws/aws-lambda-go/otellambda/example/go.sum | 3 ++- .../github.com/aws/aws-lambda-go/otellambda/go.mod | 3 ++- .../github.com/aws/aws-lambda-go/otellambda/go.sum | 4 ++-- .../github.com/aws/aws-lambda-go/otellambda/test/go.mod | 3 ++- .../github.com/aws/aws-lambda-go/otellambda/test/go.sum | 3 ++- .../github.com/aws/aws-lambda-go/otellambda/xrayconfig/go.mod | 3 ++- .../github.com/aws/aws-lambda-go/otellambda/xrayconfig/go.sum | 3 ++- 8 files changed, 16 insertions(+), 9 deletions(-) diff --git a/instrumentation/github.com/aws/aws-lambda-go/otellambda/example/go.mod b/instrumentation/github.com/aws/aws-lambda-go/otellambda/example/go.mod index dae42945a71..9084d6e259a 100644 --- a/instrumentation/github.com/aws/aws-lambda-go/otellambda/example/go.mod +++ b/instrumentation/github.com/aws/aws-lambda-go/otellambda/example/go.mod @@ -19,6 +19,7 @@ require ( go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.26.1 go.opentelemetry.io/otel v1.1.0 go.opentelemetry.io/otel/exporters/stdout/stdouttrace v1.1.0 - go.opentelemetry.io/otel/sdk v1.1.0 + // ToDo: update go.opentelemetry.io/otel/sdk package version + go.opentelemetry.io/otel/sdk v1.1.1-0.20211105153457-6d2aeb0dc3dd golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 // indirect ) diff --git a/instrumentation/github.com/aws/aws-lambda-go/otellambda/example/go.sum b/instrumentation/github.com/aws/aws-lambda-go/otellambda/example/go.sum index 49ac28e6426..f8346d09727 100644 --- a/instrumentation/github.com/aws/aws-lambda-go/otellambda/example/go.sum +++ b/instrumentation/github.com/aws/aws-lambda-go/otellambda/example/go.sum @@ -55,8 +55,9 @@ go.opentelemetry.io/otel/internal/metric v0.24.0 h1:O5lFy6kAl0LMWBjzy3k//M8VjEaT go.opentelemetry.io/otel/internal/metric v0.24.0/go.mod h1:PSkQG+KuApZjBpC6ea6082ZrWUUy/w132tJ/LOU3TXk= go.opentelemetry.io/otel/metric v0.24.0 h1:Rg4UYHS6JKR1Sw1TxnI13z7q/0p/XAbgIqUTagvLJuU= go.opentelemetry.io/otel/metric v0.24.0/go.mod h1:tpMFnCD9t+BEGiWY2bWF5+AwjuAdM0lSowQ4SBA3/K4= -go.opentelemetry.io/otel/sdk v1.1.0 h1:j/1PngUJIDOddkCILQYTevrTIbWd494djgGkSsMit+U= go.opentelemetry.io/otel/sdk v1.1.0/go.mod h1:3aQvM6uLm6C4wJpHtT8Od3vNzeZ34Pqc6bps8MywWzo= +go.opentelemetry.io/otel/sdk v1.1.1-0.20211105153457-6d2aeb0dc3dd h1:+JewuUIs3Nj/exmwl9e5WH1UP9USnglmSMTc/P/o0zY= +go.opentelemetry.io/otel/sdk v1.1.1-0.20211105153457-6d2aeb0dc3dd/go.mod h1:3aQvM6uLm6C4wJpHtT8Od3vNzeZ34Pqc6bps8MywWzo= go.opentelemetry.io/otel/trace v1.0.1/go.mod h1:5g4i4fKLaX2BQpSBsxw8YYcgKpMMSW3x7ZTuYBr3sUk= go.opentelemetry.io/otel/trace v1.1.0 h1:N25T9qCL0+7IpOT8RrRy0WYlL7y6U0WiUJzXcVdXY/o= go.opentelemetry.io/otel/trace v1.1.0/go.mod h1:i47XtdcBQiktu5IsrPqOHe8w+sBmnLwwHt8wiUsWGTI= diff --git a/instrumentation/github.com/aws/aws-lambda-go/otellambda/go.mod b/instrumentation/github.com/aws/aws-lambda-go/otellambda/go.mod index a554619ecea..d3f8d980287 100644 --- a/instrumentation/github.com/aws/aws-lambda-go/otellambda/go.mod +++ b/instrumentation/github.com/aws/aws-lambda-go/otellambda/go.mod @@ -8,6 +8,7 @@ require ( github.com/aws/aws-lambda-go v1.27.0 github.com/stretchr/testify v1.7.0 go.opentelemetry.io/otel v1.1.0 - go.opentelemetry.io/otel/sdk v1.1.0 + // ToDo: update go.opentelemetry.io/otel/sdk package version + go.opentelemetry.io/otel/sdk v1.1.1-0.20211105153457-6d2aeb0dc3dd go.opentelemetry.io/otel/trace v1.1.0 ) diff --git a/instrumentation/github.com/aws/aws-lambda-go/otellambda/go.sum b/instrumentation/github.com/aws/aws-lambda-go/otellambda/go.sum index e3f85e18d7b..4af509c7edf 100644 --- a/instrumentation/github.com/aws/aws-lambda-go/otellambda/go.sum +++ b/instrumentation/github.com/aws/aws-lambda-go/otellambda/go.sum @@ -19,8 +19,8 @@ github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/ github.com/urfave/cli/v2 v2.2.0/go.mod h1:SE9GqnLQmjVa0iPEY0f1w3ygNIYcIJ0OKPMoW2caLfQ= go.opentelemetry.io/otel v1.1.0 h1:8p0uMLcyyIx0KHNTgO8o3CW8A1aA+dJZJW6PvnMz0Wc= go.opentelemetry.io/otel v1.1.0/go.mod h1:7cww0OW51jQ8IaZChIEdqLwgh+44+7uiTdWsAL0wQpA= -go.opentelemetry.io/otel/sdk v1.1.0 h1:j/1PngUJIDOddkCILQYTevrTIbWd494djgGkSsMit+U= -go.opentelemetry.io/otel/sdk v1.1.0/go.mod h1:3aQvM6uLm6C4wJpHtT8Od3vNzeZ34Pqc6bps8MywWzo= +go.opentelemetry.io/otel/sdk v1.1.1-0.20211105153457-6d2aeb0dc3dd h1:+JewuUIs3Nj/exmwl9e5WH1UP9USnglmSMTc/P/o0zY= +go.opentelemetry.io/otel/sdk v1.1.1-0.20211105153457-6d2aeb0dc3dd/go.mod h1:3aQvM6uLm6C4wJpHtT8Od3vNzeZ34Pqc6bps8MywWzo= go.opentelemetry.io/otel/trace v1.1.0 h1:N25T9qCL0+7IpOT8RrRy0WYlL7y6U0WiUJzXcVdXY/o= go.opentelemetry.io/otel/trace v1.1.0/go.mod h1:i47XtdcBQiktu5IsrPqOHe8w+sBmnLwwHt8wiUsWGTI= golang.org/x/sys v0.0.0-20210423185535-09eb48e85fd7 h1:iGu644GcxtEcrInvDsQRCwJjtCIOlT2V7IRt6ah2Whw= diff --git a/instrumentation/github.com/aws/aws-lambda-go/otellambda/test/go.mod b/instrumentation/github.com/aws/aws-lambda-go/otellambda/test/go.mod index c564e5252c6..97c6bca102d 100644 --- a/instrumentation/github.com/aws/aws-lambda-go/otellambda/test/go.mod +++ b/instrumentation/github.com/aws/aws-lambda-go/otellambda/test/go.mod @@ -16,6 +16,7 @@ require ( go.opentelemetry.io/contrib/instrumentation/github.com/aws/aws-lambda-go/otellambda v0.26.1 go.opentelemetry.io/contrib/propagators/aws v1.1.1 go.opentelemetry.io/otel v1.1.0 - go.opentelemetry.io/otel/sdk v1.1.0 + // ToDo: update go.opentelemetry.io/otel/sdk package version + go.opentelemetry.io/otel/sdk v1.1.1-0.20211105153457-6d2aeb0dc3dd go.opentelemetry.io/otel/trace v1.1.0 ) diff --git a/instrumentation/github.com/aws/aws-lambda-go/otellambda/test/go.sum b/instrumentation/github.com/aws/aws-lambda-go/otellambda/test/go.sum index e3f85e18d7b..17b9f4dd497 100644 --- a/instrumentation/github.com/aws/aws-lambda-go/otellambda/test/go.sum +++ b/instrumentation/github.com/aws/aws-lambda-go/otellambda/test/go.sum @@ -19,8 +19,9 @@ github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/ github.com/urfave/cli/v2 v2.2.0/go.mod h1:SE9GqnLQmjVa0iPEY0f1w3ygNIYcIJ0OKPMoW2caLfQ= go.opentelemetry.io/otel v1.1.0 h1:8p0uMLcyyIx0KHNTgO8o3CW8A1aA+dJZJW6PvnMz0Wc= go.opentelemetry.io/otel v1.1.0/go.mod h1:7cww0OW51jQ8IaZChIEdqLwgh+44+7uiTdWsAL0wQpA= -go.opentelemetry.io/otel/sdk v1.1.0 h1:j/1PngUJIDOddkCILQYTevrTIbWd494djgGkSsMit+U= go.opentelemetry.io/otel/sdk v1.1.0/go.mod h1:3aQvM6uLm6C4wJpHtT8Od3vNzeZ34Pqc6bps8MywWzo= +go.opentelemetry.io/otel/sdk v1.1.1-0.20211105153457-6d2aeb0dc3dd h1:+JewuUIs3Nj/exmwl9e5WH1UP9USnglmSMTc/P/o0zY= +go.opentelemetry.io/otel/sdk v1.1.1-0.20211105153457-6d2aeb0dc3dd/go.mod h1:3aQvM6uLm6C4wJpHtT8Od3vNzeZ34Pqc6bps8MywWzo= go.opentelemetry.io/otel/trace v1.1.0 h1:N25T9qCL0+7IpOT8RrRy0WYlL7y6U0WiUJzXcVdXY/o= go.opentelemetry.io/otel/trace v1.1.0/go.mod h1:i47XtdcBQiktu5IsrPqOHe8w+sBmnLwwHt8wiUsWGTI= golang.org/x/sys v0.0.0-20210423185535-09eb48e85fd7 h1:iGu644GcxtEcrInvDsQRCwJjtCIOlT2V7IRt6ah2Whw= diff --git a/instrumentation/github.com/aws/aws-lambda-go/otellambda/xrayconfig/go.mod b/instrumentation/github.com/aws/aws-lambda-go/otellambda/xrayconfig/go.mod index 96c33378268..02a2caff6f5 100644 --- a/instrumentation/github.com/aws/aws-lambda-go/otellambda/xrayconfig/go.mod +++ b/instrumentation/github.com/aws/aws-lambda-go/otellambda/xrayconfig/go.mod @@ -16,7 +16,8 @@ require ( go.opentelemetry.io/contrib/propagators/aws v1.1.1 go.opentelemetry.io/otel v1.1.0 go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.1.0 - go.opentelemetry.io/otel/sdk v1.1.0 + // ToDo: update go.opentelemetry.io/otel/sdk package version + go.opentelemetry.io/otel/sdk v1.1.1-0.20211105153457-6d2aeb0dc3dd go.opentelemetry.io/otel/trace v1.1.0 go.opentelemetry.io/proto/otlp v0.9.0 google.golang.org/grpc v1.41.0 diff --git a/instrumentation/github.com/aws/aws-lambda-go/otellambda/xrayconfig/go.sum b/instrumentation/github.com/aws/aws-lambda-go/otellambda/xrayconfig/go.sum index e5789a18e2a..c7858fe48a3 100644 --- a/instrumentation/github.com/aws/aws-lambda-go/otellambda/xrayconfig/go.sum +++ b/instrumentation/github.com/aws/aws-lambda-go/otellambda/xrayconfig/go.sum @@ -70,8 +70,9 @@ go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.1.0 h1:PxBRMkrJnY4HRgToPzoL go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.1.0/go.mod h1:/E4iniSqAEvqbq6KM5qThKZR2sd42kDvD+SrYt00vRw= go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.1.0 h1:4UC7muAl2UqSoTV0RqgmpTz/cRLH6R9cHt9BvVcq5Bo= go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.1.0/go.mod h1:Gyc0evUosTBVNRqTFGuu0xqebkEWLkLwv42qggTCwro= -go.opentelemetry.io/otel/sdk v1.1.0 h1:j/1PngUJIDOddkCILQYTevrTIbWd494djgGkSsMit+U= go.opentelemetry.io/otel/sdk v1.1.0/go.mod h1:3aQvM6uLm6C4wJpHtT8Od3vNzeZ34Pqc6bps8MywWzo= +go.opentelemetry.io/otel/sdk v1.1.1-0.20211105153457-6d2aeb0dc3dd h1:+JewuUIs3Nj/exmwl9e5WH1UP9USnglmSMTc/P/o0zY= +go.opentelemetry.io/otel/sdk v1.1.1-0.20211105153457-6d2aeb0dc3dd/go.mod h1:3aQvM6uLm6C4wJpHtT8Od3vNzeZ34Pqc6bps8MywWzo= go.opentelemetry.io/otel/trace v1.1.0 h1:N25T9qCL0+7IpOT8RrRy0WYlL7y6U0WiUJzXcVdXY/o= go.opentelemetry.io/otel/trace v1.1.0/go.mod h1:i47XtdcBQiktu5IsrPqOHe8w+sBmnLwwHt8wiUsWGTI= go.opentelemetry.io/proto/otlp v0.7.0/go.mod h1:PqfVotwruBrMGOCsRd/89rSnXhoiJIqeYNgFYFoEGnI= From 37f37daf458c74427d910d173b36bd10a5518a86 Mon Sep 17 00:00:00 2001 From: bhautikpip Date: Mon, 8 Nov 2021 17:08:55 -0800 Subject: [PATCH 13/18] Revert "update go.mod" This reverts commit 2696b3508575282848c4c36de8939ce993f0de40. --- .../github.com/aws/aws-lambda-go/otellambda/example/go.mod | 3 +-- .../github.com/aws/aws-lambda-go/otellambda/example/go.sum | 3 +-- .../github.com/aws/aws-lambda-go/otellambda/go.mod | 3 +-- .../github.com/aws/aws-lambda-go/otellambda/go.sum | 4 ++-- .../github.com/aws/aws-lambda-go/otellambda/test/go.mod | 3 +-- .../github.com/aws/aws-lambda-go/otellambda/test/go.sum | 3 +-- .../github.com/aws/aws-lambda-go/otellambda/xrayconfig/go.mod | 3 +-- .../github.com/aws/aws-lambda-go/otellambda/xrayconfig/go.sum | 3 +-- 8 files changed, 9 insertions(+), 16 deletions(-) diff --git a/instrumentation/github.com/aws/aws-lambda-go/otellambda/example/go.mod b/instrumentation/github.com/aws/aws-lambda-go/otellambda/example/go.mod index 9084d6e259a..dae42945a71 100644 --- a/instrumentation/github.com/aws/aws-lambda-go/otellambda/example/go.mod +++ b/instrumentation/github.com/aws/aws-lambda-go/otellambda/example/go.mod @@ -19,7 +19,6 @@ require ( go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.26.1 go.opentelemetry.io/otel v1.1.0 go.opentelemetry.io/otel/exporters/stdout/stdouttrace v1.1.0 - // ToDo: update go.opentelemetry.io/otel/sdk package version - go.opentelemetry.io/otel/sdk v1.1.1-0.20211105153457-6d2aeb0dc3dd + go.opentelemetry.io/otel/sdk v1.1.0 golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 // indirect ) diff --git a/instrumentation/github.com/aws/aws-lambda-go/otellambda/example/go.sum b/instrumentation/github.com/aws/aws-lambda-go/otellambda/example/go.sum index f8346d09727..49ac28e6426 100644 --- a/instrumentation/github.com/aws/aws-lambda-go/otellambda/example/go.sum +++ b/instrumentation/github.com/aws/aws-lambda-go/otellambda/example/go.sum @@ -55,9 +55,8 @@ go.opentelemetry.io/otel/internal/metric v0.24.0 h1:O5lFy6kAl0LMWBjzy3k//M8VjEaT go.opentelemetry.io/otel/internal/metric v0.24.0/go.mod h1:PSkQG+KuApZjBpC6ea6082ZrWUUy/w132tJ/LOU3TXk= go.opentelemetry.io/otel/metric v0.24.0 h1:Rg4UYHS6JKR1Sw1TxnI13z7q/0p/XAbgIqUTagvLJuU= go.opentelemetry.io/otel/metric v0.24.0/go.mod h1:tpMFnCD9t+BEGiWY2bWF5+AwjuAdM0lSowQ4SBA3/K4= +go.opentelemetry.io/otel/sdk v1.1.0 h1:j/1PngUJIDOddkCILQYTevrTIbWd494djgGkSsMit+U= go.opentelemetry.io/otel/sdk v1.1.0/go.mod h1:3aQvM6uLm6C4wJpHtT8Od3vNzeZ34Pqc6bps8MywWzo= -go.opentelemetry.io/otel/sdk v1.1.1-0.20211105153457-6d2aeb0dc3dd h1:+JewuUIs3Nj/exmwl9e5WH1UP9USnglmSMTc/P/o0zY= -go.opentelemetry.io/otel/sdk v1.1.1-0.20211105153457-6d2aeb0dc3dd/go.mod h1:3aQvM6uLm6C4wJpHtT8Od3vNzeZ34Pqc6bps8MywWzo= go.opentelemetry.io/otel/trace v1.0.1/go.mod h1:5g4i4fKLaX2BQpSBsxw8YYcgKpMMSW3x7ZTuYBr3sUk= go.opentelemetry.io/otel/trace v1.1.0 h1:N25T9qCL0+7IpOT8RrRy0WYlL7y6U0WiUJzXcVdXY/o= go.opentelemetry.io/otel/trace v1.1.0/go.mod h1:i47XtdcBQiktu5IsrPqOHe8w+sBmnLwwHt8wiUsWGTI= diff --git a/instrumentation/github.com/aws/aws-lambda-go/otellambda/go.mod b/instrumentation/github.com/aws/aws-lambda-go/otellambda/go.mod index d3f8d980287..a554619ecea 100644 --- a/instrumentation/github.com/aws/aws-lambda-go/otellambda/go.mod +++ b/instrumentation/github.com/aws/aws-lambda-go/otellambda/go.mod @@ -8,7 +8,6 @@ require ( github.com/aws/aws-lambda-go v1.27.0 github.com/stretchr/testify v1.7.0 go.opentelemetry.io/otel v1.1.0 - // ToDo: update go.opentelemetry.io/otel/sdk package version - go.opentelemetry.io/otel/sdk v1.1.1-0.20211105153457-6d2aeb0dc3dd + go.opentelemetry.io/otel/sdk v1.1.0 go.opentelemetry.io/otel/trace v1.1.0 ) diff --git a/instrumentation/github.com/aws/aws-lambda-go/otellambda/go.sum b/instrumentation/github.com/aws/aws-lambda-go/otellambda/go.sum index 4af509c7edf..e3f85e18d7b 100644 --- a/instrumentation/github.com/aws/aws-lambda-go/otellambda/go.sum +++ b/instrumentation/github.com/aws/aws-lambda-go/otellambda/go.sum @@ -19,8 +19,8 @@ github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/ github.com/urfave/cli/v2 v2.2.0/go.mod h1:SE9GqnLQmjVa0iPEY0f1w3ygNIYcIJ0OKPMoW2caLfQ= go.opentelemetry.io/otel v1.1.0 h1:8p0uMLcyyIx0KHNTgO8o3CW8A1aA+dJZJW6PvnMz0Wc= go.opentelemetry.io/otel v1.1.0/go.mod h1:7cww0OW51jQ8IaZChIEdqLwgh+44+7uiTdWsAL0wQpA= -go.opentelemetry.io/otel/sdk v1.1.1-0.20211105153457-6d2aeb0dc3dd h1:+JewuUIs3Nj/exmwl9e5WH1UP9USnglmSMTc/P/o0zY= -go.opentelemetry.io/otel/sdk v1.1.1-0.20211105153457-6d2aeb0dc3dd/go.mod h1:3aQvM6uLm6C4wJpHtT8Od3vNzeZ34Pqc6bps8MywWzo= +go.opentelemetry.io/otel/sdk v1.1.0 h1:j/1PngUJIDOddkCILQYTevrTIbWd494djgGkSsMit+U= +go.opentelemetry.io/otel/sdk v1.1.0/go.mod h1:3aQvM6uLm6C4wJpHtT8Od3vNzeZ34Pqc6bps8MywWzo= go.opentelemetry.io/otel/trace v1.1.0 h1:N25T9qCL0+7IpOT8RrRy0WYlL7y6U0WiUJzXcVdXY/o= go.opentelemetry.io/otel/trace v1.1.0/go.mod h1:i47XtdcBQiktu5IsrPqOHe8w+sBmnLwwHt8wiUsWGTI= golang.org/x/sys v0.0.0-20210423185535-09eb48e85fd7 h1:iGu644GcxtEcrInvDsQRCwJjtCIOlT2V7IRt6ah2Whw= diff --git a/instrumentation/github.com/aws/aws-lambda-go/otellambda/test/go.mod b/instrumentation/github.com/aws/aws-lambda-go/otellambda/test/go.mod index 97c6bca102d..c564e5252c6 100644 --- a/instrumentation/github.com/aws/aws-lambda-go/otellambda/test/go.mod +++ b/instrumentation/github.com/aws/aws-lambda-go/otellambda/test/go.mod @@ -16,7 +16,6 @@ require ( go.opentelemetry.io/contrib/instrumentation/github.com/aws/aws-lambda-go/otellambda v0.26.1 go.opentelemetry.io/contrib/propagators/aws v1.1.1 go.opentelemetry.io/otel v1.1.0 - // ToDo: update go.opentelemetry.io/otel/sdk package version - go.opentelemetry.io/otel/sdk v1.1.1-0.20211105153457-6d2aeb0dc3dd + go.opentelemetry.io/otel/sdk v1.1.0 go.opentelemetry.io/otel/trace v1.1.0 ) diff --git a/instrumentation/github.com/aws/aws-lambda-go/otellambda/test/go.sum b/instrumentation/github.com/aws/aws-lambda-go/otellambda/test/go.sum index 17b9f4dd497..e3f85e18d7b 100644 --- a/instrumentation/github.com/aws/aws-lambda-go/otellambda/test/go.sum +++ b/instrumentation/github.com/aws/aws-lambda-go/otellambda/test/go.sum @@ -19,9 +19,8 @@ github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/ github.com/urfave/cli/v2 v2.2.0/go.mod h1:SE9GqnLQmjVa0iPEY0f1w3ygNIYcIJ0OKPMoW2caLfQ= go.opentelemetry.io/otel v1.1.0 h1:8p0uMLcyyIx0KHNTgO8o3CW8A1aA+dJZJW6PvnMz0Wc= go.opentelemetry.io/otel v1.1.0/go.mod h1:7cww0OW51jQ8IaZChIEdqLwgh+44+7uiTdWsAL0wQpA= +go.opentelemetry.io/otel/sdk v1.1.0 h1:j/1PngUJIDOddkCILQYTevrTIbWd494djgGkSsMit+U= go.opentelemetry.io/otel/sdk v1.1.0/go.mod h1:3aQvM6uLm6C4wJpHtT8Od3vNzeZ34Pqc6bps8MywWzo= -go.opentelemetry.io/otel/sdk v1.1.1-0.20211105153457-6d2aeb0dc3dd h1:+JewuUIs3Nj/exmwl9e5WH1UP9USnglmSMTc/P/o0zY= -go.opentelemetry.io/otel/sdk v1.1.1-0.20211105153457-6d2aeb0dc3dd/go.mod h1:3aQvM6uLm6C4wJpHtT8Od3vNzeZ34Pqc6bps8MywWzo= go.opentelemetry.io/otel/trace v1.1.0 h1:N25T9qCL0+7IpOT8RrRy0WYlL7y6U0WiUJzXcVdXY/o= go.opentelemetry.io/otel/trace v1.1.0/go.mod h1:i47XtdcBQiktu5IsrPqOHe8w+sBmnLwwHt8wiUsWGTI= golang.org/x/sys v0.0.0-20210423185535-09eb48e85fd7 h1:iGu644GcxtEcrInvDsQRCwJjtCIOlT2V7IRt6ah2Whw= diff --git a/instrumentation/github.com/aws/aws-lambda-go/otellambda/xrayconfig/go.mod b/instrumentation/github.com/aws/aws-lambda-go/otellambda/xrayconfig/go.mod index 02a2caff6f5..96c33378268 100644 --- a/instrumentation/github.com/aws/aws-lambda-go/otellambda/xrayconfig/go.mod +++ b/instrumentation/github.com/aws/aws-lambda-go/otellambda/xrayconfig/go.mod @@ -16,8 +16,7 @@ require ( go.opentelemetry.io/contrib/propagators/aws v1.1.1 go.opentelemetry.io/otel v1.1.0 go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.1.0 - // ToDo: update go.opentelemetry.io/otel/sdk package version - go.opentelemetry.io/otel/sdk v1.1.1-0.20211105153457-6d2aeb0dc3dd + go.opentelemetry.io/otel/sdk v1.1.0 go.opentelemetry.io/otel/trace v1.1.0 go.opentelemetry.io/proto/otlp v0.9.0 google.golang.org/grpc v1.41.0 diff --git a/instrumentation/github.com/aws/aws-lambda-go/otellambda/xrayconfig/go.sum b/instrumentation/github.com/aws/aws-lambda-go/otellambda/xrayconfig/go.sum index c7858fe48a3..e5789a18e2a 100644 --- a/instrumentation/github.com/aws/aws-lambda-go/otellambda/xrayconfig/go.sum +++ b/instrumentation/github.com/aws/aws-lambda-go/otellambda/xrayconfig/go.sum @@ -70,9 +70,8 @@ go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.1.0 h1:PxBRMkrJnY4HRgToPzoL go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.1.0/go.mod h1:/E4iniSqAEvqbq6KM5qThKZR2sd42kDvD+SrYt00vRw= go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.1.0 h1:4UC7muAl2UqSoTV0RqgmpTz/cRLH6R9cHt9BvVcq5Bo= go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.1.0/go.mod h1:Gyc0evUosTBVNRqTFGuu0xqebkEWLkLwv42qggTCwro= +go.opentelemetry.io/otel/sdk v1.1.0 h1:j/1PngUJIDOddkCILQYTevrTIbWd494djgGkSsMit+U= go.opentelemetry.io/otel/sdk v1.1.0/go.mod h1:3aQvM6uLm6C4wJpHtT8Od3vNzeZ34Pqc6bps8MywWzo= -go.opentelemetry.io/otel/sdk v1.1.1-0.20211105153457-6d2aeb0dc3dd h1:+JewuUIs3Nj/exmwl9e5WH1UP9USnglmSMTc/P/o0zY= -go.opentelemetry.io/otel/sdk v1.1.1-0.20211105153457-6d2aeb0dc3dd/go.mod h1:3aQvM6uLm6C4wJpHtT8Od3vNzeZ34Pqc6bps8MywWzo= go.opentelemetry.io/otel/trace v1.1.0 h1:N25T9qCL0+7IpOT8RrRy0WYlL7y6U0WiUJzXcVdXY/o= go.opentelemetry.io/otel/trace v1.1.0/go.mod h1:i47XtdcBQiktu5IsrPqOHe8w+sBmnLwwHt8wiUsWGTI= go.opentelemetry.io/proto/otlp v0.7.0/go.mod h1:PqfVotwruBrMGOCsRd/89rSnXhoiJIqeYNgFYFoEGnI= From 9ccfa6a220251e80cb66cbca2193ac925f652ca4 Mon Sep 17 00:00:00 2001 From: bhautikpip Date: Mon, 8 Nov 2021 17:20:56 -0800 Subject: [PATCH 14/18] remove depending on SDK package --- .../github.com/aws/aws-lambda-go/otellambda/go.mod | 1 - .../github.com/aws/aws-lambda-go/otellambda/go.sum | 4 ---- .../github.com/aws/aws-lambda-go/otellambda/lambda.go | 4 ---- 3 files changed, 9 deletions(-) diff --git a/instrumentation/github.com/aws/aws-lambda-go/otellambda/go.mod b/instrumentation/github.com/aws/aws-lambda-go/otellambda/go.mod index a554619ecea..30b6e138b24 100644 --- a/instrumentation/github.com/aws/aws-lambda-go/otellambda/go.mod +++ b/instrumentation/github.com/aws/aws-lambda-go/otellambda/go.mod @@ -8,6 +8,5 @@ require ( github.com/aws/aws-lambda-go v1.27.0 github.com/stretchr/testify v1.7.0 go.opentelemetry.io/otel v1.1.0 - go.opentelemetry.io/otel/sdk v1.1.0 go.opentelemetry.io/otel/trace v1.1.0 ) diff --git a/instrumentation/github.com/aws/aws-lambda-go/otellambda/go.sum b/instrumentation/github.com/aws/aws-lambda-go/otellambda/go.sum index e3f85e18d7b..30dddb54b80 100644 --- a/instrumentation/github.com/aws/aws-lambda-go/otellambda/go.sum +++ b/instrumentation/github.com/aws/aws-lambda-go/otellambda/go.sum @@ -19,12 +19,8 @@ github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/ github.com/urfave/cli/v2 v2.2.0/go.mod h1:SE9GqnLQmjVa0iPEY0f1w3ygNIYcIJ0OKPMoW2caLfQ= go.opentelemetry.io/otel v1.1.0 h1:8p0uMLcyyIx0KHNTgO8o3CW8A1aA+dJZJW6PvnMz0Wc= go.opentelemetry.io/otel v1.1.0/go.mod h1:7cww0OW51jQ8IaZChIEdqLwgh+44+7uiTdWsAL0wQpA= -go.opentelemetry.io/otel/sdk v1.1.0 h1:j/1PngUJIDOddkCILQYTevrTIbWd494djgGkSsMit+U= -go.opentelemetry.io/otel/sdk v1.1.0/go.mod h1:3aQvM6uLm6C4wJpHtT8Od3vNzeZ34Pqc6bps8MywWzo= go.opentelemetry.io/otel/trace v1.1.0 h1:N25T9qCL0+7IpOT8RrRy0WYlL7y6U0WiUJzXcVdXY/o= go.opentelemetry.io/otel/trace v1.1.0/go.mod h1:i47XtdcBQiktu5IsrPqOHe8w+sBmnLwwHt8wiUsWGTI= -golang.org/x/sys v0.0.0-20210423185535-09eb48e85fd7 h1:iGu644GcxtEcrInvDsQRCwJjtCIOlT2V7IRt6ah2Whw= -golang.org/x/sys v0.0.0-20210423185535-09eb48e85fd7/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= diff --git a/instrumentation/github.com/aws/aws-lambda-go/otellambda/lambda.go b/instrumentation/github.com/aws/aws-lambda-go/otellambda/lambda.go index b621ecd0398..b1287bbada7 100644 --- a/instrumentation/github.com/aws/aws-lambda-go/otellambda/lambda.go +++ b/instrumentation/github.com/aws/aws-lambda-go/otellambda/lambda.go @@ -24,10 +24,6 @@ import ( "go.opentelemetry.io/otel" "go.opentelemetry.io/otel/attribute" - - // import to call ForceFlush method of batch_span_processor.go - //https://github.com/open-telemetry/opentelemetry-go/blob/main/sdk/trace/batch_span_processor.go#L167 - _ "go.opentelemetry.io/otel/sdk/trace" semconv "go.opentelemetry.io/otel/semconv/v1.7.0" "go.opentelemetry.io/otel/trace" ) From acb7ad31ff83936ac892efeb0ab477a220b4568f Mon Sep 17 00:00:00 2001 From: bhautikpip Date: Mon, 8 Nov 2021 17:34:50 -0800 Subject: [PATCH 15/18] renaming the public API for xrayconfig package --- .../otellambda/xrayconfig/README.md | 10 ++++----- .../otellambda/xrayconfig/xrayconfig.go | 22 +++++-------------- .../otellambda/xrayconfig/xrayconfig_test.go | 2 +- 3 files changed, 11 insertions(+), 23 deletions(-) diff --git a/instrumentation/github.com/aws/aws-lambda-go/otellambda/xrayconfig/README.md b/instrumentation/github.com/aws/aws-lambda-go/otellambda/xrayconfig/README.md index a5e60ea709f..f092fd46b80 100644 --- a/instrumentation/github.com/aws/aws-lambda-go/otellambda/xrayconfig/README.md +++ b/instrumentation/github.com/aws/aws-lambda-go/otellambda/xrayconfig/README.md @@ -46,17 +46,17 @@ import "go.opentelemetry.io/contrib/instrumentation/github.com/aws/aws-lambda-go // add options to InstrumentHandler call func main() { - lambda.Start(otellambda.InstrumentHandler(HandleRequest, xrayconfig.RecommendedOptions()...)) + lambda.Start(otellambda.InstrumentHandler(HandleRequest, xrayconfig.WithRecommendedOptions()...)) } ``` ## Recommended AWS Lambda Instrumentation Options | Instrumentation Option | Recommended Value | Exported As | | --- | --- | --- | -| `WithTracerProvider` | An `sdktrace.TracerProvider` configured to export in batches to an OTel Collector running locally in Lambda | Not individually exported. Can only be used via `RecommendedOptions()` -| `WithFlusher` | An `otellambda.Flusher` which yields before calling ForceFlush on the configured `sdktrace.TracerProvider`. Yielding mitigates data delays caused by asynchronous nature of batching TracerProvider when in Lambda | Not individually exported. Can only be used via `RecommendedOptions()` -| `WithEventToCarrier` | Function which reads X-Ray TraceID from Lambda environment and inserts it into a `propagtation.TextMapCarrier` | Individually exported as `EventToCarrier()`, also included in `RecommendedOptions()` -| `WithPropagator` | An `xray.propagator` | Individually exported as `Propagator()`, also included in `RecommendedOptions()` +| `WithTracerProvider` | An `sdktrace.TracerProvider` configured to export in batches to an OTel Collector running locally in Lambda | Not individually exported. Can only be used via `WithRecommendedOptions()` +| `WithFlusher` | An `otellambda.Flusher` which yields before calling ForceFlush on the configured `sdktrace.TracerProvider`. Yielding mitigates data delays caused by asynchronous nature of batching TracerProvider when in Lambda | Not individually exported. Can only be used via `WithRecommendedOptions()` +| `WithEventToCarrier` | Function which reads X-Ray TraceID from Lambda environment and inserts it into a `propagtation.TextMapCarrier` | Individually exported as `EventToCarrier()`, also included in `WithRecommendedOptions()` +| `WithPropagator` | An `xray.propagator` | Individually exported as `Propagator()`, also included in `WithRecommendedOptions()` ## Useful links diff --git a/instrumentation/github.com/aws/aws-lambda-go/otellambda/xrayconfig/xrayconfig.go b/instrumentation/github.com/aws/aws-lambda-go/otellambda/xrayconfig/xrayconfig.go index 91e04d44c43..c749eaaba32 100644 --- a/instrumentation/github.com/aws/aws-lambda-go/otellambda/xrayconfig/xrayconfig.go +++ b/instrumentation/github.com/aws/aws-lambda-go/otellambda/xrayconfig/xrayconfig.go @@ -58,33 +58,21 @@ func NewTracerProvider(ctx context.Context) (*sdktrace.TracerProvider, error) { ), nil } -// TracerProvider returns an otellambda.Option(s) to -// enable using a TracerProvider configured for AWS XRay via a collector -func TracerProvider(tp *sdktrace.TracerProvider) otellambda.Option { - return otellambda.WithTracerProvider(tp) -} - -// Flusher returns an otellambda.Option(s) to -// enable flushing any unexported spans during lambda invocation -func Flusher(tp *sdktrace.TracerProvider) otellambda.Option { - return otellambda.WithFlusher(tp) -} - // EventToCarrier returns an otellambda.Option to enable // an otellambda.EventToCarrier function which reads the XRay trace // information from the environment and returns this information in // a propagation.HeaderCarrier -func EventToCarrier() otellambda.Option { +func WithEventToCarrier() otellambda.Option { return otellambda.WithEventToCarrier(xrayEventToCarrier) } // Propagator returns an otellambda.Option to enable the xray.Propagator -func Propagator() otellambda.Option { +func WithPropagator() otellambda.Option { return otellambda.WithPropagator(xray.Propagator{}) } -// RecommendedOptions returns a list of all otellambda.Option(s) +// WithRecommendedOptions returns a list of all otellambda.Option(s) // recommended for the otellambda package when using AWS XRay -func RecommendedOptions(tp *sdktrace.TracerProvider) []otellambda.Option { - return []otellambda.Option{EventToCarrier(), Propagator(), TracerProvider(tp), Flusher(tp)} +func WithRecommendedOptions(tp *sdktrace.TracerProvider) []otellambda.Option { + return []otellambda.Option{WithEventToCarrier(), WithPropagator(), otellambda.WithTracerProvider(tp), otellambda.WithFlusher(tp)} } diff --git a/instrumentation/github.com/aws/aws-lambda-go/otellambda/xrayconfig/xrayconfig_test.go b/instrumentation/github.com/aws/aws-lambda-go/otellambda/xrayconfig/xrayconfig_test.go index 7706292aa45..dda10b20c04 100644 --- a/instrumentation/github.com/aws/aws-lambda-go/otellambda/xrayconfig/xrayconfig_test.go +++ b/instrumentation/github.com/aws/aws-lambda-go/otellambda/xrayconfig/xrayconfig_test.go @@ -166,7 +166,7 @@ func TestWrapEndToEnd(t *testing.T) { }() <-time.After(5 * time.Millisecond) - wrapped := otellambda.InstrumentHandler(customerHandler, RecommendedOptions(tp)...) + wrapped := otellambda.InstrumentHandler(customerHandler, WithRecommendedOptions(tp)...) wrappedCallable := reflect.ValueOf(wrapped) resp := wrappedCallable.Call([]reflect.Value{reflect.ValueOf(mockContext)}) assert.Len(t, resp, 2) From 0a8ad6ae0ecca17853e76dd76ba13a5189765c64 Mon Sep 17 00:00:00 2001 From: bhautikpip Date: Tue, 9 Nov 2021 12:49:29 -0800 Subject: [PATCH 16/18] fix README review suggestions --- .../aws/aws-lambda-go/otellambda/xrayconfig/README.md | 4 ++-- .../aws/aws-lambda-go/otellambda/xrayconfig/xrayconfig.go | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/instrumentation/github.com/aws/aws-lambda-go/otellambda/xrayconfig/README.md b/instrumentation/github.com/aws/aws-lambda-go/otellambda/xrayconfig/README.md index f092fd46b80..18ae68d3322 100644 --- a/instrumentation/github.com/aws/aws-lambda-go/otellambda/xrayconfig/README.md +++ b/instrumentation/github.com/aws/aws-lambda-go/otellambda/xrayconfig/README.md @@ -55,8 +55,8 @@ func main() { | --- | --- | --- | | `WithTracerProvider` | An `sdktrace.TracerProvider` configured to export in batches to an OTel Collector running locally in Lambda | Not individually exported. Can only be used via `WithRecommendedOptions()` | `WithFlusher` | An `otellambda.Flusher` which yields before calling ForceFlush on the configured `sdktrace.TracerProvider`. Yielding mitigates data delays caused by asynchronous nature of batching TracerProvider when in Lambda | Not individually exported. Can only be used via `WithRecommendedOptions()` -| `WithEventToCarrier` | Function which reads X-Ray TraceID from Lambda environment and inserts it into a `propagtation.TextMapCarrier` | Individually exported as `EventToCarrier()`, also included in `WithRecommendedOptions()` -| `WithPropagator` | An `xray.propagator` | Individually exported as `Propagator()`, also included in `WithRecommendedOptions()` +| `WithEventToCarrier` | Function which reads X-Ray TraceID from Lambda environment and inserts it into a `propagtation.TextMapCarrier` | Individually exported as `WithEventToCarrier()`, also included in `WithRecommendedOptions()` +| `WithPropagator` | An `xray.propagator` | Individually exported as `WithPropagator()`, also included in `WithRecommendedOptions()` ## Useful links diff --git a/instrumentation/github.com/aws/aws-lambda-go/otellambda/xrayconfig/xrayconfig.go b/instrumentation/github.com/aws/aws-lambda-go/otellambda/xrayconfig/xrayconfig.go index c749eaaba32..61f8d18acc2 100644 --- a/instrumentation/github.com/aws/aws-lambda-go/otellambda/xrayconfig/xrayconfig.go +++ b/instrumentation/github.com/aws/aws-lambda-go/otellambda/xrayconfig/xrayconfig.go @@ -58,7 +58,7 @@ func NewTracerProvider(ctx context.Context) (*sdktrace.TracerProvider, error) { ), nil } -// EventToCarrier returns an otellambda.Option to enable +// WithEventToCarrier returns an otellambda.Option to enable // an otellambda.EventToCarrier function which reads the XRay trace // information from the environment and returns this information in // a propagation.HeaderCarrier @@ -66,7 +66,7 @@ func WithEventToCarrier() otellambda.Option { return otellambda.WithEventToCarrier(xrayEventToCarrier) } -// Propagator returns an otellambda.Option to enable the xray.Propagator +// WithPropagator returns an otellambda.Option to enable the xray.Propagator func WithPropagator() otellambda.Option { return otellambda.WithPropagator(xray.Propagator{}) } From 6eea7893a464052f223a8ee82b80deb40358d252 Mon Sep 17 00:00:00 2001 From: bhautikpip Date: Fri, 12 Nov 2021 11:27:27 -0800 Subject: [PATCH 17/18] remove logger and minor changes --- .../aws/aws-lambda-go/otellambda/xrayconfig/xrayconfig.go | 5 ----- .../aws-lambda-go/otellambda/xrayconfig/xrayconfig_test.go | 5 ++++- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/instrumentation/github.com/aws/aws-lambda-go/otellambda/xrayconfig/xrayconfig.go b/instrumentation/github.com/aws/aws-lambda-go/otellambda/xrayconfig/xrayconfig.go index 61f8d18acc2..0ed24977b9e 100644 --- a/instrumentation/github.com/aws/aws-lambda-go/otellambda/xrayconfig/xrayconfig.go +++ b/instrumentation/github.com/aws/aws-lambda-go/otellambda/xrayconfig/xrayconfig.go @@ -16,7 +16,6 @@ package xrayconfig import ( "context" - "log" "os" lambdadetector "go.opentelemetry.io/contrib/detectors/aws/lambda" @@ -27,8 +26,6 @@ import ( sdktrace "go.opentelemetry.io/otel/sdk/trace" ) -var errorLogger = log.New(log.Writer(), "OTel Lambda XRay Configuration Error: ", 0) - func xrayEventToCarrier([]byte) propagation.TextMapCarrier { xrayTraceID := os.Getenv("_X_AMZN_TRACE_ID") return propagation.HeaderCarrier{"X-Amzn-Trace-Id": []string{xrayTraceID}} @@ -40,14 +37,12 @@ func xrayEventToCarrier([]byte) propagation.TextMapCarrier { func NewTracerProvider(ctx context.Context) (*sdktrace.TracerProvider, error) { exp, err := otlptracegrpc.New(ctx, otlptracegrpc.WithInsecure()) if err != nil { - errorLogger.Println("failed to create exporter: ", err) return nil, err } detector := lambdadetector.NewResourceDetector() resource, err := detector.Detect(ctx) if err != nil { - errorLogger.Println("failed to detect lambda resources: ", err) return nil, err } diff --git a/instrumentation/github.com/aws/aws-lambda-go/otellambda/xrayconfig/xrayconfig_test.go b/instrumentation/github.com/aws/aws-lambda-go/otellambda/xrayconfig/xrayconfig_test.go index dda10b20c04..e6fd8a375a6 100644 --- a/instrumentation/github.com/aws/aws-lambda-go/otellambda/xrayconfig/xrayconfig_test.go +++ b/instrumentation/github.com/aws/aws-lambda-go/otellambda/xrayconfig/xrayconfig_test.go @@ -155,7 +155,10 @@ func TestWrapEndToEnd(t *testing.T) { setEnvVars() ctx := context.Background() - tp, _ := NewTracerProvider(ctx) + tp, err := NewTracerProvider(ctx) + if err != nil { + return + } customerHandler := func() (string, error) { return "hello world", nil From 284530bfff6fddcab5a0a18f65bdaf1415f6446c Mon Sep 17 00:00:00 2001 From: Anthony Mirabella Date: Fri, 12 Nov 2021 11:29:15 -0800 Subject: [PATCH 18/18] Update instrumentation/github.com/aws/aws-lambda-go/otellambda/xrayconfig/xrayconfig_test.go --- .../aws-lambda-go/otellambda/xrayconfig/xrayconfig_test.go | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/instrumentation/github.com/aws/aws-lambda-go/otellambda/xrayconfig/xrayconfig_test.go b/instrumentation/github.com/aws/aws-lambda-go/otellambda/xrayconfig/xrayconfig_test.go index e6fd8a375a6..a0a3ea74c77 100644 --- a/instrumentation/github.com/aws/aws-lambda-go/otellambda/xrayconfig/xrayconfig_test.go +++ b/instrumentation/github.com/aws/aws-lambda-go/otellambda/xrayconfig/xrayconfig_test.go @@ -156,9 +156,7 @@ func TestWrapEndToEnd(t *testing.T) { ctx := context.Background() tp, err := NewTracerProvider(ctx) - if err != nil { - return - } + assert.NoError(t, err) customerHandler := func() (string, error) { return "hello world", nil