Skip to content

Commit e07be38

Browse files
author
Pierre Massat
authored
feat(profiling): Run profiling on self-hosted (#2154)
1 parent ecfa34e commit e07be38

File tree

8 files changed

+51
-6
lines changed

8 files changed

+51
-6
lines changed

.env

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ SENTRY_IMAGE=getsentry/sentry:nightly
99
SNUBA_IMAGE=getsentry/snuba:nightly
1010
RELAY_IMAGE=getsentry/relay:nightly
1111
SYMBOLICATOR_IMAGE=getsentry/symbolicator:nightly
12+
VROOM_IMAGE=getsentry/vroom:nightly
1213
WAL2JSON_VERSION=latest
1314
HEALTHCHECK_INTERVAL=30s
1415
HEALTHCHECK_TIMEOUT=60s
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
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":{"profile":{"profile_id":"e73aaf1f29b24812be60132f32d09f92"},"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":{}}
4+
{"type":"profile"}
5+
{"event_id":"e73aaf1f29b24812be60132f32d09f92","timestamp":"2023-05-17T14:54:27.744Z","platform":"node","version":"1","release":"","environment":"production","runtime":{"name":"node","version":"16.16.0"},"os":{"name":"darwin","version":"22.3.0","build_number":"Darwin Kernel Version 22.3.0: Thu Jan 5 20:48:54 PST 2023; root:xnu-8792.81.2~2/RELEASE_ARM64_T6000"},"device":{"locale":"en_US.UTF-8","model":"arm64","manufacturer":"Darwin","architecture":"arm64","is_emulator":false},"debug_meta":{"images":[]},"profile":{"samples":[{"stack_id":0,"thread_id":"0","elapsed_since_start_ns":125000},{"stack_id":0,"thread_id":"0","elapsed_since_start_ns":13958000}],"frames":[{"lineno":14129,"colno":17,"function":"startProfiling","abs_path":"/Users/jonasbadalic/code/node-profiler/lib/index.js"}],"stacks":[[0]],"thread_metadata":{"0":{"name":"main"}}},"transaction":{"name":"fib: sourcemaps here","id":"66578634d48d433db0ad52882d1efe5b","trace_id":"33321bfbd5304bcc9663d1b53b08f84e","active_thread_id":"0"}}

_integration-test/run.sh

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,18 @@ $dcr --no-deps web python3 /etc/sentry/test-custom-ca-roots.py
135135
source _integration-test/custom-ca-roots/teardown.sh
136136
echo "${_endgroup}"
137137

138+
echo "${_group}Test that profiling work ..."
139+
echo "Sending a test profile..."
140+
PROFILE_FIXTURE_PATH="$(git rev-parse --show-toplevel)/_integration-test/fixtures/envelope-with-profile"
141+
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
142+
143+
printf "Getting the test profile back"
144+
PROFILE_ID="$(jq -r -n --slurpfile profile $PROFILE_FIXTURE_PATH '$profile[4].event_id')"
145+
PROFILE_PATH="api/0/projects/sentry/sentry/profiling/raw_profiles/$PROFILE_ID/"
146+
timeout 60 bash -c 'until $(sentry_api_request "$PROFILE_PATH" -Isf -X GET -o /dev/null); do printf '.'; sleep 0.5; done'
147+
echo " got it!"
148+
echo "${_endgroup}"
149+
138150
# Table formatting based on https://stackoverflow.com/a/39144364
139151
COMPOSE_PS_OUTPUT=$(docker compose ps --format json | jq -r \
140152
'.[] |

_unit-test/create-docker-volumes-test.sh

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,6 @@ before=$(get_volumes)
2121

2222
test "$before" == "" || test "$before" == "$expected_volumes"
2323

24-
source install/create-docker-volumes.sh
25-
source install/create-docker-volumes.sh
2624
source install/create-docker-volumes.sh
2725

2826
after=$(get_volumes)

docker-compose.yml

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,12 +52,15 @@ x-sentry-defaults: &sentry_defaults
5252
<<: *depends_on-default
5353
symbolicator:
5454
<<: *depends_on-default
55+
vroom:
56+
<<: *depends_on-default
5557
entrypoint: "/etc/sentry/entrypoint.sh"
5658
command: ["run", "web"]
5759
environment:
5860
PYTHONUSERBASE: "/data/custom-packages"
5961
SENTRY_CONF: "/etc/sentry"
6062
SNUBA: "http://snuba-api:1218"
63+
VROOM: "http://vroom:8085"
6164
# Force everything to use the system CA bundle
6265
# This is mostly needed to support installing custom CA certs
6366
# This one is used by botocore
@@ -283,6 +286,12 @@ services:
283286
snuba-subscription-consumer-transactions:
284287
<<: *snuba_defaults
285288
command: subscriptions-scheduler-executor --dataset transactions --entity transactions --auto-offset-reset=latest --no-strict-offset-reset --consumer-group=snuba-transactions-subscriptions-consumers --followed-consumer-group=transactions_group --delay-seconds=60 --schedule-ttl=60 --stale-threshold-seconds=900
289+
snuba-profiling-profiles-consumer:
290+
<<: *snuba_defaults
291+
command: consumer --storage profiles --auto-offset-reset=latest --max-batch-time-ms 1000 --no-strict-offset-reset
292+
snuba-profiling-functions-consumer:
293+
<<: *snuba_defaults
294+
command: consumer --storage functions_raw --auto-offset-reset=latest --max-batch-time-ms 1000 --no-strict-offset-reset
286295
symbolicator:
287296
<<: *restart_policy
288297
image: "$SYMBOLICATOR_IMAGE"
@@ -329,10 +338,12 @@ services:
329338
ingest-replay-recordings:
330339
<<: *sentry_defaults
331340
command: run ingest-replay-recordings
341+
ingest-profiles:
342+
<<: *sentry_defaults
343+
command: run ingest-profiles --no-strict-offset-reset
332344
post-process-forwarder-errors:
333345
<<: *sentry_defaults
334346
command: run post-process-forwarder --entity errors
335-
336347
post-process-forwarder-transactions:
337348
<<: *sentry_defaults
338349
command: run post-process-forwarder --entity transactions --commit-log-topic=snuba-transactions-commit-log --synchronize-commit-group transactions_group
@@ -384,6 +395,19 @@ services:
384395
<<: *depends_on-healthy
385396
web:
386397
<<: *depends_on-healthy
398+
vroom:
399+
<<: *restart_policy
400+
image: "$VROOM_IMAGE"
401+
environment:
402+
SENTRY_KAFKA_BROKERS_PROFILING: "kafka:9092"
403+
SENTRY_KAFKA_BROKERS_OCCURRENCES: "kafka:9092"
404+
SENTRY_BUCKET_PROFILES: file://localhost//var/lib/sentry-profiles
405+
SENTRY_SNUBA_HOST: "http://snuba-api:1218"
406+
volumes:
407+
- sentry-vroom:/var/lib/sentry-profiles
408+
depends_on:
409+
kafka:
410+
<<: *depends_on-healthy
387411
volumes:
388412
# These store application data that should persist across restarts.
389413
sentry-data:
@@ -400,8 +424,12 @@ volumes:
400424
external: true
401425
sentry-symbolicator:
402426
external: true
403-
427+
# This volume stores profiles and should be persisted.
428+
# Not being external will still persist data across restarts.
429+
# It won't persist if someone does a docker compose down -v.
430+
sentry-vroom:
404431
# These store ephemeral data that needn't persist across restarts.
432+
# That said, volumes will be persisted across restarts until they are deleted.
405433
sentry-secrets:
406434
sentry-smtp:
407435
sentry-nginx-cache:

install/create-kafka-topics.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ echo "${_group}Creating additional Kafka topics ..."
33
# NOTE: This step relies on `kafka` being available from the previous `snuba-api bootstrap` step
44
# XXX(BYK): We cannot use auto.create.topics as Confluence and Apache hates it now (and makes it very hard to enable)
55
EXISTING_KAFKA_TOPICS=$($dcr -T kafka kafka-topics --list --bootstrap-server kafka:9092 2>/dev/null)
6-
NEEDED_KAFKA_TOPICS="ingest-attachments ingest-transactions ingest-events ingest-replay-recordings"
6+
NEEDED_KAFKA_TOPICS="ingest-attachments ingest-transactions ingest-events ingest-replay-recordings profiles"
77
for topic in $NEEDED_KAFKA_TOPICS; do
88
if ! echo "$EXISTING_KAFKA_TOPICS" | grep -wq $topic; then
99
$dcr kafka kafka-topics --create --topic $topic --bootstrap-server kafka:9092

scripts/bump-version.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ NEW_VERSION="$2"
77
WAL2JSON_VERSION=${WAL2JSON_VERSION:-$(curl -s "https://api.github.com/repos/getsentry/wal2json/releases/latest" | grep -Po '"tag_name": "\K.*?(?=")')}
88

99
sed -i -e "s/^WAL2JSON_VERSION=\([^:]\+\):.\+\$/WAL2JSON_VERSION=\1:$WAL2JSON_VERSION/" .env
10-
sed -i -e "s/^\(SENTRY\|SNUBA\|RELAY\|SYMBOLICATOR\)_IMAGE=\([^:]\+\):.\+\$/\1_IMAGE=\2:$NEW_VERSION/" .env
10+
sed -i -e "s/^\(SENTRY\|SNUBA\|RELAY\|SYMBOLICATOR|VROOM\)_IMAGE=\([^:]\+\):.\+\$/\1_IMAGE=\2:$NEW_VERSION/" .env
1111
sed -i -e "s/^\# Self-Hosted Sentry .*/# Self-Hosted Sentry $NEW_VERSION/" README.md
1212
sed -i -e "s/\(Change Date:\s*\)[-0-9]\+\$/\\1$(date +'%Y-%m-%d' -d '3 years')/" LICENSE
1313

sentry/sentry.conf.example.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -269,6 +269,7 @@ def get_internal_network():
269269
"organizations:performance-view",
270270
"organizations:advanced-search",
271271
"organizations:session-replay",
272+
"organizations:profiling",
272273
"projects:custom-inbound-filters",
273274
"projects:data-forwarding",
274275
"projects:discard-groups",

0 commit comments

Comments
 (0)