elastic-apm 3.7.0 → 3.8.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 86463e0604357bc3c88e3507de76b0a2e92ba2a1311aab220b6b092df9523319
4
- data.tar.gz: 97b3fcbc28f6b46de4e72f536b314380884f6dd192747258f861bf060aa588ab
3
+ metadata.gz: 32d176ac5c22246df60ecc92f1baad37011a872af4e64f842b5a43c699a6ced3
4
+ data.tar.gz: bf0505e728d8f1bd0bb941574a844a8990d14e13a94a7c9f2a6c2d0f9eb5d35b
5
5
  SHA512:
6
- metadata.gz: 56a3b688bf4646a11888677fad884937b9f83b04b2cb47d5740f9cb0ce3e1c754abbe861e4888418f6ec168695f940d8ac24c4de3461c61a2d4f7360953d3f30
7
- data.tar.gz: 9743b2bc369dfedf3ff28893062171bb1af0a2af201f845701966409ab4c0063a4584257f445fabc6c14eba8a170ddbac9e5fe391554be53652f801cf2d482d5
6
+ metadata.gz: d57b6bdbc7e78bea95e197d33f3eef4db7a35b23f9e450c636c3c1e3a5dd75ee8ee195709944ac51d6af7a3ab2451fd19d6139f0dedf9e86a4827732d5097f2a
7
+ data.tar.gz: 924b9bbf782a0fa4e376137e9a44d10cc01be71455ca7614ab1374c70f0926d174eb1078b985cd60c1693e2e0ec1cdd8446502bd40007359262dcc31241250aa
@@ -5,14 +5,10 @@ import co.elastic.matrix.*
5
5
  import groovy.transform.Field
6
6
 
7
7
  /**
8
- This is required to know if there any failures when running the downstream jobs.
8
+ This is the parallel tasks generator,
9
+ it is need as field to store the results of the tests.
9
10
  */
10
- @Field def rubyTasksFailed = false
11
-
12
- /**
13
- This is required to store the build status for the downstream jobs.
14
- */
15
- @Field def rubyDownstreamJobs = [:]
11
+ @Field def rubyTasksGen
16
12
 
