instana 1.215.0 → 1.216.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (38) hide show
  1. checksums.yaml +4 -4
  2. data/.circleci/config.yml +83 -3
  3. data/.tekton/.currency/resources/requirements.txt +0 -1
  4. data/.tekton/.currency/resources/table.json +13 -13
  5. data/.tekton/.currency/scripts/generate_report.py +37 -130
  6. data/.tekton/README.md +278 -0
  7. data/.tekton/github-pr-eventlistener.yaml +1 -1
  8. data/.tekton/pipeline.yaml +96 -2
  9. data/.tekton/pipelinerun.yaml +2 -2
  10. data/.tekton/ruby-tracer-prepuller.yaml +4 -0
  11. data/.tekton/run_unittests.sh +27 -6
  12. data/.tekton/scheduled-eventlistener.yaml +1 -1
  13. data/.tekton/task.yaml +72 -0
  14. data/gemfiles/rails_61.gemfile +1 -0
  15. data/gemfiles/rails_70.gemfile +1 -0
  16. data/gemfiles/rails_71.gemfile +1 -0
  17. data/gemfiles/sequel_56.gemfile +16 -0
  18. data/gemfiles/sequel_57.gemfile +16 -0
  19. data/gemfiles/sequel_58.gemfile +16 -0
  20. data/instana.gemspec +2 -0
  21. data/lib/instana/activators/sequel.rb +20 -0
  22. data/lib/instana/backend/host_agent.rb +5 -1
  23. data/lib/instana/config.rb +1 -0
  24. data/lib/instana/instrumentation/sequel.rb +42 -0
  25. data/lib/instana/tracing/span.rb +2 -2
  26. data/lib/instana/version.rb +1 -1
  27. data/test/activator_test.rb +1 -1
  28. data/test/backend/host_agent_test.rb +2 -0
  29. data/test/instrumentation/rails_active_record_test.rb +1 -1
  30. data/test/instrumentation/sequel_test.rb +105 -0
  31. data/test/tracing/span_test.rb +2 -2
  32. data/test/tracing/tracer_test.rb +1 -3
  33. metadata +39 -8
  34. data/.tekton/.currency/currency-pipeline.yaml +0 -36
  35. data/.tekton/.currency/currency-pipelinerun.yaml +0 -20
  36. data/.tekton/.currency/currency-rbac.yaml +0 -29
  37. data/.tekton/.currency/currency-scheduled-eventlistener.yaml +0 -56
  38. data/.tekton/.currency/currency-tasks.yaml +0 -94
@@ -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: "../"
data/instana.gemspec CHANGED
@@ -40,7 +40,9 @@ Gem::Specification.new do |spec|
40
40
  spec.add_development_dependency "appraisal"
41
41
  spec.add_development_dependency "fakefs"
42
42
 
43
+ spec.add_runtime_dependency('base64', '>= 0.1')
43
44
  spec.add_runtime_dependency('concurrent-ruby', '>= 1.1')
45
+ spec.add_runtime_dependency('csv', '>= 0.1')
44
46
  spec.add_runtime_dependency('sys-proctable', '>= 1.2.2')
45
47
  spec.add_runtime_dependency('oj', '>=3.0.11') unless RUBY_PLATFORM =~ /java/i
46
48
  end
@@ -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
@@ -28,7 +28,11 @@ module Instana
28
28
 
29
29
  def announce
30
30
  @client = until_not_nil { HostAgentLookup.new.call }
31
- @discovery.delete_observers
31
+ begin
32
+ @discovery.send(:observers)&.send(:notify_and_delete_observers, Time.now, nil, nil)
33
+ ensure
34
+ @discovery.delete_observers
35
+ end
32
36
  @discovery
33
37
  .with_observer(HostAgentActivationObserver.new(@client, @discovery))
34
38
  .with_observer(HostAgentReportingObserver.new(@client, @discovery))
@@ -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
@@ -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 ].freeze
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
@@ -2,6 +2,6 @@
2
2
  # (c) Copyright Instana Inc. 2016
