elastic-apm 4.6.0 → 4.7.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (64) hide show
  1. checksums.yaml +4 -4
  2. data/.ci/.exclude.yml +193 -0
  3. data/.ci/.main_framework.yml +4 -0
  4. data/.ci/.ruby.yml +10 -0
  5. data/.ci/docker/jruby/11-jdk/Dockerfile +8 -3
  6. data/.ci/docker/jruby/12-jdk/Dockerfile +5 -2
  7. data/.ci/docker/jruby/13-jdk/Dockerfile +5 -2
  8. data/.ci/docker/jruby/7-jdk/Dockerfile +6 -3
  9. data/.ci/docker/jruby/8-jdk/Dockerfile +8 -3
  10. data/.ci/docker/jruby/README.md +1 -1
  11. data/.ci/docker/jruby/run.sh +33 -9
  12. data/.ci/docker/jruby/test.sh +17 -2
  13. data/.ci/scripts/bench.sh +52 -0
  14. data/.ci/scripts/install-build-system.sh +5 -0
  15. data/.ci/snapshoty.yml +33 -0
  16. data/.ci/updatecli.d/update-gherkin-specs.yml +117 -0
  17. data/.ci/updatecli.d/update-json-specs.yml +121 -0
  18. data/.ci/updatecli.d/update-specs.yml +108 -0
  19. data/.github/workflows/ci-docs.yml +20 -0
  20. data/.github/workflows/ci.yml +70 -0
  21. data/.github/workflows/coverage-reporter.yml +34 -0
  22. data/.github/workflows/microbenchmark.yml +48 -0
  23. data/.github/workflows/opentelemetry.yml +27 -0
  24. data/.github/workflows/release.yml +71 -0
  25. data/.github/workflows/run-matrix.yml +56 -0
  26. data/.github/workflows/snapshoty.yml +35 -0
  27. data/.github/workflows/test-reporter.yml +24 -0
  28. data/.github/workflows/updatecli.yml +28 -0
  29. data/.pre-commit-config.yaml +0 -2
  30. data/CHANGELOG.asciidoc +29 -1
  31. data/CONTRIBUTING.md +1 -1
  32. data/Gemfile +8 -2
  33. data/README.md +1 -1
  34. data/Rakefile +2 -2
  35. data/bench/rubyprof.rb +1 -0
  36. data/bin/run-tests +10 -1
  37. data/docker-compose.yml +10 -1
  38. data/docs/configuration.asciidoc +6 -5
  39. data/docs/index.asciidoc +2 -2
  40. data/docs/{log-correlation.asciidoc → logs.asciidoc} +29 -2
  41. data/docs/opentracing.asciidoc +1 -1
  42. data/docs/redirects.asciidoc +9 -0
  43. data/lib/elastic_apm/context_builder.rb +3 -3
  44. data/lib/elastic_apm/metrics.rb +24 -20
  45. data/lib/elastic_apm/span_helpers.rb +6 -6
  46. data/lib/elastic_apm/spies/faraday.rb +13 -4
  47. data/lib/elastic_apm/trace_context/tracestate.rb +3 -1
  48. data/lib/elastic_apm/transport/connection/http.rb +9 -3
  49. data/lib/elastic_apm/version.rb +1 -1
  50. metadata +25 -17
  51. data/.ci/.jenkins_exclude.yml +0 -191
  52. data/.ci/.jenkins_main_framework.yml +0 -4
  53. data/.ci/.jenkins_ruby.yml +0 -10
  54. data/.ci/.jenkins_ruby_benchmarks.yml +0 -6
  55. data/.ci/Jenkinsfile +0 -419
  56. data/.ci/jobs/apm-agent-ruby-downstream.yml +0 -38
  57. data/.ci/jobs/apm-agent-ruby-linting-mbp.yml +0 -39
  58. data/.ci/jobs/apm-agent-ruby-mbp.yml +0 -43
  59. data/.ci/jobs/apm-agent-ruby.yml +0 -4
  60. data/.ci/jobs/defaults.yml +0 -24
  61. data/.ci/linting.groovy +0 -32
  62. data/.ci/packer_cache.sh +0 -16
  63. /data/.ci/{.jenkins_codecov.yml → .codecov.yml} +0 -0
  64. /data/.ci/{.jenkins_framework.yml → .framework.yml} +0 -0