17
13
  pipeline {
18
14
  agent { label 'linux && immutable' }
@@ -42,7 +38,7 @@ pipeline {
42
38
  quietPeriod(10)
43
39
  }
44
40
  triggers {
45
- issueCommentTrigger('(?i).*(?:jenkins\\W+)?run\\W+(?:the\\W+)?tests(?:\\W+please)?.*')
41
+ issueCommentTrigger('(?i).*(?:jenkins\\W+)?run\\W+(?:the\\W+)?(?:benchmark\\W+)?tests(?:\\W+please)?.*')
46
42
  }
47
43
  parameters {
48
44
  booleanParam(name: 'Run_As_Master_Branch', defaultValue: false, description: 'Allow to run any steps on a PR, some steps normally only run on master branch.')
@@ -98,50 +94,53 @@ pipeline {
98
94
  /**
99
95
  Execute unit tests.
100
96
  */
101
- stage('Test') {
102
- options { skipDefaultCheckout() }
97
+ stage('Tests') {
103
98
  when {
104
99
  beforeAgent true
105
100
  expression { return env.ONLY_DOCS == "false" }
106
101
  }
107
- steps {
108
- withGithubNotify(context: 'Tests', tab: 'tests') {
109
- deleteDir()
110
- unstash "source"
111
- dir("${BASE_DIR}"){
112
- script {
113
- def ruby = readYaml(file: '.ci/.jenkins_ruby.yml')
114
- def testTasks = [:]
115
- def i = 0
116
- ruby['RUBY_VERSION'].each{ rubyVersion ->
117
- testTasks[rubyVersion] = { runJob(rubyVersion, i++) }
118
- }
119
- parallel(testTasks)
102
+ failFast false
103
+ parallel {
104
+ stage('Tests') {
105
+ options { skipDefaultCheckout() }
106
+ steps {
107
+ withGithubNotify(context: 'Tests', tab: 'tests') {
108
+ runTests('.ci/.jenkins_framework.yml')
109
+ }
110
+ }
111
+ post {
112
+ always {
113
+ convergeCoverage()
120
114
  }
121
115
  }
122
116
  }
123
- }
124
- }
125
- stage('Integration Tests') {
126
- agent none
127
- when {
128
- beforeAgent true
129
- allOf {
130
- expression { return env.ONLY_DOCS == "false" }
131
- anyOf {
132
- changeRequest()
133
- expression { return !params.Run_As_Master_Branch }
117
+ stage('Master Tests frameworks') {
118
+ options { skipDefaultCheckout() }
119
+ steps {
120
+ catchError(buildResult: 'SUCCESS', stageResult: 'UNSTABLE', message: "The tests for the master framework have failed. Let's warn instead.") {
121
+ runTests('.ci/.jenkins_master_framework.yml')
122
+ }
123
+ }
124
+ }
125
+ stage('Integration Tests') {
126
+ agent none
127
+ when {
128
+ beforeAgent true
129
+ anyOf {
130
+ changeRequest()
131
+ expression { return !params.Run_As_Master_Branch }
132
+ }
133
+ }
134
+ steps {
135
+ githubNotify(context: "${env.GITHUB_CHECK_ITS_NAME}", description: "${env.GITHUB_CHECK_ITS_NAME} ...", status: 'PENDING', targetUrl: "${env.JENKINS_URL}search/?q=${env.ITS_PIPELINE.replaceAll('/','+')}")
136
+ build(job: env.ITS_PIPELINE, propagate: false, wait: true,
137
+ parameters: [ string(name: 'INTEGRATION_TEST', value: 'Ruby'),
138
+ string(name: 'BUILD_OPTS', value: "--ruby-agent-version ${env.GIT_BASE_COMMIT} --ruby-agent-version-state ${env.GIT_BUILD_CAUSE} --ruby-agent-repo ${env.CHANGE_FORK?.trim() ?: 'elastic'}/${env.REPO} --opbeans-ruby-agent-branch ${env.GIT_BASE_COMMIT}"),
139
+ string(name: 'GITHUB_CHECK_NAME', value: env.GITHUB_CHECK_ITS_NAME),
140
+ string(name: 'GITHUB_CHECK_REPO', value: env.REPO),
141
+ string(name: 'GITHUB_CHECK_SHA1', value: env.GIT_BASE_COMMIT) ])
134
142
  }
135
143
  }
136
- }
137
- steps {
138
- build(job: env.ITS_PIPELINE, propagate: false, wait: false,
139
- parameters: [string(name: 'INTEGRATION_TEST', value: 'Ruby'),
140
- string(name: 'BUILD_OPTS', value: "--ruby-agent-version ${env.GIT_BASE_COMMIT} --ruby-agent-version-state ${env.GIT_BUILD_CAUSE} --ruby-agent-repo ${env.CHANGE_FORK?.trim() ?: 'elastic'}/${env.REPO} --opbeans-ruby-agent-branch ${env.GIT_BASE_COMMIT}"),
141
- string(name: 'GITHUB_CHECK_NAME', value: env.GITHUB_CHECK_ITS_NAME),
142
- string(name: 'GITHUB_CHECK_REPO', value: env.REPO),
143
- string(name: 'GITHUB_CHECK_SHA1', value: env.GIT_BASE_COMMIT)])
144
- githubNotify(context: "${env.GITHUB_CHECK_ITS_NAME}", description: "${env.GITHUB_CHECK_ITS_NAME} ...", status: 'PENDING', targetUrl: "${env.JENKINS_URL}search/?q=${env.ITS_PIPELINE.replaceAll('/','+')}")
145
144
  }
146
145
  }
147
146
  stage('Benchmarks') {
@@ -155,6 +154,7 @@ pipeline {
155
154
  branch "v\\d?"
156
155
  tag pattern: 'v\\d+.*', comparator: "REGEXP"
157
156
  expression { return params.Run_As_Master_Branch }
157
+ expression { return env.GITHUB_COMMENT?.contains('benchmark tests') }
158
158
  }
159
159
  expression { return params.bench_ci }
160
160
  }
@@ -195,20 +195,6 @@ pipeline {
195
195
  }
196
196
  }
197
197
  }
198
- stage('Populate Downstream failures') {
199
- when {
200
- expression { return rubyTasksFailed }
201
- }
202
- steps {
203
- script {
204
- def message = 'Failures when running the "Test" stage'
205
- if (notifyBuildResult.isAnyDownstreamJobFailedWithTimeout(rubyDownstreamJobs)) {
206
- message += ' related to a timeout issue'
207
- }
208
- error(message)
209
- }
210
- }
211
- }
212
198
  stage('Release') {
213
199
  options { skipDefaultCheckout() }
214
200
  environment {
@@ -272,33 +258,14 @@ pipeline {
272
258
  }
273
259
  }
274
260
  }
275
- stage('Coverage converge') {
276
- when {
277
- beforeAgent true
278
- expression { return env.ONLY_DOCS == "false" }
279
- }
280
- steps{
281
- dir("${BASE_DIR}"){
282
- unpack_artifacts(rubyDownstreamJobs)
283
- sh(script: "./spec/scripts/coverage_converge.sh")
284
- cobertura coberturaReportFile: "coverage/coverage.xml"
285
- }
286
- }
287
- }
288
261
  }
289
262
  post {
290
263
  cleanup {
291
- notifyBuildResult(downstreamJobs: rubyDownstreamJobs)
264
+ notifyBuildResult()
292
265
  }
293
266
  }
294
267
  }
295
268
 
296
- def unpack_artifacts(builds) {
297
- builds.values().each() { build ->
298
- copyArtifacts(projectName: "apm-agent-ruby/apm-agent-ruby-downstream/${env.BRANCH_NAME}", selector: specific(buildNumber: build.number.toString()))
299
- }
300
- }
301
-
302
269
  /**
303
270
  Run benchmarks for a Ruby version, then report the results to the Elasticsearch server.
304
271
  */
@@ -337,26 +304,95 @@ def runBenchmark(version){
337
304
  }
338
305
  }
339
306
 
340
- def runJob(String rubyVersion, int sleep = 1){
341
- def buildObject
342
- def branch = env.CHANGE_ID?.trim() ? env.CHANGE_TARGET : env.BRANCH_NAME
343
- try {
344
- def quiet = (sleep * randomNumber(min: 2, max: 6)) + 5
345
- buildObject = build(job: "apm-agent-ruby/apm-agent-ruby-downstream/${env.BRANCH_NAME}",
346
- parameters: [
347
- string(name: 'RUBY_VERSION', value: "${rubyVersion}"),
348
- string(name: 'BRANCH_SPECIFIER', value: "${env.GIT_BASE_COMMIT}"),
349
- string(name: 'MERGE_TARGET', value: "${branch}")
350
- ],
351
- quietPeriod: quiet)
352
- } catch(e) {
353
- rubyTasksFailed = true
354
- buildObject = e
355
- warnError('Downstream Failed') {
356
- error("Downstream job for '${rubyVersion}' failed")
307
+ class RubyParallelTaskGenerator extends DefaultParallelTaskGenerator {
308
+
309
+ public RubyParallelTaskGenerator(Map params){
310
+ super(params)
311
+ }
312
+
313
+ /**
314
+ build a clousure that launch and agent and execute the corresponding test script,
315
+ then store the results.
316
+ */
317
+ public Closure generateStep(x, y){
318
+ return {
319
+ steps.sleep steps.randomNumber(min:10, max: 30)
320
+ steps.node('linux && immutable'){
321
+ // Label is transformed to avoid using the internal docker registry in the x coordinate
322
+ // TODO: def label = "${tag}:${x?.drop(x?.lastIndexOf('/')+1)}#${y}"
323
+ def label = "${tag}:${x}#${y}"
324
+ try {
325
+ steps.runScript(label: label, ruby: x, framework: y)
326
+ saveResult(x, y, 1)
327
+ } catch(e){
328
+ saveResult(x, y, 0)
329
+ steps.error("${label} tests failed : ${e.toString()}\n")
330
+ } finally {
331
+ steps.junit(allowEmptyResults: false,
332
+ keepLongStdio: true,
333
+ testResults: "**/spec/junit-reports/**/ruby-agent-junit.xml")
334
+ steps.dir("${steps.env.BASE_DIR}"){
335
+ steps.archiveArtifacts(artifacts: 'coverage/matrix_results/', defaultExcludes: false)
336
+ steps.stash(name: steps.normalise("coverage-${x}-${y}"), includes: 'coverage/matrix_results/', allowEmpty: true)
337
+ }
338
+ }
339
+ }
357
340
  }
358
- } finally {
359
- rubyDownstreamJobs["${rubyVersion}"] = buildObject
341
+ }
342
+ }
343
+
344
+ /**
345
+ Run all the tests for the given file with the frameworks to test
346
+ */
347
+ def runTests(frameworkFile) {
348
+ deleteDir()
349
+ unstash "source"
350
+ dir("${BASE_DIR}"){
351
+ rubyTasksGen = new RubyParallelTaskGenerator(
352
+ xKey: 'RUBY_VERSION',
353
+ yKey: 'FRAMEWORK',
354
+ xFile: ".ci/.jenkins_ruby.yml",
355
+ yFile: frameworkFile,
356
+ exclusionFile: ".ci/.jenkins_exclude.yml",
357
+ tag: "Ruby",
358
+ name: "Ruby",
359
+ steps: this
360
+ )
361
+ def testTasks = rubyTasksGen.generateParallelTests()
362
+ parallel(testTasks)
363
+ }
364
+ }
365
+
366
+ /**
367
+ Run tests for a Ruby version and framework version.
368
+ */
369
+ def runScript(Map params = [:]){
370
+ def label = params.label
371
+ def ruby = params.ruby
372
+ def framework = params.framework
373
+ log(level: 'INFO', text: "${label}")
374
+ retry(2){
375
+ withEnv(["HOME=${env.WORKSPACE}", "PATH=${env.PATH}:${env.WORKSPACE}/bin"]) {
376
+ deleteDir()
377
+ unstash 'source'
378
+ dir("${BASE_DIR}"){
379
+ sleep randomNumber(min:10, max: 30)
380
+ dockerLogin(secret: "${DOCKER_SECRET}", registry: "${DOCKER_REGISTRY}")
381
+ sh("./spec/scripts/spec.sh ${ruby} ${framework}")
382
+ }
383
+ }
384
+ }
385
+ }
386
+
387
+ def convergeCoverage() {
388
+ deleteDir()
389
+ unstash('source')
390
+ dir("${BASE_DIR}"){
391
+ rubyTasksGen.dumpMatrix('-')?.each {
392
+ unstash(normalise("coverage-${it}"))
393
+ }
394
+ sh(script: './spec/scripts/coverage_converge.sh')
395
+ cobertura coberturaReportFile: 'coverage/coverage.xml', onlyStable: false
360
396
  }
361
397
  }
362
398
 
@@ -374,3 +410,10 @@ def prepareRelease(Closure body){
374
410
  }
375
411
  }
376
412
  }
413
+
414
+ // Transform the versions like:
415
+ // - docker.elastic.co/observability-ci/jruby:9.2-12-jdk to jruby-9.2-12-jdk
416
+ // - jruby:9.1 to jruby-9.1
417
+ def normalise(def what) {
418
+ return what.replaceAll('.*/', '').replaceAll(':', '-')
419
+ }
@@ -2,13 +2,15 @@
2
2
 
3
3
  source /usr/local/bin/bash_standard_lib.sh
4
4
 
5
- grep "-" .ci/.jenkins_ruby.yml | grep -v 'observability-ci' | cut -d'-' -f2- | \
6
- while read -r version;
7
- do
8
- transformedName=${version/:/-}
9
- transformedVersion=$(echo "${version}" | cut -d":" -f2)
10
- imageName="apm-agent-ruby"
11
- registryImageName="docker.elastic.co/observability-ci/${imageName}:${transformedName}"
12
- (retry 2 docker pull "${registryImageName}")
13
- docker tag "${registryImageName}" "${imageName}:${transformedVersion}"
14
- done
5
+ if [ -x "$(command -v docker)" ]; then
6
+ grep "-" .ci/.jenkins_ruby.yml | grep -v 'observability-ci' | cut -d'-' -f2- | \
7
+ while read -r version;
8
+ do
9
+ transformedName=${version/:/-}
10
+ transformedVersion=$(echo "${version}" | cut -d":" -f2)
11
+ imageName="apm-agent-ruby"
12
+ registryImageName="docker.elastic.co/observability-ci/${imageName}:${transformedName}"
13
+ (retry 2 docker pull "${registryImageName}")
14
+ docker tag "${registryImageName}" "${imageName}:${transformedVersion}"
15
+ done
16
+ fi
data/.rspec CHANGED
@@ -1,3 +1,2 @@
1
1
  --color
2
- --require spec_helper
3
2
  --exclude-pattern spec/integration/**/*_spec.rb
@@ -35,7 +35,23 @@ endif::[]
35
35
  [[release-notes-3.x]]
36
36
  === Ruby Agent version 3.x
37
37
 
38
+ [[release-notes-3.8.0]]
39
+ ==== 3.8.0 (2020-06-18)
40
+
41
+ [float]
42
+ ===== Added
43
+
44
+ - Add the option `capture_elasticsearch_queries` {pull}789[#789]
45
+ - Add option to skip patching Kernal#require {pull}812[#812]
46
+ - Add option `service_node_name` {pull}820[#820]
47
+
38
48
  [float]
49
+ ===== Fixed
50
+
51
+ - Allow underscores in hostnames in Net::HTTP spy {pull}804[#804]
52
+ - Don't change log level on logger object via remote config {pull}809[#809]
53
+ - Update and fix the Opentracing bridge {pull}791[#791]
54
+
39
55
  [[release-notes-3.7.0]]
40
56
  ==== 3.7.0 (2020-05-14)
41
57
 
data/Gemfile CHANGED
@@ -39,7 +39,8 @@ gem 'elasticsearch', require: nil
39
39
  gem 'fakeredis', require: nil
40
40
  gem 'faraday', require: nil
41
41
  gem 'graphql', require: nil
42
- gem 'grpc' if !defined?(JRUBY_VERSION) && RUBY_VERSION < '2.7'
42
+ gem 'google-protobuf', '< 3.12' if !defined?(JRUBY_VERSION) && RUBY_VERSION < '2.5'
43
+ gem 'grpc' if !defined?(JRUBY_VERSION)
43
44
  gem 'json-schema', require: nil
44
45
  gem 'mongo', require: nil
45
46
  gem 'opentracing', require: nil
@@ -8,7 +8,10 @@ runRspec(){
8
8
  if [ -n "${case}" ]; then
9
9
  bn="$(basename ${case} _spec.rb)/"
10
10
  fi
11
- bundle exec rspec -f progress -f JUnit -o spec/junit-reports/${bn}ruby-agent-junit.xml ${case}
11
+ bundle exec rspec \
12
+ -f progress \
13
+ -r yarjuf -f JUnit -o spec/junit-reports/${bn}ruby-agent-junit.xml \
14
+ ${case}
12
15
  }
13
16
  specific_spec=$1
14
17
 
@@ -26,11 +26,13 @@ services:
26
26
  - /tmp:exec,mode=1777
27
27
  depends_on:
28
28
  - mongodb
29
+ user: ${USER_ID}
29
30
 
30
31
  ruby_rspec:
31
32
  image: apm-agent-ruby:${RUBY_VERSION}
32
33
  environment:
33
34
  MONGODB_URL: 'mongodb:27017'
35
+ user: ${USER_ID}
34
36
 
35
37
  volumes:
36
38
  vendor:
@@ -287,6 +287,16 @@ If your service handles data like this, we advise to only enable this feature wi
287
287
 
288
288
  Whether or not to attach the request headers to transactions and errors.
289
289
 
290
+ [float]
291
+ [[config-capture-elasticsearch-queries]]
292
+ ==== `capture_elasticsearch_queries`
293
+ |============
294
+ | Environment | `Config` key | Default
295
+ | `ELASTIC_APM_CAPTURE_ELASTICSEARCH_QUERIES` | `capture_elasticsearch_queries` | `false`
296
+ |============
297
+
298
+ Whether or not to capture the body from requests in Elasticsearch.
299
+
290
300
  [float]
291
301
  [[config-capture-env]]
292
302
  ==== `capture_env`
@@ -707,6 +717,23 @@ NOTE: The service name must conform to this regular expression: `^[a-zA-Z0-9 _-]
707
717
  In layman's terms: Your service name must only contain characters from the ASCII
708
718
  alphabet, numbers, dashes, underscores and spaces.
709
719
 
720
+ [float]
721
+ [[config-service-node-name]]
722
+ ==== `service_node_name`
723
+
724
+ [options="header"]
725
+ |============
726
+ | Environment | `Config` key | Default | Example
727
+ | `ELASTIC_APM_SERVICE_NODE_NAME` | `service_node_name` | `nil` | `"my-app-1"`
728
+ |============
729
+
730
+ The name of the given service node. This is optional, and if omitted, the APM
731
+ Server will fall back on `system.container.id` if available, and finally
732
+ `host.name` if necessary.
733
+
734
+ This option allows you to set the node name manually to ensure uniqueness and
735
+ meaningfulness.
736
+
710
737
  [float]
711
738
  [[config-service-version]]
712
739
  ==== `service_version`
@@ -890,3 +917,13 @@ The unit is provided as suffix directly after the number, without any separation
890
917
  * `gb` (gigabytes)
891
918
 
892
919
  NOTE: we use the power-of-two sizing convention, e.g. `1 kilobyte == 1024 bytes`
920
+
921
+ [float]
922
+ [[special-configuration]]
923
+ === Special configuration
924
+
925
+ Elastic APM patches `Kernel#require` to auto-detect and instrument supported third party libraries. It does so with the utmost care but in rare cases it can conflict with some libraries.
926
+
927
+ To get around this patch, set the environment variable `ELASTIC_APM_SKIP_REQUIRE_PATCH` to `"1"`.
928
+
929
+ If you choose to do so, the agent might need some additional tweaking to make sure the third party libraries are picked up and instrumented. Make sure you require the agent _after_ you require your other dependencies.