3
3
 
4
4
  module Instana
5
- VERSION = "1.215.0"
5
+ VERSION = "1.216.0"
6
6
  VERSION_FULL = "instana-#{VERSION}"
7
7
  end
@@ -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 31, subject.length
46
+ assert_equal 32, subject.length
47
47
  ensure
48
48
  ENV.delete('INSTANA_ACTIVATE_SET')
49
49
  end
@@ -32,6 +32,8 @@ class HostAgentTest < Minitest::Test
32
32
 
33
33
  discovery = Minitest::Mock.new
34
34
  discovery.expect(:delete_observers, discovery, [])
35
+ discovery.expect(:observers, discovery, [])
36
+ discovery.expect(:notify_and_delete_observers, discovery, [Object, nil, nil])
35
37
  discovery.expect(:with_observer, discovery, [Instana::Backend::HostAgentActivationObserver])
36
38
  discovery.expect(:with_observer, discovery, [Instana::Backend::HostAgentReportingObserver])
37
39
  discovery.expect(:swap, discovery, [])
@@ -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(@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
@@ -9,8 +9,8 @@ class SpanTest < Minitest::Test
9
9
 
10
10
  assert_equal span[:s], span.id
11
11
  assert_equal span[:t], span.trace_id
12
- assert_equal span[:p], span.parent_id
13
- assert_equal span[:d], span.duration
12
+ assert_nil span[:p] # parent_id of a root span is nil
13
+ assert_nil span[:d] # duration of an open span is nil
14
14
 
15
15
  span.parent_id = 'test'
16
16
  assert_equal 'test', span.parent_id
@@ -51,9 +51,7 @@ class TracerTest < Minitest::Test
51
51
 
52
52
  assert_equal false, ::Instana.tracer.tracing?
53
53
 
54
- require 'resolv'
55
- r = Resolv::DNS.new
56
- ipv4 = r.getaddress("www.pwpush.com")
54
+ ipv4 = '111.111.111.111'
57
55
 
58
56
  ::Instana.tracer.start_or_continue_trace(:rack, {:ipaddr => ipv4}) do
59
57
  assert_equal true, ::Instana.tracer.tracing?
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: instana
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.215.0
4
+ version: 1.216.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Peter Giacomo Lombardo
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2024-06-26 00:00:00.000000000 Z
11
+ date: 2024-09-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -80,6 +80,20 @@ dependencies:
80
80
  - - ">="
81
81
  - !ruby/object:Gem::Version
82
82
  version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: base64
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0.1'
90
+ type: :runtime
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0.1'
83
97
  - !ruby/object:Gem::Dependency
84
98
  name: concurrent-ruby
85
99
  requirement: !ruby/object:Gem::Requirement
@@ -94,6 +108,20 @@ dependencies:
94
108
  - - ">="
95
109
  - !ruby/object:Gem::Version
96
110
  version: '1.1'
111
+ - !ruby/object:Gem::Dependency
112
+ name: csv
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - ">="
116
+ - !ruby/object:Gem::Version
117
+ version: '0.1'
118
+ type: :runtime
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - ">="
123
+ - !ruby/object:Gem::Version
124
+ version: '0.1'
97
125
  - !ruby/object:Gem::Dependency
98
126
  name: sys-proctable
99
127
  requirement: !ruby/object:Gem::Requirement
@@ -142,15 +170,11 @@ files:
142
170
  - ".gitignore"
143
171
  - ".rubocop.yml"
144
172
  - ".rubocop_todo.yml"
145
- - ".tekton/.currency/currency-pipeline.yaml"
146
- - ".tekton/.currency/currency-pipelinerun.yaml"
147
- - ".tekton/.currency/currency-rbac.yaml"
148
- - ".tekton/.currency/currency-scheduled-eventlistener.yaml"
149
- - ".tekton/.currency/currency-tasks.yaml"
150
173
  - ".tekton/.currency/docs/report.md"
151
174
  - ".tekton/.currency/resources/requirements.txt"
152
175
  - ".tekton/.currency/resources/table.json"
153
176
  - ".tekton/.currency/scripts/generate_report.py"
177
+ - ".tekton/README.md"
154
178
  - ".tekton/github-interceptor-secret.yaml"
155
179
  - ".tekton/github-pr-eventlistener.yaml"
156
180
  - ".tekton/github-pr-pipeline.yaml.part"
@@ -217,6 +241,9 @@ files:
217
241
  - gemfiles/roda_20.gemfile
218
242
  - gemfiles/roda_30.gemfile
219
243
  - gemfiles/rubocop_162.gemfile
244
+ - gemfiles/sequel_56.gemfile
245
+ - gemfiles/sequel_57.gemfile
246
+ - gemfiles/sequel_58.gemfile
220
247
  - gemfiles/shoryuken_50.gemfile
221
248
  - gemfiles/shoryuken_60.gemfile
222
249
  - gemfiles/sidekiq_42.gemfile
@@ -258,6 +285,7 @@ files:
258
285
  - lib/instana/activators/resque_worker.rb
259
286
  - lib/instana/activators/rest_client.rb
260
287
  - lib/instana/activators/roda.rb
288
+ - lib/instana/activators/sequel.rb
261
289
  - lib/instana/activators/shoryuken.rb
262
290
  - lib/instana/activators/sidekiq_client.rb
263
291
  - lib/instana/activators/sidekiq_worker.rb
@@ -299,6 +327,7 @@ files:
299
327
  - lib/instana/instrumentation/redis.rb
300
328
  - lib/instana/instrumentation/resque.rb
301
329
  - lib/instana/instrumentation/rest-client.rb
330
+ - lib/instana/instrumentation/sequel.rb
302
331
  - lib/instana/instrumentation/shoryuken.rb
303
332
  - lib/instana/instrumentation/sidekiq-client.rb
304
333
  - lib/instana/instrumentation/sidekiq-worker.rb
@@ -364,6 +393,7 @@ files:
364
393
  - test/instrumentation/redis_test.rb
365
394
  - test/instrumentation/resque_test.rb
366
395
  - test/instrumentation/rest_client_test.rb
396
+ - test/instrumentation/sequel_test.rb
367
397
  - test/instrumentation/shoryuken_test.rb
368
398
  - test/instrumentation/sidekiq-client_test.rb
369
399
  - test/instrumentation/sidekiq-worker_test.rb
@@ -428,7 +458,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
428
458
  - !ruby/object:Gem::Version
429
459
  version: '0'
430
460
  requirements: []
431
- rubygems_version: 3.5.9
461
+ rubygems_version: 3.5.18
432
462
  signing_key:
433
463
  specification_version: 4
434
464
  summary: Ruby Distributed Tracing & Metrics Sensor for Instana
@@ -469,6 +499,7 @@ test_files:
469
499
  - test/instrumentation/redis_test.rb
470
500
  - test/instrumentation/resque_test.rb
471
501
  - test/instrumentation/rest_client_test.rb
502
+ - test/instrumentation/sequel_test.rb
472
503
  - test/instrumentation/shoryuken_test.rb
473
504
  - test/instrumentation/sidekiq-client_test.rb
474
505
  - test/instrumentation/sidekiq-worker_test.rb
@@ -1,36 +0,0 @@
1
- apiVersion: tekton.dev/v1beta1
2
- kind: Pipeline
3
- metadata:
4
- name: ruby-currency-pipeline
5
- spec:
6
- params:
7
- - name: revision
8
- type: string
9
- workspaces:
10
- - name: ruby-currency-pvc
11
- tasks:
12
- - name: clone-repo
13
- params:
14
- - name: revision
15
- value: $(params.revision)
16
- taskRef:
17
- name: ruby-git-clone-task
18
- workspaces:
19
- - name: task-pvc
20
- workspace: ruby-currency-pvc
21
- - name: generate-currency-report
22
- runAfter:
23
- - clone-repo
24
- taskRef:
25
- name: ruby-generate-currency-report-task
26
- workspaces:
27
- - name: task-pvc
28
- workspace: ruby-currency-pvc
29
- - name: upload-currency-report
30
- runAfter:
31
- - generate-currency-report
32
- taskRef:
33
- name: ruby-upload-currency-report-task
34
- workspaces:
35
- - name: task-pvc
36
- workspace: ruby-currency-pvc
@@ -1,20 +0,0 @@
1
- apiVersion: tekton.dev/v1beta1
2
- kind: PipelineRun
3
- metadata:
4
- name: ruby-currency-pipelinerun
5
- spec:
6
- params:
7
- - name: revision
8
- value: "master"
9
- pipelineRef:
10
- name: ruby-currency-pipeline
11
- serviceAccountName: currency-serviceaccount
12
- workspaces:
13
- - name: ruby-currency-pvc
14
- volumeClaimTemplate:
15
- spec:
16
- accessModes:
17
- - ReadWriteOnce
18
- resources:
19
- requests:
20
- storage: 100Mi
@@ -1,29 +0,0 @@
1
- apiVersion: v1
2
- kind: ServiceAccount
3
- metadata:
4
- name: currency-serviceaccount
5
- ---
6
- apiVersion: rbac.authorization.k8s.io/v1
7
- kind: ClusterRole
8
- metadata:
9
- name: currency-clusterrole
10
- rules:
11
- - apiGroups: [""]
12
- resources: ["pods", "pods/log"]
13
- verbs: ["get", "list"]
14
- - apiGroups: ["tekton.dev"]
15
- resources: ["taskruns"]
16
- verbs: ["get", "list"]
17
- ---
18
- apiVersion: rbac.authorization.k8s.io/v1
19
- kind: ClusterRoleBinding
20
- metadata:
21
- name: currency-clusterrolebinding
22
- subjects:
23
- - kind: ServiceAccount
24
- name: currency-serviceaccount
25
- namespace: default
26
- roleRef:
27
- apiGroup: rbac.authorization.k8s.io
28
- kind: ClusterRole
29
- name: currency-clusterrole
@@ -1,56 +0,0 @@
1
- apiVersion: triggers.tekton.dev/v1beta1
2
- kind: EventListener
3
- metadata:
4
- name: ruby-currency-cron-listener
5
- spec:
6
- serviceAccountName: tekton-triggers-eventlistener-serviceaccount
7
- triggers:
8
- - name: currency-cron-trigger
9
- template:
10
- ref: ruby-currency-trigger-template
11
- ---
12
- apiVersion: triggers.tekton.dev/v1beta1
13
- kind: TriggerTemplate
14
- metadata:
15
- name: ruby-currency-trigger-template
16
- spec:
17
- resourcetemplates:
18
- - apiVersion: tekton.dev/v1beta1
19
- kind: PipelineRun
20
- metadata:
21
- generateName: ruby-currency-
22
- spec:
23
- pipelineRef:
24
- name: ruby-currency-pipeline
25
- serviceAccountName: currency-serviceaccount
26
- params:
27
- - name: revision
28
- value: "master"
29
- workspaces:
30
- - name: ruby-currency-pvc
31
- volumeClaimTemplate:
32
- spec:
33
- accessModes:
34
- - ReadWriteOnce
35
- resources:
36
- requests:
37
- storage: 100Mi
38
- ---
39
- apiVersion: batch/v1
40
- kind: CronJob
41
- metadata:
42
- name: ruby-currency-cronjob
43
- spec:
44
- schedule: "5 3 * * Mon-Fri"
45
- jobTemplate:
46
- spec:
47
- template:
48
- spec:
49
- containers:
50
- - name: http-request-to-el-svc
51
- # curlimages/curl:8.6.0
52
- image: curlimages/curl@sha256:f2237028bed58de91f62aea74260bb2a299cf12fbcabc23cfaf125fef276c884
53
- imagePullPolicy: IfNotPresent
54
- args: ["curl", "-X", "POST", "--data", "{}", "el-ruby-currency-cron-listener.default.svc.cluster.local:8080"]
55
- restartPolicy: OnFailure
56
- ---
@@ -1,94 +0,0 @@
1
- apiVersion: tekton.dev/v1beta1
2
- kind: Task
3
- metadata:
4
- name: ruby-git-clone-task
5
- spec:
6
- params:
7
- - name: revision
8
- type: string
9
- workspaces:
10
- - name: task-pvc
11
- mountPath: /workspace
12
- steps:
13
- - name: clone-repo
14
- # alpine/git:2.43.0
15
- image: alpine/git@sha256:6ff4de047dcc8f0c7d75d2efff63fbc189e87d2f458305f2cc8f165ff83309cf
16
- script: |
17
- #!/bin/sh
18
- echo "Cloning repo"
19
- cd /workspace && git clone --filter=blob:none --sparse --depth 1 https://github.com/instana/ruby-sensor -b $(params.revision)
20
- cd ruby-sensor
21
- git sparse-checkout add .tekton/.currency
22
- ls -lah /workspace/ruby-sensor
23
- ---
24
- apiVersion: tekton.dev/v1beta1
25
- kind: Task
26
- metadata:
27
- name: ruby-generate-currency-report-task
28
- spec:
29
- workspaces:
30
- - name: task-pvc
31
- mountPath: /workspace
32
- steps:
33
- - name: generate-currency-report
34
- # 3.10.13-bookworm
35
- image: python@sha256:c970ff53939772f47b0672e380328afb50d8fd1c0568ed4f82c22effc54244fc
36
- script: |
37
- #!/usr/bin/env bash
38
-
39
- cd /workspace/ruby-sensor/.tekton/.currency
40
-
41
- python -m venv /tmp/venv
42
- source /tmp/venv/bin/activate
43
- pip install -r resources/requirements.txt
44
-
45
- python scripts/generate_report.py
46
- if [ $? -ne 0 ]; then
47
- echo "Error occured while generating the ruby tracer currency report." >&2
48
- exit 1
49
- fi
50
- cat docs/report.md
51
- ---
52
- apiVersion: tekton.dev/v1beta1
53
- kind: Task
54
- metadata:
55
- name: ruby-upload-currency-report-task
56
- spec:
57
- params:
58
- - name: github-token-secret
59
- default: instanacd-github-api-token
60
- workspaces:
61
- - name: task-pvc
62
- mountPath: /workspace
63
- steps:
64
- - name: upload-currency-report
65
- # alpine/git:2.43.0
66
- image: alpine/git@sha256:6ff4de047dcc8f0c7d75d2efff63fbc189e87d2f458305f2cc8f165ff83309cf
67
- env:
68
- - name: GH_ENTERPRISE_TOKEN
69
- valueFrom:
70
- secretKeyRef:
71
- name: $(params.github-token-secret)
72
- key: "GH_ENTERPRISE_TOKEN"
73
- script: |
74
- #!/bin/sh
75
-
76
- cd /workspace
77
- git clone https://oauth2:$GH_ENTERPRISE_TOKEN@github.ibm.com/instana/tracer-reports.git
78
-
79
- if [ $? -ne 0 ]; then
80
- echo "The attempt to clone the tracer-reports repository failed, preventing the upload of ruby tracer currency report." >&2
81
- exit 1
82
- fi
83
-
84
- cd tracer-reports
85
-
86
- cp ../ruby-sensor/.tekton/.currency/docs/report.md ./automated/currency/ruby/report.md
87
-
88
- git config user.name "Instanacd PAT for GitHub Enterprise"
89
- git config user.email instana.ibm.github.enterprise@ibm.com
90
-
91
- git add .
92
-
93
- git commit -m "chore: Updated ruby currency report"
94
- git push origin main