Skip to content
This repository was archived by the owner on Apr 28, 2025. It is now read-only.

Commit 17d8763

Browse files
Update RUM, add session replay, update GKE deploy (#183)
* update gke yamls to point to 2.1.1 images * update RUM, add session replay * add baseline docker compose * remove build context from storefront-fixed * update filename * allow RUM env to be set via compose * rebuild patches * add DD_ENV, regen patches
1 parent d8eab89 commit 17d8763

File tree

11 files changed

+265
-140
lines changed

11 files changed

+265
-140
lines changed

deploy/docker-compose/docker-compose-broken-instrumented.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,8 @@ services:
5050
- DB_PASSWORD
5151
- DD_CLIENT_TOKEN
5252
- DD_APPLICATION_ID
53+
- DD_ENV=development
54+
- DD_SITE=datadoghq.com
5355
image: "ddtraining/storefront:2.1.0"
5456
command: sh docker-entrypoint.sh
5557
ports:

deploy/docker-compose/docker-compose-fixed-instrumented-attack.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,8 @@ services:
5252
- DD_VERSION=1.1
5353
- DD_CLIENT_TOKEN
5454
- DD_APPLICATION_ID
55+
- DD_ENV=development
56+
- DD_SITE=datadoghq.com
5557
image: "ddtraining/storefront-fixed:2.1.0"
5658
ports:
5759
- "3000:3000"

deploy/docker-compose/docker-compose-fixed-instrumented-livecode.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,8 @@ services:
5252
- DB_PASSWORD
5353
- DD_CLIENT_TOKEN
5454
- DD_APPLICATION_ID
55+
- DD_ENV=development
56+
- DD_SITE=datadoghq.com
5557
image: "ddtraining/storefront-fixed:2.1.0"
5658
command: sh docker-entrypoint.sh
5759
ports:

deploy/docker-compose/docker-compose-fixed-instrumented.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,8 @@ services:
5252
- DD_VERSION=1.1
5353
- DD_CLIENT_TOKEN
5454
- DD_APPLICATION_ID
55+
- DD_ENV=development
56+
- DD_SITE=datadoghq.com
5557
image: "ddtraining/storefront-fixed:2.1.0"
5658
command: sh docker-entrypoint.sh
5759
ports:
Lines changed: 120 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,120 @@
1+
# Docker compose file which uses build context plus mounted volumes for easier local development
2+
# Note: storefront-fixed cannot use the build context because the .patch files are located in a parent directory of the Dockerfile
3+
version: '3'
4+
services:
5+
agent:
6+
image: "datadog/agent:7.29.0"
7+
environment:
8+
- DD_API_KEY
9+
- DD_APM_ENABLED=true
10+
- DD_LOGS_ENABLED=true
11+
- DD_LOGS_CONFIG_CONTAINER_COLLECT_ALL=true
12+
- DD_PROCESS_AGENT_ENABLED=true
13+
- DD_DOCKER_LABELS_AS_TAGS={"my.custom.label.team":"team"}
14+
- DD_TAGS='env:development'
15+
ports:
16+
- "8126:8126"
17+
volumes:
18+
- /var/run/docker.sock:/var/run/docker.sock:ro
19+
- /proc/:/host/proc/:ro
20+
- /sys/fs/cgroup/:/host/sys/fs/cgroup:ro
21+
labels:
22+
com.datadoghq.ad.logs: '[{"source": "agent", "service": "agent"}]'
23+
discounts:
24+
environment:
25+
- FLASK_APP=discounts.py
26+
- FLASK_DEBUG=1
27+
- POSTGRES_PASSWORD
28+
- POSTGRES_USER
29+
- POSTGRES_HOST=db
30+
- DD_SERVICE=discounts-service
31+
- DD_AGENT_HOST=agent
32+
- DD_LOGS_INJECTION=true
33+
- DD_TRACE_ANALYTICS_ENABLED=true
34+
- DD_PROFILING_ENABLED=true
35+
- DD_VERSION=1.1
36+
build:
37+
context: ../../discounts-service-fixed
38+
volumes:
39+
- "../../discounts-service-fixed:/app"
40+
command: ddtrace-run flask run --port=5001 --host=0.0.0.0
41+
ports:
42+
- "5001:5001"
43+
depends_on:
44+
- agent
45+
- db
46+
labels:
47+
com.datadoghq.ad.logs: '[{"source": "python", "service": "discounts-service"}]'
48+
my.custom.label.team: "discount"
49+
frontend:
50+
environment:
51+
- DD_AGENT_HOST=agent
52+
- DD_LOGS_INJECTION=true
53+
- DD_TRACE_ANALYTICS_ENABLED=true
54+
- DD_SERVICE=store-frontend
55+
- DB_USERNAME
56+
- DB_PASSWORD
57+
- DD_VERSION=1.1
58+
- DD_CLIENT_TOKEN
59+
- DD_APPLICATION_ID
60+
- DD_ENV=development
61+
- DD_SITE=datadoghq.com
62+
image: "ddtraining/storefront-fixed:latest"
63+
command: sh docker-entrypoint.sh
64+
volumes:
65+
- "../../store-frontend/src/store-frontend-instrumented-fixed:/app"
66+
ports:
67+
- "3000:3000"
68+
depends_on:
69+
- agent
70+
- db
71+
- discounts
72+
- advertisements
73+
labels:
74+
com.datadoghq.ad.logs: '[{"source": "ruby", "service": "store-frontend"}]'
75+
my.custom.label.team: "frontend"
76+
advertisements:
77+
environment:
78+
- FLASK_APP=ads.py
79+
- FLASK_DEBUG=1
80+
- POSTGRES_PASSWORD
81+
- POSTGRES_USER
82+
- POSTGRES_HOST=db
83+
- DD_SERVICE=advertisements-service
84+
- DD_AGENT_HOST=agent
85+
- DD_LOGS_INJECTION=true
86+
- DD_TRACE_ANALYTICS_ENABLED=true
87+
- DD_PROFILING_ENABLED=true
88+
- DD_VERSION=1.0
89+
build:
90+
context: ../../ads-service-fixed
91+
volumes:
92+
- "../../ads-service-fixed:/app"
93+
command: ddtrace-run flask run --port=5002 --host=0.0.0.0
94+
ports:
95+
- "5002:5002"
96+
depends_on:
97+
- agent
98+
- db
99+
labels:
100+
com.datadoghq.ad.logs: '[{"source": "python", "service": "ads-service"}]'
101+
my.custom.label.team: "advertisements"
102+
db:
103+
image: postgres:11-alpine
104+
restart: always
105+
environment:
106+
- POSTGRES_PASSWORD
107+
- POSTGRES_USER
108+
labels:
109+
com.datadoghq.ad.logs: '[{"source": "postgresql", "service": "postgres"}]'
110+
attackbox:
111+
build:
112+
context: ../../attack-box
113+
environment:
114+
- ATTACK_GOBUSTER
115+
- ATTACK_HYDRA
116+
- ATTACK_GOBUSTER_INTERVAL
117+
- ATTACK_HYDRA_INTERVAL
118+
depends_on:
119+
- discounts
120+
- frontend

deploy/gcp/gke/advertisements.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ spec:
2020
app: ecommerce
2121
spec:
2222
containers:
23-
- image: ddtraining/advertisements-service:latest
23+
- image: ddtraining/advertisements:2.1.1
2424
name: advertisements
2525
command: ["ddtrace-run"]
2626
args: ["flask", "run", "--port=5002", "--host=0.0.0.0"]

deploy/gcp/gke/discounts.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ spec:
2020
app: ecommerce
2121
spec:
2222
containers:
23-
- image: ddtraining/discounts-service:latest
23+
- image: ddtraining/discounts-fixed:2.1.1
2424
name: discounts
2525
command: ["ddtrace-run"]
2626
args: ["flask", "run", "--port=5001", "--host=0.0.0.0"]

deploy/gcp/gke/frontend.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ spec:
4848
# value: ""
4949
#- name: DD_APPLICATION_ID
5050
# value: ""
51-
image: ddtraining/ecommerce-frontend:latest
51+
image: ddtraining/storefront-fixed:2.1.1
5252
imagePullPolicy: Always
5353
name: ecommerce-spree-observability
5454
ports:

store-frontend/src/broken-instrumented.patch

Lines changed: 64 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
diff -urN store-frontend-initial-state/Gemfile store-frontend-broken-instrumented/Gemfile
2-
--- store-frontend-initial-state/Gemfile 2021-07-14 12:26:50.000000000 +0200
3-
+++ store-frontend-broken-instrumented/Gemfile 2021-07-19 11:19:24.000000000 +0200
2+
--- store-frontend-initial-state/Gemfile 2021-08-31 09:59:14.000000000 -0400
3+
+++ store-frontend-broken-instrumented/Gemfile 2021-12-01 15:21:36.000000000 -0500
44
@@ -43,6 +43,7 @@
55
gem 'spree', github: 'spree/spree', ref: 'f8e7b4ed9856d1a2f4521f5b8ef7de158a30b398'
66
gem 'spree_auth_devise', github: 'spree/spree_auth_devise', ref: '7e9c4d102e0eb84446ec0f4cb3aeefa7f6dfa65d'
@@ -10,8 +10,8 @@ diff -urN store-frontend-initial-state/Gemfile store-frontend-broken-instrumente
1010
gem 'amazing_print'
1111
gem 'rails_semantic_logger'
1212
diff -urN store-frontend-initial-state/Gemfile.lock store-frontend-broken-instrumented/Gemfile.lock
13-
--- store-frontend-initial-state/Gemfile.lock 2021-07-14 12:26:50.000000000 +0200
14-
+++ store-frontend-broken-instrumented/Gemfile.lock 2021-07-19 11:19:24.000000000 +0200
13+
--- store-frontend-initial-state/Gemfile.lock 2021-08-31 09:59:14.000000000 -0400
14+
+++ store-frontend-broken-instrumented/Gemfile.lock 2021-12-01 15:21:36.000000000 -0500
1515
@@ -164,6 +164,9 @@
1616
crass (1.0.6)
1717
css_parser (1.9.0)
@@ -39,78 +39,76 @@ diff -urN store-frontend-initial-state/Gemfile.lock store-frontend-broken-instru
3939
jbuilder (~> 2.5)
4040
listen (>= 3.0.5, < 3.2)
4141
diff -urN store-frontend-initial-state/app/views/layouts/application.html.erb store-frontend-broken-instrumented/app/views/layouts/application.html.erb
42-
--- store-frontend-initial-state/app/views/layouts/application.html.erb 2021-07-14 12:26:50.000000000 +0200
43-
+++ store-frontend-broken-instrumented/app/views/layouts/application.html.erb 2021-07-19 11:19:24.000000000 +0200
44-
@@ -2,6 +2,31 @@
42+
--- store-frontend-initial-state/app/views/layouts/application.html.erb 2021-09-10 16:21:30.000000000 -0400
43+
+++ store-frontend-broken-instrumented/app/views/layouts/application.html.erb 2021-12-01 16:10:03.000000000 -0500
44+
@@ -2,6 +2,30 @@
4545
<html>
4646
<head>
4747
<title>Sandbox</title>
48-
+ <script
49-
+ src="https://www.datadoghq-browser-agent.com/datadog-rum-us.js"
50-
+ type="text/javascript">
51-
+</script>
52-
+<script>
53-
+if (window.DD_RUM) {
54-
+ window.DD_RUM.init({
55-
+ clientToken: '<%= ENV['DD_CLIENT_TOKEN'] %>',
56-
+ applicationId: '<%= ENV['DD_APPLICATION_ID'] %>',
57-
+ sampleRate: 100,
58-
+ trackInteractions: true,
59-
+ service: 'storedog-ui',
60-
+ env: 'production',
61-
+ version: 1.1
62-
+ });
63-
+
64-
+ if (!window._DATADOG_SYNTHETICS_BROWSER) {
65-
+ window.DD_RUM.setRumGlobalContext({'usr.handle': 'john@storedog.com'});
66-
+ };
67-
+
68-
+ if (window.location.href.includes('utm')) {
69-
+ window.DD_RUM.addRumGlobalContext({'fromUtm': true});
70-
+ };
71-
+}
72-
+</script>
48+
+ <script src="https://www.datadoghq-browser-agent.com/datadog-rum-v3.js" type="text/javascript"></script>
49+
+ <script>
50+
+ window.DD_RUM && window.DD_RUM.init({
51+
+ clientToken: '<%= ENV['DD_CLIENT_TOKEN'] %>',
52+
+ applicationId: '<%= ENV['DD_APPLICATION_ID'] %>',
53+
+ site: '<%= ENV['DD_SITE'] %>',
54+
+ service: '<%= ENV['DD_SERVICE'] %>',
55+
+ env: '<%= ENV['DD_ENV'] %>',
56+
+ version: '1.0.0',
57+
+ sampleRate: 100,
58+
+ trackInteractions: true,
59+
+ defaultPrivacyLevel: 'mask-user-input'
60+
+ });
61+
+
62+
+ window.DD_RUM && window.DD_RUM.startSessionReplayRecording();
63+
+
64+
+ if (!window._DATADOG_SYNTHETICS_BROWSER) {
65+
+ window.DD_RUM.setRumGlobalContext({'usr.handle': 'john@storedog.com'});
66+
+ };
67+
+
68+
+ if (window.location.href.includes('utm')) {
69+
+ window.DD_RUM.addRumGlobalContext({'fromUtm': true});
70+
+ };
71+
+ </script>
7372
<%= csrf_meta_tags %>
7473
<%= csp_meta_tag %>
7574

7675
diff -urN store-frontend-initial-state/app/views/spree/layouts/spree_application.html.erb store-frontend-broken-instrumented/app/views/spree/layouts/spree_application.html.erb
77-
--- store-frontend-initial-state/app/views/spree/layouts/spree_application.html.erb 2021-07-14 12:26:50.000000000 +0200
78-
+++ store-frontend-broken-instrumented/app/views/spree/layouts/spree_application.html.erb 2021-07-19 11:19:24.000000000 +0200
79-
@@ -5,6 +5,31 @@
76+
--- store-frontend-initial-state/app/views/spree/layouts/spree_application.html.erb 2021-08-31 09:59:14.000000000 -0400
77+
+++ store-frontend-broken-instrumented/app/views/spree/layouts/spree_application.html.erb 2021-12-01 16:09:55.000000000 -0500
78+
@@ -5,6 +5,30 @@
8079
<!--[if IE 9 ]> <html class="ie ie9" lang="<%= I18n.locale %>"> <![endif]-->
8180
<!--[if gt IE 9]><!--><html lang="<%= I18n.locale %>"><!--<![endif]-->
8281
<head data-hook="inside_head">
83-
+ <script
84-
+ src="https://www.datadoghq-browser-agent.com/datadog-rum-us.js"
85-
+ type="text/javascript">
86-
+</script>
87-
+<script>
88-
+if (window.DD_RUM) {
89-
+ window.DD_RUM.init({
90-
+ clientToken: '<%= ENV['DD_CLIENT_TOKEN'] %>',
91-
+ applicationId: '<%= ENV['DD_APPLICATION_ID'] %>',
92-
+ sampleRate: 100,
93-
+ trackInteractions: true,
94-
+ service: 'storedog-ui',
95-
+ env: 'production',
96-
+ version: 1.1
97-
+ });
98-
+
99-
+ if (!window._DATADOG_SYNTHETICS_BROWSER) {
100-
+ window.DD_RUM.setRumGlobalContext({'usr.handle': 'john@storedog.com'});
101-
+ };
102-
+
103-
+ if (window.location.href.includes('utm')) {
104-
+ window.DD_RUM.addRumGlobalContext({'fromUtm': true});
105-
+ };
106-
+}
107-
+</script>
82+
+ <script src="https://www.datadoghq-browser-agent.com/datadog-rum-v3.js" type="text/javascript"></script>
83+
+ <script>
84+
+ window.DD_RUM && window.DD_RUM.init({
85+
+ clientToken: '<%= ENV['DD_CLIENT_TOKEN'] %>',
86+
+ applicationId: '<%= ENV['DD_APPLICATION_ID'] %>',
87+
+ site: '<%= ENV['DD_SITE'] %>',
88+
+ service: '<%= ENV['DD_SERVICE'] %>',
89+
+ env: '<%= ENV['DD_ENV'] %>',
90+
+ version: '1.0.0',
91+
+ sampleRate: 100,
92+
+ trackInteractions: true,
93+
+ defaultPrivacyLevel: 'mask-user-input'
94+
+ });
95+
+
96+
+ window.DD_RUM && window.DD_RUM.startSessionReplayRecording();
97+
+
98+
+ if (!window._DATADOG_SYNTHETICS_BROWSER) {
99+
+ window.DD_RUM.setRumGlobalContext({'usr.handle': 'john@storedog.com'});
100+
+ };
101+
+
102+
+ if (window.location.href.includes('utm')) {
103+
+ window.DD_RUM.addRumGlobalContext({'fromUtm': true});
104+
+ };
105+
+ </script>
108106
<%= render partial: 'spree/shared/head' %>
109107
</head>
110108
<body class="<%= body_class %>" id="<%= @body_id || 'default' %>" data-hook="body">
111109
diff -urN store-frontend-initial-state/config/environments/development.rb store-frontend-broken-instrumented/config/environments/development.rb
112-
--- store-frontend-initial-state/config/environments/development.rb 2021-07-14 12:26:50.000000000 +0200
113-
+++ store-frontend-broken-instrumented/config/environments/development.rb 2021-07-19 11:19:24.000000000 +0200
110+
--- store-frontend-initial-state/config/environments/development.rb 2021-09-10 17:19:31.000000000 -0400
111+
+++ store-frontend-broken-instrumented/config/environments/development.rb 2021-12-01 15:21:36.000000000 -0500
114112
@@ -107,6 +107,21 @@
115113
config.log_to = %w[stdout file]
116114
end
@@ -134,8 +132,8 @@ diff -urN store-frontend-initial-state/config/environments/development.rb store-
134132
config.show_log_configuration = true
135133
end
136134
diff -urN store-frontend-initial-state/config/environments/production.rb store-frontend-broken-instrumented/config/environments/production.rb
137-
--- store-frontend-initial-state/config/environments/production.rb 2021-07-14 12:26:50.000000000 +0200
138-
+++ store-frontend-broken-instrumented/config/environments/production.rb 2021-07-19 11:19:24.000000000 +0200
135+
--- store-frontend-initial-state/config/environments/production.rb 2021-08-31 09:59:14.000000000 -0400
136+
+++ store-frontend-broken-instrumented/config/environments/production.rb 2021-12-01 15:21:36.000000000 -0500
139137
@@ -53,6 +53,9 @@
140138
# when problems arise.
141139
config.log_level = :warn
@@ -147,8 +145,8 @@ diff -urN store-frontend-initial-state/config/environments/production.rb store-f
147145
# config.cache_store = :mem_cache_store
148146

149147
diff -urN store-frontend-initial-state/config/initializers/datadog.rb store-frontend-broken-instrumented/config/initializers/datadog.rb
150-
--- store-frontend-initial-state/config/initializers/datadog.rb 1970-01-01 01:00:00.000000000 +0100
151-
+++ store-frontend-broken-instrumented/config/initializers/datadog.rb 2021-07-19 11:19:24.000000000 +0200
148+
--- store-frontend-initial-state/config/initializers/datadog.rb 1969-12-31 19:00:00.000000000 -0500
149+
+++ store-frontend-broken-instrumented/config/initializers/datadog.rb 2021-12-01 15:21:36.000000000 -0500
152150
@@ -0,0 +1,6 @@
153151
+Datadog.configure do |c|
154152
+ # This will activate auto-instrumentation for Rails

0 commit comments

Comments
 (0)