Skip to content

Commit 19a95c3

Browse files
authored
feat(replays): add replays to self hosted (#1990)
1 parent 0e7c7c7 commit 19a95c3

File tree

4 files changed

+31
-1
lines changed

4 files changed

+31
-1
lines changed

_integration-test/run.sh

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,28 @@ $dcr --no-deps web python3 /etc/sentry/test-custom-ca-roots.py
171171
source _integration-test/custom-ca-roots/teardown.sh
172172
echo "${_endgroup}"
173173

174+
echo "${_group}Test that replays work ..."
175+
echo "Creating test replay..."
176+
TEST_REPLAY_ID=$(
177+
export LC_ALL=C
178+
head /dev/urandom | tr -dc "a-f0-9" | head -c 32
179+
)
180+
TIME_IN_SECONDS=$(date +%s)
181+
curl -sf --data '{"event_id":"'"$TEST_REPLAY_ID"'","sdk":{"name":"sentry.javascript.browser","version":"7.38.0"}}
182+
{"type":"replay_event"}
183+
{"type":"replay_event","replay_start_timestamp":$TIME_IN_SECONDS,"timestamp":$TIME_IN_SECONDS,"error_ids":[],"trace_ids":[],"urls":["example.com"],"replay_id":"'"$TEST_REPLAY_ID"'","segment_id":0,"replay_type":"session","event_id":"'"$TEST_REPLAY_ID"'","environment":"production","sdk":{"name":"sentry.javascript.browser","version":"7.38.0"},"request":{"url":"example.com","headers":{"platform":"javascript","contexts":{"replay":{"session_sample_rate":1,"error_sample_rate":1}}}
184+
{"type":"replay_recording","length":19}
185+
{"segment_id":0}
186+
[]' -H 'Content-Type: application/json' -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
187+
188+
printf "Getting the test replay back"
189+
REPLAY_SEGMENT_PATH="api/0/projects/sentry/internal/replays/$TEST_EVENT_ID/recording-segments/?download"
190+
REPLAY_EVENT_PATH="api/0/projects/sentry/internal/replays/$TEST_EVENT_ID/"
191+
timeout 60 bash -c 'until $(sentry_api_request "$REPLAY_EVENT_PATH" -Isf -X GET -o /dev/null); do printf '.'; sleep 0.5; done'
192+
timeout 60 bash -c 'until $(sentry_api_request "$REPLAY_SEGMENT_PATH" -Isf -X GET -o /dev/null); do printf '.'; sleep 0.5; done'
193+
echo " got it!"
194+
echo "${_endgroup}"
195+
174196
# Table formatting based on https://stackoverflow.com/a/39144364
175197
COMPOSE_PS_OUTPUT=$(docker compose ps --format json | jq -r \
176198
'.[] |

docker-compose.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -258,6 +258,9 @@ services:
258258
snuba-transactions-consumer:
259259
<<: *snuba_defaults
260260
command: consumer --storage transactions --consumer-group transactions_group --auto-offset-reset=latest --max-batch-time-ms 750
261+
snuba-replays-consumer:
262+
<<: *snuba_defaults
263+
command: consumer --storage replays --auto-offset-reset=latest --max-batch-time-ms 750
261264
snuba-replacer:
262265
<<: *snuba_defaults
263266
command: replacer --storage errors --auto-offset-reset=latest
@@ -322,6 +325,9 @@ services:
322325
ingest-consumer:
323326
<<: *sentry_defaults
324327
command: run ingest-consumer --all-consumer-types
328+
ingest-replay-recordings:
329+
<<: *sentry_defaults
330+
command: run ingest-replay-recordings
325331
post-process-forwarder-errors:
326332
<<: *sentry_defaults
327333
# Increase `--commit-batch-size 1` below to deal with high-load environments.

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"
6+
NEEDED_KAFKA_TOPICS="ingest-attachments ingest-transactions ingest-events ingest-replay-recordings"
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

sentry/sentry.conf.example.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -258,6 +258,8 @@ def get_internal_network():
258258
"organizations:sso-saml2",
259259
"organizations:performance-view",
260260
"organizations:advanced-search",
261+
"organizations:session-replay",
262+
"organizations:session-replay-ui",
261263
"projects:custom-inbound-filters",
262264
"projects:data-forwarding",
263265
"projects:discard-groups",

0 commit comments

Comments
 (0)