instana 1.215.1 → 1.216.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.circleci/config.yml +83 -3
- data/.tekton/.currency/resources/requirements.txt +0 -1
- data/.tekton/.currency/scripts/generate_report.py +37 -130
- data/.tekton/README.md +278 -0
- data/.tekton/github-pr-eventlistener.yaml +1 -1
- data/.tekton/pipeline.yaml +96 -2
- data/.tekton/pipelinerun.yaml +2 -2
- data/.tekton/ruby-tracer-prepuller.yaml +4 -0
- data/.tekton/run_unittests.sh +27 -6
- data/.tekton/scheduled-eventlistener.yaml +1 -1
- data/.tekton/task.yaml +72 -0
- data/gemfiles/rails_61.gemfile +1 -0
- data/gemfiles/rails_70.gemfile +1 -0
- data/gemfiles/rails_71.gemfile +1 -0
- data/gemfiles/sequel_56.gemfile +16 -0
- data/gemfiles/sequel_57.gemfile +16 -0
- data/gemfiles/sequel_58.gemfile +16 -0
- data/lib/instana/activators/sequel.rb +20 -0
- data/lib/instana/config.rb +1 -0
- data/lib/instana/instrumentation/sequel.rb +42 -0
- data/lib/instana/tracing/span.rb +2 -2
- data/lib/instana/version.rb +1 -1
- data/test/activator_test.rb +1 -1
- data/test/instrumentation/rails_active_record_test.rb +1 -1
- data/test/instrumentation/sequel_test.rb +105 -0
- metadata +11 -8
- data/.tekton/.currency/currency-pipeline.yaml +0 -36
- data/.tekton/.currency/currency-pipelinerun.yaml +0 -20
- data/.tekton/.currency/currency-rbac.yaml +0 -29
- data/.tekton/.currency/currency-scheduled-eventlistener.yaml +0 -56
- data/.tekton/.currency/currency-tasks.yaml +0 -94
data/.tekton/pipeline.yaml
CHANGED
@@ -53,6 +53,8 @@ spec:
|
|
53
53
|
- "sha256:007d2edd515f9cfc8c5c571486aca4fc4a25c903d004decee302961bb8c636ed"
|
54
54
|
# 3.3.1-bookworm
|
55
55
|
- "sha256:5cf0004738f54bd67e4c4316394208ca38a6726eda7a1b0586d95601aad86e5d"
|
56
|
+
# 3.4.0-preview1-bookworm
|
57
|
+
- "sha256:2690af2a931469abe513b22a083b5ae0b56d4feffc0d3496eb6378723ab203e7"
|
56
58
|
- name: gemfile
|
57
59
|
value:
|
58
60
|
- "./Gemfile"
|
@@ -217,9 +219,47 @@ spec:
|
|
217
219
|
workspaces:
|
218
220
|
- name: task-pvc
|
219
221
|
workspace: ruby-tracer-ci-pipeline-pvc
|
220
|
-
- name: unittest-
|
222
|
+
- name: unittest-default-ruby-34
|
221
223
|
runAfter:
|
222
224
|
- unittest-default-ruby-33
|
225
|
+
matrix:
|
226
|
+
params:
|
227
|
+
- name: imageDigest
|
228
|
+
value:
|
229
|
+
# 3.4.0-preview1-bookworm
|
230
|
+
- "sha256:2690af2a931469abe513b22a083b5ae0b56d4feffc0d3496eb6378723ab203e7"
|
231
|
+
- name: gemfile
|
232
|
+
value:
|
233
|
+
- "./gemfiles/cuba_30.gemfile"
|
234
|
+
- "./gemfiles/cuba_40.gemfile"
|
235
|
+
- "./gemfiles/excon_02.gemfile"
|
236
|
+
- "./gemfiles/excon_079.gemfile"
|
237
|
+
- "./gemfiles/excon_100.gemfile"
|
238
|
+
- "./gemfiles/graphql_10.gemfile"
|
239
|
+
- "./gemfiles/graphql_20.gemfile"
|
240
|
+
- "./gemfiles/grpc_10.gemfile"
|
241
|
+
- "./gemfiles/net_http_01.gemfile"
|
242
|
+
- "./gemfiles/rack_20.gemfile"
|
243
|
+
- "./gemfiles/rack_30.gemfile"
|
244
|
+
- "./gemfiles/rest_client_20.gemfile"
|
245
|
+
- "./gemfiles/roda_20.gemfile"
|
246
|
+
- "./gemfiles/roda_30.gemfile"
|
247
|
+
- "./gemfiles/sinatra_22.gemfile"
|
248
|
+
- "./gemfiles/sinatra_30.gemfile"
|
249
|
+
- "./gemfiles/sinatra_40.gemfile"
|
250
|
+
- "./gemfiles/shoryuken_50.gemfile"
|
251
|
+
- "./gemfiles/shoryuken_60.gemfile"
|
252
|
+
- name: configuration
|
253
|
+
value:
|
254
|
+
- "libraries"
|
255
|
+
taskRef:
|
256
|
+
name: ruby-tracer-unittest-default-libraries-task
|
257
|
+
workspaces:
|
258
|
+
- name: task-pvc
|
259
|
+
workspace: ruby-tracer-ci-pipeline-pvc
|
260
|
+
- name: unittest-mongo
|
261
|
+
runAfter:
|
262
|
+
- unittest-default-ruby-34
|
223
263
|
matrix:
|
224
264
|
params:
|
225
265
|
- name: imageDigest
|
@@ -232,6 +272,8 @@ spec:
|
|
232
272
|
- "sha256:007d2edd515f9cfc8c5c571486aca4fc4a25c903d004decee302961bb8c636ed"
|
233
273
|
# 3.3.1-bookworm
|
234
274
|
- "sha256:5cf0004738f54bd67e4c4316394208ca38a6726eda7a1b0586d95601aad86e5d"
|
275
|
+
# 3.4.0-preview1-bookworm
|
276
|
+
- "sha256:2690af2a931469abe513b22a083b5ae0b56d4feffc0d3496eb6378723ab203e7"
|
235
277
|
- name: gemfile
|
236
278
|
value:
|
237
279
|
- "./gemfiles/mongo_216.gemfile"
|
@@ -256,6 +298,8 @@ spec:
|
|
256
298
|
- "sha256:007d2edd515f9cfc8c5c571486aca4fc4a25c903d004decee302961bb8c636ed"
|
257
299
|
# 3.3.1-bookworm
|
258
300
|
- "sha256:5cf0004738f54bd67e4c4316394208ca38a6726eda7a1b0586d95601aad86e5d"
|
301
|
+
# 3.4.0-preview1-bookworm
|
302
|
+
- "sha256:2690af2a931469abe513b22a083b5ae0b56d4feffc0d3496eb6378723ab203e7"
|
259
303
|
- name: gemfile
|
260
304
|
value:
|
261
305
|
- "./gemfiles/dalli_20.gemfile"
|
@@ -281,6 +325,8 @@ spec:
|
|
281
325
|
- "sha256:007d2edd515f9cfc8c5c571486aca4fc4a25c903d004decee302961bb8c636ed"
|
282
326
|
# 3.3.1-bookworm
|
283
327
|
- "sha256:5cf0004738f54bd67e4c4316394208ca38a6726eda7a1b0586d95601aad86e5d"
|
328
|
+
# 3.4.0-preview1-bookworm
|
329
|
+
- "sha256:2690af2a931469abe513b22a083b5ae0b56d4feffc0d3496eb6378723ab203e7"
|
284
330
|
- name: gemfile
|
285
331
|
value:
|
286
332
|
- "./gemfiles/aws_30.gemfile"
|
@@ -346,9 +392,35 @@ spec:
|
|
346
392
|
workspaces:
|
347
393
|
- name: task-pvc
|
348
394
|
workspace: ruby-tracer-ci-pipeline-pvc
|
349
|
-
- name: unittest-
|
395
|
+
- name: unittest-redis-ruby-34
|
350
396
|
runAfter:
|
351
397
|
- unittest-redis-ruby-32-33
|
398
|
+
matrix:
|
399
|
+
params:
|
400
|
+
- name: imageDigest
|
401
|
+
value:
|
402
|
+
# 3.4.0-preview1-bookworm
|
403
|
+
- "sha256:2690af2a931469abe513b22a083b5ae0b56d4feffc0d3496eb6378723ab203e7"
|
404
|
+
- name: gemfile
|
405
|
+
value:
|
406
|
+
- "./gemfiles/redis_40.gemfile"
|
407
|
+
- "./gemfiles/redis_50.gemfile"
|
408
|
+
- "./gemfiles/redis_51.gemfile"
|
409
|
+
- "./gemfiles/resque_122.gemfile"
|
410
|
+
- "./gemfiles/resque_20.gemfile"
|
411
|
+
- "./gemfiles/sidekiq_42.gemfile"
|
412
|
+
- "./gemfiles/sidekiq_50.gemfile"
|
413
|
+
- "./gemfiles/sidekiq_60.gemfile"
|
414
|
+
- "./gemfiles/sidekiq_65.gemfile"
|
415
|
+
- "./gemfiles/sidekiq_70.gemfile"
|
416
|
+
taskRef:
|
417
|
+
name: ruby-tracer-unittest-redis-libraries-task
|
418
|
+
workspaces:
|
419
|
+
- name: task-pvc
|
420
|
+
workspace: ruby-tracer-ci-pipeline-pvc
|
421
|
+
- name: unittest-rails-sqlite3
|
422
|
+
runAfter:
|
423
|
+
- unittest-redis-ruby-34
|
352
424
|
matrix:
|
353
425
|
params:
|
354
426
|
- name: imageDigest
|
@@ -361,6 +433,8 @@ spec:
|
|
361
433
|
- "sha256:007d2edd515f9cfc8c5c571486aca4fc4a25c903d004decee302961bb8c636ed"
|
362
434
|
# 3.3.1-bookworm
|
363
435
|
- "sha256:5cf0004738f54bd67e4c4316394208ca38a6726eda7a1b0586d95601aad86e5d"
|
436
|
+
# 3.4.0-preview1-bookworm
|
437
|
+
- "sha256:2690af2a931469abe513b22a083b5ae0b56d4feffc0d3496eb6378723ab203e7"
|
364
438
|
- name: gemfile
|
365
439
|
value:
|
366
440
|
- "./gemfiles/rails_61.gemfile"
|
@@ -386,6 +460,8 @@ spec:
|
|
386
460
|
- "sha256:007d2edd515f9cfc8c5c571486aca4fc4a25c903d004decee302961bb8c636ed"
|
387
461
|
# 3.3.1-bookworm
|
388
462
|
- "sha256:5cf0004738f54bd67e4c4316394208ca38a6726eda7a1b0586d95601aad86e5d"
|
463
|
+
# 3.4.0-preview1-bookworm
|
464
|
+
- "sha256:2690af2a931469abe513b22a083b5ae0b56d4feffc0d3496eb6378723ab203e7"
|
389
465
|
- name: gemfile
|
390
466
|
value:
|
391
467
|
- "./gemfiles/rails_61.gemfile"
|
@@ -411,6 +487,8 @@ spec:
|
|
411
487
|
- "sha256:007d2edd515f9cfc8c5c571486aca4fc4a25c903d004decee302961bb8c636ed"
|
412
488
|
# 3.3.1-bookworm
|
413
489
|
- "sha256:5cf0004738f54bd67e4c4316394208ca38a6726eda7a1b0586d95601aad86e5d"
|
490
|
+
# 3.4.0-preview1-bookworm
|
491
|
+
- "sha256:2690af2a931469abe513b22a083b5ae0b56d4feffc0d3496eb6378723ab203e7"
|
414
492
|
- name: gemfile
|
415
493
|
value:
|
416
494
|
- "./gemfiles/rails_61.gemfile"
|
@@ -421,3 +499,19 @@ spec:
|
|
421
499
|
workspaces:
|
422
500
|
- name: task-pvc
|
423
501
|
workspace: ruby-tracer-ci-pipeline-pvc
|
502
|
+
- name: generate-currency-report
|
503
|
+
runAfter:
|
504
|
+
- unittest-rails-postgres
|
505
|
+
taskRef:
|
506
|
+
name: ruby-generate-currency-report-task
|
507
|
+
workspaces:
|
508
|
+
- name: task-pvc
|
509
|
+
workspace: ruby-tracer-ci-pipeline-pvc
|
510
|
+
- name: upload-currency-report
|
511
|
+
runAfter:
|
512
|
+
- generate-currency-report
|
513
|
+
taskRef:
|
514
|
+
name: ruby-upload-currency-report-task
|
515
|
+
workspaces:
|
516
|
+
- name: task-pvc
|
517
|
+
workspace: ruby-tracer-ci-pipeline-pvc
|
data/.tekton/pipelinerun.yaml
CHANGED
@@ -7,7 +7,7 @@ spec:
|
|
7
7
|
pipeline: "2h"
|
8
8
|
params:
|
9
9
|
- name: revision
|
10
|
-
value: "
|
10
|
+
value: "master"
|
11
11
|
pipelineRef:
|
12
12
|
name: ruby-tracer-ci-pipeline
|
13
13
|
workspaces:
|
@@ -18,4 +18,4 @@ spec:
|
|
18
18
|
- ReadWriteOnce
|
19
19
|
resources:
|
20
20
|
requests:
|
21
|
-
storage:
|
21
|
+
storage: 200Mi
|
@@ -69,6 +69,10 @@ spec:
|
|
69
69
|
# 3.3.1-bookworm
|
70
70
|
image: ruby@sha256:5cf0004738f54bd67e4c4316394208ca38a6726eda7a1b0586d95601aad86e5d
|
71
71
|
command: ["sh", "-c", "'true'"]
|
72
|
+
- name: prepuller-34
|
73
|
+
# 3.4.0-preview1-bookworm
|
74
|
+
image: ruby@sha256:2690af2a931469abe513b22a083b5ae0b56d4feffc0d3496eb6378723ab203e7
|
75
|
+
command: ["sh", "-c", "'true'"]
|
72
76
|
# Use the pause container to ensure the Pod goes into a `Running` phase
|
73
77
|
# but doesn't take up resource on the cluster
|
74
78
|
containers:
|
data/.tekton/run_unittests.sh
CHANGED
@@ -21,7 +21,7 @@ fi
|
|
21
21
|
|
22
22
|
case "${TEST_CONFIGURATION}" in
|
23
23
|
libraries)
|
24
|
-
export
|
24
|
+
export TEST_SETUP="$(basename ${BUNDLE_GEMFILE%.gemfile})_ruby_${RUBY_VERSION}"
|
25
25
|
export APPRAISAL_INITIALIZED=1 ;;
|
26
26
|
rails)
|
27
27
|
if [[ -z "${DATABASE_URL}" ]]; then
|
@@ -31,23 +31,36 @@ rails)
|
|
31
31
|
else
|
32
32
|
echo "DATABASE_URL is '${DATABASE_URL}'"
|
33
33
|
fi
|
34
|
-
export
|
34
|
+
export TEST_SETUP="$(basename ${BUNDLE_GEMFILE%.gemfile})_${DATABASE_URL%:[:/]*}_ruby_${RUBY_VERSION}"
|
35
35
|
export APPRAISAL_INITIALIZED=1 ;;
|
36
36
|
core)
|
37
|
-
export
|
37
|
+
export TEST_SETUP="core_ruby_${RUBY_VERSION}" ;;
|
38
38
|
lint)
|
39
|
-
|
39
|
+
export TEST_SETUP="lint_ruby_${RUBY_VERSION}" ;;
|
40
40
|
*)
|
41
41
|
echo "ERROR \$TEST_CONFIGURATION='${TEST_CONFIGURATION}' is unsupported " \
|
42
42
|
"not in (libraries|rails|core|lint)" >&2
|
43
43
|
exit 5 ;;
|
44
44
|
esac
|
45
45
|
|
46
|
+
export COVERAGE_PATH="cov_${TEST_SETUP}"
|
47
|
+
export DEPENDENCY_PATH="dep_${TEST_SETUP}"
|
48
|
+
|
46
49
|
echo -n "Configuration is '${TEST_CONFIGURATION}' on Ruby ${RUBY_VERSION} "
|
47
50
|
echo "with dependencies in '${BUNDLE_GEMFILE}'"
|
48
51
|
|
52
|
+
# The gemfiles folder is under the tekton shared workspace
|
53
|
+
# but we have to prevent the sharing, and the concurrent writing
|
54
|
+
# of the gemfiles/*.lock files
|
55
|
+
# so here we create a container-local, non-shared copy, of the sources and use that.
|
56
|
+
cp --recursive ../ruby-sensor/ /tmp/
|
57
|
+
pushd /tmp/ruby-sensor/
|
58
|
+
|
49
59
|
# Update RubyGems
|
50
|
-
gem update --system > /dev/null
|
60
|
+
while ! gem update --system > /dev/null; do
|
61
|
+
echo "Updating Gem with 'gem update --system' failed, retrying in a minute"
|
62
|
+
sleep 60
|
63
|
+
done
|
51
64
|
echo "Gem version $(gem --version)"
|
52
65
|
|
53
66
|
# Configure Bundler
|
@@ -55,7 +68,10 @@ bundler --version
|
|
55
68
|
bundle config set path '/tmp/vendor/bundle'
|
56
69
|
|
57
70
|
# Install Dependencies
|
58
|
-
bundle check || bundle install
|
71
|
+
while ! (bundle check || bundle install) | tee "${DEPENDENCY_PATH}"; do
|
72
|
+
echo "Bundle install failed, retrying in a minute"
|
73
|
+
sleep 60
|
74
|
+
done
|
59
75
|
|
60
76
|
# Run tests
|
61
77
|
if [[ "${TEST_CONFIGURATION}" = "lint" ]]; then
|
@@ -63,4 +79,9 @@ if [[ "${TEST_CONFIGURATION}" = "lint" ]]; then
|
|
63
79
|
else
|
64
80
|
mkdir --parents "${COVERAGE_PATH}/_junit"
|
65
81
|
bundle exec rake
|
82
|
+
cp --recursive "${COVERAGE_PATH}" "${OLDPWD}/"
|
66
83
|
fi
|
84
|
+
|
85
|
+
# Put back the dependency insallation results to the shared workspace
|
86
|
+
cp --recursive "${DEPENDENCY_PATH}" "${OLDPWD}/"
|
87
|
+
popd
|
data/.tekton/task.yaml
CHANGED
@@ -291,3 +291,75 @@ spec:
|
|
291
291
|
workingDir: /workspace/ruby-sensor/
|
292
292
|
command:
|
293
293
|
- /workspace/ruby-sensor/.tekton/run_unittests.sh
|
294
|
+
---
|
295
|
+
apiVersion: tekton.dev/v1
|
296
|
+
kind: Task
|
297
|
+
metadata:
|
298
|
+
name: ruby-generate-currency-report-task
|
299
|
+
spec:
|
300
|
+
workspaces:
|
301
|
+
- name: task-pvc
|
302
|
+
mountPath: /workspace
|
303
|
+
steps:
|
304
|
+
- name: generate-currency-report
|
305
|
+
# 3.10.13-bookworm
|
306
|
+
image: python@sha256:c970ff53939772f47b0672e380328afb50d8fd1c0568ed4f82c22effc54244fc
|
307
|
+
script: |
|
308
|
+
#!/usr/bin/env bash
|
309
|
+
|
310
|
+
cd /workspace/ruby-sensor/.tekton/.currency
|
311
|
+
|
312
|
+
python -m venv /tmp/venv
|
313
|
+
source /tmp/venv/bin/activate
|
314
|
+
pip install -r resources/requirements.txt
|
315
|
+
|
316
|
+
python scripts/generate_report.py
|
317
|
+
if [ $? -ne 0 ]; then
|
318
|
+
echo "Error occured while generating the ruby tracer currency report." >&2
|
319
|
+
exit 1
|
320
|
+
fi
|
321
|
+
cat docs/report.md
|
322
|
+
---
|
323
|
+
apiVersion: tekton.dev/v1
|
324
|
+
kind: Task
|
325
|
+
metadata:
|
326
|
+
name: ruby-upload-currency-report-task
|
327
|
+
spec:
|
328
|
+
params:
|
329
|
+
- name: github-token-secret
|
330
|
+
default: instanacd-github-api-token
|
331
|
+
workspaces:
|
332
|
+
- name: task-pvc
|
333
|
+
mountPath: /workspace
|
334
|
+
steps:
|
335
|
+
- name: upload-currency-report
|
336
|
+
# alpine/git:2.43.0
|
337
|
+
image: alpine/git@sha256:6ff4de047dcc8f0c7d75d2efff63fbc189e87d2f458305f2cc8f165ff83309cf
|
338
|
+
env:
|
339
|
+
- name: GH_ENTERPRISE_TOKEN
|
340
|
+
valueFrom:
|
341
|
+
secretKeyRef:
|
342
|
+
name: $(params.github-token-secret)
|
343
|
+
key: "GH_ENTERPRISE_TOKEN"
|
344
|
+
script: |
|
345
|
+
#!/bin/sh
|
346
|
+
|
347
|
+
cd /workspace
|
348
|
+
git clone https://oauth2:$GH_ENTERPRISE_TOKEN@github.ibm.com/instana/tracer-reports.git
|
349
|
+
|
350
|
+
if [ $? -ne 0 ]; then
|
351
|
+
echo "The attempt to clone the tracer-reports repository failed, preventing the upload of ruby tracer currency report." >&2
|
352
|
+
exit 1
|
353
|
+
fi
|
354
|
+
|
355
|
+
cd tracer-reports
|
356
|
+
|
357
|
+
cp ../ruby-sensor/.tekton/.currency/docs/report.md ./automated/currency/ruby/report.md
|
358
|
+
|
359
|
+
git config user.name "Instanacd PAT for GitHub Enterprise"
|
360
|
+
git config user.email instana.ibm.github.enterprise@ibm.com
|
361
|
+
|
362
|
+
git add .
|
363
|
+
|
364
|
+
git commit -m "chore: Updated ruby currency report"
|
365
|
+
git push origin main
|
data/gemfiles/rails_61.gemfile
CHANGED
data/gemfiles/rails_70.gemfile
CHANGED
data/gemfiles/rails_71.gemfile
CHANGED
@@ -0,0 +1,16 @@
|
|
1
|
+
# This file was generated by Appraisal
|
2
|
+
|
3
|
+
# (c) Copyright IBM Corp. 2024
|
4
|
+
|
5
|
+
source "https://rubygems.org"
|
6
|
+
|
7
|
+
gem "minitest-reporters"
|
8
|
+
gem "webmock"
|
9
|
+
gem "puma"
|
10
|
+
gem "rack-test"
|
11
|
+
gem "simplecov", "~> 0.21.2"
|
12
|
+
gem "sequel", "~> 5.60"
|
13
|
+
gem "sqlite3", "~> 1.4"
|
14
|
+
gem "mysql2", "0.5.5"
|
15
|
+
|
16
|
+
gemspec path: "../"
|
@@ -0,0 +1,16 @@
|
|
1
|
+
# This file was generated by Appraisal
|
2
|
+
|
3
|
+
# (c) Copyright IBM Corp. 2024
|
4
|
+
|
5
|
+
source "https://rubygems.org"
|
6
|
+
|
7
|
+
gem "minitest-reporters"
|
8
|
+
gem "webmock"
|
9
|
+
gem "puma"
|
10
|
+
gem "rack-test"
|
11
|
+
gem "simplecov", "~> 0.21.2"
|
12
|
+
gem "sequel", "~> 5.70"
|
13
|
+
gem "sqlite3", "~> 1.4"
|
14
|
+
gem "mysql2", "0.5.5"
|
15
|
+
|
16
|
+
gemspec path: "../"
|
@@ -0,0 +1,16 @@
|
|
1
|
+
# This file was generated by Appraisal
|
2
|
+
|
3
|
+
# (c) Copyright IBM Corp. 2024
|
4
|
+
|
5
|
+
source "https://rubygems.org"
|
6
|
+
|
7
|
+
gem "minitest-reporters"
|
8
|
+
gem "webmock"
|
9
|
+
gem "puma"
|
10
|
+
gem "rack-test"
|
11
|
+
gem "simplecov", "~> 0.21.2"
|
12
|
+
gem "sequel", ">= 5.80"
|
13
|
+
gem "sqlite3", "~> 1.4"
|
14
|
+
gem "mysql2", "0.5.5"
|
15
|
+
|
16
|
+
gemspec path: "../"
|
@@ -0,0 +1,20 @@
|
|
1
|
+
# (c) Copyright IBM Corp. 2024
|
2
|
+
|
3
|
+
module Instana
|
4
|
+
module Activators
|
5
|
+
class Sequel < Activator
|
6
|
+
def can_instrument?
|
7
|
+
defined?(::Sequel::Database)
|
8
|
+
end
|
9
|
+
|
10
|
+
def instrument
|
11
|
+
require 'instana/instrumentation/sequel'
|
12
|
+
|
13
|
+
::Sequel::Database
|
14
|
+
.prepend(Instana::Instrumentation::Sequel)
|
15
|
+
|
16
|
+
true
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
data/lib/instana/config.rb
CHANGED
@@ -73,6 +73,7 @@ module Instana
|
|
73
73
|
@config[:'resque-client'] = { :enabled => true, :propagate => true }
|
74
74
|
@config[:'resque-worker'] = { :enabled => true, :'setup-fork' => true }
|
75
75
|
@config[:'rest-client'] = { :enabled => true }
|
76
|
+
@config[:sequel] = { :enabled => true }
|
76
77
|
@config[:'sidekiq-client'] = { :enabled => true }
|
77
78
|
@config[:'sidekiq-worker'] = { :enabled => true }
|
78
79
|
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
# (c) Copyright IBM Corp. 2024
|
2
|
+
|
3
|
+
module Instana
|
4
|
+
module Instrumentation
|
5
|
+
module Sequel
|
6
|
+
IGNORED_SQL = %w[BEGIN COMMIT SET].freeze
|
7
|
+
VERSION_SELECT_STATEMENT = "SELECT VERSION()".freeze
|
8
|
+
SANITIZE_REGEXP = /('[\s\S][^']*'|\d*\.\d+|\d+|NULL)/i.freeze
|
9
|
+
|
10
|
+
def log_connection_yield(sql, conn, *args)
|
11
|
+
call_payload = {
|
12
|
+
sequel: {
|
13
|
+
adapter: opts[:adapter],
|
14
|
+
host: opts[:host],
|
15
|
+
username: opts[:user],
|
16
|
+
db: opts[:database],
|
17
|
+
sql: maybe_sanitize(sql)
|
18
|
+
}
|
19
|
+
}
|
20
|
+
maybe_trace(call_payload) { super(sql, conn, *args) }
|
21
|
+
end
|
22
|
+
|
23
|
+
private
|
24
|
+
|
25
|
+
def maybe_sanitize(sql)
|
26
|
+
::Instana.config[:sanitize_sql] ? sql.gsub(SANITIZE_REGEXP, '?') : sql
|
27
|
+
end
|
28
|
+
|
29
|
+
def maybe_trace(call_payload, &blk)
|
30
|
+
if ::Instana.tracer.tracing? && !ignored?(call_payload)
|
31
|
+
::Instana.tracer.trace(:sequel, call_payload, &blk)
|
32
|
+
else
|
33
|
+
yield
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
def ignored?(call_payload)
|
38
|
+
IGNORED_SQL.any? { |s| call_payload[:sequel][:sql].upcase.start_with?(s) } || call_payload[:sequel][:sql].upcase == VERSION_SELECT_STATEMENT
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
data/lib/instana/tracing/span.rb
CHANGED
@@ -7,12 +7,12 @@ module Instana
|
|
7
7
|
:memcache, :'net-http', :rack, :render, :'rpc-client',
|
8
8
|
:'rpc-server', :'sidekiq-client', :'sidekiq-worker',
|
9
9
|
:redis, :'resque-client', :'resque-worker', :'graphql.server', :dynamodb, :s3, :sns, :sqs, :'aws.lambda.entry', :activejob, :log, :"mail.actionmailer",
|
10
|
-
:"aws.lambda.invoke", :mongo
|
10
|
+
:"aws.lambda.invoke", :mongo, :sequel ].freeze
|
11
11
|
ENTRY_SPANS = [ :rack, :'resque-worker', :'rpc-server', :'sidekiq-worker', :'graphql.server', :sqs,
|
12
12
|
:'aws.lambda.entry' ].freeze
|
13
13
|
EXIT_SPANS = [ :activerecord, :excon, :'net-http', :'resque-client',
|
14
14
|
:'rpc-client', :'sidekiq-client', :redis, :dynamodb, :s3, :sns, :sqs, :log, :"mail.actionmailer",
|
15
|
-
:"aws.lambda.invoke", :mongo ].freeze
|
15
|
+
:"aws.lambda.invoke", :mongo, :sequel ].freeze
|
16
16
|
HTTP_SPANS = [ :rack, :excon, :'net-http' ].freeze
|
17
17
|
|
18
18
|
attr_accessor :parent
|
data/lib/instana/version.rb
CHANGED
data/test/activator_test.rb
CHANGED
@@ -43,7 +43,7 @@ class ActivatorTest < Minitest::Test
|
|
43
43
|
ENV.delete('INSTANA_ACTIVATE_SET')
|
44
44
|
subject = activated_set
|
45
45
|
assert_instance_of Set, subject
|
46
|
-
assert_equal
|
46
|
+
assert_equal 32, subject.length
|
47
47
|
ensure
|
48
48
|
ENV.delete('INSTANA_ACTIVATE_SET')
|
49
49
|
end
|
@@ -17,7 +17,7 @@ class RailsActiveRecordTest < Minitest::Test
|
|
17
17
|
ActiveRecord::Migration.suppress_messages do
|
18
18
|
ActiveRecord::Migration.run(CreateBlocks, direction: :down)
|
19
19
|
end
|
20
|
-
ActiveRecord::Base.remove_connection
|
20
|
+
ActiveRecord::Base.remove_connection
|
21
21
|
end
|
22
22
|
|
23
23
|
def test_config_defaults
|
@@ -0,0 +1,105 @@
|
|
1
|
+
# (c) Copyright IBM Corp. 2024
|
2
|
+
|
3
|
+
require 'test_helper'
|
4
|
+
require 'sequel'
|
5
|
+
|
6
|
+
class SequelTest < Minitest::Test
|
7
|
+
def setup
|
8
|
+
skip unless ENV['DATABASE_URL']
|
9
|
+
db_url = ENV['DATABASE_URL'].sub("sqlite3", "sqlite")
|
10
|
+
@db = Sequel.connect(db_url)
|
11
|
+
@db.create_table!(:blocks) do
|
12
|
+
String :name
|
13
|
+
String :color
|
14
|
+
end
|
15
|
+
@model = @db[:blocks]
|
16
|
+
end
|
17
|
+
|
18
|
+
def teardown
|
19
|
+
@db.drop_table(:blocks)
|
20
|
+
@db.disconnect
|
21
|
+
end
|
22
|
+
|
23
|
+
def test_config_defaults
|
24
|
+
assert ::Instana.config[:sanitize_sql] == true
|
25
|
+
assert ::Instana.config[:sequel].is_a?(Hash)
|
26
|
+
assert ::Instana.config[:sequel].key?(:enabled)
|
27
|
+
assert_equal true, ::Instana.config[:sequel][:enabled]
|
28
|
+
end
|
29
|
+
|
30
|
+
def test_create
|
31
|
+
Instana::Tracer.start_or_continue_trace(:sequel_test, {}) do
|
32
|
+
@model.insert(name: 'core', color: 'blue')
|
33
|
+
end
|
34
|
+
spans = ::Instana.processor.queued_spans
|
35
|
+
assert_equal 2, spans.length
|
36
|
+
span = find_first_span_by_name(spans, :sequel)
|
37
|
+
data = span[:data][:sequel]
|
38
|
+
assert data[:sql].start_with?('INSERT INTO')
|
39
|
+
end
|
40
|
+
|
41
|
+
def test_read
|
42
|
+
@model.insert(name: 'core', color: 'blue')
|
43
|
+
Instana::Tracer.start_or_continue_trace(:sequel_test, {}) do
|
44
|
+
@model.where(name: 'core').first
|
45
|
+
end
|
46
|
+
spans = ::Instana.processor.queued_spans
|
47
|
+
assert_equal 2, spans.length
|
48
|
+
span = find_first_span_by_name(spans, :sequel)
|
49
|
+
data = span[:data][:sequel]
|
50
|
+
assert data[:sql].start_with?('SELECT')
|
51
|
+
assert_nil span[:ec]
|
52
|
+
end
|
53
|
+
|
54
|
+
def test_update
|
55
|
+
@model.insert(name: 'core', color: 'blue')
|
56
|
+
Instana::Tracer.start_or_continue_trace(:sequel_test, {}) do
|
57
|
+
@model.where(name: 'core').update(color: 'red')
|
58
|
+
end
|
59
|
+
spans = ::Instana.processor.queued_spans
|
60
|
+
assert_equal 2, spans.length
|
61
|
+
span = find_first_span_by_name(spans, :sequel)
|
62
|
+
data = span[:data][:sequel]
|
63
|
+
assert data[:sql].start_with?('UPDATE')
|
64
|
+
assert_nil span[:ec]
|
65
|
+
assert_equal 'red', @model.where(name: 'core').first[:color]
|
66
|
+
end
|
67
|
+
|
68
|
+
def test_delete
|
69
|
+
@model.insert(name: 'core', color: 'blue')
|
70
|
+
Instana::Tracer.start_or_continue_trace(:sequel_test, {}) do
|
71
|
+
@model.where(name: 'core').delete
|
72
|
+
end
|
73
|
+
spans = ::Instana.processor.queued_spans
|
74
|
+
assert_equal 2, spans.length
|
75
|
+
span = find_first_span_by_name(spans, :sequel)
|
76
|
+
data = span[:data][:sequel]
|
77
|
+
assert data[:sql].start_with?('DELETE')
|
78
|
+
assert_nil span[:ec]
|
79
|
+
assert_nil @model.where(name: 'core').first
|
80
|
+
end
|
81
|
+
|
82
|
+
def test_raw
|
83
|
+
Instana::Tracer.start_or_continue_trace(:sequel_test, {}) do
|
84
|
+
@db.run('SELECT 1')
|
85
|
+
end
|
86
|
+
spans = ::Instana.processor.queued_spans
|
87
|
+
assert_equal 2, spans.length
|
88
|
+
span = find_first_span_by_name(spans, :sequel)
|
89
|
+
data = span[:data][:sequel]
|
90
|
+
assert 'SELECT 1', data[:sql]
|
91
|
+
assert_nil span[:ec]
|
92
|
+
end
|
93
|
+
|
94
|
+
def test_raw_error
|
95
|
+
assert_raises Sequel::DatabaseError do
|
96
|
+
Instana::Tracer.start_or_continue_trace(:sequel_test, {}) do
|
97
|
+
@db.run('INVALID')
|
98
|
+
end
|
99
|
+
end
|
100
|
+
spans = ::Instana.processor.queued_spans
|
101
|
+
assert_equal 2, spans.length
|
102
|
+
span = find_first_span_by_name(spans, :sequel)
|
103
|
+
assert_equal 1, span[:ec]
|
104
|
+
end
|
105
|
+
end
|