From b31e66f24e0285bf476dce93ba9c5b8da69580cf Mon Sep 17 00:00:00 2001 From: Pierre Massat Date: Wed, 6 Mar 2024 12:46:36 -0500 Subject: [PATCH 01/21] feat(spans): Ingest spans --- docker-compose.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/docker-compose.yml b/docker-compose.yml index 76aa45f249..6b5401acd4 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -301,6 +301,9 @@ services: snuba-profiling-functions-consumer: <<: *snuba_defaults command: rust-consumer --storage functions_raw --consumer-group snuba-consumers --auto-offset-reset=latest --max-batch-time-ms 1000 --no-strict-offset-reset --no-skip-write + snuba-spans-consumer: + <<: *snuba_defaults + command: rust-consumer --storage spans --consumer-group snuba-consumers --auto-offset-reset=latest --max-batch-time-ms 1000 --no-strict-offset-reset --no-skip-write symbolicator: <<: *restart_policy image: "$SYMBOLICATOR_IMAGE" From 82a8c3ab40edcb043da5c914d954e5ec2c0f8201 Mon Sep 17 00:00:00 2001 From: Pierre Massat Date: Wed, 6 Mar 2024 12:54:47 -0500 Subject: [PATCH 02/21] Enable span extraction from event --- sentry/sentry.conf.example.py | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/sentry/sentry.conf.example.py b/sentry/sentry.conf.example.py index 5cc74239c8..5b72939a88 100644 --- a/sentry/sentry.conf.example.py +++ b/sentry/sentry.conf.example.py @@ -5,10 +5,12 @@ BYTE_MULTIPLIER = 1024 UNITS = ("K", "M", "G") + + def unit_text_to_bytes(text): unit = text[-1].upper() power = UNITS.index(unit) + 1 - return float(text[:-1])*(BYTE_MULTIPLIER**power) + return float(text[:-1]) * (BYTE_MULTIPLIER**power) # Generously adapted from pynetlinux: https://github.com/rlisagor/pynetlinux/blob/e3f16978855c6649685f0c43d4c3fcf768427ae5/pynetlinux/ifconfig.py#L197-L223 @@ -114,7 +116,7 @@ def get_internal_network(): "BACKEND": "django.core.cache.backends.memcached.PyMemcacheCache", "LOCATION": ["memcached:11211"], "TIMEOUT": 3600, - "OPTIONS": {"ignore_exc": True} + "OPTIONS": {"ignore_exc": True}, } } @@ -191,7 +193,9 @@ def get_internal_network(): ################### SENTRY_RELEASE_HEALTH = "sentry.release_health.metrics.MetricsReleaseHealthBackend" -SENTRY_RELEASE_MONITOR = "sentry.release_health.release_monitor.metrics.MetricReleaseMonitorBackend" +SENTRY_RELEASE_MONITOR = ( + "sentry.release_health.release_monitor.metrics.MetricReleaseMonitorBackend" +) ############## # Web Server # @@ -248,7 +252,7 @@ def get_internal_network(): # Mail # ######## -SENTRY_OPTIONS["mail.list-namespace"] = env('SENTRY_MAIL_HOST', 'localhost') +SENTRY_OPTIONS["mail.list-namespace"] = env("SENTRY_MAIL_HOST", "localhost") SENTRY_OPTIONS["mail.from"] = f"sentry@{SENTRY_OPTIONS['mail.list-namespace']}" ############ @@ -288,6 +292,7 @@ def get_internal_network(): "projects:plugins", "projects:rate-limits", "projects:servicehooks", + "projects:span-metrics-extraction", ) } ) @@ -296,7 +301,7 @@ def get_internal_network(): # MaxMind Integration # ####################### -GEOIP_PATH_MMDB = '/geoip/GeoLite2-City.mmdb' +GEOIP_PATH_MMDB = "/geoip/GeoLite2-City.mmdb" ######################### # Bitbucket Integration # From 6087506aba9f29ec811f7a460322be45d426a7ca Mon Sep 17 00:00:00 2001 From: Pierre Massat Date: Thu, 7 Mar 2024 11:05:24 -0500 Subject: [PATCH 03/21] Add an integration test --- _integration-test/fixtures/envelope-with-transaction | 3 +++ _integration-test/run.sh | 12 ++++++++++++ 2 files changed, 15 insertions(+) create mode 100644 _integration-test/fixtures/envelope-with-transaction diff --git a/_integration-test/fixtures/envelope-with-transaction b/_integration-test/fixtures/envelope-with-transaction new file mode 100644 index 0000000000..1211e208a8 --- /dev/null +++ b/_integration-test/fixtures/envelope-with-transaction @@ -0,0 +1,3 @@ +{"event_id":"66578634d48d433db0ad52882d1efe5b","sent_at":"2023-05-17T14:54:31.057Z","sdk":{"name":"sentry.javascript.node","version":"7.46.0"},"trace":{"environment":"production","transaction":"fib: sourcemaps here","public_key":"05ab86aebbe14a24bcab62caa839cf27","trace_id":"33321bfbd5304bcc9663d1b53b08f84e","sample_rate":"1"}} +{"type":"transaction"} +{"contexts":{"trace":{"op":"test","span_id":"b38f2b24537c3858","trace_id":"33321bfbd5304bcc9663d1b53b08f84e"},"runtime":{"name":"node","version":"v16.16.0"},"app":{"app_start_time":"2023-05-17T14:54:27.678Z","app_memory":57966592},"os":{"kernel_version":"22.3.0","name":"macOS","version":"13.2","build":"22D49"},"device":{"boot_time":"2023-05-12T15:08:41.047Z","arch":"arm64","memory_size":34359738368,"free_memory":6861651968,"processor_count":10,"cpu_description":"Apple M1 Pro","processor_frequency":24},"culture":{"locale":"en-US","timezone":"America/New_York"}},"spans":[],"start_timestamp":1684335267.744,"tags":{},"timestamp":1684335271.033,"transaction":"fib: sourcemaps here","type":"transaction","transaction_info":{"source":"custom"},"platform":"node","server_name":"TK6G745PW1.local","event_id":"66578634d48d433db0ad52882d1efe5b","environment":"production","sdk":{"integrations":["InboundFilters","FunctionToString","Console","Http","OnUncaughtException","OnUnhandledRejection","ContextLines","LocalVariables","Context","Modules","RequestData","LinkedErrors","ProfilingIntegration"],"name":"sentry.javascript.node","version":"7.46.0","packages":[{"name":"npm:@sentry/node","version":"7.46.0"}]},"debug_meta":{"images":[]},"modules":{}} diff --git a/_integration-test/run.sh b/_integration-test/run.sh index 4c7ef9beae..9fb51bdb14 100755 --- a/_integration-test/run.sh +++ b/_integration-test/run.sh @@ -149,6 +149,18 @@ timeout 60 bash -c 'until $(sentry_api_request "$PROFILE_PATH" -Isf -X GET -o /d echo " got it!" echo "${_endgroup}" +echo "${_group}Test we can extract spans from an event..." +echo "Sending a test span..." +SPAN_FIXTURE_PATH="$(git rev-parse --show-toplevel)/_integration-test/fixtures/envelope-with-transaction" +curl -sf --data-binary @$PROFILE_FIXTURE_PATH -H 'Content-Type: application/x-sentry-envelope' -H "X-Sentry-Auth: Sentry sentry_version=7, sentry_key=$SENTRY_KEY, sentry_client=test-bash/0.1" "$SENTRY_TEST_HOST/api/$PROJECT_ID/envelope/" -o /dev/null + +printf "Getting a span back" +TRACE_ID="$(jq -r -n --slurpfile span $SPAN_FIXTURE_PATH '$span[2].contexts.trace.trace_id')" +SPAN_PATH="api/0/organizations/sentry/events/?dataset=spansIndexed&field=id&project=1&query=trace%3A$TRACE_ID&statsPeriod=1h" +timeout 60 bash -c "until (($(sentry_api_request "$SPAN_PATH" -Isf -X GET | jq 'data.length') -gt 0)); do printf '.'; sleep 0.5; done" +echo " got it!" +echo "${_endgroup}" + # Table formatting based on https://stackoverflow.com/a/39144364 COMPOSE_PS_OUTPUT=$(docker compose ps --format json | jq -r \ '.[] | From 75a2b2b73d91758ab899a00e07fd56a69e64517f Mon Sep 17 00:00:00 2001 From: Pierre Massat Date: Thu, 7 Mar 2024 11:09:18 -0500 Subject: [PATCH 04/21] Remove arithmetic context for simplicity --- _integration-test/run.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/_integration-test/run.sh b/_integration-test/run.sh index 9fb51bdb14..d9db9617d4 100755 --- a/_integration-test/run.sh +++ b/_integration-test/run.sh @@ -157,7 +157,7 @@ curl -sf --data-binary @$PROFILE_FIXTURE_PATH -H 'Content-Type: application/x-se printf "Getting a span back" TRACE_ID="$(jq -r -n --slurpfile span $SPAN_FIXTURE_PATH '$span[2].contexts.trace.trace_id')" SPAN_PATH="api/0/organizations/sentry/events/?dataset=spansIndexed&field=id&project=1&query=trace%3A$TRACE_ID&statsPeriod=1h" -timeout 60 bash -c "until (($(sentry_api_request "$SPAN_PATH" -Isf -X GET | jq 'data.length') -gt 0)); do printf '.'; sleep 0.5; done" +timeout 60 bash -c "until $(sentry_api_request "$SPAN_PATH" -Isf -X GET | jq '.data[]' -e); do printf '.'; sleep 0.5; done" echo " got it!" echo "${_endgroup}" From 246e05ba56ddfca88c548f1f303f04061e7de38a Mon Sep 17 00:00:00 2001 From: Pierre Massat Date: Thu, 7 Mar 2024 11:14:43 -0500 Subject: [PATCH 05/21] Add all UI feature flags for spans + Starfish --- sentry/sentry.conf.example.py | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/sentry/sentry.conf.example.py b/sentry/sentry.conf.example.py index 5b72939a88..d5d036cdce 100644 --- a/sentry/sentry.conf.example.py +++ b/sentry/sentry.conf.example.py @@ -292,8 +292,25 @@ def get_internal_network(): "projects:plugins", "projects:rate-limits", "projects:servicehooks", - "projects:span-metrics-extraction", ) + + ( + "projects:span-metrics-extraction", + "organizations:starfish-browser-resource-module-image-view", + "organizations:starfish-browser-resource-module-ui", + "organizations:starfish-browser-webvitals", + "organizations:starfish-browser-webvitals-pageoverview-v2", + "organizations:starfish-browser-webvitals-use-backend-scores", + "organizations:performance-calculate-score-relay", + "organizations:starfish-browser-webvitals-replace-fid-with-inp", + "organizations:deprecate-fid-from-performance-score", + "organizations:performance-database-view", + "organizations:starfish-browser-webvitals", + "organizations:performance-screens-view", + "organizations:starfish-browser-resource-module-ui", + "organizations:starfish-browser-webvitals-pageoverview-v2", + "organizations:starfish-browser-webvitals-use-backend-scores", + "organizations:mobile-ttid-ttfd-contribution", + ) # starfish related flags } ) From 61932eb8f6277782fa0e7147b82ebc87f5f3e19e Mon Sep 17 00:00:00 2001 From: Pierre Massat Date: Thu, 7 Mar 2024 15:54:14 -0500 Subject: [PATCH 06/21] Rename the consumer group to something specific to spans --- docker-compose.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docker-compose.yml b/docker-compose.yml index 6b5401acd4..56ae512d47 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -303,7 +303,7 @@ services: command: rust-consumer --storage functions_raw --consumer-group snuba-consumers --auto-offset-reset=latest --max-batch-time-ms 1000 --no-strict-offset-reset --no-skip-write snuba-spans-consumer: <<: *snuba_defaults - command: rust-consumer --storage spans --consumer-group snuba-consumers --auto-offset-reset=latest --max-batch-time-ms 1000 --no-strict-offset-reset --no-skip-write + command: rust-consumer --storage spans --consumer-group snuba-spans-consumers --auto-offset-reset=latest --max-batch-time-ms 1000 --no-strict-offset-reset --no-skip-write symbolicator: <<: *restart_policy image: "$SYMBOLICATOR_IMAGE" From 51a8515bef0f5c7cc46dcb978d01761db7f69651 Mon Sep 17 00:00:00 2001 From: Pierre Massat Date: Thu, 7 Mar 2024 15:55:26 -0500 Subject: [PATCH 07/21] Add missing flag --- sentry/sentry.conf.example.py | 1 + 1 file changed, 1 insertion(+) diff --git a/sentry/sentry.conf.example.py b/sentry/sentry.conf.example.py index d5d036cdce..6610251012 100644 --- a/sentry/sentry.conf.example.py +++ b/sentry/sentry.conf.example.py @@ -310,6 +310,7 @@ def get_internal_network(): "organizations:starfish-browser-webvitals-pageoverview-v2", "organizations:starfish-browser-webvitals-use-backend-scores", "organizations:mobile-ttid-ttfd-contribution", + "organizations:starfish-mobile-appstart", ) # starfish related flags } ) From 577f44feb4f96062ee265f25993438668f8f0311 Mon Sep 17 00:00:00 2001 From: Pierre Massat Date: Mon, 11 Mar 2024 10:59:48 -0400 Subject: [PATCH 08/21] Use single quotes --- _integration-test/run.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/_integration-test/run.sh b/_integration-test/run.sh index d9db9617d4..edb22c5793 100755 --- a/_integration-test/run.sh +++ b/_integration-test/run.sh @@ -157,7 +157,7 @@ curl -sf --data-binary @$PROFILE_FIXTURE_PATH -H 'Content-Type: application/x-se printf "Getting a span back" TRACE_ID="$(jq -r -n --slurpfile span $SPAN_FIXTURE_PATH '$span[2].contexts.trace.trace_id')" SPAN_PATH="api/0/organizations/sentry/events/?dataset=spansIndexed&field=id&project=1&query=trace%3A$TRACE_ID&statsPeriod=1h" -timeout 60 bash -c "until $(sentry_api_request "$SPAN_PATH" -Isf -X GET | jq '.data[]' -e); do printf '.'; sleep 0.5; done" +timeout 60 bash -c 'until $(sentry_api_request "$SPAN_PATH" -Isf -X GET | jq '.data[]' -e); do printf '.'; sleep 0.5; done' echo " got it!" echo "${_endgroup}" From 55278036d2136aecc87f9c5cdca5f5ad9672adc6 Mon Sep 17 00:00:00 2001 From: Pierre Massat Date: Mon, 11 Mar 2024 11:38:18 -0400 Subject: [PATCH 09/21] Debug request --- _integration-test/run.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/_integration-test/run.sh b/_integration-test/run.sh index edb22c5793..26534d93be 100755 --- a/_integration-test/run.sh +++ b/_integration-test/run.sh @@ -158,6 +158,7 @@ printf "Getting a span back" TRACE_ID="$(jq -r -n --slurpfile span $SPAN_FIXTURE_PATH '$span[2].contexts.trace.trace_id')" SPAN_PATH="api/0/organizations/sentry/events/?dataset=spansIndexed&field=id&project=1&query=trace%3A$TRACE_ID&statsPeriod=1h" timeout 60 bash -c 'until $(sentry_api_request "$SPAN_PATH" -Isf -X GET | jq '.data[]' -e); do printf '.'; sleep 0.5; done' +sentry_api_request "$SPAN_PATH" -Isf -X GET echo " got it!" echo "${_endgroup}" From 6001f9641908543feac41c1f99f51d4b37fa245b Mon Sep 17 00:00:00 2001 From: Pierre Massat Date: Mon, 11 Mar 2024 11:42:37 -0400 Subject: [PATCH 10/21] Print the body, not the headers --- _integration-test/run.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/_integration-test/run.sh b/_integration-test/run.sh index 26534d93be..62cbc5a8b8 100755 --- a/_integration-test/run.sh +++ b/_integration-test/run.sh @@ -157,8 +157,8 @@ curl -sf --data-binary @$PROFILE_FIXTURE_PATH -H 'Content-Type: application/x-se printf "Getting a span back" TRACE_ID="$(jq -r -n --slurpfile span $SPAN_FIXTURE_PATH '$span[2].contexts.trace.trace_id')" SPAN_PATH="api/0/organizations/sentry/events/?dataset=spansIndexed&field=id&project=1&query=trace%3A$TRACE_ID&statsPeriod=1h" -timeout 60 bash -c 'until $(sentry_api_request "$SPAN_PATH" -Isf -X GET | jq '.data[]' -e); do printf '.'; sleep 0.5; done' -sentry_api_request "$SPAN_PATH" -Isf -X GET +timeout 60 bash -c 'until $(sentry_api_request "$SPAN_PATH" -sf -X GET | jq '.data[]' -e); do printf '.'; sleep 0.5; done' +sentry_api_request "$SPAN_PATH" -sf -X GET echo " got it!" echo "${_endgroup}" From e54df6509bb19d93d4498a1ea07c6eb20c95494a Mon Sep 17 00:00:00 2001 From: Pierre Massat Date: Mon, 11 Mar 2024 12:04:22 -0400 Subject: [PATCH 11/21] Show the body before we call the failing loop --- _integration-test/run.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/_integration-test/run.sh b/_integration-test/run.sh index 62cbc5a8b8..d20f48500d 100755 --- a/_integration-test/run.sh +++ b/_integration-test/run.sh @@ -157,8 +157,8 @@ curl -sf --data-binary @$PROFILE_FIXTURE_PATH -H 'Content-Type: application/x-se printf "Getting a span back" TRACE_ID="$(jq -r -n --slurpfile span $SPAN_FIXTURE_PATH '$span[2].contexts.trace.trace_id')" SPAN_PATH="api/0/organizations/sentry/events/?dataset=spansIndexed&field=id&project=1&query=trace%3A$TRACE_ID&statsPeriod=1h" -timeout 60 bash -c 'until $(sentry_api_request "$SPAN_PATH" -sf -X GET | jq '.data[]' -e); do printf '.'; sleep 0.5; done' sentry_api_request "$SPAN_PATH" -sf -X GET +timeout 60 bash -c 'until $(sentry_api_request "$SPAN_PATH" -sf -X GET | jq '.data' -e); do printf '.'; sleep 0.5; done' echo " got it!" echo "${_endgroup}" From ef96b852cc0556580f610cacdaa26ad0e777911d Mon Sep 17 00:00:00 2001 From: Pierre Massat Date: Mon, 11 Mar 2024 12:05:38 -0400 Subject: [PATCH 12/21] Remove bad prefix --- _integration-test/run.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/_integration-test/run.sh b/_integration-test/run.sh index d20f48500d..404aded88b 100755 --- a/_integration-test/run.sh +++ b/_integration-test/run.sh @@ -144,7 +144,7 @@ curl -sf --data-binary @$PROFILE_FIXTURE_PATH -H 'Content-Type: application/x-se printf "Getting the test profile back" PROFILE_ID="$(jq -r -n --slurpfile profile $PROFILE_FIXTURE_PATH '$profile[4].event_id')" -PROFILE_PATH="api/0/projects/sentry/sentry/profiling/raw_profiles/$PROFILE_ID/" +PROFILE_PATH="projects/sentry/sentry/profiling/raw_profiles/$PROFILE_ID/" timeout 60 bash -c 'until $(sentry_api_request "$PROFILE_PATH" -Isf -X GET -o /dev/null); do printf '.'; sleep 0.5; done' echo " got it!" echo "${_endgroup}" @@ -156,7 +156,7 @@ curl -sf --data-binary @$PROFILE_FIXTURE_PATH -H 'Content-Type: application/x-se printf "Getting a span back" TRACE_ID="$(jq -r -n --slurpfile span $SPAN_FIXTURE_PATH '$span[2].contexts.trace.trace_id')" -SPAN_PATH="api/0/organizations/sentry/events/?dataset=spansIndexed&field=id&project=1&query=trace%3A$TRACE_ID&statsPeriod=1h" +SPAN_PATH="organizations/sentry/events/?dataset=spansIndexed&field=id&project=1&query=trace%3A$TRACE_ID&statsPeriod=1h" sentry_api_request "$SPAN_PATH" -sf -X GET timeout 60 bash -c 'until $(sentry_api_request "$SPAN_PATH" -sf -X GET | jq '.data' -e); do printf '.'; sleep 0.5; done' echo " got it!" From a6c34ec45c86cef5ee90df5325a2710bae4f03f4 Mon Sep 17 00:00:00 2001 From: Pierre Massat Date: Mon, 11 Mar 2024 12:27:05 -0400 Subject: [PATCH 13/21] Fix jq query --- _integration-test/run.sh | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/_integration-test/run.sh b/_integration-test/run.sh index 404aded88b..2f6e7d35ec 100755 --- a/_integration-test/run.sh +++ b/_integration-test/run.sh @@ -157,8 +157,7 @@ curl -sf --data-binary @$PROFILE_FIXTURE_PATH -H 'Content-Type: application/x-se printf "Getting a span back" TRACE_ID="$(jq -r -n --slurpfile span $SPAN_FIXTURE_PATH '$span[2].contexts.trace.trace_id')" SPAN_PATH="organizations/sentry/events/?dataset=spansIndexed&field=id&project=1&query=trace%3A$TRACE_ID&statsPeriod=1h" -sentry_api_request "$SPAN_PATH" -sf -X GET -timeout 60 bash -c 'until $(sentry_api_request "$SPAN_PATH" -sf -X GET | jq '.data' -e); do printf '.'; sleep 0.5; done' +timeout 60 bash -c 'until $(sentry_api_request "$SPAN_PATH" -sf -X GET | jq '.data[]' -e); do printf '.'; sleep 0.5; done' echo " got it!" echo "${_endgroup}" From 57a3a207e3b905d73fbceedcfbb8b42f65137f24 Mon Sep 17 00:00:00 2001 From: Pierre Massat Date: Mon, 11 Mar 2024 12:42:08 -0400 Subject: [PATCH 14/21] Try to understand what's returned --- _integration-test/run.sh | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/_integration-test/run.sh b/_integration-test/run.sh index 2f6e7d35ec..32a065747d 100755 --- a/_integration-test/run.sh +++ b/_integration-test/run.sh @@ -145,7 +145,7 @@ curl -sf --data-binary @$PROFILE_FIXTURE_PATH -H 'Content-Type: application/x-se printf "Getting the test profile back" PROFILE_ID="$(jq -r -n --slurpfile profile $PROFILE_FIXTURE_PATH '$profile[4].event_id')" PROFILE_PATH="projects/sentry/sentry/profiling/raw_profiles/$PROFILE_ID/" -timeout 60 bash -c 'until $(sentry_api_request "$PROFILE_PATH" -Isf -X GET -o /dev/null); do printf '.'; sleep 0.5; done' +timeout 60 bash -c 'until $(sentry_api_request "$PROFILE_PATH" -X GET -o /dev/null); do printf '.'; sleep 0.5; done' echo " got it!" echo "${_endgroup}" @@ -157,7 +157,9 @@ curl -sf --data-binary @$PROFILE_FIXTURE_PATH -H 'Content-Type: application/x-se printf "Getting a span back" TRACE_ID="$(jq -r -n --slurpfile span $SPAN_FIXTURE_PATH '$span[2].contexts.trace.trace_id')" SPAN_PATH="organizations/sentry/events/?dataset=spansIndexed&field=id&project=1&query=trace%3A$TRACE_ID&statsPeriod=1h" -timeout 60 bash -c 'until $(sentry_api_request "$SPAN_PATH" -sf -X GET | jq '.data[]' -e); do printf '.'; sleep 0.5; done' +span_output=$(sentry_api_request "$SPAN_PATH" -X GET) +echo $span_output | jq '.data[]' -e +timeout 60 bash -c 'until $(sentry_api_request "$SPAN_PATH" -X GET | jq '.data[]' -e); do printf '.'; sleep 0.5; done' echo " got it!" echo "${_endgroup}" From 9ea5bab512fe15af5b5bf9cdc27a802432bff2dc Mon Sep 17 00:00:00 2001 From: Pierre Massat Date: Mon, 11 Mar 2024 12:57:10 -0400 Subject: [PATCH 15/21] Keep the output but move to the next step --- _integration-test/run.sh | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/_integration-test/run.sh b/_integration-test/run.sh index 32a065747d..daf9293375 100755 --- a/_integration-test/run.sh +++ b/_integration-test/run.sh @@ -157,9 +157,8 @@ curl -sf --data-binary @$PROFILE_FIXTURE_PATH -H 'Content-Type: application/x-se printf "Getting a span back" TRACE_ID="$(jq -r -n --slurpfile span $SPAN_FIXTURE_PATH '$span[2].contexts.trace.trace_id')" SPAN_PATH="organizations/sentry/events/?dataset=spansIndexed&field=id&project=1&query=trace%3A$TRACE_ID&statsPeriod=1h" -span_output=$(sentry_api_request "$SPAN_PATH" -X GET) -echo $span_output | jq '.data[]' -e -timeout 60 bash -c 'until $(sentry_api_request "$SPAN_PATH" -X GET | jq '.data[]' -e); do printf '.'; sleep 0.5; done' +sentry_api_request "$SPAN_PATH" -X GET +timeout 60 bash -c 'until $(sentry_api_request "$SPAN_PATH" -X GET | jq .data[] -e); do printf '.'; sleep 0.5; done' echo " got it!" echo "${_endgroup}" From 6381f9e4fef583afd2a1696ca99fb88c81e46b3f Mon Sep 17 00:00:00 2001 From: Pierre Massat Date: Mon, 11 Mar 2024 13:29:25 -0400 Subject: [PATCH 16/21] Let until managed the result --- _integration-test/run.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/_integration-test/run.sh b/_integration-test/run.sh index daf9293375..1d5c103d02 100755 --- a/_integration-test/run.sh +++ b/_integration-test/run.sh @@ -158,7 +158,7 @@ printf "Getting a span back" TRACE_ID="$(jq -r -n --slurpfile span $SPAN_FIXTURE_PATH '$span[2].contexts.trace.trace_id')" SPAN_PATH="organizations/sentry/events/?dataset=spansIndexed&field=id&project=1&query=trace%3A$TRACE_ID&statsPeriod=1h" sentry_api_request "$SPAN_PATH" -X GET -timeout 60 bash -c 'until $(sentry_api_request "$SPAN_PATH" -X GET | jq .data[] -e); do printf '.'; sleep 0.5; done' +timeout 60 bash -c 'until sentry_api_request "$SPAN_PATH" -X GET | jq .data[] -e; do printf '.'; sleep 0.5; done' echo " got it!" echo "${_endgroup}" From 33a2aa027d1bed0be36cb46dc933d666ff17cd3f Mon Sep 17 00:00:00 2001 From: Pierre Massat Date: Mon, 11 Mar 2024 14:01:50 -0400 Subject: [PATCH 17/21] Different way for the same thing --- _integration-test/run.sh | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/_integration-test/run.sh b/_integration-test/run.sh index 1d5c103d02..43c39ac59f 100755 --- a/_integration-test/run.sh +++ b/_integration-test/run.sh @@ -157,7 +157,21 @@ curl -sf --data-binary @$PROFILE_FIXTURE_PATH -H 'Content-Type: application/x-se printf "Getting a span back" TRACE_ID="$(jq -r -n --slurpfile span $SPAN_FIXTURE_PATH '$span[2].contexts.trace.trace_id')" SPAN_PATH="organizations/sentry/events/?dataset=spansIndexed&field=id&project=1&query=trace%3A$TRACE_ID&statsPeriod=1h" -sentry_api_request "$SPAN_PATH" -X GET +count=0 +while true; +do + sentry_api_request "$SPAN_PATH" -X GET | jq .data[] -e + if [ $? -eq 0 ] + then + break + fi + printf '.' + ((count++)) + if [[ $count -eq 60 ]] + then + break + fi +done timeout 60 bash -c 'until sentry_api_request "$SPAN_PATH" -X GET | jq .data[] -e; do printf '.'; sleep 0.5; done' echo " got it!" echo "${_endgroup}" From 2905b9962b296a9577327429400349c3bff979ae Mon Sep 17 00:00:00 2001 From: Pierre Massat Date: Mon, 11 Mar 2024 14:45:36 -0400 Subject: [PATCH 18/21] Split URL params and encode them if needed --- _integration-test/run.sh | 22 ++++------------------ 1 file changed, 4 insertions(+), 18 deletions(-) diff --git a/_integration-test/run.sh b/_integration-test/run.sh index 43c39ac59f..0bc36b0960 100755 --- a/_integration-test/run.sh +++ b/_integration-test/run.sh @@ -145,7 +145,7 @@ curl -sf --data-binary @$PROFILE_FIXTURE_PATH -H 'Content-Type: application/x-se printf "Getting the test profile back" PROFILE_ID="$(jq -r -n --slurpfile profile $PROFILE_FIXTURE_PATH '$profile[4].event_id')" PROFILE_PATH="projects/sentry/sentry/profiling/raw_profiles/$PROFILE_ID/" -timeout 60 bash -c 'until $(sentry_api_request "$PROFILE_PATH" -X GET -o /dev/null); do printf '.'; sleep 0.5; done' +timeout 60 bash -c 'until sentry_api_request "$PROFILE_PATH" -X GET -o /dev/null; do printf '.'; sleep 0.5; done' echo " got it!" echo "${_endgroup}" @@ -156,23 +156,9 @@ curl -sf --data-binary @$PROFILE_FIXTURE_PATH -H 'Content-Type: application/x-se printf "Getting a span back" TRACE_ID="$(jq -r -n --slurpfile span $SPAN_FIXTURE_PATH '$span[2].contexts.trace.trace_id')" -SPAN_PATH="organizations/sentry/events/?dataset=spansIndexed&field=id&project=1&query=trace%3A$TRACE_ID&statsPeriod=1h" -count=0 -while true; -do - sentry_api_request "$SPAN_PATH" -X GET | jq .data[] -e - if [ $? -eq 0 ] - then - break - fi - printf '.' - ((count++)) - if [[ $count -eq 60 ]] - then - break - fi -done -timeout 60 bash -c 'until sentry_api_request "$SPAN_PATH" -X GET | jq .data[] -e; do printf '.'; sleep 0.5; done' +SPAN_PATH="organizations/sentry/events/" +SPAN_QUERY_PARAMS="-G --data-urlencode 'dataset=spansIndexed' --data-urlencode 'field=id' --data-urlencode 'project=1' --data-urlencode'query=trace:$TRACE_ID' --data-urlencode 'statsPeriod=1h'" +timeout 60 bash -c 'until sentry_api_request $SPAN_PATH $SPAN_QUERY_PARAMS -X GET | jq .data[] -e; do printf '.'; sleep 0.5; done' echo " got it!" echo "${_endgroup}" From d036eb9290dbd751ea45f1ab3361f5e2166ab186 Mon Sep 17 00:00:00 2001 From: Pierre Massat Date: Mon, 11 Mar 2024 15:17:19 -0400 Subject: [PATCH 19/21] Different loop --- _integration-test/run.sh | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/_integration-test/run.sh b/_integration-test/run.sh index 0bc36b0960..c93c78f700 100755 --- a/_integration-test/run.sh +++ b/_integration-test/run.sh @@ -140,7 +140,7 @@ echo "${_endgroup}" echo "${_group}Test that profiling work ..." echo "Sending a test profile..." PROFILE_FIXTURE_PATH="$(git rev-parse --show-toplevel)/_integration-test/fixtures/envelope-with-profile" -curl -sf --data-binary @$PROFILE_FIXTURE_PATH -H 'Content-Type: application/x-sentry-envelope' -H "X-Sentry-Auth: Sentry sentry_version=7, sentry_key=$SENTRY_KEY, sentry_client=test-bash/0.1" "$SENTRY_TEST_HOST/api/$PROJECT_ID/envelope/" -o /dev/null +curl -sf --data-binary @$PROFILE_FIXTURE_PATH -H 'Content-Type: application/x-sentry-envelope' -H "X-Sentry-Auth: Sentry sentry_version=7, sentry_key=$SENTRY_KEY, sentry_client=test-bash/0.1" "$SENTRY_TEST_HOST/api/$PROJECT_ID/envelope/" printf "Getting the test profile back" PROFILE_ID="$(jq -r -n --slurpfile profile $PROFILE_FIXTURE_PATH '$profile[4].event_id')" @@ -152,12 +152,18 @@ echo "${_endgroup}" echo "${_group}Test we can extract spans from an event..." echo "Sending a test span..." SPAN_FIXTURE_PATH="$(git rev-parse --show-toplevel)/_integration-test/fixtures/envelope-with-transaction" -curl -sf --data-binary @$PROFILE_FIXTURE_PATH -H 'Content-Type: application/x-sentry-envelope' -H "X-Sentry-Auth: Sentry sentry_version=7, sentry_key=$SENTRY_KEY, sentry_client=test-bash/0.1" "$SENTRY_TEST_HOST/api/$PROJECT_ID/envelope/" -o /dev/null +curl -sf --data-binary @$PROFILE_FIXTURE_PATH -H 'Content-Type: application/x-sentry-envelope' -H "X-Sentry-Auth: Sentry sentry_version=7, sentry_key=$SENTRY_KEY, sentry_client=test-bash/0.1" "$SENTRY_TEST_HOST/api/$PROJECT_ID/envelope/" printf "Getting a span back" TRACE_ID="$(jq -r -n --slurpfile span $SPAN_FIXTURE_PATH '$span[2].contexts.trace.trace_id')" SPAN_PATH="organizations/sentry/events/" -SPAN_QUERY_PARAMS="-G --data-urlencode 'dataset=spansIndexed' --data-urlencode 'field=id' --data-urlencode 'project=1' --data-urlencode'query=trace:$TRACE_ID' --data-urlencode 'statsPeriod=1h'" +SPAN_QUERY_PARAMS="-G --data-urlencode 'dataset=spansIndexed' --data-urlencode 'field=id' --data-urlencode 'project=1' --data-urlencode 'query=trace:$TRACE_ID' --data-urlencode 'statsPeriod=1h'" +retries=0 +while [ $retries -lt 60 ] +do + sentry_api_request $SPAN_PATH -X GET $SPAN_QUERY_PARAMS + ((retries++)) +done timeout 60 bash -c 'until sentry_api_request $SPAN_PATH $SPAN_QUERY_PARAMS -X GET | jq .data[] -e; do printf '.'; sleep 0.5; done' echo " got it!" echo "${_endgroup}" From 13c1c1a432208ab850b021cbb994c3a762fa3268 Mon Sep 17 00:00:00 2001 From: Pierre Massat Date: Mon, 11 Mar 2024 16:00:39 -0400 Subject: [PATCH 20/21] Encode properly --- _integration-test/run.sh | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/_integration-test/run.sh b/_integration-test/run.sh index c93c78f700..76e5145ca5 100755 --- a/_integration-test/run.sh +++ b/_integration-test/run.sh @@ -157,10 +157,9 @@ curl -sf --data-binary @$PROFILE_FIXTURE_PATH -H 'Content-Type: application/x-se printf "Getting a span back" TRACE_ID="$(jq -r -n --slurpfile span $SPAN_FIXTURE_PATH '$span[2].contexts.trace.trace_id')" SPAN_PATH="organizations/sentry/events/" -SPAN_QUERY_PARAMS="-G --data-urlencode 'dataset=spansIndexed' --data-urlencode 'field=id' --data-urlencode 'project=1' --data-urlencode 'query=trace:$TRACE_ID' --data-urlencode 'statsPeriod=1h'" +SPAN_QUERY_PARAMS="-G --data-urlencode dataset=spansIndexed --data-urlencode field=id --data-urlencode project=1 --data-urlencode query=trace:$TRACE_ID --data-urlencode statsPeriod=1h" retries=0 -while [ $retries -lt 60 ] -do +while [ $retries -lt 60 ]; do sentry_api_request $SPAN_PATH -X GET $SPAN_QUERY_PARAMS ((retries++)) done From 27d502990b3663255b498f51bee2cb73232d9501 Mon Sep 17 00:00:00 2001 From: Pierre Massat Date: Mon, 11 Mar 2024 16:31:06 -0400 Subject: [PATCH 21/21] More basic approach --- _integration-test/run.sh | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/_integration-test/run.sh b/_integration-test/run.sh index 76e5145ca5..51b0ef1b4e 100755 --- a/_integration-test/run.sh +++ b/_integration-test/run.sh @@ -158,12 +158,8 @@ printf "Getting a span back" TRACE_ID="$(jq -r -n --slurpfile span $SPAN_FIXTURE_PATH '$span[2].contexts.trace.trace_id')" SPAN_PATH="organizations/sentry/events/" SPAN_QUERY_PARAMS="-G --data-urlencode dataset=spansIndexed --data-urlencode field=id --data-urlencode project=1 --data-urlencode query=trace:$TRACE_ID --data-urlencode statsPeriod=1h" -retries=0 -while [ $retries -lt 60 ]; do - sentry_api_request $SPAN_PATH -X GET $SPAN_QUERY_PARAMS - ((retries++)) -done -timeout 60 bash -c 'until sentry_api_request $SPAN_PATH $SPAN_QUERY_PARAMS -X GET | jq .data[] -e; do printf '.'; sleep 0.5; done' +sleep 10 +sentry_api_request $SPAN_PATH -X GET $SPAN_QUERY_PARAMS | jq .data[] -e echo " got it!" echo "${_endgroup}"