elastic-apm 4.5.1 → 4.7.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (88) hide show
  1. checksums.yaml +4 -4
  2. data/.ci/.exclude.yml +193 -0
  3. data/.ci/{.jenkins_framework.yml → .framework.yml} +3 -2
  4. data/.ci/.main_framework.yml +4 -0
  5. data/.ci/.ruby.yml +10 -0
  6. data/.ci/docker/jruby/11-jdk/Dockerfile +8 -3
  7. data/.ci/docker/jruby/12-jdk/Dockerfile +5 -2
  8. data/.ci/docker/jruby/13-jdk/Dockerfile +5 -2
  9. data/.ci/docker/jruby/7-jdk/Dockerfile +6 -3
  10. data/.ci/docker/jruby/8-jdk/Dockerfile +8 -3
  11. data/.ci/docker/jruby/README.md +1 -1
  12. data/.ci/docker/jruby/run.sh +33 -9
  13. data/.ci/docker/jruby/test.sh +17 -2
  14. data/.ci/scripts/bench.sh +52 -0
  15. data/.ci/scripts/install-build-system.sh +5 -0
  16. data/.ci/snapshoty.yml +33 -0
  17. data/.ci/updatecli.d/update-gherkin-specs.yml +126 -0
  18. data/.ci/updatecli.d/update-json-specs.yml +130 -0
  19. data/.ci/updatecli.d/update-specs.yml +118 -0
  20. data/.github/dependabot.yml +17 -1
  21. data/.github/workflows/README.md +58 -0
  22. data/.github/workflows/ci-docs.yml +20 -0
  23. data/.github/workflows/ci.yml +70 -0
  24. data/.github/workflows/coverage-reporter.yml +34 -0
  25. data/.github/workflows/microbenchmark.yml +48 -0
  26. data/.github/workflows/opentelemetry.yml +27 -0
  27. data/.github/workflows/release.yml +71 -0
  28. data/.github/workflows/run-matrix.yml +56 -0
  29. data/.github/workflows/snapshoty.yml +35 -0
  30. data/.github/workflows/test-reporter.yml +24 -0
  31. data/.github/workflows/updatecli.yml +28 -0
  32. data/.pre-commit-config.yaml +0 -2
  33. data/CHANGELOG.asciidoc +73 -1
  34. data/CONTRIBUTING.md +1 -1
  35. data/Gemfile +28 -8
  36. data/README.md +1 -1
  37. data/Rakefile +2 -2
  38. data/bench/report.rb +1 -1
  39. data/bench/rubyprof.rb +1 -0
  40. data/bin/run-tests +10 -1
  41. data/docker-compose.yml +10 -1
  42. data/docs/configuration.asciidoc +12 -9
  43. data/docs/index.asciidoc +2 -2
  44. data/docs/{log-correlation.asciidoc → logs.asciidoc} +29 -2
  45. data/docs/opentracing.asciidoc +1 -1
  46. data/docs/redirects.asciidoc +9 -0
  47. data/elastic-apm.gemspec +3 -2
  48. data/lib/elastic_apm/central_config.rb +5 -0
  49. data/lib/elastic_apm/config/server_info.rb +50 -0
  50. data/lib/elastic_apm/config.rb +25 -4
  51. data/lib/elastic_apm/context_builder.rb +6 -3
  52. data/lib/elastic_apm/error.rb +2 -1
  53. data/lib/elastic_apm/error_builder.rb +1 -0
  54. data/lib/elastic_apm/instrumenter.rb +4 -2
  55. data/lib/elastic_apm/metadata/cloud_info.rb +9 -7
  56. data/lib/elastic_apm/metadata/system_info/container_info.rb +4 -3
  57. data/lib/elastic_apm/metadata/system_info.rb +1 -1
  58. data/lib/elastic_apm/metrics.rb +24 -20
  59. data/lib/elastic_apm/span/context/links.rb +32 -0
  60. data/lib/elastic_apm/span/context/service.rb +55 -0
  61. data/lib/elastic_apm/span/context.rb +19 -3
  62. data/lib/elastic_apm/span.rb +3 -0
  63. data/lib/elastic_apm/span_helpers.rb +8 -8
  64. data/lib/elastic_apm/spies/action_dispatch.rb +11 -3
  65. data/lib/elastic_apm/spies/faraday.rb +20 -4
  66. data/lib/elastic_apm/spies/racecar.rb +77 -0
  67. data/lib/elastic_apm/spies/redis.rb +1 -1
  68. data/lib/elastic_apm/spies/sequel.rb +9 -0
  69. data/lib/elastic_apm/spies/sqs.rb +1 -0
  70. data/lib/elastic_apm/trace_context/tracestate.rb +4 -2
  71. data/lib/elastic_apm/trace_context.rb +1 -1
  72. data/lib/elastic_apm/transport/connection/http.rb +9 -3
  73. data/lib/elastic_apm/transport/serializers/span_serializer.rb +25 -0
  74. data/lib/elastic_apm/version.rb +1 -1
  75. data/lib/elastic_apm.rb +1 -0
  76. metadata +46 -17
  77. data/.ci/.jenkins_exclude.yml +0 -134
  78. data/.ci/.jenkins_main_framework.yml +0 -4
  79. data/.ci/.jenkins_ruby.yml +0 -10
  80. data/.ci/Jenkinsfile +0 -441
  81. data/.ci/jobs/apm-agent-ruby-downstream.yml +0 -38
  82. data/.ci/jobs/apm-agent-ruby-linting-mbp.yml +0 -39
  83. data/.ci/jobs/apm-agent-ruby-mbp.yml +0 -43
  84. data/.ci/jobs/apm-agent-ruby.yml +0 -4
  85. data/.ci/jobs/defaults.yml +0 -24
  86. data/.ci/linting.groovy +0 -32
  87. data/.ci/packer_cache.sh +0 -16
  88. /data/.ci/{.jenkins_codecov.yml → .codecov.yml} +0 -0
