elastic-apm 4.6.2 → 4.8.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.
Files changed (99) hide show
  1. checksums.yaml +4 -4
  2. data/.ci/.exclude.yml +132 -0
  3. data/.ci/{.jenkins_framework.yml → .framework.yml} +1 -4
  4. data/.ci/.ruby.yml +10 -0
  5. data/.ci/scripts/bench.sh +52 -0
  6. data/.ci/scripts/install-build-system.sh +5 -0
  7. data/.ci/updatecli/values.d/apm-data-spec.yml +1 -0
  8. data/.ci/updatecli/values.d/apm-gherkin.yml +1 -0
  9. data/.ci/updatecli/values.d/apm-json-specs.yml +1 -0
  10. data/.ci/updatecli/values.d/scm.yml +10 -0
  11. data/.ci/updatecli/values.d/update-compose.yml +3 -0
  12. data/.github/PULL_REQUEST_TEMPLATE.md +2 -2
  13. data/.github/dependabot.yml +35 -14
  14. data/.github/workflows/README.md +57 -0
  15. data/.github/workflows/addToProject.yml +19 -2
  16. data/.github/workflows/ci-docs.yml +20 -0
  17. data/.github/workflows/ci.yml +70 -0
  18. data/.github/workflows/docs-build.yml +19 -0
  19. data/.github/workflows/docs-cleanup.yml +14 -0
  20. data/.github/workflows/github-commands-comment.yml +38 -0
  21. data/.github/workflows/labeler.yml +5 -0
  22. data/.github/workflows/microbenchmark.yml +31 -0
  23. data/.github/workflows/release.yml +86 -0
  24. data/.github/workflows/run-matrix.yml +68 -0
  25. data/.github/workflows/test-reporter.yml +25 -0
  26. data/.github/workflows/updatecli.yml +61 -0
  27. data/.pre-commit-config.yaml +0 -2
  28. data/Gemfile +29 -3
  29. data/README.md +1 -1
  30. data/bench/rubyprof.rb +1 -0
  31. data/bin/dev +2 -2
  32. data/bin/run-tests +10 -1
  33. data/docker-compose.yml +4 -1
  34. data/docs/docset.yml +9 -0
  35. data/docs/reference/advanced-topics.md +12 -0
  36. data/docs/reference/api-reference.md +422 -0
  37. data/docs/reference/configuration.md +734 -0
  38. data/docs/{context.asciidoc → reference/context.md} +21 -21
  39. data/docs/reference/custom-instrumentation.md +72 -0
  40. data/docs/{getting-started-rack.asciidoc → reference/getting-started-rack.md} +20 -29
  41. data/docs/reference/getting-started-rails.md +27 -0
  42. data/docs/reference/graphql.md +21 -0
  43. data/docs/reference/index.md +24 -0
  44. data/docs/{log-correlation.asciidoc → reference/logs.md} +50 -41
  45. data/docs/reference/metrics.md +199 -0
  46. data/docs/reference/opentracing-api.md +70 -0
  47. data/docs/reference/performance-tuning.md +71 -0
  48. data/docs/reference/set-up-apm-ruby-agent.md +16 -0
  49. data/docs/reference/supported-technologies.md +128 -0
  50. data/docs/reference/toc.yml +22 -0
  51. data/docs/reference/upgrading.md +19 -0
  52. data/docs/release-notes/index.md +166 -0
  53. data/docs/release-notes/known-issues.md +24 -0
  54. data/docs/release-notes/toc.yml +3 -0
  55. data/lib/elastic_apm/context_builder.rb +15 -7
  56. data/lib/elastic_apm/metadata/cloud_info.rb +9 -7
  57. data/lib/elastic_apm/metrics.rb +24 -20
  58. data/lib/elastic_apm/span_helpers.rb +6 -6
  59. data/lib/elastic_apm/spies/action_dispatch.rb +11 -3
  60. data/lib/elastic_apm/spies/faraday.rb +8 -1
  61. data/lib/elastic_apm/spies/sidekiq.rb +2 -1
  62. data/lib/elastic_apm/stacktrace_builder.rb +3 -3
  63. data/lib/elastic_apm/version.rb +1 -1
  64. data/updatecli-compose.yaml +23 -0
  65. metadata +52 -44
  66. data/.ci/.jenkins_exclude.yml +0 -191
  67. data/.ci/.jenkins_ruby.yml +0 -10
  68. data/.ci/.jenkins_ruby_benchmarks.yml +0 -6
  69. data/.ci/Jenkinsfile +0 -450
  70. data/.ci/jobs/apm-agent-ruby-downstream.yml +0 -38
  71. data/.ci/jobs/apm-agent-ruby-linting-mbp.yml +0 -39
  72. data/.ci/jobs/apm-agent-ruby-mbp.yml +0 -43
  73. data/.ci/jobs/apm-agent-ruby.yml +0 -4
  74. data/.ci/jobs/defaults.yml +0 -24
  75. data/.ci/linting.groovy +0 -32
  76. data/.ci/packer_cache.sh +0 -16
  77. data/.ci/snapshoty.yml +0 -34
  78. data/.ci/update-specs.yml +0 -108
  79. data/.github/workflows/update-specs.yml +0 -30
  80. data/CHANGELOG.asciidoc +0 -951
  81. data/docs/advanced.asciidoc +0 -14
  82. data/docs/api.asciidoc +0 -487
  83. data/docs/configuration.asciidoc +0 -888
  84. data/docs/custom-instrumentation.asciidoc +0 -80
  85. data/docs/debugging.asciidoc +0 -44
  86. data/docs/getting-started-rails.asciidoc +0 -30
  87. data/docs/graphql.asciidoc +0 -23
  88. data/docs/index.asciidoc +0 -38
  89. data/docs/introduction.asciidoc +0 -36
  90. data/docs/metrics.asciidoc +0 -235
  91. data/docs/opentracing.asciidoc +0 -94
  92. data/docs/performance-tuning.asciidoc +0 -106
  93. data/docs/release-notes.asciidoc +0 -15
  94. data/docs/set-up.asciidoc +0 -19
  95. data/docs/supported-technologies.asciidoc +0 -157
  96. data/docs/upgrading.asciidoc +0 -18
  97. /data/.ci/{.jenkins_codecov.yml → .codecov.yml} +0 -0
  98. /data/.ci/{.jenkins_main_framework.yml → .main_framework.yml} +0 -0
  99. /data/docs/{images → reference/images}/dynamic-config.svg +0 -0
