From 84fd21797115d4c7575d926886ac0d4253a5ce92 Mon Sep 17 00:00:00 2001 From: robert-smartbear <126675445+robert-smartbear@users.noreply.github.com> Date: Thu, 27 Jul 2023 13:37:40 +0200 Subject: [PATCH] [PLAT-10672] Fixed: `bugsnag.sampling.p` is missing or `0` since iOS v1.0.0 (#195) Co-authored-by: Robert --- CHANGELOG.md | 6 +++++- Gemfile.lock | 3 +++ Sources/BugsnagPerformance/Private/SpanData.mm | 1 + features/sampling.feature | 1 + features/steps/app_steps.rb | 7 +++++++ 5 files changed, 17 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e19b3d95..dcc0b1ac 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,9 +5,13 @@ Changelog ### Enhancements -* Network spans can now be controlled via user callbacks. +* Network spans can now be controlled via user callbacks [189](https://github.com/bugsnag/bugsnag-cocoa-performance/pull/189) + +### Bug fixes +* The span sampling attribute was not being set when equal to 1.0 + [195](https://github.com/bugsnag/bugsnag-cocoa-performance/pull/195) ## 1.0.0 (2023-07-17) diff --git a/Gemfile.lock b/Gemfile.lock index 71dc27b0..7fca4697 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -84,6 +84,8 @@ GEM multi_test (0.1.2) nokogiri (1.15.3-arm64-darwin) racc (~> 1.4) + nokogiri (1.15.3-x86_64-darwin) + racc (~> 1.4) optimist (3.0.1) os (1.0.1) power_assert (2.0.3) @@ -117,6 +119,7 @@ GEM PLATFORMS arm64-darwin-22 + x86_64-darwin-21 DEPENDENCIES bugsnag-maze-runner (~> 8.0) diff --git a/Sources/BugsnagPerformance/Private/SpanData.mm b/Sources/BugsnagPerformance/Private/SpanData.mm index 35aa1661..4c9220c1 100644 --- a/Sources/BugsnagPerformance/Private/SpanData.mm +++ b/Sources/BugsnagPerformance/Private/SpanData.mm @@ -27,6 +27,7 @@ if (firstClass != BSGFirstClassUnset) { attributes[@"bugsnag.span.first_class"] = @(firstClass == BSGFirstClassYes); } + attributes[@"bugsnag.sampling.p"] = @(samplingProbability); } void diff --git a/features/sampling.feature b/features/sampling.feature index b2390769..5162eb8e 100644 --- a/features/sampling.feature +++ b/features/sampling.feature @@ -12,3 +12,4 @@ Feature: Sampling * the trace "Bugsnag-Span-Sampling" header equals "1:1" * the trace "Bugsnag-Sent-At" header matches the regex "^\d\d\d\d-\d\d-\d\dT\d\d:\d\d:\d\d\.\d\d\dZ$" * a span field "name" equals "Post-start" + * a span double attribute "bugsnag.sampling.p" equals 1.0 diff --git a/features/steps/app_steps.rb b/features/steps/app_steps.rb index ad283153..732e703e 100644 --- a/features/steps/app_steps.rb +++ b/features/steps/app_steps.rb @@ -173,3 +173,10 @@ def assert_received_exactly_spans(span_count, list) Maze::Schemas::Validator.verify_against_schema(list, 'trace') Maze::Schemas::Validator.validate_payload_elements(list, 'trace') end + +Then('a span double attribute {string} equals {float}') do |attribute, value| + spans = spans_from_request_list(Maze::Server.list_for('traces')) + selected_attributes = spans.map { |span| span['attributes'].find { |a| a['key'].eql?(attribute) && a['value'].has_key?('doubleValue') } }.compact + selected_attributes = selected_attributes.map { |a| a['value']['doubleValue'] == value } + Maze.check.false(selected_attributes.empty?) +end