@@ -0,0 +1,71 @@
1
+ name: release
2
+
3
+ on:
4
+ push:
5
+ tags:
6
+ - "v[0-9]+*"
7
+
8
+ permissions:
9
+ contents: write
10
+
11
+ jobs:
12
+ release:
13
+ runs-on: ubuntu-latest
14
+ steps:
15
+ - uses: actions/checkout@v3
16
+ - uses: ruby/setup-ruby@v1
17
+ with:
18
+ ruby-version: 2.6
19
+ - uses: hashicorp/vault-action@v2.4.2
20
+ with:
21
+ url: ${{ secrets.VAULT_ADDR }}
22
+ method: approle
23
+ roleId: ${{ secrets.VAULT_ROLE_ID }}
24
+ secretId: ${{ secrets.VAULT_SECRET_ID }}
25
+ secrets: |
26
+ secret/apm-team/ci/apm-agent-ruby-rubygems-release apiKey | API_KEY ;
27
+ - name: RubyGems login
28
+ run: |
29
+ RUBY_HOME="${HOME}/.gem"
30
+ RUBY_CREDENTIALS_FILE="${RUBY_HOME}/credentials"
31
+ mkdir -p "${RUBY_HOME}"
32
+ echo '---' > "${RUBY_CREDENTIALS_FILE}"
33
+ echo ":rubygems_api_key: ${API_KEY}" >> "${RUBY_CREDENTIALS_FILE}"
34
+ chmod 0600 "${RUBY_CREDENTIALS_FILE}"
35
+ - name: Install build system
36
+ run: .ci/scripts/install-build-system.sh
37
+ - run: rake release
38
+ update-branch:
39
+ needs:
40
+ - release
41
+ runs-on: ubuntu-latest
42
+ steps:
43
+ - uses: actions/checkout@v3
44
+ - uses: ruby/setup-ruby@v1
45
+ with:
46
+ ruby-version: 2.6
47
+ - name: Setup Git
48
+ uses: elastic/apm-pipeline-library/.github/actions/setup-git@current
49
+ - name: Install build system
50
+ run: .ci/scripts/install-build-system.sh
51
+ - run: rake release:update_branch
52
+
53
+ status:
54
+ if: always()
55
+ runs-on: ubuntu-latest
56
+ needs:
57
+ - release
58
+ - update-branch
59
+ steps:
60
+ - id: check
61
+ uses: elastic/apm-pipeline-library/.github/actions/check-dependent-jobs@current
62
+ with:
63
+ needs: ${{ toJSON(needs) }}
64
+ - run: ${{ steps.check.outputs.isSuccess }}
65
+ - if: always()
66
+ uses: elastic/apm-pipeline-library/.github/actions/notify-build-status@current
67
+ with:
68
+ vaultUrl: ${{ secrets.VAULT_ADDR }}
69
+ vaultRoleId: ${{ secrets.VAULT_ROLE_ID }}
70
+ vaultSecretId: ${{ secrets.VAULT_SECRET_ID }}
71
+ slackChannel: "#apm-agent-ruby"
@@ -0,0 +1,56 @@
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
+ jobs:
19
+ create-test-matrix:
20
+ runs-on: ubuntu-latest
21
+ outputs:
22
+ matrix: ${{ steps.generate.outputs.matrix }}
23
+ steps:
24
+ - uses: actions/checkout@v3
25
+ - id: generate
26
+ uses: elastic/apm-pipeline-library/.github/actions/version-framework@current
27
+ with:
28
+ versionsFile: ${{ inputs.versionsFile }}
29
+ frameworksFile: ${{ inputs.frameworksFile }}
30
+ excludedFile: ${{ inputs.excludedFile }}
31
+ test:
32
+ needs:
33
+ - create-test-matrix
34
+ runs-on: ubuntu-latest
35
+ strategy:
36
+ fail-fast: false
37
+ max-parallel: 20
38
+ matrix: ${{ fromJSON(needs.create-test-matrix.outputs.matrix) }}
39
+ steps:
40
+ - uses: actions/checkout@v3
41
+ - name: Run BDD tests
42
+ run: ./spec/scripts/features.sh ${{ matrix.version }}
43
+ - name: Run test
44
+ run: ./spec/scripts/spec.sh ${{ matrix.version }} ${{ matrix.framework }}
45
+ env:
46
+ JUNIT_PREFIX: ${{ matrix.version }}-${{ matrix.framework }}
47
+ - if: success() || failure()
48
+ uses: actions/upload-artifact@v3
49
+ with:
50
+ name: test-results
51
+ path: "**/spec/junit-reports/**/*ruby-agent-junit.xml"
52
+ - if: success() || failure()
53
+ uses: actions/upload-artifact@v3
54
+ with:
55
+ name: coverage
56
+ path: "coverage/"
@@ -0,0 +1,35 @@
1
+ name: snapshoty
2
+
3
+ on:
4
+ workflow_run:
5
+ workflows:
6
+ - ci
7
+ types:
8
+ - completed
9
+ branches:
10
+ - main
11
+
12
+ permissions:
13
+ contents: read
14
+
15
+ jobs:
16
+ publish:
17
+ if: ${{ github.event.workflow_run.conclusion == 'success' }}
18
+ runs-on: ubuntu-latest
19
+ steps:
20
+ - uses: actions/checkout@v3
21
+ - name: Download artifacts
22
+ run: >
23
+ gh run download ${{ github.event.workflow_run.id }}
24
+ --name package
25
+ --repo "${GITHUB_REPOSITORY}"
26
+ --dir pkg
27
+ env:
28
+ GH_TOKEN: ${{ github.token }}
29
+ - name: Publish snapshot
30
+ uses: elastic/apm-pipeline-library/.github/actions/snapshoty-simple@current
31
+ with:
32
+ config: '.ci/snapshoty.yml'
33
+ vaultUrl: ${{ secrets.VAULT_ADDR }}
34
+ vaultRoleId: ${{ secrets.VAULT_ROLE_ID }}
35
+ vaultSecretId: ${{ secrets.VAULT_SECRET_ID }}
@@ -0,0 +1,24 @@
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
+ checks: write
14
+
15
+ jobs:
16
+ report:
17
+ runs-on: ubuntu-latest
18
+ steps:
19
+ - uses: elastic/apm-pipeline-library/.github/actions/test-report@current
20
+ with:
21
+ artifact: test-results
22
+ name: test-report
23
+ path: "**/*ruby-agent-junit.xml"
24
+ reporter: java-junit
@@ -0,0 +1,28 @@
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
+ bump:
13
+ runs-on: ubuntu-latest
14
+ steps:
15
+ - uses: actions/checkout@v3
16
+ - uses: elastic/apm-pipeline-library/.github/actions/updatecli@current
17
+ with:
18
+ vaultUrl: ${{ secrets.VAULT_ADDR }}
19
+ vaultRoleId: ${{ secrets.VAULT_ROLE_ID }}
20
+ vaultSecretId: ${{ secrets.VAULT_SECRET_ID }}
21
+ pipeline: .ci/updatecli.d
22
+ - if: failure()
23
+ uses: elastic/apm-pipeline-library/.github/actions/notify-build-status@current
24
+ with:
25
+ vaultUrl: ${{ secrets.VAULT_ADDR }}
26
+ vaultRoleId: ${{ secrets.VAULT_ROLE_ID }}
27
+ vaultSecretId: ${{ secrets.VAULT_SECRET_ID }}
28
+ slackChannel: "#apm-agent-ruby"
@@ -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/CHANGELOG.asciidoc CHANGED
@@ -25,7 +25,6 @@ endif::[]
25
25
 