@@ -0,0 +1,86 @@
1
+ name: release
2
+
3
+ on:
4
+ push:
5
+ tags:
6
+ - "v[0-9]+*"
7
+ branches:
8
+ - main
9
+
10
+ permissions:
11
+ contents: read
12
+
13
+ jobs:
14
+ release:
15
+ runs-on: ubuntu-latest
16
+ permissions:
17
+ attestations: write
18
+ contents: write
19
+ id-token: write
20
+ steps:
21
+ - uses: actions/checkout@v4
22
+ - uses: ruby/setup-ruby@v1
23
+ with:
24
+ ruby-version: 2.6
25
+ - name: RubyGems login
26
+ run: |
27
+ RUBY_HOME="${HOME}/.gem"
28
+ RUBY_CREDENTIALS_FILE="${RUBY_HOME}/credentials"
29
+ mkdir -p "${RUBY_HOME}"
30
+ echo '---' > "${RUBY_CREDENTIALS_FILE}"
31
+ echo ":rubygems_api_key: ${{ secrets.RUBYGEMS_API_KEY }}" >> "${RUBY_CREDENTIALS_FILE}"
32
+ chmod 0600 "${RUBY_CREDENTIALS_FILE}"
33
+
34
+ - name: Install build system
35
+ run: .ci/scripts/install-build-system.sh
36
+
37
+ - name: rake release (only for tags)
38
+ run: rake release
39
+ if: startsWith(github.ref, 'refs/tags')
40
+
41
+ - name: rake build
42
+ run: rake build
43
+ if: ${{ ! startsWith(github.ref, 'refs/tags') }}
44
+
45
+ - name: generate build provenance
46
+ uses: actions/attest-build-provenance@db473fddc028af60658334401dc6fa3ffd8669fd # v2.3.0
47
+ with:
48
+ subject-path: "${{ github.workspace }}/pkg/*.gem"
49
+
50
+ update-branch:
51
+ needs:
52
+ - release
53
+ runs-on: ubuntu-latest
54
+ permissions:
55
+ contents: write
56
+ steps:
57
+ - uses: actions/checkout@v4
58
+ - uses: ruby/setup-ruby@v1
59
+ with:
60
+ ruby-version: 2.6
61
+ - name: Setup Git
62
+ uses: elastic/oblt-actions/git/setup@v1
63
+ - name: Install build system
64
+ run: .ci/scripts/install-build-system.sh
65
+ - name: rake release:update_branch (only for tags)
66
+ run: rake release:update_branch
67
+ if: startsWith(github.ref, 'refs/tags')
68
+
69
+ status:
70
+ if: always()
71
+ runs-on: ubuntu-latest
72
+ needs:
73
+ - release
74
+ - update-branch
75
+ steps:
76
+ - id: check
77
+ uses: elastic/oblt-actions/check-dependent-jobs@v1
78
+ with:
79
+ jobs: ${{ toJSON(needs) }}
80
+ - run: ${{ steps.check.outputs.is-success }}
81
+ - if: ${{ always() && startsWith(github.ref, 'refs/tags') }}
82
+ uses: elastic/oblt-actions/slack/notify-result@v1
83
+ with:
84
+ bot-token: ${{ secrets.SLACK_BOT_TOKEN }}
85
+ channel-id: "#apm-agent-ruby"
86
+ message: ":traffic_cone: updatecli failed for `${{ github.repository }}@${{ github.ref_name }}`, @robots-ci please look what's going on <https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}|here>"
@@ -0,0 +1,68 @@
1
+ ---
2
+ # Runs the tests based on the provided files in ci.yml
3
+ name: run-matrix
4
+
5
+ on:
6
+ workflow_call:
7
+ inputs:
8
+ versionsFile:
9
+ required: true
10
+ type: string
11
+ frameworksFile:
12
+ required: true
13
+ type: string
14
+ excludedFile:
15
+ required: true
16
+ type: string
17
+
18
+ permissions:
19
+ contents: read
20
+
21
+ jobs:
22
+ create-test-matrix:
23
+ runs-on: ubuntu-latest
24
+ outputs:
25
+ matrix: ${{ steps.generate.outputs.matrix }}
26
+ steps:
27
+ - uses: actions/checkout@v4
28
+ - id: generate
29
+ uses: elastic/oblt-actions/version-framework@v1
30
+ with:
31
+ versions-file: ${{ inputs.versionsFile }}
32
+ frameworks-file: ${{ inputs.frameworksFile }}
33
+ excluded-file: ${{ inputs.excludedFile }}
34
+ test:
35
+ needs:
36
+ - create-test-matrix
37
+ runs-on: ubuntu-latest
38
+ strategy:
39
+ fail-fast: false
40
+ max-parallel: 20
41
+ matrix: ${{ fromJSON(needs.create-test-matrix.outputs.matrix) }}
42
+ steps:
43
+ - uses: actions/checkout@v4
44
+ - name: Run BDD tests
45
+ run: ./spec/scripts/features.sh ${{ matrix.version }}
46
+ - name: Run test
47
+ run: ./spec/scripts/spec.sh ${{ matrix.version }} ${{ matrix.framework }}
48
+ env:
49
+ JUNIT_PREFIX: ${{ matrix.version }}-${{ matrix.framework }}
50
+
51
+ - if: success() || failure()
52
+ id: normalize-junit
53
+ uses: actions/github-script@v7
54
+ with:
55
+ result-encoding: string
56
+ script: |
57
+ function normalizeName(name) {
58
+ return name.replace(/["/:<>|*?\\]/g, '-')
59
+ }
60
+ const framework = normalizeName('${{ matrix.framework }}')
61
+ const version = normalizeName('${{ matrix.version }}')
62
+ return `${version}-${framework}`
63
+ - if: success() || failure()
64
+ name: Upload JUnit Test Results
65
+ uses: actions/upload-artifact@v4
66
+ with:
67
+ name: test-results-${{ steps.normalize-junit.outputs.result }}
68
+ path: "**/spec/junit-reports/**/*ruby-agent-junit.xml"
@@ -0,0 +1,25 @@
1
+ ---
2
+ ## Workflow to process the JUnit test results and add a report to the checks.
3
+ name: test-reporter
4
+ on:
5
+ workflow_run:
6
+ workflows:
7
+ - ci
8
+ types:
9
+ - completed
10
+
11
+ permissions:
12
+ contents: read
13
+ actions: read
14
+ checks: write
15
+
16
+ jobs:
17
+ report:
18
+ runs-on: ubuntu-latest
19
+ steps:
20
+ - uses: elastic/oblt-actions/test-report@v1
21
+ with:
22
+ artifact: /test-results(.*)/
23
+ name: 'Test Report $1'
24
+ path: "**/*ruby-agent-junit.xml"
25
+ reporter: java-junit
@@ -0,0 +1,61 @@
1
+ name: updatecli
2
+
3
+ on:
4
+ workflow_dispatch: ~
5
+ schedule:
6
+ - cron: '0 6 * * *'
7
+
8
+ permissions:
9
+ contents: read
10
+
11
+ jobs:
12
+ compose:
13
+ runs-on: ubuntu-latest
14
+ permissions:
15
+ contents: read
16
+ packages: read
17
+ steps:
18
+ - uses: actions/checkout@v4
19
+
20
+ - name: Get token
21
+ id: get_token
22
+ uses: tibdex/github-app-token@3beb63f4bd073e61482598c45c71c1019b59b73a # v2.1.0
23
+ with:
24
+ app_id: ${{ secrets.OBS_AUTOMATION_APP_ID }}
25
+ private_key: ${{ secrets.OBS_AUTOMATION_APP_PEM }}
26
+ permissions: >-
27
+ {
28
+ "contents": "write",
29
+ "pull_requests": "write"
30
+ }
31
+
32
+ - uses: docker/login-action@74a5d142397b4f367a81961eba4e8cd7edddf772 # v3.4.0
33
+ with:
34
+ registry: ghcr.io
35
+ username: ${{ github.actor }}
36
+ password: ${{ secrets.GITHUB_TOKEN }}
37
+
38
+ - uses: elastic/oblt-actions/updatecli/run@v1
39
+ with:
40
+ command: --experimental compose diff
41
+ # TODO: update to the latest version so the policies can work as expected.
42
+ # latest changes in the policies require to use the dependson feature.
43
+ version: "v0.88.0"
44
+ env:
45
+ GITHUB_TOKEN: ${{ steps.get_token.outputs.token }}
46
+
47
+ - uses: elastic/oblt-actions/updatecli/run@v1
48
+ with:
49
+ command: --experimental compose apply
50
+ # TODO: update to the latest version so the policies can work as expected.
51
+ # latest changes in the policies require to use the dependson feature.
52
+ version: "v0.88.0"
53
+ env:
54
+ GITHUB_TOKEN: ${{ steps.get_token.outputs.token }}
55
+
56
+ - if: failure()
57
+ uses: elastic/oblt-actions/slack/send@v1
58
+ with:
59
+ bot-token: ${{ secrets.SLACK_BOT_TOKEN }}
60
+ channel-id: "#apm-agent-ruby"
61
+ message: ":traffic_cone: updatecli failed for `${{ github.repository }}@${{ github.ref_name }}`, @robots-ci please look what's going on <https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}|here>"
@@ -13,6 +13,4 @@ repos:
13
13
  rev: current
14
14
  hooks:
15
15
  - id: check-bash-syntax
16
- - id: check-jenkins-pipelines
17
- - id: check-jjbb
18
16
  - id: check-unicode-non-breaking-spaces
data/Gemfile CHANGED
@@ -41,9 +41,14 @@ gem 'ecs-logging', require: 'ecs_logging/logger'
41
41
  gem 'elasticsearch', require: nil
42
42
  gem 'fakeredis', require: nil
43
43
  gem 'faraday', require: nil
44
- gem 'graphql', require: nil
45
- if !defined?(JRUBY_VERSION) && RUBY_VERSION < '2.5'
46
- gem 'google-protobuf', '< 3.12'
44
+ if RUBY_VERSION < '2.7'
45
+ gem 'graphql', '< 2.1', require: nil
46
+ else
47
+ gem 'graphql', require: nil
48
+ end
49
+ if !defined?(JRUBY_VERSION)
50
+ gem 'google-protobuf', '< 3.12' if RUBY_VERSION < '2.5'
51
+ gem 'google-protobuf', '< 3.23' if RUBY_VERSION < '2.7' && RUBY_VERSION > '2.5'
47
52
  end
48
53
  gem 'grpc' if !defined?(JRUBY_VERSION) && RUBY_VERSION < '3.0'
49
54
  gem 'json'
@@ -62,6 +67,10 @@ gem 'sucker_punch', '~> 2.0', require: nil
62
67
  gem 'yard', require: nil
63
68
  gem 'yarjuf'
64
69
 
70
+ if RUBY_VERSION < '2.5'
71
+ gem 'loofah', '~> 2.20.0', require: nil
72
+ end
73
+
65
74
  ## Install Framework
66
75
  GITHUB_REPOS = {
67
76
  'grape' => 'ruby-grape/grape',
@@ -82,6 +91,10 @@ frameworks_versions.each do |framework, version|
82
91
  gem 'net-smtp', require: false
83
92
  end
84
93
 
94
+ if framework =='rails' && RUBY_VERSION >= '3.4' && ['4.2', '5.2', '6.1'].include?(version)
95
+ gem 'mutex_m'
96
+ end
97
+
85
98
  case version
86
99
  when 'master' # grape
87
100
  gem framework, github: GITHUB_REPOS.fetch(framework)
@@ -94,6 +107,11 @@ frameworks_versions.each do |framework, version|
94
107
  end
95
108
  end
96
109
 
110
+ # Handle Rack::Auth::Digest being removed in rack 3.1, grape requires it
111
+ if frameworks_versions.key?('grape')
112
+ gem 'rack', '~> 3.0.0'
113
+ end
114
+
97
115
  if frameworks_versions.key?('rails')
98
116
  unless /^(main|6)/.match?(frameworks_versions['rails'])
99
117
  gem 'delayed_job', require: nil
@@ -116,8 +134,12 @@ if RUBY_PLATFORM == 'java'
116
134
  end
117
135
  elsif frameworks_versions['rails'] =~ /^(4|5)/
118
136
  gem 'sqlite3', '~> 1.3.6'
137
+ elsif frameworks_versions['rails'] =~ /^(6|7)/
138
+ gem 'sqlite3', '~> 1.4'
119
139
  elsif RUBY_VERSION < '2.7'
120
140
  gem 'sqlite3', '~> 1.4.4'
141
+ elsif RUBY_VERSION < '3.0'
142
+ gem 'sqlite3', '~> 1.3.6'
121
143
  else
122
144
  gem 'sqlite3'
123
145
  end
@@ -127,6 +149,10 @@ if Gem::Version.create(RUBY_VERSION) >= Gem::Version.create('2.5.0') && !defined
127
149
  gem 'sneakers', github: 'jondot/sneakers', ref: 'd761dfe1493', require: nil
128
150
  end
129
151
 
152
+ if Gem::Version.create(RUBY_VERSION) <= Gem::Version.create('2.5.0')
153
+ gem 'bigdecimal', '1.3.5'
154
+ end
155
+
130
156
  group :bench do
131
157
  gem 'ruby-prof', require: nil, platforms: %i[ruby]
132
158
  gem 'stackprof', require: nil, platforms: %i[ruby]
data/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  ## Elastic APM agent for Ruby
4
4
 
5
- [![Jenkins](https://apm-ci.elastic.co/buildStatus/icon?job=apm-agent-ruby/apm-agent-ruby-mbp/main)](https://apm-ci.elastic.co/job/apm-agent-ruby/job/apm-agent-ruby-mbp/job/main/) [![Gem](https://img.shields.io/gem/v/elastic-apm.svg)](https://rubygems.org/gems/elastic-apm)
5
+ [![ci](https://github.com/elastic/apm-agent-ruby/actions/workflows/ci.yml/badge.svg)](https://github.com/elastic/apm-agent-ruby/actions/workflows/ci.yml) [![Gem](https://img.shields.io/gem/v/elastic-apm.svg)](https://rubygems.org/gems/elastic-apm)
6
6
 
7
7
  The official Rubygem for [Elastic][] [APM][].
8
8
 
data/bench/rubyprof.rb CHANGED
@@ -1,3 +1,4 @@
1
+ #!/usr/bin/env ruby
1
2
  # frozen_string_literal: true
2
3
 
3
4
  require 'ruby-prof'
data/bin/dev CHANGED
@@ -40,7 +40,7 @@ def run(cmd)
40
40
  end
41
41
 
42
42
  unless options[:skip_build]
43
- run 'docker-compose build ' \
43
+ run 'docker compose build ' \
44
44
  " --build-arg RUBY_IMAGE=#{RUBY_IMAGE}" \
45
45
  " --build-arg USER_ID_GROUP=#{USER_ID_GROUP}" \
46
46
  " --build-arg FRAMEWORKS=#{FRAMEWORKS}" \
@@ -48,7 +48,7 @@ unless options[:skip_build]
48
48
  exit $?.exitstatus unless $?.success?
49
49
  end
50
50
 
51
- run 'docker-compose run' \
51
+ run 'docker compose run' \
52
52
  " -u #{USER_ID_GROUP}" \
53
53
  ' --rm' \
54
54
  " specs #{ARGV.join}"
data/bin/run-tests CHANGED
@@ -1,6 +1,8 @@
1
1
  #!/bin/bash
2
2
  set -e
3
3
 
4
+ JUNIT_PREFIX=${JUNIT_PREFIX:-""}
5
+
4
6
  runRspec(){
5
7
  local case=${1:-""}
6
8
  local bn=${case}
@@ -8,9 +10,16 @@ runRspec(){
8
10
  if [ -n "${case}" ]; then
9
11
  bn="$(basename ${case} _spec.rb)/"
10
12
  fi
13
+ # If working on an isolated environment then copy the file to
14
+ # the original location
15
+ TEST_REPORT_DIR=spec/junit-reports/${JUNIT_PREFIX}${bn}
16
+ if [ -n "$APP_PATH" ] ; then
17
+ TEST_REPORT_DIR=$APP_PATH/$TEST_REPORT_DIR
18
+ mkdir -p $TEST_REPORT_DIR
19
+ fi
11
20
  bundle exec rspec \
12
21
  -f progress \
13
- -r yarjuf -f JUnit -o spec/junit-reports/${bn}ruby-agent-junit.xml \
22
+ -r yarjuf -f JUnit -o ${TEST_REPORT_DIR}ruby-agent-junit.xml \
14
23
  ${case}
15
24
  }
16
25
  specific_spec=$1
data/docker-compose.yml CHANGED
@@ -35,8 +35,11 @@ services:
35
35
  ruby_rspec:
36
36
  image: apm-agent-ruby:${RUBY_VERSION}
37
37
  environment:
38
+ APP_PATH: /opt/app
39
+ FRAMEWORK: rails
40
+ LOCAL_USER_ID: ${LOCAL_USER_ID}
41
+ LOCAL_GROUP_ID: ${LOCAL_GROUP_ID}
38
42
  MONGODB_URL: 'mongodb:27017'
39
- user: ${USER_ID}
40
43
  security_opt:
41
44
  - no-new-privileges
42
45
 
data/docs/docset.yml ADDED
@@ -0,0 +1,9 @@
1
+ project: 'APM Ruby agent docs'
2
+ cross_links:
3
+ - apm-agent-rum-js
4
+ - docs-content
5
+ - ecs-logging
6
+ - ecs-logging-ruby
7
+ toc:
8
+ - toc: reference
9
+ - toc: release-notes
@@ -0,0 +1,12 @@
1
+ ---
2
+ mapped_pages:
3
+ - https://www.elastic.co/guide/en/apm/agent/ruby/current/advanced.html
4
+ ---
5
+
6
+ # Advanced topics [advanced]
7
+
8
+ * [Adding additional context](/reference/context.md)
9
+ * [Custom instrumentation](/reference/custom-instrumentation.md)
10
+
11
+
12
+