@@ -1,191 +0,0 @@
1
- exclude:
2
- # Ruby 2.4
3
- # Only test on rails-5.2, sinatra-1.4
4
- - RUBY_VERSION: ruby:2.4
5
- FRAMEWORK: rails-7.0
6
- - RUBY_VERSION: ruby:2.4
7
- FRAMEWORK: rails-6.1
8
- - RUBY_VERSION: ruby:2.4
9
- FRAMEWORK: rails-6.0
10
- - RUBY_VERSION: ruby:2.4
11
- FRAMEWORK: rails-4.2
12
- - RUBY_VERSION: ruby:2.4
13
- FRAMEWORK: sinatra-2.2
14
- - RUBY_VERSION: ruby:2.4
15
- FRAMEWORK: grape-1.6
16
- - RUBY_VERSION: ruby:2.4
17
- FRAMEWORK: grape-1.6,sinatra-2.2,rails-6.0
18
- - RUBY_VERSION: ruby:2.4
19
- FRAMEWORK: rails-main
20
- - RUBY_VERSION: ruby:2.4
21
- FRAMEWORK: sinatra-master
22
- - RUBY_VERSION: ruby:2.4
23
- FRAMEWORK: grape-master
24
-
25
- # rails-4.2 exclusions
26
- # Only test on ruby 2.6, 2.5, 2.4
27
- - RUBY_VERSION: ruby:3.1
28
- FRAMEWORK: rails-4.2
29
- - RUBY_VERSION: ruby:3.0
30
- FRAMEWORK: rails-4.2
31
- - RUBY_VERSION: ruby:2.7
32
- FRAMEWORK: rails-4.2
33
- - RUBY_VERSION: jruby:9.2
34
- FRAMEWORK: rails-4.2
35
- - RUBY_VERSION: docker.elastic.co/observability-ci/jruby:9.2-13-jdk
36
- FRAMEWORK: rails-4.2
37
- - RUBY_VERSION: docker.elastic.co/observability-ci/jruby:9.2-11-jdk
38
- FRAMEWORK: rails-4.2
39
- - RUBY_VERSION: docker.elastic.co/observability-ci/jruby:9.2-8-jdk
40
- FRAMEWORK: rails-4.2
41
- # sinatra-1.4 exclusions
42
- - RUBY_VERSION: ruby:3.1
43
- FRAMEWORK: sinatra-1.4
44
- - RUBY_VERSION: ruby:3.0
45
- FRAMEWORK: sinatra-1.4
46
- - RUBY_VERSION: ruby:2.7
47
- FRAMEWORK: sinatra-1.4
48
- - RUBY_VERSION: jruby:9.2
49
- FRAMEWORK: sinatra-1.4
50
- - RUBY_VERSION: docker.elastic.co/observability-ci/jruby:9.2-13-jdk
51
- FRAMEWORK: sinatra-1.4
52
- - RUBY_VERSION: docker.elastic.co/observability-ci/jruby:9.2-11-jdk
53
- FRAMEWORK: sinatra-1.4
54
- - RUBY_VERSION: docker.elastic.co/observability-ci/jruby:9.2-8-jdk
55
- FRAMEWORK: sinatra-1.4
56
-
57
- # rails-6.0 and rails-6.1 exclusions
58
- # Don't test on ruby 2.4
59
- - RUBY_VERSION: ruby:2.4
60
- FRAMEWORK: rails-6.1
61
- - RUBY_VERSION: ruby:2.4
62
- FRAMEWORK: rails-6.0
63
-
64
- # Only test rails master on ruby 3.1
65
- - RUBY_VERSION: ruby:3.0
66
- FRAMEWORK: rails-main
67
- - RUBY_VERSION: ruby:2.7
68
- FRAMEWORK: rails-main
69
- - RUBY_VERSION: ruby:2.6
70
- FRAMEWORK: rails-main
71
- - RUBY_VERSION: ruby:2.5
72
- FRAMEWORK: rails-main
73
- - RUBY_VERSION: ruby:2.4
74
- FRAMEWORK: rails-main
75
- - RUBY_VERSION: jruby:9.2
76
- FRAMEWORK: rails-main
77
- - RUBY_VERSION: docker.elastic.co/observability-ci/jruby:9.2-13-jdk
78
- FRAMEWORK: rails-main
79
- - RUBY_VERSION: docker.elastic.co/observability-ci/jruby:9.2-11-jdk
80
- FRAMEWORK: rails-main
81
- - RUBY_VERSION: docker.elastic.co/observability-ci/jruby:9.2-8-jdk
82
- FRAMEWORK: rails-main
83
-
84
- # Only test rails 7.0 on ruby >= 2.7
85
- - RUBY_VERSION: ruby:2.6
86
- FRAMEWORK: rails-7.0
87
- - RUBY_VERSION: ruby:2.5
88
- FRAMEWORK: rails-7.0
89
- - RUBY_VERSION: ruby:2.4
90
- FRAMEWORK: rails-7.0
91
- - RUBY_VERSION: jruby:9.2
92
- FRAMEWORK: rails-7.0
93
- - RUBY_VERSION: docker.elastic.co/observability-ci/jruby:9.2-13-jdk
94
- FRAMEWORK: rails-7.0
95
- - RUBY_VERSION: docker.elastic.co/observability-ci/jruby:9.2-11-jdk
96
- FRAMEWORK: rails-7.0
97
- - RUBY_VERSION: docker.elastic.co/observability-ci/jruby:9.2-8-jdk
98
- FRAMEWORK: rails-7.0
99
-
100
- # Only test sinatra master on ruby 2.7 and ruby 3.1
101
- - RUBY_VERSION: ruby:3.0
102
- FRAMEWORK: sinatra-master
103
- - RUBY_VERSION: ruby:2.6
104
- FRAMEWORK: sinatra-master
105
- - RUBY_VERSION: ruby:2.5
106
- FRAMEWORK: sinatra-master
107
- - RUBY_VERSION: ruby:2.4
108
- FRAMEWORK: sinatra-master
109
- - RUBY_VERSION: jruby:9.2
110
- FRAMEWORK: sinatra-master
111
- - RUBY_VERSION: docker.elastic.co/observability-ci/jruby:9.2-13-jdk
112
- FRAMEWORK: sinatra-master
113
- - RUBY_VERSION: docker.elastic.co/observability-ci/jruby:9.2-11-jdk
114
- FRAMEWORK: sinatra-master
115
- - RUBY_VERSION: docker.elastic.co/observability-ci/jruby:9.2-8-jdk
116
- FRAMEWORK: sinatra-master
117
-
118
- # Only test grape master on ruby 2.7 and ruby 3.0
119
- - RUBY_VERSION: ruby:2.6
120
- FRAMEWORK: grape-master
121
- - RUBY_VERSION: ruby:2.5
122
- FRAMEWORK: grape-master
123
- - RUBY_VERSION: ruby:2.4
124
- FRAMEWORK: grape-master
125
- - RUBY_VERSION: jruby:9.2
126
- FRAMEWORK: grape-master
127
- - RUBY_VERSION: docker.elastic.co/observability-ci/jruby:9.2-13-jdk
128
- FRAMEWORK: grape-master
129
- - RUBY_VERSION: docker.elastic.co/observability-ci/jruby:9.2-11-jdk
130
- FRAMEWORK: grape-master
131
- - RUBY_VERSION: docker.elastic.co/observability-ci/jruby:9.2-8-jdk
132
- FRAMEWORK: grape-master
133
-
134
- # grape 1.5 doesn't support ruby 3.0
135
- - RUBY_VERSION: ruby:3.1
136
- FRAMEWORK: grape-1.6
137
- - RUBY_VERSION: ruby:3.1
138
- FRAMEWORK: grape-1.6,sinatra-2.2,rails-7.0
139
- - RUBY_VERSION: ruby:3.1
140
- FRAMEWORK: grape-1.6,sinatra-2.2,rails-6.1
141
- - RUBY_VERSION: ruby:3.0
142
- FRAMEWORK: grape-1.6
143
- - RUBY_VERSION: ruby:3.0
144
- FRAMEWORK: grape-1.6,sinatra-2.2,rails-6.1
145
-
146
- # only test ruby >= 3.0 with rails 6.0 and rails 6.1
147
- - RUBY_VERSION: ruby:3.1
148
- FRAMEWORK: rails-5.2
149
- - RUBY_VERSION: ruby:3.1
150
- FRAMEWORK: rails-5.1
151
- - RUBY_VERSION: ruby:3.0
152
- FRAMEWORK: rails-5.2
153
- - RUBY_VERSION: ruby:3.0
154
- FRAMEWORK: rails-5.1
155
-
156
- # Unsupported
157
- # Ruby 2.6
158
- - RUBY_VERSION: ruby:2.6
159
- FRAMEWORK: grape-1.6,sinatra-2.2,rails-6.1
160
- - RUBY_VERSION: ruby:2.6
161
- FRAMEWORK: grape-1.6,sinatra-2.2,rails-7.0
162
- # Ruby 2.5
163
- - RUBY_VERSION: ruby:2.5
164
- FRAMEWORK: grape-1.6,sinatra-2.2,rails-6.1
165
- - RUBY_VERSION: ruby:2.5
166
- FRAMEWORK: grape-1.6,sinatra-2.2,rails-7.0
167
- # Ruby 2.4
168
- - RUBY_VERSION: ruby:2.4
169
- FRAMEWORK: grape-1.6,sinatra-2.2,rails-6.1
170
- - RUBY_VERSION: ruby:2.4
171
- FRAMEWORK: grape-1.6,sinatra-2.2,rails-7.0
172
- # JRuby 9.2
173
- - RUBY_VERSION: jruby:9.2
174
- FRAMEWORK: grape-1.6,sinatra-2.2,rails-6.1
175
- - RUBY_VERSION: jruby:9.2
176
- FRAMEWORK: grape-1.6,sinatra-2.2,rails-7.0
177
- # JRuby 9.2-13-jdk
178
- - RUBY_VERSION: docker.elastic.co/observability-ci/jruby:9.2-13-jdk
179
- FRAMEWORK: grape-1.6,sinatra-2.2,rails-6.1
180
- - RUBY_VERSION: docker.elastic.co/observability-ci/jruby:9.2-13-jdk
181
- FRAMEWORK: grape-1.6,sinatra-2.2,rails-7.0
182
- # JRuby 9.2-11-jdk
183
- - RUBY_VERSION: docker.elastic.co/observability-ci/jruby:9.2-11-jdk
184
- FRAMEWORK: grape-1.6,sinatra-2.2,rails-6.1
185
- - RUBY_VERSION: docker.elastic.co/observability-ci/jruby:9.2-11-jdk
186
- FRAMEWORK: grape-1.6,sinatra-2.2,rails-7.0
187
- # JRuby 9.2-8-jdk
188
- - RUBY_VERSION: docker.elastic.co/observability-ci/jruby:9.2-8-jdk
189
- FRAMEWORK: grape-1.6,sinatra-2.2,rails-6.1
190
- - RUBY_VERSION: docker.elastic.co/observability-ci/jruby:9.2-8-jdk
191
- FRAMEWORK: grape-1.6,sinatra-2.2,rails-7.0
@@ -1,4 +0,0 @@
1
- FRAMEWORK:
2
- - rails-main
3
- - sinatra-master
4
- - grape-master
@@ -1,10 +0,0 @@
1
- RUBY_VERSION:
2
- - ruby:3.1
3
- - ruby:3.0
4
- - ruby:2.7
5
- - ruby:2.6
6
- - ruby:2.4
7
- - jruby:9.2
8
- - docker.elastic.co/observability-ci/jruby:9.2-13-jdk
9
- - docker.elastic.co/observability-ci/jruby:9.2-11-jdk
10
- - docker.elastic.co/observability-ci/jruby:9.2-8-jdk
@@ -1,6 +0,0 @@
1
- RUBY_VERSION:
2
- - ruby:3.1
3
- - ruby:3.0
4
- - ruby:2.7
5
- - ruby:2.6
6
- - jruby:9.2
data/.ci/Jenkinsfile DELETED
@@ -1,419 +0,0 @@
1
- #!/usr/bin/env groovy
2
- @Library('apm@current') _
3
-
4
- import co.elastic.matrix.*
5
- import groovy.transform.Field
6
-
7
- /**
8
- This is the parallel tasks generator,
9
- it is need as field to store the results of the tests.
10
- */
11
- @Field def rubyTasksGen
12
-
13
- pipeline {
14
- agent { label 'linux && immutable' }
15
- environment {
16
- REPO = 'apm-agent-ruby'
17
- BASE_DIR = "src/github.com/elastic/${env.REPO}"
18
- PIPELINE_LOG_LEVEL = 'INFO'
19
- NOTIFY_TO = credentials('notify-to')
20
- JOB_GCS_BUCKET = credentials('gcs-bucket')
21
- CODECOV_SECRET = 'secret/apm-team/ci/apm-agent-ruby-codecov'
22
- DOCKER_REGISTRY = 'docker.elastic.co'
23
- DOCKER_SECRET = 'secret/apm-team/ci/docker-registry/prod'
24
- RELEASE_SECRET = 'secret/apm-team/ci/apm-agent-ruby-rubygems-release'
25
- OPBEANS_REPO = 'opbeans-ruby'
26
- REFERENCE_REPO = '/var/lib/jenkins/.git-references/apm-agent-ruby.git'
27
- SLACK_CHANNEL = '#apm-agent-ruby'
28
- }
29
- options {
30
- timeout(time: 2, unit: 'HOURS')
31
- buildDiscarder(logRotator(numToKeepStr: '20', artifactNumToKeepStr: '20', daysToKeepStr: '30'))
32
- timestamps()
33
- ansiColor('xterm')
34
- disableResume()
35
- durabilityHint('PERFORMANCE_OPTIMIZED')
36
- rateLimitBuilds(throttle: [count: 60, durationName: 'hour', userBoost: true])
37
- quietPeriod(10)
38
- }
39
- triggers {
40
- issueCommentTrigger("(${obltGitHubComments()}|^run benchmark tests)")
41
- }
42
- parameters {
43
- booleanParam(name: 'Run_As_Main_Branch', defaultValue: false, description: 'Allow to run any steps on a PR, some steps normally only run on main branch.')
44
- booleanParam(name: 'bench_ci', defaultValue: true, description: 'Enable run benchmarks.')
45
- }
46
- stages {
47
- /**
48
- Checkout the code and stash it, to use it on other stages.
49
- */
50
- stage('Checkout') {
51
- options { skipDefaultCheckout() }
52
- steps {
53
- pipelineManager([ cancelPreviousRunningBuilds: [ when: 'PR' ] ])
54
- deleteDir()
55
- gitCheckout(basedir: "${BASE_DIR}", githubNotifyFirstTimeContributor: true, reference: "${env.REFERENCE_REPO}")
56
- stash allowEmpty: true, name: 'source', useDefaultExcludes: false
57
- script {
58
- dir("${BASE_DIR}"){
59
- // Skip all the stages except docs for PR's with asciidoc and md changes only
60
- env.ONLY_DOCS = isGitRegionMatch(patterns: [ '.*\\.(asciidoc|md)' ], shouldMatchAll: true)
61
- }
62
- }
63
- }
64
- }
65
- stage('Sanity checks') {
66
- when {
67
- beforeAgent true
68
- allOf {
69
- expression { return env.ONLY_DOCS == "false" }
70
- anyOf {
71
- not { changeRequest() }
72
- expression { return params.Run_As_Main_Branch }
73
- }
74
- }
75
- }
76
- options { skipDefaultCheckout() }
77
- environment {
78
- HOME = "${env.WORKSPACE}"
79
- PATH = "${env.WORKSPACE}/bin:${env.PATH}"
80
- }
81
- steps {
82
- withGithubNotify(context: 'Sanity checks') {
83
- deleteDir()
84
- unstash 'source'
85
- dir(BASE_DIR) {
86
- catchError(buildResult: 'SUCCESS', stageResult: 'UNSTABLE', message: 'Sanity checks failed but keep running the build') {
87
- preCommit(commit: "${GIT_BASE_COMMIT}", junit: true)
88
- }
89
- }
90
- }
91
- }
92
- }
93
- /**
94
- Execute unit tests.
95
- */
96
- stage('Tests') {
97
- when {
98
- beforeAgent true
99
- expression { return env.ONLY_DOCS == "false" }
100
- }
101
- failFast false
102
- parallel {
103
- stage('Tests') {
104
- options { skipDefaultCheckout() }
105
- steps {
106
- withGithubNotify(context: 'Tests', tab: 'tests') {
107
- runTests('.ci/.jenkins_framework.yml')
108
- }
109
- }
110
- post {
111
- always {
112
- convergeCoverage()
113
- }
114
- }
115
- }
116
- stage('Main Tests frameworks') {
117
- options { skipDefaultCheckout() }
118
- steps {
119
- catchError(buildResult: 'SUCCESS', stageResult: 'UNSTABLE', message: "The tests for the main framework have failed. Let's warn instead.") {
120
- runTests('.ci/.jenkins_main_framework.yml')
121
- }
122
- }
123
- }
124
- }
125
- }
126
- stage('Benchmarks') {
127
- options { skipDefaultCheckout() }
128
- when {
129
- beforeAgent true
130
- allOf {
131
- anyOf {
132
- branch 'main'
133
- branch "\\d+\\.\\d+"
134
- branch "v\\d?"
135
- tag pattern: 'v\\d+.*', comparator: "REGEXP"
136
- expression { return params.Run_As_Main_Branch }
137
- expression { return env.GITHUB_COMMENT?.contains('benchmark tests') }
138
- }
139
- expression { return params.bench_ci }
140
- }
141
- }
142
- stages {
143
- stage('Clean Workspace') {
144
- agent { label 'microbenchmarks-pool' }
145
- steps {
146
- echo "Cleaning Workspace"
147
- }
148
- post {
149
- always {
150
- cleanWs(notFailBuild: true)
151
- }
152
- }
153
- }
154
- /**
155
- Run the benchmarks and store the results on ES.
156
- The result JSON files are also archive into Jenkins.
157
- */
158
- stage('Run Benchmarks') {
159
- steps {
160
- withGithubNotify(context: 'Run Benchmarks') {
161
- deleteDir()
162
- unstash 'source'
163
- dir("${BASE_DIR}"){
164
- script {
165
- def versions = readYaml(file: ".ci/.jenkins_ruby_benchmarks.yml")
166
- def benchmarkTask = [:]
167
- versions['RUBY_VERSION'].each{ v ->
168
- benchmarkTask[v] = runBenchmark(v)
169
- }
170
- parallel(benchmarkTask)
171
- }
172
- }
173
- }
174
- }
175
- }
176
- }
177
- }
178
- stage('Release') {
179
- options { skipDefaultCheckout() }
180
- environment {
181
- RUBY_DOCKER_TAG = 'ruby:2.6'
182
- HOME = '/var/lib/jenkins'
183
- }
184
- when {
185
- beforeAgent true
186
- tag pattern: 'v\\d+.*', comparator: 'REGEXP'
187
- }
188
- stages {
189
- stage('Notify') {
190
- steps {
191
- notifyStatus(slackStatus: 'warning', subject: "[${env.REPO}] Release *${env.TAG_NAME}* ready to be pushed",
192
- body: "(<${env.RUN_DISPLAY_URL}|Open>).\n Changes: ${env.TAG_NAME}")
193
- }
194
- }
195
- stage('Release') {
196
- steps {
197
- deleteDir()
198
- unstash 'source'
199
- prepareRelease(){
200
- sh 'rake release'
201
- }
202
- }
203
- }
204
- stage('Update Branch') {
205
- steps {
206
- deleteDir()
207
- unstash 'source'
208
- prepareRelease(){
209
- catchError(buildResult: 'SUCCESS', message: 'Update branch task failed', stageResult: 'UNSTABLE') {
210
- sh 'rake release:update_branch'
211
- }
212
- }
213
- }
214
- post {
215
- success {
216
- notifyStatus(slackStatus: 'good', subject: "[${env.REPO}] Release *${env.TAG_NAME}* published",
217
- body: "Great news, the release has been done successfully. (<${env.RUN_DISPLAY_URL}|Open>).")
218
- }
219
- unsuccessful {
220
- notifyStatus(slackStatus: 'warning', subject: "[${env.REPO}] Release *${env.TAG_NAME}* has some sync-up post-release failures.",
221
- body: "Please go to ${env.BUILD_URL} to review the logs. Most likely you need to update the branch manually. (<${env.RUN_DISPLAY_URL}|Open>)")
222
- }
223
- }
224
- }
225
- stage('Opbeans') {
226
- environment {
227
- REPO_NAME = "${OPBEANS_REPO}"
228
- VERSION = "${env.BRANCH_NAME.replaceAll('^v', '')}"
229
- }
230
- steps {
231
- deleteDir()
232
- // Let's wait for the Gem to be available
233
- sh label: 'Wait for gem', script: """#!/usr/bin/env bash
234
- source /usr/local/bin/bash_standard_lib.sh
235
- (retry 10 curl --silent --show-error --fail -I https://rubygems.org/gems/elastic-apm/versions/${env.VERSION})
236
- """
237
- dir("${OPBEANS_REPO}"){
238
- git(credentialsId: 'f6c7695a-671e-4f4f-a331-acdce44ff9ba',
239
- url: "git@github.com:elastic/${OPBEANS_REPO}.git",
240
- branch: 'main')
241
- // It's required to transform the tag value to the gem version
242
- sh script: ".ci/bump-version.sh ${env.VERSION}", label: 'Bump version'
243
- // The opbeans pipeline will trigger a release for the main branch
244
- gitPush()
245
- // The opbeans pipeline will trigger a release for the release tag
246
- gitCreateTag(tag: "${env.BRANCH_NAME}")
247
- }
248
- }
249
- }
250
- }
251
- }
252
- }
253
- post {
254
- cleanup {
255
- notifyBuildResult()
256
- }
257
- }
258
- }
259
-
260
- /**
261
- Run benchmarks for a Ruby version, then report the results to the Elasticsearch server.
262
- */
263
- def runBenchmark(version){
264
- return {
265
- node('microbenchmarks-pool'){
266
- // Transform the versions like:
267
- // - docker.elastic.co/observability-ci/jruby:9.2-12-jdk to jruby-9.2-12-jdk
268
- // - jruby:9.1 to jruby-9.1
269
- def transformedVersion = version.replaceAll('.*/', '').replaceAll(':', '-')
270
- withEnv(["HOME=${env.WORKSPACE}/${transformedVersion}"]){
271
- dir("${transformedVersion}"){
272
- deleteDir()
273
- unstash 'source'
274
- dir("${BASE_DIR}"){
275
- retry(2){
276
- sleep randomNumber(min:10, max: 30)
277
- dockerLogin(secret: "${DOCKER_SECRET}", registry: "${DOCKER_REGISTRY}")
278
- }
279
- try{
280
- sh """./spec/scripts/benchmarks.sh "${version}" "${REFERENCE_REPO}" """
281
- } finally {
282
- archiveArtifacts(
283
- allowEmptyArchive: true,
284
- artifacts: "**/benchmark-${transformedVersion}.raw,**/benchmark-${transformedVersion}.error",
285
- onlyIfSuccessful: false)
286
- sendBenchmarks(file: "benchmark-${transformedVersion}.bulk",
287
- index: "benchmark-ruby", archive: true)
288
- cleanWs(notFailBuild: true)
289
- }
290
- }
291
- }
292
- }
293
- }
294
- }
295
- }
296
-
297
- class RubyParallelTaskGenerator extends DefaultParallelTaskGenerator {
298
-
299
- public RubyParallelTaskGenerator(Map params){
300
- super(params)
301
- }
302
-
303
- /**
304
- build a clousure that launch and agent and execute the corresponding test script,
305
- then store the results.
306
- */
307
- public Closure generateStep(x, y){
308
- return {
309
- steps.sleep steps.randomNumber(min:10, max: 30)
310
- steps.node('linux && immutable'){
311
- // Label is transformed to avoid using the internal docker registry in the x coordinate
312
- // TODO: def label = "${tag}:${x?.drop(x?.lastIndexOf('/')+1)}#${y}"
313
- def label = "${tag}:${x}#${y}"
314
- try {
315
- steps.runScript(label: label, ruby: x, framework: y)
316
- saveResult(x, y, 1)
317
- } catch(e){
318
- saveResult(x, y, 0)
319
- steps.error("${label} tests failed : ${e.toString()}\n")
320
- } finally {
321
- steps.junit(allowEmptyResults: false,
322
- keepLongStdio: true,
323
- testResults: "**/spec/junit-reports/**/ruby-agent-junit.xml")
324
- steps.dir("${steps.env.BASE_DIR}"){
325
- steps.archiveArtifacts(artifacts: 'coverage/matrix_results/', defaultExcludes: false)
326
- steps.stash(name: steps.normalise("coverage-${x}-${y}"), includes: 'coverage/matrix_results/', allowEmpty: true)
327
- }
328
- }
329
- }
330
- }
331
- }
332
- }
333
-
334
- /**
335
- Run all the tests for the given file with the frameworks to test
336
- */
337
- def runTests(frameworkFile) {
338
- deleteDir()
339
- unstash "source"
340
- dir("${BASE_DIR}"){
341
- rubyTasksGen = new RubyParallelTaskGenerator(
342
- xKey: 'RUBY_VERSION',
343
- yKey: 'FRAMEWORK',
344
- xFile: ".ci/.jenkins_ruby.yml",
345
- yFile: frameworkFile,
346
- exclusionFile: ".ci/.jenkins_exclude.yml",
347
- tag: "Ruby",
348
- name: "Ruby",
349
- steps: this
350
- )
351
- def testTasks = rubyTasksGen.generateParallelTests()
352
- parallel(testTasks)
353
- }
354
- }
355
-
356
- /**
357
- Run tests for a Ruby version and framework version.
358
- */
359
- def runScript(Map params = [:]){
360
- def label = params.label
361
- def ruby = params.ruby
362
- def framework = params.framework
363
- log(level: 'INFO', text: "${label}")
364
- retry(2){
365
- withEnv(["HOME=${env.WORKSPACE}", "PATH=${env.PATH}:${env.WORKSPACE}/bin"]) {
366
- deleteDir()
367
- unstash 'source'
368
- dir("${BASE_DIR}"){
369
- sleep randomNumber(min:10, max: 30)
370
- dockerLogin(secret: "${DOCKER_SECRET}", registry: "${DOCKER_REGISTRY}")
371
- sh(label: "Run BDD tests", script: "./spec/scripts/features.sh ${ruby}")
372
- sh("./spec/scripts/spec.sh ${ruby} ${framework}")
373
- }
374
- }
375
- }
376
- }
377
-
378
- def convergeCoverage() {
379
- deleteDir()
380
- unstash('source')
381
- dir("${BASE_DIR}"){
382
- rubyTasksGen.dumpMatrix('-')?.each {
383
- unstash(normalise("coverage-${it}"))
384
- }
385
- sh(script: './spec/scripts/coverage_converge.sh')
386
- cobertura coberturaReportFile: 'coverage/coverage.xml', onlyStable: false
387
- }
388
- }
389
-
390
- def prepareRelease(Closure body){
391
- dir("${env.BASE_DIR}"){
392
- docker.image("${env.RUBY_DOCKER_TAG}").inside('-v ${REFERENCE_REPO}:${REFERENCE_REPO} -v /etc/passwd:/etc/passwd -v ${HOME}/.ssh:${HOME}/.ssh') {
393
- withEnv(["HOME=${env.WORKSPACE}/${env.BASE_DIR ?: ''}"]) {
394
- rubygemsLogin.withApi(secret: "${env.RELEASE_SECRET}") {
395
- withGitRelease(credentialsId: '2a9602aa-ab9f-4e52-baf3-b71ca88469c7-UserAndToken') {
396
- sh 'gem install rake yard rspec'
397
- body()
398
- }
399
- }
400
- }
401
- }
402
- }
403
- }
404
-
405
- // Transform the versions like:
406
- // - docker.elastic.co/observability-ci/jruby:9.2-12-jdk to jruby-9.2-12-jdk
407
- // - jruby:9.1 to jruby-9.1
408
- def normalise(def what) {
409
- return what.replaceAll('.*/', '').replaceAll(':', '-')
410
- }
411
-
412
- def notifyStatus(def args = [:]) {
413
- releaseNotification(slackChannel: "${env.SLACK_CHANNEL}",
414
- slackColor: args.slackStatus,
415
- slackCredentialsId: 'jenkins-slack-integration-token',
416
- to: "${env.NOTIFY_TO}",
417
- subject: args.subject,
418
- body: args.body)
419
- }
@@ -1,38 +0,0 @@
1
- ---
2
- - job:
3
- name: apm-agent-ruby/apm-agent-ruby-downstream
4
- display-name: APM Agent Ruby Downstream
5
- description: APM Agent Ruby Downstream .
6
- script-path: .ci/downstreamTests.groovy
7
- scm:
8
- - github:
9
- branch-discovery: no-pr
10
- discover-pr-forks-strategy: merge-current
11
- discover-pr-forks-trust: permission
12
- discover-pr-origin: merge-current
13
- discover-tags: true
14
- notification-context: 'apm-ci/downstream'
15
- property-strategies:
16
- all-branches:
17
- - suppress-scm-triggering: true
18
- repo: apm-agent-ruby
19
- repo-owner: elastic
20
- credentials-id: 2a9602aa-ab9f-4e52-baf3-b71ca88469c7-UserAndToken
21
- ssh-checkout:
22
- credentials: f6c7695a-671e-4f4f-a331-acdce44ff9ba
23
- clean:
24
- after: true
25
- before: true
26
- prune: true
27
- shallow-clone: true
28
- depth: 3
29
- do-not-fetch-tags: true
30
- submodule:
31
- disable: false
32
- recursive: true
33
- parent-credentials: true
34
- timeout: 100
35
- reference-repo: /var/lib/jenkins/.git-references/apm-agent-ruby.git
36
- timeout: '15'
37
- use-author: true
38
- wipe-workspace: 'True'