26
26
  [float]
27
27
  ===== Fixed
28
- - Fix {pull}2526[#2526]
29
28
 
30
29
  [float]
31
30
  [[unreleased]]
@@ -35,6 +34,79 @@ endif::[]
35
34
  [[release-notes-4.x]]
36
35
  === Ruby Agent version 4.x
37
36
 
37
+ [[release-notes-4.7.2]
38
+ ==== 4.7.2
39
+
40
+ [float]
41
+ ===== Fixed
42
+ - Address machineType not being returned in GCP metadata {pull}1435[#1435]
43
+
44
+ [[release-notes-4.7.1]
45
+ ==== 4.7.1
46
+
47
+ [float]
48
+ ===== Fixed
49
+ - Skip capturing cookie header when it's set separately {pull}1405[#1405]
50
+ - Changes/fixes to metadata.cloud.* fields collected for GCP {pull}1415[#1415]
51
+ - Pin version of bigdecimal for ruby 2.4 {pull}1417[#1417]
52
+ - Use response method on Faraday error for older versions of the library {pull}1419[#1419]
53
+ - Fix ActionDispatchSpy#render_exception for Rails 7.1 {pull}1423[#1423]
54
+ - Use graphql < 2.1 when Ruby < 2.7 {pull}1425[#1425]
55
+ - Guard against various Faraday exception response formats {pull}1428[#1428]
56
+
57
+ [[release-notes-4.7.0]]
58
+ ==== 4.7.0
59
+
60
+ [float]
61
+ ===== Fixed
62
+ - Handle Faraday response being nil {pull}1382[#1382]
63
+ - Fix error with invalid %-encoding {pull}1400[#1400]
64
+
65
+ [float]
66
+ ===== Added
67
+ - Add keyword args for span_method helper {pull}1395[#1395]
68
+
69
+ [[release-notes-4.6.2]]
70
+ ==== 4.6.2
71
+
72
+ [float]
73
+ ===== Fixed
74
+ - Fix Faraday::RackBuilder::StackLocked {pull}1371[#1371]
75
+
76
+ [[release-notes-4.6.1]]
77
+ ==== 4.6.1
78
+
79
+ [float]
80
+ ===== Fixed
81
+
82
+ - Fix growing number of open file descriptors when HTTP request to APM is never sent {pull}1351[#1351]
83
+ - Fix setting span http status code when Faraday Middleware is used {pull}1368[#1368]
84
+ - Handle whitespace when splitting tracestate entries {pull}1353[#1353]
85
+
86
+ [[release-notes-4.6.0]]
87
+ ==== 4.6.0
88
+
89
+ [float]
90
+ ===== Added
91
+
92
+ - Added transaction_name to reported error to allow grouping by transaction name {pull}1267[#1267]
93
+ - Added ability to query server for version (useful in the future) {pull}1278[#1278]
94
+ - Added instrumentation for https://github.com/zendesk/racecar/ Racecar Kafka library {pull}1284[#1284]
95
+
96
+ ===== Changed
97
+
98
+ - Expanded filtering to sanitize any key that contains the string 'auth' {pull}1266[#1266]
99
+ - Rename `log_ecs_formatting` option to `log_ecs_reformatting`, deprecate old option name {pull}1248[#1248]
100
+ - When the configuration value for `log_path` is set, override the `logger` to point to that path instead of using e.g. Rails logger {pull}1247[#1247]
101
+ - Only send tracestate header for distributed tracing when it has content {pull}1277[#1277]
102
+ - Use the hostname as the Kubernetes pod name in the Container Info metadata if the pod id is parsed from cgroup {pull}1314[#1314]
103
+
104
+ ====== Fixed
105
+
106
+ - Small change to Sidekiq tests to handle new configuration passing method {pull}1283[#1283]
107
+ - Set transaction sample rate to 0 when it's unsampled {pull}1339[#1339]
108
+ - Don't send unsampled transactions to APM server >= 8.0 {pull}1341[#1341]
109
+
38
110
  [[release-notes-4.5.1]]
39
111
  ==== 4.5.1
40
112
 
data/CONTRIBUTING.md CHANGED
@@ -49,4 +49,4 @@ To release a new version:
49
49
  2. Push the tag to GitHub.
50
50
  3. Build the gem and upload to Rubygems (local user needs to be signed in and authorized.)
51
51
  1. Run `rake release:update_branch`. This will...
52
- 1. Update `3.x` branch to be at released commit and push it to GitHub.
52
+ 1. Update `4.x` branch to be at released commit and push it to GitHub.
data/Gemfile CHANGED
@@ -41,16 +41,22 @@ 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
- gem 'json', '2.6.2' # note: can be unpinned when https://github.com/flori/json/issues/495 is resolved
54
+ gem 'json'
50
55
  gem 'json-schema', require: nil
51
56
  gem 'mongo', require: nil
52
57
  gem 'opentracing', require: nil
53
58
  gem 'rake', '>= 13.0', require: nil
59
+ gem 'racecar', require: nil if !defined?(JRUBY_VERSION)
54
60
  gem 'resque', require: nil
55
61
  gem 'sequel', require: nil
56
62
  gem 'shoryuken', require: nil
@@ -61,6 +67,10 @@ gem 'sucker_punch', '~> 2.0', require: nil
61
67
  gem 'yard', require: nil
62
68
  gem 'yarjuf'
63
69
 
70
+ if RUBY_VERSION < '2.5'
71
+ gem 'loofah', '~> 2.20.0', require: nil
72
+ end
73
+
64
74
  ## Install Framework
65
75
  GITHUB_REPOS = {
66
76
  'grape' => 'ruby-grape/grape',
@@ -77,10 +87,14 @@ frameworks_versions = parsed_frameworks.inject({}) do |frameworks, str|
77
87
  end
78
88
 
79
89
  frameworks_versions.each do |framework, version|
90
+ if framework =='rails' && RUBY_VERSION >= '3.1'
91
+ gem 'net-smtp', require: false
92
+ end
93
+
80
94
  case version
81
- when 'master' # sinatra, grape
95
+ when 'master' # grape
82
96
  gem framework, github: GITHUB_REPOS.fetch(framework)
83
- when 'main' # rails
97
+ when 'main' # sinatra, rails
84
98
  gem framework, github: GITHUB_REPOS.fetch(framework), branch: 'main'
85
99
  when /.+/
86
100
  gem framework, "~> #{version}.0"
@@ -111,15 +125,21 @@ if RUBY_PLATFORM == 'java'
111
125
  end
112
126
  elsif frameworks_versions['rails'] =~ /^(4|5)/
113
127
  gem 'sqlite3', '~> 1.3.6'
128
+ elsif RUBY_VERSION < '2.7'
129
+ gem 'sqlite3', '~> 1.4.4'
114
130
  else
115
131
  gem 'sqlite3'
116
132
  end
117
133
 
118
- # current sneakers only supports >=2.5.0
119
- if Gem::Version.create(RUBY_VERSION) >= Gem::Version.create('2.5.0')
134
+ # sneakers main only supports >=2.5.0
135
+ if Gem::Version.create(RUBY_VERSION) >= Gem::Version.create('2.5.0') && !defined?(JRUBY_VERSION)
120
136
  gem 'sneakers', github: 'jondot/sneakers', ref: 'd761dfe1493', require: nil
121
137
  end
122
138
 
139
+ if Gem::Version.create(RUBY_VERSION) <= Gem::Version.create('2.5.0')
140
+ gem 'bigdecimal', '1.3.5'
141
+ end
142
+
123
143
  group :bench do
124
144
  gem 'ruby-prof', require: nil, platforms: %i[ruby]
125
145
  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/Rakefile CHANGED
@@ -24,9 +24,9 @@ desc 'Post release action:'\
24
24
 
25
25
  namespace :release do
26
26
  task :update_branch do
27
- `git checkout 3.x &&
27
+ `git checkout 4.x &&
28
28
  git rebase main &&
29
- git push origin 3.x &&
29
+ git push origin 4.x &&
30
30
  git checkout main`
31
31
  end
32
32
  end
data/bench/report.rb CHANGED
@@ -11,7 +11,7 @@ git_date = `git log -n 1 --pretty="format:%ai"`
11
11
  platform = Gem::Platform.local
12
12
 
13
13
  def doc(payload)
14
- puts({ index: { _index: "benchmark-ruby", _type: "_doc" } }.to_json)
14
+ puts({ index: { _index: "benchmark-ruby" } }.to_json)
15
15
  puts(payload.to_json)
16
16
  end
17
17
 
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/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
@@ -6,6 +6,8 @@ services:
6
6
  image: mongo:latest
7
7
  volumes: ['mongodata:/data/db']
8
8
  ports: ['27017:27017']
9
+ security_opt:
10
+ - no-new-privileges
9
11
 
10
12
  specs:
11
13
  build:
@@ -27,12 +29,19 @@ services:
27
29
  depends_on:
28
30
  - mongodb
29
31
  user: ${USER_ID}
32
+ security_opt:
33
+ - no-new-privileges
30
34
 
31
35
  ruby_rspec:
32
36
  image: apm-agent-ruby:${RUBY_VERSION}
33
37
  environment:
38
+ APP_PATH: /opt/app
39
+ FRAMEWORK: rails
40
+ LOCAL_USER_ID: ${LOCAL_USER_ID}
41
+ LOCAL_GROUP_ID: ${LOCAL_GROUP_ID}
34
42
  MONGODB_URL: 'mongodb:27017'
35
- user: ${USER_ID}
43
+ security_opt:
44
+ - no-new-privileges
36
45
 
37
46
  volumes:
38
47
  vendor:
@@ -24,7 +24,7 @@ When using this method, strings are split by comma, e.g.,
24
24
  [[configuration-precedence]]
25
25
  === Configuration precedence
26
26
 
27
- Options are applied in the following order (last one wins):
27
+ Options are applied in the following order (last one wins):
28
28
 
29
29
  1. Defaults
30
30
  2. Arguments to `ElasticAPM.start` / `Config.new`
@@ -170,7 +170,7 @@ WARNING: Secret tokens only provide any real security if your APM server uses TL
170
170
  |============
171
171
 
172
172
  This base64-encoded string is used to ensure that only your agents can send data to your APM server.
173
- The API key must be created using the {apm-guide-ref}/api-key.html[APM server command-line tool].
173
+ The API key must be created using the {apm-guide-ref}/api-key.html[APM server command-line tool].
174
174
 
175
175
  WARNING: API keys only provide any real security if your APM server uses TLS.
176
176
 
@@ -199,7 +199,7 @@ The <<config-log-path,logs>> should tell you what went wrong.
199
199
  | `ELASTIC_APM_API_REQUEST_SIZE` | `api_request_size` | `"750kb"`
200
200
  |============
201
201
 
202
- The maximum amount of bytes sent over one request to APM Server. The agent will open a new request when this limit is reached.
202
+ The maximum amount of bytes sent over one request to APM Server. The agent will open a new request when this limit is reached.
203
203
 
204
204
  This must be provided in *<<config-format-size, size format>>*.
205
205
 
@@ -301,7 +301,8 @@ If set to `true`, the client will poll the APM Server regularly for new agent co
301
301
 
302
302
  Usually APM Server determines how often to poll, but if not, set the default interval is 5 minutes.
303
303
 
304
- NOTE: This feature requires APM Server v7.3 or later and that the APM Server is configured with `kibana.enabled: true`.
304
+ NOTE: This feature requires APM Server v7.3 or later.
305
+ See {kibana-ref}/agent-configuration.html[APM Agent central configuration] for more information.
305
306
 
306
307
  [float]
307
308
  [[config-cloud-provider]]
@@ -506,12 +507,12 @@ Elastic APM can instrument your Rake tasks. This is an opt-in field, as they are
506
507
 
507
508
  [float]
508
509
  [[config-log-ecs-formatting]]
509
- ==== `log_ecs_formatting`
510
+ ==== `log_ecs_reformatting`
510
511
 
511
512
  [options="header"]
512
513
  |============
513
514
  | Environment | `Config` key | Default
514
- | `ELASTIC_APM_LOG_ECS_FORMATTING` | `log_ecs_formatting` | `off`
515
+ | `ELASTIC_APM_LOG_ECS_REFORMATTING` | `log_ecs_reformatting` | `off`
515
516
  |============
516
517
 
517
518
  This is an experimental option that configures the agent to use the logger from the `ecs-logging` gem. The two
@@ -520,7 +521,7 @@ valid options are `off` and `override`.
520
521
  Setting this option to `override` will set the agent logger to a `EcsLogging::Logger` instance and all logged output
521
522
  will be in ECS-compatible json.
522
523
 
523
- The `ecs-logging` gem must be installed before the agent is started. If `log_ecs_formatting` is set to `override`,
524
+ The `ecs-logging` gem must be installed before the agent is started. If `log_ecs_reformatting` is set to `override`,
524
525
  the agent will attempt to require the gem and if it cannot be loaded, it will fall back to using the standard Ruby
525
526
  `::Logger` and log the load error.
526
527
 
@@ -556,6 +557,8 @@ A path to a log file.
556
557
 
557
558
  By default Elastic APM logs to `stdout` or uses `Rails.log` when used with Rails.
558
559
 
560
+ If `log_path` is specified, this will override `Rails.log` to point to that path instead.
561
+
559
562
  This should support both absolute and relative paths. Please be sure the directory exists.
560
563
 
561
564
  [float]
@@ -654,7 +657,7 @@ when this option is false.
654
657
  [options="header"]
655
658
  |============
656
659
  | Environment | `Config` key | Default | Example
657
- | `ELASTIC_APM_SANITIZE_FIELD_NAMES` | `sanitize_field_names` | `"password,passwd,pwd,secret,*key,*token*,*session*,*credit*,*card*,authorization,set-cookie"` | `Auth*tion,abc*,*xyz`
660
+ | `ELASTIC_APM_SANITIZE_FIELD_NAMES` | `sanitize_field_names` | `"password,passwd,pwd,secret,*key,*token*,*session*,*credit*,*card*,*auth*,set-cookie"` | `Auth*tion,abc*,*xyz`
658
661
  |============
659
662
 
660
663
  Sometimes it is necessary to sanitize the data sent to Elastic APM to remove sensitive values.
@@ -699,7 +702,7 @@ The name of the given service node. This is optional, and if omitted, the APM
699
702
  Server will fall back on `system.container.id` if available, and
700
703
  `host.name` if necessary.
701
704
 
702
- This option allows you to set the node name manually to ensure it's unique and meaningful.
705
+ This option allows you to set the node name manually to ensure it's unique and meaningful.
703
706
 
704
707
  [float]
705
708
  [[config-service-version]]
data/docs/index.asciidoc CHANGED
@@ -23,12 +23,12 @@ include::./api.asciidoc[]
23
23
 
24
24
  include::./metrics.asciidoc[]
25
25
 
26
+ include::./logs.asciidoc[]
27
+
26
28
  include::./opentracing.asciidoc[]
27
29
 
28
30
  include::./graphql.asciidoc[]
29
31
 
30
- include::./log-correlation.asciidoc[]
31
-
32
32
  include::./performance-tuning.asciidoc[]
33
33
 
34
34
  include::./debugging.asciidoc[]
@@ -3,8 +3,26 @@ NOTE: For the best reading experience,
3
3
  please view this documentation at https://www.elastic.co/guide/en/apm/agent/ruby[elastic.co]
4
4
  endif::[]
5
5
 
6
- [[log-correlation]]
7
- == Log correlation
6
+ [[logs]]
7
+ == Logs
8
+
9
+ Elastic Ruby APM Agent provides the following log features:
10
+
11
+ - <<log-correlation-ids>>: Automatically inject correlation IDs that allow navigation between logs, traces and services.
12
+ - <<log-reformatting>>: Automatically reformat plaintext logs in {ecs-logging-ref}/intro.html[ECS logging] format.
13
+
14
+ Those features are part of {observability-guide}/application-logs.html[Application log ingestion strategies].
15
+
16
+ The {ecs-logging-ruby-ref}/intro.html[`ecs-logging-ruby`] library can also be used to format logs in the {ecs-logging-ref}/intro.html[ECS logging] format without an APM agent.
17
+ When deployed with the Ruby APM agent, the agent will provide <<log-correlation-ids,log correlation>> IDs.
18
+
19
+ [float]
20
+ [[log-correlation-ids]]
21
+ === Log correlation
22
+
23
+ {apm-guide-ref}/log-correlation.html[Log correlation] allows you to navigate to all logs belonging to a particular trace
24
+ and vice-versa: for a specific log, see in which context it has been logged and which parameters the user provided.
25
+
8
26
 
9
27
  Trace/log correlation can be set up in three different ways.
10
28
 
@@ -119,3 +137,12 @@ PUT _ingest/pipeline/extract_trace_id
119
137
  ----
120
138
 
121
139
  Please see {apm-guide-ref}/log-correlation.html[Observability integrations] for more information.
140
+
141
+ [float]
142
+ [[log-reformatting]]
143
+ === Log reformatting (experimental)
144
+
145
+ Log reformatting is controlled by the <<config-log-ecs-formatting, `log_ecs_reformatting`>> configuration option, and is disabled by default.
146
+
147
+ The reformatted logs will include both the <<log-correlation-ids, trace and service correlation>> IDs.
148
+
@@ -89,6 +89,6 @@ The `Span.set_baggage` method is not supported.
89
89
  Baggage items are dropped with a warning log message.
90
90
 
91
91
  [float]
92
- [[logs]]
92
+ [[opentracing-logs]]
93
93
  === Logs
94
94
  Logs are currently not supported.
@@ -0,0 +1,9 @@
1
+ ["appendix",role="exclude",id="redirects"]
2
+ = Deleted pages
3
+
4
+ The following pages have moved or been deleted.
5
+
6
+ [role="exclude",id="log-correlation"]
7
+ === Log correlation
8
+
9
+ This section has moved. See <<logs>>.