Skip to content

Commit f64b0fb

Browse files
authored
feat(spans): Ingest spans (#2861)
1 parent 746031d commit f64b0fb

File tree

4 files changed

+51
-8
lines changed

4 files changed

+51
-8
lines changed
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{"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"}}
2+
{"type":"transaction"}
3+
{"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":{}}

_integration-test/run.sh

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -113,12 +113,26 @@ echo "${_endgroup}"
113113
echo "${_group}Test that profiling work ..."
114114
echo "Sending a test profile..."
115115
PROFILE_FIXTURE_PATH="$(git rev-parse --show-toplevel)/_integration-test/fixtures/envelope-with-profile"
116-
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
116+
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/"
117117

118118
printf "Getting the test profile back"
119119
PROFILE_ID="$(jq -r -n --slurpfile profile $PROFILE_FIXTURE_PATH '$profile[4].event_id')"
120-
PROFILE_PATH="api/0/projects/sentry/sentry/profiling/raw_profiles/$PROFILE_ID/"
121-
timeout 60 bash -c 'until $(sentry_api_request "$PROFILE_PATH" -Isf -X GET -o /dev/null); do printf '.'; sleep 0.5; done'
120+
PROFILE_PATH="projects/sentry/sentry/profiling/raw_profiles/$PROFILE_ID/"
121+
timeout 60 bash -c 'until sentry_api_request "$PROFILE_PATH" -X GET -o /dev/null; do printf '.'; sleep 0.5; done'
122+
echo " got it!"
123+
echo "${_endgroup}"
124+
125+
echo "${_group}Test we can extract spans from an event..."
126+
echo "Sending a test span..."
127+
SPAN_FIXTURE_PATH="$(git rev-parse --show-toplevel)/_integration-test/fixtures/envelope-with-transaction"
128+
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/"
129+
130+
printf "Getting a span back"
131+
TRACE_ID="$(jq -r -n --slurpfile span $SPAN_FIXTURE_PATH '$span[2].contexts.trace.trace_id')"
132+
SPAN_PATH="organizations/sentry/events/"
133+
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"
134+
sleep 10
135+
sentry_api_request $SPAN_PATH -X GET $SPAN_QUERY_PARAMS | jq .data[] -e
122136
echo " got it!"
123137
echo "${_endgroup}"
124138

docker-compose.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -303,6 +303,9 @@ services:
303303
snuba-profiling-functions-consumer:
304304
<<: *snuba_defaults
305305
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
306+
snuba-spans-consumer:
307+
<<: *snuba_defaults
308+
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
306309
symbolicator:
307310
<<: *restart_policy
308311
image: "$SYMBOLICATOR_IMAGE"

sentry/sentry.conf.example.py

Lines changed: 28 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,12 @@
55

66
BYTE_MULTIPLIER = 1024
77
UNITS = ("K", "M", "G")
8+
9+
810
def unit_text_to_bytes(text):
911
unit = text[-1].upper()
1012
power = UNITS.index(unit) + 1
11-
return float(text[:-1])*(BYTE_MULTIPLIER**power)
13+
return float(text[:-1]) * (BYTE_MULTIPLIER**power)
1214

1315

1416
# Generously adapted from pynetlinux: https://github.com/rlisagor/pynetlinux/blob/e3f16978855c6649685f0c43d4c3fcf768427ae5/pynetlinux/ifconfig.py#L197-L223
@@ -114,7 +116,7 @@ def get_internal_network():
114116
"BACKEND": "django.core.cache.backends.memcached.PyMemcacheCache",
115117
"LOCATION": ["memcached:11211"],
116118
"TIMEOUT": 3600,
117-
"OPTIONS": {"ignore_exc": True}
119+
"OPTIONS": {"ignore_exc": True},
118120
}
119121
}
120122

@@ -191,7 +193,9 @@ def get_internal_network():
191193
###################
192194

193195
SENTRY_RELEASE_HEALTH = "sentry.release_health.metrics.MetricsReleaseHealthBackend"
194-
SENTRY_RELEASE_MONITOR = "sentry.release_health.release_monitor.metrics.MetricReleaseMonitorBackend"
196+
SENTRY_RELEASE_MONITOR = (
197+
"sentry.release_health.release_monitor.metrics.MetricReleaseMonitorBackend"
198+
)
195199

196200
##############
197201
# Web Server #
@@ -248,7 +252,7 @@ def get_internal_network():
248252
# Mail #
249253
########
250254

251-
SENTRY_OPTIONS["mail.list-namespace"] = env('SENTRY_MAIL_HOST', 'localhost')
255+
SENTRY_OPTIONS["mail.list-namespace"] = env("SENTRY_MAIL_HOST", "localhost")
252256
SENTRY_OPTIONS["mail.from"] = f"sentry@{SENTRY_OPTIONS['mail.list-namespace']}"
253257

254258
############
@@ -289,14 +293,33 @@ def get_internal_network():
289293
"projects:rate-limits",
290294
"projects:servicehooks",
291295
)
296+
+ (
297+
"projects:span-metrics-extraction",
298+
"organizations:starfish-browser-resource-module-image-view",
299+
"organizations:starfish-browser-resource-module-ui",
300+
"organizations:starfish-browser-webvitals",
301+
"organizations:starfish-browser-webvitals-pageoverview-v2",
302+
"organizations:starfish-browser-webvitals-use-backend-scores",
303+
"organizations:performance-calculate-score-relay",
304+
"organizations:starfish-browser-webvitals-replace-fid-with-inp",
305+
"organizations:deprecate-fid-from-performance-score",
306+
"organizations:performance-database-view",
307+
"organizations:starfish-browser-webvitals",
308+
"organizations:performance-screens-view",
309+
"organizations:starfish-browser-resource-module-ui",
310+
"organizations:starfish-browser-webvitals-pageoverview-v2",
311+
"organizations:starfish-browser-webvitals-use-backend-scores",
312+
"organizations:mobile-ttid-ttfd-contribution",
313+
"organizations:starfish-mobile-appstart",
314+
) # starfish related flags
292315
}
293316
)
294317

295318
#######################
296319
# MaxMind Integration #
297320
#######################
298321

299-
GEOIP_PATH_MMDB = '/geoip/GeoLite2-City.mmdb'
322+
GEOIP_PATH_MMDB = "/geoip/GeoLite2-City.mmdb"
300323

301324
#########################
302325
# Bitbucket Integration #

0 commit comments

Comments
 (0)