instana 1.217.1 → 2.0.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 +101 -225
- data/.tekton/.currency/scripts/generate_report.py +194 -22
- data/.tekton/pipeline.yaml +65 -152
- data/.tekton/prepuller-restart-service-account.yaml +31 -0
- data/.tekton/ruby-tracer-prepuller-cronjob.yaml +20 -0
- data/.tekton/ruby-tracer-prepuller.yaml +27 -26
- data/.tekton/task.yaml +31 -27
- data/Gemfile +5 -0
- data/README.md +2 -1
- data/Rakefile +1 -1
- data/examples/otel.rb +98 -0
- data/examples/tracing.rb +1 -0
- data/gemfiles/rails_61.gemfile +1 -0
- data/gemfiles/rails_70.gemfile +1 -0
- data/instana.gemspec +5 -0
- data/lib/instana/base.rb +4 -2
- data/lib/instana/instrumentation/action_cable.rb +8 -4
- data/lib/instana/instrumentation/action_controller.rb +2 -4
- data/lib/instana/instrumentation/action_mailer.rb +1 -1
- data/lib/instana/instrumentation/action_view.rb +4 -4
- data/lib/instana/instrumentation/active_job.rb +20 -5
- data/lib/instana/instrumentation/active_record.rb +1 -1
- data/lib/instana/instrumentation/aws_sdk_dynamodb.rb +1 -1
- data/lib/instana/instrumentation/aws_sdk_lambda.rb +1 -1
- data/lib/instana/instrumentation/aws_sdk_s3.rb +1 -1
- data/lib/instana/instrumentation/aws_sdk_sns.rb +1 -1
- data/lib/instana/instrumentation/aws_sdk_sqs.rb +1 -1
- data/lib/instana/instrumentation/dalli.rb +1 -1
- data/lib/instana/instrumentation/excon.rb +2 -2
- data/lib/instana/instrumentation/graphql.rb +3 -3
- data/lib/instana/instrumentation/grpc.rb +14 -13
- data/lib/instana/instrumentation/mongo.rb +3 -3
- data/lib/instana/instrumentation/net-http.rb +5 -4
- data/lib/instana/instrumentation/rack.rb +36 -4
- data/lib/instana/instrumentation/redis.rb +1 -1
- data/lib/instana/instrumentation/resque.rb +10 -8
- data/lib/instana/instrumentation/rest-client.rb +4 -4
- data/lib/instana/instrumentation/sequel.rb +3 -3
- data/lib/instana/instrumentation/shoryuken.rb +4 -1
- data/lib/instana/instrumentation/sidekiq-client.rb +21 -19
- data/lib/instana/instrumentation/sidekiq-worker.rb +22 -21
- data/lib/instana/instrumented_logger.rb +1 -1
- data/lib/instana/samplers/result.rb +32 -0
- data/lib/instana/samplers/samplers.rb +76 -0
- data/lib/instana/serverless.rb +4 -2
- data/lib/instana/setup.rb +4 -5
- data/lib/instana/trace/export.rb +36 -0
- data/lib/instana/{tracing → trace}/processor.rb +19 -15
- data/lib/instana/trace/span.rb +532 -0
- data/lib/instana/{tracing → trace}/span_context.rb +17 -8
- data/lib/instana/trace/span_kind.rb +51 -0
- data/lib/instana/trace/span_limits.rb +63 -0
- data/lib/instana/{tracer.rb → trace/tracer.rb} +106 -54
- data/lib/instana/trace/tracer_provider.rb +198 -0
- data/lib/instana/trace.rb +74 -0
- data/lib/instana/util.rb +11 -0
- data/lib/instana/version.rb +1 -1
- data/test/instrumentation/aws_test.rb +7 -7
- data/test/instrumentation/dalli_test.rb +8 -8
- data/test/instrumentation/excon_test.rb +3 -3
- data/test/instrumentation/graphql_test.rb +4 -4
- data/test/instrumentation/grpc_test.rb +8 -8
- data/test/instrumentation/mongo_test.rb +1 -1
- data/test/instrumentation/net_http_test.rb +6 -6
- data/test/instrumentation/rails_action_cable_test.rb +2 -2
- data/test/instrumentation/rails_action_mailer_test.rb +1 -1
- data/test/instrumentation/rails_active_job_test.rb +1 -1
- data/test/instrumentation/rails_active_record_database_missing_test.rb +2 -3
- data/test/instrumentation/rails_active_record_test.rb +8 -7
- data/test/instrumentation/redis_test.rb +7 -7
- data/test/instrumentation/resque_test.rb +5 -5
- data/test/instrumentation/rest_client_test.rb +1 -2
- data/test/instrumentation/sequel_test.rb +12 -6
- data/test/instrumentation/sidekiq-client_test.rb +2 -2
- data/test/instrumentation/sidekiq-worker_test.rb +2 -2
- data/test/{tracing → trace}/custom_test.rb +32 -25
- data/test/{tracing → trace}/id_management_test.rb +0 -2
- data/test/{tracing → trace}/instrumented_logger_test.rb +1 -1
- data/test/{tracing → trace}/processor_test.rb +6 -6
- data/test/{tracing → trace}/span_context_test.rb +3 -3
- data/test/{tracing → trace}/span_test.rb +7 -7
- data/test/{tracing → trace}/tracer_async_test.rb +43 -30
- data/test/trace/tracer_provider_test.rb +148 -0
- data/test/{tracing → trace}/tracer_test.rb +48 -37
- metadata +105 -32
- data/examples/opentracing.rb +0 -35
- data/lib/instana/open_tracing/carrier.rb +0 -7
- data/lib/instana/open_tracing/instana_tracer.rb +0 -99
- data/lib/instana/tracing/span.rb +0 -431
- data/lib/opentracing.rb +0 -32
- data/test/tracing/opentracing_test.rb +0 -382
@@ -0,0 +1,31 @@
|
|
1
|
+
---
|
2
|
+
# Service account which will be use to reset the daemonset,
|
3
|
+
kind: ServiceAccount
|
4
|
+
apiVersion: v1
|
5
|
+
metadata:
|
6
|
+
name: prepuller-restart
|
7
|
+
---
|
8
|
+
# allow getting status and patching only the one daemonset you want
|
9
|
+
# to restart
|
10
|
+
apiVersion: rbac.authorization.k8s.io/v1
|
11
|
+
kind: Role
|
12
|
+
metadata:
|
13
|
+
name: prepuller-restart
|
14
|
+
rules:
|
15
|
+
- apiGroups: ["apps", "extensions"]
|
16
|
+
resources: ["daemonsets"]
|
17
|
+
resourceNames: ["ruby-tracer-prepuller"]
|
18
|
+
verbs: ["get", "patch"]
|
19
|
+
---
|
20
|
+
# bind the role to the service account
|
21
|
+
apiVersion: rbac.authorization.k8s.io/v1
|
22
|
+
kind: RoleBinding
|
23
|
+
metadata:
|
24
|
+
name: prepuller-restart
|
25
|
+
roleRef:
|
26
|
+
apiGroup: rbac.authorization.k8s.io
|
27
|
+
kind: Role
|
28
|
+
name: prepuller-restart
|
29
|
+
subjects:
|
30
|
+
- kind: ServiceAccount
|
31
|
+
name: prepuller-restart
|
@@ -0,0 +1,20 @@
|
|
1
|
+
apiVersion: batch/v1
|
2
|
+
kind: CronJob
|
3
|
+
metadata:
|
4
|
+
name: deploy-daemonset
|
5
|
+
spec:
|
6
|
+
schedule: "0 0 * * Mon-Fri" # Run every weekday at 12AM
|
7
|
+
jobTemplate:
|
8
|
+
spec:
|
9
|
+
template:
|
10
|
+
spec:
|
11
|
+
serviceAccountName: prepuller-restart
|
12
|
+
containers:
|
13
|
+
- name: kubectl
|
14
|
+
image: bitnami/kubectl
|
15
|
+
command:
|
16
|
+
- 'kubectl'
|
17
|
+
- 'rollout'
|
18
|
+
- 'restart'
|
19
|
+
- 'daemonset/ruby-tracer-prepuller'
|
20
|
+
restartPolicy: OnFailure
|
@@ -14,65 +14,66 @@ spec:
|
|
14
14
|
# Configure an init container for each image you want to pull
|
15
15
|
initContainers:
|
16
16
|
- name: prepuller-git
|
17
|
-
# alpine/git:
|
18
|
-
image: alpine
|
17
|
+
# alpine/git:latest
|
18
|
+
image: public.ecr.aws/docker/library/alpine:latest
|
19
19
|
command: ["sh", "-c", "'true'"]
|
20
20
|
- name: prepuller-dynamodb
|
21
21
|
# amazon/dynamodb-local:2.3.0
|
22
|
-
image:
|
22
|
+
image: public.ecr.aws/aws-dynamodb-local/aws-dynamodb-local:2.3.0
|
23
23
|
command: ["sh", "-c", "'true'"]
|
24
24
|
- name: prepuller-s3
|
25
|
-
# minio/minio
|
26
|
-
image: minio/minio
|
25
|
+
# minio/minio
|
26
|
+
image: quay.io/minio/minio
|
27
27
|
command: ["sh", "-c", "'true'"]
|
28
28
|
- name: prepuller-sns
|
29
29
|
# s12v/sns:latest
|
30
|
-
image: s12v/sns
|
30
|
+
image: public.ecr.aws/redbox-public/s12v/sns:latest
|
31
31
|
command: ["sh", "-c", "'true'"]
|
32
32
|
- name: prepuller-sqs
|
33
|
-
#
|
34
|
-
image:
|
33
|
+
# sprig/elasticmq-native
|
34
|
+
image: public.ecr.aws/sprig/elasticmq-native
|
35
35
|
command: ["sh", "-c", "'true'"]
|
36
36
|
- name: prepuller-memcached
|
37
37
|
# memcached:1.6.24-bookworm
|
38
|
-
image: memcached
|
38
|
+
image: public.ecr.aws/docker/library/memcached:1.6.24-bookworm
|
39
39
|
command: ["sh", "-c", "'true'"]
|
40
40
|
- name: prepuller-redis
|
41
41
|
# redis:7.2.4-bookworm
|
42
|
-
image: redis
|
42
|
+
image: public.ecr.aws/docker/library/redis:7.2.4-bookworm
|
43
43
|
command: ["sh", "-c", "'true'"]
|
44
44
|
- name: prepuller-mongo
|
45
|
-
# mongo:5
|
46
|
-
image: mongo
|
45
|
+
# mongo:5-focal
|
46
|
+
image: public.ecr.aws/docker/library/mongo:5-focal
|
47
47
|
command: ["sh", "-c", "'true'"]
|
48
|
+
imagePullPolicy: Always
|
48
49
|
- name: prepuller-mariadb
|
49
50
|
# mariadb:11.3.2
|
50
|
-
image: mariadb
|
51
|
+
image: public.ecr.aws/docker/library/mariadb:11.3.2
|
51
52
|
command: ["sh", "-c", "'true'"]
|
52
53
|
- name: prepuller-postgres
|
53
54
|
# postgres:16.2-bookworm
|
54
|
-
image: postgres
|
55
|
-
command: ["sh", "-c", "'true'"]
|
56
|
-
- name: prepuller-30
|
57
|
-
# 3.0.6-bullseye
|
58
|
-
image: ruby@sha256:3166618469ad8a3190d80f43b322818fafb4bfac0b4882255eee3346af2a0a35
|
55
|
+
image: public.ecr.aws/docker/library/postgres:16.2-bookworm
|
59
56
|
command: ["sh", "-c", "'true'"]
|
60
57
|
- name: prepuller-31
|
61
|
-
# 3.1
|
62
|
-
image: ruby
|
58
|
+
# ruby-3.1
|
59
|
+
image: public.ecr.aws/docker/library/ruby:3.1
|
63
60
|
command: ["sh", "-c", "'true'"]
|
61
|
+
imagePullPolicy: Always
|
64
62
|
- name: prepuller-32
|
65
|
-
# 3.2
|
66
|
-
image: ruby
|
63
|
+
# ruby-3.2
|
64
|
+
image: public.ecr.aws/docker/library/ruby:3.2
|
67
65
|
command: ["sh", "-c", "'true'"]
|
66
|
+
imagePullPolicy: Always
|
68
67
|
- name: prepuller-33
|
69
|
-
# 3.3
|
70
|
-
image: ruby
|
68
|
+
# ruby-3.3
|
69
|
+
image: public.ecr.aws/docker/library/ruby:3.3
|
71
70
|
command: ["sh", "-c", "'true'"]
|
71
|
+
imagePullPolicy: Always
|
72
72
|
- name: prepuller-34
|
73
|
-
# 3.4
|
74
|
-
image: ruby
|
73
|
+
# ruby-3.4
|
74
|
+
image: public.ecr.aws/docker/library/ruby:3.4
|
75
75
|
command: ["sh", "-c", "'true'"]
|
76
|
+
imagePullPolicy: Always
|
76
77
|
# Use the pause container to ensure the Pod goes into a `Running` phase
|
77
78
|
# but doesn't take up resource on the cluster
|
78
79
|
containers:
|
data/.tekton/task.yaml
CHANGED
@@ -12,10 +12,12 @@ spec:
|
|
12
12
|
mountPath: /workspace
|
13
13
|
steps:
|
14
14
|
- name: clone
|
15
|
-
# alpine/git:
|
16
|
-
image: alpine
|
15
|
+
# alpine/git:latest
|
16
|
+
image: public.ecr.aws/docker/library/alpine:latest
|
17
17
|
script: |
|
18
18
|
#!/bin/sh
|
19
|
+
echo "Installing git"
|
20
|
+
apk fix && apk --no-cache --update add git gpg less openssh patch
|
19
21
|
echo "Cloning repo"
|
20
22
|
cd /workspace && git clone --depth 1 -b $(params.revision) https://github.com/instana/ruby-sensor
|
21
23
|
ls -lah /workspace
|
@@ -35,7 +37,7 @@ spec:
|
|
35
37
|
mountPath: /workspace
|
36
38
|
steps:
|
37
39
|
- name: unittest
|
38
|
-
image:
|
40
|
+
image: $(params.imageDigest)
|
39
41
|
env:
|
40
42
|
- name: TEST_CONFIGURATION
|
41
43
|
value: rails
|
@@ -56,7 +58,7 @@ spec:
|
|
56
58
|
# MySQL (compatible Mariadb)
|
57
59
|
- name: mariadb
|
58
60
|
# mariadb:11.3.2
|
59
|
-
image: mariadb
|
61
|
+
image: public.ecr.aws/docker/library/mariadb:11.3.2
|
60
62
|
startupProbe:
|
61
63
|
initialDelaySeconds: 10
|
62
64
|
tcpSocket:
|
@@ -76,7 +78,7 @@ spec:
|
|
76
78
|
mountPath: /workspace
|
77
79
|
steps:
|
78
80
|
- name: unittest
|
79
|
-
image:
|
81
|
+
image: $(params.imageDigest)
|
80
82
|
env:
|
81
83
|
- name: TEST_CONFIGURATION
|
82
84
|
value: rails
|
@@ -96,7 +98,7 @@ spec:
|
|
96
98
|
sidecars:
|
97
99
|
- name: postgres
|
98
100
|
# postgres:16.2-bookworm
|
99
|
-
image: postgres
|
101
|
+
image: public.ecr.aws/docker/library/postgres:16.2-bookworm
|
100
102
|
startupProbe:
|
101
103
|
initialDelaySeconds: 10
|
102
104
|
tcpSocket:
|
@@ -118,7 +120,7 @@ spec:
|
|
118
120
|
mountPath: /workspace
|
119
121
|
steps:
|
120
122
|
- name: unittest
|
121
|
-
image:
|
123
|
+
image: $(params.imageDigest)
|
122
124
|
env:
|
123
125
|
- name: TEST_CONFIGURATION
|
124
126
|
value: rails
|
@@ -139,15 +141,15 @@ spec:
|
|
139
141
|
# Amazon DynamoDB
|
140
142
|
- name: dynamodb
|
141
143
|
# amazon/dynamodb-local:2.3.0
|
142
|
-
image:
|
144
|
+
image: public.ecr.aws/aws-dynamodb-local/aws-dynamodb-local:2.3.0
|
143
145
|
startupProbe:
|
144
146
|
tcpSocket:
|
145
147
|
port: 8000
|
146
148
|
initialDelaySeconds: 10
|
147
149
|
# Amazon S3
|
148
150
|
- name: s3
|
149
|
-
# minio/minio:
|
150
|
-
image: minio/minio
|
151
|
+
# minio/minio:latest
|
152
|
+
image: quay.io/minio/minio
|
151
153
|
command:
|
152
154
|
- /usr/bin/minio
|
153
155
|
- server
|
@@ -155,11 +157,11 @@ spec:
|
|
155
157
|
# Amazon SNS
|
156
158
|
- name: sns
|
157
159
|
# s12v/sns:latest
|
158
|
-
image: s12v/sns
|
160
|
+
image: public.ecr.aws/redbox-public/s12v/sns:latest
|
159
161
|
# Amazon SQS
|
160
162
|
- name: sqs
|
161
163
|
# softwaremill/elasticmq-native:1.5.7
|
162
|
-
image:
|
164
|
+
image: public.ecr.aws/sprig/elasticmq-native
|
163
165
|
params:
|
164
166
|
- name: imageDigest
|
165
167
|
type: string
|
@@ -170,7 +172,7 @@ spec:
|
|
170
172
|
mountPath: /workspace
|
171
173
|
steps:
|
172
174
|
- name: unittest
|
173
|
-
image:
|
175
|
+
image: $(params.imageDigest)
|
174
176
|
env:
|
175
177
|
- name: TEST_CONFIGURATION
|
176
178
|
value: libraries
|
@@ -189,7 +191,7 @@ spec:
|
|
189
191
|
# Redis
|
190
192
|
- name: redis
|
191
193
|
# redis:7.2.4-bookworm
|
192
|
-
image: redis
|
194
|
+
image: public.ecr.aws/docker/library/redis:7.2.4-bookworm
|
193
195
|
startupProbe:
|
194
196
|
initialDelaySeconds: 10
|
195
197
|
tcpSocket:
|
@@ -204,7 +206,7 @@ spec:
|
|
204
206
|
mountPath: /workspace
|
205
207
|
steps:
|
206
208
|
- name: unittest
|
207
|
-
image:
|
209
|
+
image: $(params.imageDigest)
|
208
210
|
env:
|
209
211
|
- name: TEST_CONFIGURATION
|
210
212
|
value: libraries
|
@@ -223,7 +225,7 @@ spec:
|
|
223
225
|
# Memcached
|
224
226
|
- name: memcached
|
225
227
|
# memcached:1.6.24-bookworm
|
226
|
-
image: memcached
|
228
|
+
image: public.ecr.aws/docker/library/memcached:1.6.24-bookworm
|
227
229
|
startupProbe:
|
228
230
|
tcpSocket:
|
229
231
|
port: 11211
|
@@ -238,7 +240,7 @@ spec:
|
|
238
240
|
mountPath: /workspace
|
239
241
|
steps:
|
240
242
|
- name: unittest
|
241
|
-
image:
|
243
|
+
image: $(params.imageDigest)
|
242
244
|
env:
|
243
245
|
- name: TEST_CONFIGURATION
|
244
246
|
value: libraries
|
@@ -256,7 +258,7 @@ spec:
|
|
256
258
|
sidecars:
|
257
259
|
- name: mongo
|
258
260
|
# mongo:5.0.25-focal
|
259
|
-
image: mongo
|
261
|
+
image: public.ecr.aws/docker/library/mongo:5-focal
|
260
262
|
startupProbe:
|
261
263
|
initialDelaySeconds: 10
|
262
264
|
tcpSocket:
|
@@ -271,7 +273,7 @@ spec:
|
|
271
273
|
mountPath: /workspace
|
272
274
|
steps:
|
273
275
|
- name: unittest
|
274
|
-
image:
|
276
|
+
image: $(params.imageDigest)
|
275
277
|
env:
|
276
278
|
- name: TEST_CONFIGURATION
|
277
279
|
value: libraries
|
@@ -298,7 +300,7 @@ spec:
|
|
298
300
|
mountPath: /workspace
|
299
301
|
steps:
|
300
302
|
- name: unittest
|
301
|
-
image:
|
303
|
+
image: $(params.imageDigest)
|
302
304
|
env:
|
303
305
|
- name: TEST_CONFIGURATION
|
304
306
|
value: $(params.configuration)
|
@@ -323,7 +325,7 @@ spec:
|
|
323
325
|
mountPath: /workspace
|
324
326
|
steps:
|
325
327
|
- name: unittest
|
326
|
-
image:
|
328
|
+
image: $(params.imageDigest)
|
327
329
|
env:
|
328
330
|
- name: TEST_CONFIGURATION
|
329
331
|
value: libraries
|
@@ -344,7 +346,7 @@ spec:
|
|
344
346
|
# MySQL (compatible Mariadb)
|
345
347
|
- name: mariadb
|
346
348
|
# mariadb:11.3.2
|
347
|
-
image: mariadb
|
349
|
+
image: public.ecr.aws/docker/library/mariadb:11.3.2
|
348
350
|
startupProbe:
|
349
351
|
initialDelaySeconds: 10
|
350
352
|
tcpSocket:
|
@@ -364,7 +366,7 @@ spec:
|
|
364
366
|
mountPath: /workspace
|
365
367
|
steps:
|
366
368
|
- name: unittest
|
367
|
-
image:
|
369
|
+
image: $(params.imageDigest)
|
368
370
|
env:
|
369
371
|
- name: TEST_CONFIGURATION
|
370
372
|
value: libraries
|
@@ -386,8 +388,8 @@ spec:
|
|
386
388
|
mountPath: /workspace
|
387
389
|
steps:
|
388
390
|
- name: generate-currency-report
|
389
|
-
# 3.10
|
390
|
-
image: python
|
391
|
+
# 3.10-bookworm
|
392
|
+
image: public.ecr.aws/docker/library/python:3.10-bookworm
|
391
393
|
script: |
|
392
394
|
#!/usr/bin/env bash
|
393
395
|
|
@@ -418,7 +420,7 @@ spec:
|
|
418
420
|
steps:
|
419
421
|
- name: upload-currency-report
|
420
422
|
# alpine/git:2.43.0
|
421
|
-
image: alpine
|
423
|
+
image: public.ecr.aws/docker/library/alpine:latest
|
422
424
|
env:
|
423
425
|
- name: GH_ENTERPRISE_TOKEN
|
424
426
|
valueFrom:
|
@@ -427,7 +429,9 @@ spec:
|
|
427
429
|
key: "GH_ENTERPRISE_TOKEN"
|
428
430
|
script: |
|
429
431
|
#!/bin/sh
|
430
|
-
|
432
|
+
echo "Installing git"
|
433
|
+
apk fix && apk --no-cache --update add git gpg less openssh patch
|
434
|
+
|
431
435
|
cd /workspace
|
432
436
|
git clone https://oauth2:$GH_ENTERPRISE_TOKEN@github.ibm.com/instana/tracer-reports.git
|
433
437
|
|
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -8,7 +8,8 @@ Any and all feedback is welcome. Happy Ruby visibility.
|
|
8
8
|
|
9
9
|
[](https://badge.fury.io/rb/instana)
|
10
10
|
[](https://circleci.com/gh/instana/ruby-sensor)
|
11
|
-
[](http://opentracing.io)
|
12
|
+
[](http://opentelemetry.io)
|
12
13
|
|
13
14
|
## Installation
|
14
15
|
|
data/Rakefile
CHANGED
data/examples/otel.rb
ADDED
@@ -0,0 +1,98 @@
|
|
1
|
+
# Simple Instana Tracing Examples
|
2
|
+
# ===========================
|
3
|
+
|
4
|
+
# (c) Copyright IBM Corp. 2025
|
5
|
+
|
6
|
+
#######################################
|
7
|
+
## in_span Method Examples
|
8
|
+
#######################################
|
9
|
+
|
10
|
+
# 1. Basic tracing - simplest way to trace code
|
11
|
+
Instana.tracer.in_span('my_operation') do
|
12
|
+
# Your code here
|
13
|
+
end
|
14
|
+
|
15
|
+
# 2. HTTP request tracing with basic attributes
|
16
|
+
Instana.tracer.in_span('http.request',
|
17
|
+
attributes: {
|
18
|
+
'http.method' => 'GET',
|
19
|
+
'http.url' => 'https://example.com'
|
20
|
+
},
|
21
|
+
kind: Instana::Trace::SpanKind::CLIENT) do
|
22
|
+
# HTTP request code here
|
23
|
+
end
|
24
|
+
|
25
|
+
# 3. Error handling - errors are automatically captured
|
26
|
+
begin
|
27
|
+
Instana.tracer.in_span('risky_operation') do
|
28
|
+
raise StandardError, 'Something went wrong'
|
29
|
+
end
|
30
|
+
rescue
|
31
|
+
# Handle error
|
32
|
+
end
|
33
|
+
|
34
|
+
# 4. Nested spans - parent-child relationship
|
35
|
+
Instana.tracer.in_span('parent') do
|
36
|
+
# Parent code
|
37
|
+
Instana.tracer.in_span('child') do
|
38
|
+
# Child code
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
# 5. Adding tags during execution
|
43
|
+
Instana.tracer.in_span('process_order') do |span|
|
44
|
+
span.set_tag('order.id', 12345)
|
45
|
+
span.set_tag('status', 'completed')
|
46
|
+
end
|
47
|
+
|
48
|
+
#######################################
|
49
|
+
## start_span Method Examples
|
50
|
+
#######################################
|
51
|
+
|
52
|
+
# 1. Basic manual span control
|
53
|
+
span = Instana.tracer.start_span('manual_operation')
|
54
|
+
# Your code here
|
55
|
+
span.finish
|
56
|
+
|
57
|
+
# 2. Spans across methods
|
58
|
+
def start_work
|
59
|
+
span = Instana.tracer.start_span('long_process')
|
60
|
+
# Initial work
|
61
|
+
finish_work(span)
|
62
|
+
end
|
63
|
+
|
64
|
+
def finish_work(span)
|
65
|
+
# More work
|
66
|
+
span.finish
|
67
|
+
end
|
68
|
+
|
69
|
+
# 3. Async operations across threads
|
70
|
+
parent_span = Instana.tracer.start_span('main_task')
|
71
|
+
|
72
|
+
Thread.new do
|
73
|
+
child_span = Instana.tracer.start_span('async_task',
|
74
|
+
with_parent: parent_span.context)
|
75
|
+
# Async work
|
76
|
+
child_span.finish
|
77
|
+
end
|
78
|
+
|
79
|
+
parent_span.finish
|
80
|
+
|
81
|
+
# 4. Manual error handling
|
82
|
+
span = Instana.tracer.start_span('custom_error_handling')
|
83
|
+
begin
|
84
|
+
# Your code here
|
85
|
+
rescue => e
|
86
|
+
span.record_exception(e)
|
87
|
+
ensure
|
88
|
+
span.finish
|
89
|
+
end
|
90
|
+
|
91
|
+
# 5. Parent-child relationship (explicit)
|
92
|
+
parent = Instana.tracer.start_span('parent_task')
|
93
|
+
child = Instana.tracer.start_span('child_task', with_parent: parent.context)
|
94
|
+
|
95
|
+
child.finish
|
96
|
+
parent.finish
|
97
|
+
|
98
|
+
# Made with Bob
|
data/examples/tracing.rb
CHANGED
data/gemfiles/rails_61.gemfile
CHANGED
data/gemfiles/rails_70.gemfile
CHANGED
data/instana.gemspec
CHANGED
@@ -39,10 +39,15 @@ Gem::Specification.new do |spec|
|
|
39
39
|
spec.add_development_dependency "minitest", "~> 5.20"
|
40
40
|
spec.add_development_dependency "appraisal"
|
41
41
|
spec.add_development_dependency "fakefs"
|
42
|
+
spec.add_development_dependency "irb"
|
43
|
+
spec.add_development_dependency "benchmark"
|
42
44
|
|
43
45
|
spec.add_runtime_dependency('base64', '>= 0.1')
|
46
|
+
spec.add_runtime_dependency('logger')
|
44
47
|
spec.add_runtime_dependency('concurrent-ruby', '>= 1.1')
|
45
48
|
spec.add_runtime_dependency('csv', '>= 0.1')
|
46
49
|
spec.add_runtime_dependency('sys-proctable', '>= 1.2.2')
|
50
|
+
spec.add_runtime_dependency('opentelemetry-api', '~> 1.4')
|
51
|
+
spec.add_runtime_dependency('opentelemetry-common')
|
47
52
|
spec.add_runtime_dependency('oj', '>=3.0.11') unless RUBY_PLATFORM =~ /java/i
|
48
53
|
end
|
data/lib/instana/base.rb
CHANGED
@@ -14,6 +14,7 @@ module Instana
|
|
14
14
|
attr_accessor :pid
|
15
15
|
attr_reader :secrets
|
16
16
|
attr_reader :serverless
|
17
|
+
attr_accessor :tracer_provider
|
17
18
|
|
18
19
|
##
|
19
20
|
# setup
|
@@ -22,8 +23,9 @@ module Instana
|
|
22
23
|
# to run" state.
|
23
24
|
#
|
24
25
|
def setup
|
25
|
-
@agent
|
26
|
-
@
|
26
|
+
@agent = ::Instana::Backend::Agent.new
|
27
|
+
@tracer_provider = ::Instana::Trace::TracerProvider.new
|
28
|
+
@tracer = @tracer_provider.tracer('instana_tracer')
|
27
29
|
@processor = ::Instana::Processor.new
|
28
30
|
@secrets = ::Instana::Secrets.new
|
29
31
|
@serverless = ::Instana::Serverless.new
|
@@ -27,8 +27,10 @@ module Instana
|
|
27
27
|
}
|
28
28
|
|
29
29
|
context = connection.instana_trace_context
|
30
|
-
::
|
31
|
-
|
30
|
+
Trace.with_span(OpenTelemetry::Trace.non_recording_span(context)) do
|
31
|
+
::Instana.tracer.in_span(:'rpc-server', attributes: rpc_tags) do
|
32
|
+
super(data, via: via)
|
33
|
+
end
|
32
34
|
end
|
33
35
|
end
|
34
36
|
|
@@ -44,8 +46,10 @@ module Instana
|
|
44
46
|
}
|
45
47
|
|
46
48
|
context = connection.instana_trace_context
|
47
|
-
::
|
48
|
-
|
49
|
+
Trace.with_span(OpenTelemetry::Trace.non_recording_span(context)) do
|
50
|
+
::Instana.tracer.in_span(:'rpc-server', attributes: rpc_tags) do
|
51
|
+
super(action, data)
|
52
|
+
end
|
49
53
|
end
|
50
54
|
end
|
51
55
|
end
|
@@ -11,9 +11,8 @@ module Instana
|
|
11
11
|
action: action_name
|
12
12
|
}
|
13
13
|
}
|
14
|
-
|
15
14
|
request.env['INSTANA_HTTP_PATH_TEMPLATE'] = matched_path_template
|
16
|
-
::Instana
|
15
|
+
::Instana.tracer.in_span(:actioncontroller, attributes: call_payload) { super(*args) }
|
17
16
|
end
|
18
17
|
|
19
18
|
def render(*args, &block)
|
@@ -22,8 +21,7 @@ module Instana
|
|
22
21
|
name: describe_render_options(args.first) || 'Default'
|
23
22
|
}
|
24
23
|
}
|
25
|
-
|
26
|
-
::Instana::Tracer.trace(:actionview, call_payload) { super(*args, &block) }
|
24
|
+
::Instana.tracer.in_span(:actionview, attributes: call_payload) { super(*args, &block) }
|
27
25
|
end
|
28
26
|
|
29
27
|
private
|
@@ -13,7 +13,7 @@ module Instana
|
|
13
13
|
}
|
14
14
|
}
|
15
15
|
|
16
|
-
::Instana
|
16
|
+
::Instana.tracer.in_span(:render, attributes: call_payload) { super(*args) }
|
17
17
|
end
|
18
18
|
|
19
19
|
def render_collection(*args)
|
@@ -24,7 +24,7 @@ module Instana
|
|
24
24
|
}
|
25
25
|
}
|
26
26
|
|
27
|
-
::Instana
|
27
|
+
::Instana.tracer.in_span(:render, attributes: call_payload) { super(*args) }
|
28
28
|
end
|
29
29
|
|
30
30
|
def render_partial_template(*args)
|
@@ -35,7 +35,7 @@ module Instana
|
|
35
35
|
}
|
36
36
|
}
|
37
37
|
|
38
|
-
::Instana
|
38
|
+
::Instana.tracer.in_span(:render, attributes: call_payload) { super(*args) }
|
39
39
|
end
|
40
40
|
end
|
41
41
|
|
@@ -48,7 +48,7 @@ module Instana
|
|
48
48
|
}
|
49
49
|
}
|
50
50
|
|
51
|
-
::Instana
|
51
|
+
::Instana.tracer.in_span(:render, attributes: call_payload) { super(*args) }
|
52
52
|
end
|
53
53
|
end
|
54
54
|
end
|