Skip to content

Commit

Permalink
Merge pull request #20 from bugsnag/oteldemotest
Browse files Browse the repository at this point in the history
Add SDK name and version to bugsnag attributes
  • Loading branch information
DariaKunoichi authored Nov 12, 2024
2 parents 316fa56 + c64c7d2 commit 52de6ae
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 15 deletions.
15 changes: 12 additions & 3 deletions bugsnag_performance.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,13 +83,22 @@ 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: bugsnagSDKNameAttribute,
Value: attribute.StringValue(sdkName),
},
{
Key: bugsnagSDKVersionAttribute,
Value: attribute.StringValue(Version),
},
}
bsgResource, err := resource.Merge(
customResource,
resource.NewSchemaless(attr...),
Expand Down
17 changes: 11 additions & 6 deletions consts.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
bugsnagSDKNameAttribute = "bugsnag.telemetry.sdk.name"
bugsnagSDKVersionAttribute = "bugsnag.telemetry.sdk.version"
sdkName = "Go Bugsnag Performance SDK"
)
7 changes: 5 additions & 2 deletions delivery.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand All @@ -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 - 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
for k, v := range headers {
newHeaders[k] = v
Expand Down
9 changes: 5 additions & 4 deletions delivery_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,16 +80,17 @@ 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 - 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")
//}
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"))
}
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"))
}
}))
Expand Down
2 changes: 2 additions & 0 deletions features/support/env.rb
Original file line number Diff line number Diff line change
@@ -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
Expand Down

0 comments on commit 52de6ae

Please sign in to comment.