From 99841444fb00f5305db838702d37ba70c8dc4128 Mon Sep 17 00:00:00 2001 From: Daria Bialobrzeska Date: Fri, 8 Nov 2024 12:06:37 +0100 Subject: [PATCH 1/4] Add SDK name and version to bugsnag attributes --- bugsnag_performance.go | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/bugsnag_performance.go b/bugsnag_performance.go index 97e8917..2de296a 100644 --- a/bugsnag_performance.go +++ b/bugsnag_performance.go @@ -89,7 +89,16 @@ func createBugsnagMergedResource() *resource.Resource { { Key: "service.version", Value: attribute.StringValue(Config.AppVersion), - }} + }, + { + Key: "bugsnag.telemetry.sdk.name", + Value: attribute.StringValue("Go Bugsnag Performance SDK"), + }, + { + Key: "bugsnag.telemetry.sdk.version", + Value: attribute.StringValue(Version), + }, + } bsgResource, err := resource.Merge( customResource, resource.NewSchemaless(attr...), From a95b7620af9d474de09f98d95ba21a5cf1b950db Mon Sep 17 00:00:00 2001 From: Daria Bialobrzeska Date: Fri, 8 Nov 2024 17:50:04 +0100 Subject: [PATCH 2/4] Move resource attribute strings to consts --- bugsnag_performance.go | 10 +++++----- consts.go | 17 +++++++++++------ delivery.go | 2 +- delivery_test.go | 2 +- 4 files changed, 18 insertions(+), 13 deletions(-) diff --git a/bugsnag_performance.go b/bugsnag_performance.go index 2de296a..73f42b3 100644 --- a/bugsnag_performance.go +++ b/bugsnag_performance.go @@ -83,19 +83,19 @@ func createBugsnagMergedResource() *resource.Resource { attr := []attribute.KeyValue{ { - Key: "deployment.environment", + Key: deploymentEnvAttribute, Value: attribute.StringValue(Config.ReleaseStage), }, { - Key: "service.version", + Key: serviceVersionAttribute, Value: attribute.StringValue(Config.AppVersion), }, { - Key: "bugsnag.telemetry.sdk.name", - Value: attribute.StringValue("Go Bugsnag Performance SDK"), + Key: bugsnagTelemetrySDKName, + Value: attribute.StringValue(sdkName), }, { - Key: "bugsnag.telemetry.sdk.version", + Key: bugsnagTelemetrySDKVer, Value: attribute.StringValue(Version), }, } diff --git a/consts.go b/consts.go index e80030d..e17dd7d 100644 --- a/consts.go +++ b/consts.go @@ -3,10 +3,15 @@ package bugsnagperformance import "time" const ( - samplingAttribute = "bugsnag.sampling.p" - samplingResponseHeader = "Bugsnag-Sampling-Probability" - samplingRequestHeader = "Bugsnag-Span-Sampling" - fetcherRetryInterval = 30 * time.Second - fetcherRefreshInterval = 24 * time.Hour - fetcherRequestBody = `{"resourceSpans": []}` + samplingAttribute = "bugsnag.sampling.p" + samplingResponseHeader = "Bugsnag-Sampling-Probability" + samplingRequestHeader = "Bugsnag-Span-Sampling" + fetcherRetryInterval = 30 * time.Second + fetcherRefreshInterval = 24 * time.Hour + fetcherRequestBody = `{"resourceSpans": []}` + deploymentEnvAttribute = "deployment.environment" + serviceVersionAttribute = "service.version" + bugsnagTelemetrySDKName = "bugsnag.telemetry.sdk.name" + bugsnagTelemetrySDKVer = "bugsnag.telemetry.sdk.version" + sdkName = "Go Bugsnag Performance SDK" ) diff --git a/delivery.go b/delivery.go index 1396b8d..63972c9 100644 --- a/delivery.go +++ b/delivery.go @@ -72,7 +72,7 @@ func createDelivery() *delivery { headers := map[string]string{ "Bugsnag-Api-Key": Config.APIKey, "Content-Type": "application/json", - "User-Agent": fmt.Sprintf("Go Bugsnag Performance SDK v%v", Version), + "User-Agent": fmt.Sprintf("%v v%v", sdkName, Version), } return &delivery{ diff --git a/delivery_test.go b/delivery_test.go index 1baef98..c51bd4b 100644 --- a/delivery_test.go +++ b/delivery_test.go @@ -89,7 +89,7 @@ func TestHeadersPresentAtSend(t *testing.T) { if r.Header.Get("Content-Type") != "application/json" { t.Errorf("Expected header Content-Type to be application/json, got %s", r.Header.Get("Content-Type")) } - if r.Header.Get("User-Agent") != fmt.Sprintf("Go Bugsnag Performance SDK v%v", Version) { + if r.Header.Get("User-Agent") != fmt.Sprintf("%v v%v", sdkName, Version) { t.Errorf("Expected header User-Agent to match current version, got %s", r.Header.Get("User-Agent")) } })) From 1768147d3239ac722cba0c649591f946633db23c Mon Sep 17 00:00:00 2001 From: Daria Bialobrzeska Date: Fri, 8 Nov 2024 17:52:33 +0100 Subject: [PATCH 3/4] Comment out Bugsnag-Sent-At header for now --- delivery.go | 5 ++++- delivery_test.go | 7 ++++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/delivery.go b/delivery.go index 63972c9..4afb44b 100644 --- a/delivery.go +++ b/delivery.go @@ -83,7 +83,10 @@ func createDelivery() *delivery { func (d *delivery) send(headers map[string]string, payload []byte) (*http.Response, error) { newHeaders := map[string]string{} - newHeaders["Bugsnag-Sent-At"] = time.Now().Format(time.RFC3339) + + // TODO - add this back when pipeline is prepared to handle it + //newHeaders["Bugsnag-Sent-At"] = time.Now().Format(time.RFC3339) + // merge constant headers with the headers passed in for k, v := range headers { newHeaders[k] = v diff --git a/delivery_test.go b/delivery_test.go index c51bd4b..e1b062c 100644 --- a/delivery_test.go +++ b/delivery_test.go @@ -80,9 +80,10 @@ func TestHeadersPresentAtSend(t *testing.T) { if r.Header.Get("key1") != "value1" { t.Errorf("Expected header key1 to be value1, got %s", r.Header.Get("key1")) } - if r.Header.Get("Bugsnag-Sent-At") == "" { - t.Errorf("Expected header Bugsnag-Sent-At to be present") - } + // TODO - add this back when pipeline is ready + //if r.Header.Get("Bugsnag-Sent-At") == "" { + // t.Errorf("Expected header Bugsnag-Sent-At to be present") + //} if r.Header.Get("Bugsnag-Api-Key") != testAPIKey { t.Errorf("Expected header Bugsnag-Api-Key to be %s, got %s", testAPIKey, r.Header.Get("Bugsnag-Api-Key")) } From c64c7d2da85c07af8c26bf1db8100c87e6087587 Mon Sep 17 00:00:00 2001 From: Daria Bialobrzeska Date: Fri, 8 Nov 2024 18:13:16 +0100 Subject: [PATCH 4/4] Disable maze trace validation until PIPE-7498 is done --- bugsnag_performance.go | 4 ++-- consts.go | 22 +++++++++++----------- delivery.go | 2 +- delivery_test.go | 2 +- features/support/env.rb | 2 ++ 5 files changed, 17 insertions(+), 15 deletions(-) diff --git a/bugsnag_performance.go b/bugsnag_performance.go index 73f42b3..cc771e5 100644 --- a/bugsnag_performance.go +++ b/bugsnag_performance.go @@ -91,11 +91,11 @@ func createBugsnagMergedResource() *resource.Resource { Value: attribute.StringValue(Config.AppVersion), }, { - Key: bugsnagTelemetrySDKName, + Key: bugsnagSDKNameAttribute, Value: attribute.StringValue(sdkName), }, { - Key: bugsnagTelemetrySDKVer, + Key: bugsnagSDKVersionAttribute, Value: attribute.StringValue(Version), }, } diff --git a/consts.go b/consts.go index e17dd7d..222bea3 100644 --- a/consts.go +++ b/consts.go @@ -3,15 +3,15 @@ package bugsnagperformance import "time" const ( - samplingAttribute = "bugsnag.sampling.p" - samplingResponseHeader = "Bugsnag-Sampling-Probability" - samplingRequestHeader = "Bugsnag-Span-Sampling" - fetcherRetryInterval = 30 * time.Second - fetcherRefreshInterval = 24 * time.Hour - fetcherRequestBody = `{"resourceSpans": []}` - deploymentEnvAttribute = "deployment.environment" - serviceVersionAttribute = "service.version" - bugsnagTelemetrySDKName = "bugsnag.telemetry.sdk.name" - bugsnagTelemetrySDKVer = "bugsnag.telemetry.sdk.version" - sdkName = "Go Bugsnag Performance SDK" + samplingAttribute = "bugsnag.sampling.p" + samplingResponseHeader = "Bugsnag-Sampling-Probability" + samplingRequestHeader = "Bugsnag-Span-Sampling" + fetcherRetryInterval = 30 * time.Second + fetcherRefreshInterval = 24 * time.Hour + fetcherRequestBody = `{"resourceSpans": []}` + deploymentEnvAttribute = "deployment.environment" + serviceVersionAttribute = "service.version" + bugsnagSDKNameAttribute = "bugsnag.telemetry.sdk.name" + bugsnagSDKVersionAttribute = "bugsnag.telemetry.sdk.version" + sdkName = "Go Bugsnag Performance SDK" ) diff --git a/delivery.go b/delivery.go index 4afb44b..8cb84f6 100644 --- a/delivery.go +++ b/delivery.go @@ -84,7 +84,7 @@ func createDelivery() *delivery { func (d *delivery) send(headers map[string]string, payload []byte) (*http.Response, error) { newHeaders := map[string]string{} - // TODO - add this back when pipeline is prepared to handle it + // TODO - can be restored after https://smartbear.atlassian.net/browse/PIPE-7498 //newHeaders["Bugsnag-Sent-At"] = time.Now().Format(time.RFC3339) // merge constant headers with the headers passed in diff --git a/delivery_test.go b/delivery_test.go index e1b062c..13930d7 100644 --- a/delivery_test.go +++ b/delivery_test.go @@ -80,7 +80,7 @@ func TestHeadersPresentAtSend(t *testing.T) { if r.Header.Get("key1") != "value1" { t.Errorf("Expected header key1 to be value1, got %s", r.Header.Get("key1")) } - // TODO - add this back when pipeline is ready + // TODO - can be restored after https://smartbear.atlassian.net/browse/PIPE-7498 //if r.Header.Get("Bugsnag-Sent-At") == "" { // t.Errorf("Expected header Bugsnag-Sent-At to be present") //} diff --git a/features/support/env.rb b/features/support/env.rb index a255aae..027ff17 100644 --- a/features/support/env.rb +++ b/features/support/env.rb @@ -1,6 +1,8 @@ Before do # we don't need to send the integrity header Maze.config.enforce_bugsnag_integrity = false + # TODO - can be restored after https://smartbear.atlassian.net/browse/PIPE-7498 + Maze.config.skip_default_validation('trace') $address = nil steps %( When I configure the maze endpoint