elastic-apm 4.5.0 → 4.6.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (65) hide show
  1. checksums.yaml +4 -4
  2. data/.ci/.jenkins_exclude.yml +94 -37
  3. data/.ci/.jenkins_framework.yml +4 -3
  4. data/.ci/.jenkins_main_framework.yml +4 -0
  5. data/.ci/.jenkins_ruby.yml +1 -1
  6. data/.ci/.jenkins_ruby_benchmarks.yml +6 -0
  7. data/.ci/Jenkinsfile +46 -36
  8. data/.ci/docker/jruby/11-jdk/Dockerfile +8 -3
  9. data/.ci/docker/jruby/12-jdk/Dockerfile +5 -2
  10. data/.ci/docker/jruby/13-jdk/Dockerfile +5 -2
  11. data/.ci/docker/jruby/7-jdk/Dockerfile +6 -3
  12. data/.ci/docker/jruby/8-jdk/Dockerfile +8 -3
  13. data/.ci/docker/jruby/README.md +1 -1
  14. data/.ci/docker/jruby/run.sh +33 -9
  15. data/.ci/docker/jruby/test.sh +17 -2
  16. data/.ci/jobs/apm-agent-ruby-mbp.yml +1 -1
  17. data/.ci/snapshoty.yml +34 -0
  18. data/.ci/update-specs.yml +108 -0
  19. data/.github/PULL_REQUEST_TEMPLATE.md +5 -5
  20. data/.github/workflows/update-specs.yml +30 -0
  21. data/.pre-commit-config.yaml +2 -2
  22. data/CHANGELOG.asciidoc +55 -1
  23. data/CONTRIBUTING.md +3 -3
  24. data/Gemfile +15 -4
  25. data/README.md +1 -1
  26. data/Rakefile +4 -4
  27. data/bench/report.rb +1 -1
  28. data/docker-compose.yml +6 -0
  29. data/docs/api.asciidoc +2 -2
  30. data/docs/configuration.asciidoc +7 -5
  31. data/docs/introduction.asciidoc +3 -3
  32. data/docs/log-correlation.asciidoc +1 -1
  33. data/docs/upgrading.asciidoc +1 -1
  34. data/elastic-apm.gemspec +3 -2
  35. data/lib/elastic_apm/central_config.rb +5 -0
  36. data/lib/elastic_apm/config/server_info.rb +50 -0
  37. data/lib/elastic_apm/config.rb +25 -4
  38. data/lib/elastic_apm/error.rb +2 -1
  39. data/lib/elastic_apm/error_builder.rb +1 -0
  40. data/lib/elastic_apm/instrumenter.rb +4 -2
  41. data/lib/elastic_apm/metadata/system_info/container_info.rb +4 -3
  42. data/lib/elastic_apm/metadata/system_info.rb +1 -1
  43. data/lib/elastic_apm/metrics.rb +1 -4
  44. data/lib/elastic_apm/span/context/links.rb +32 -0
  45. data/lib/elastic_apm/span/context/service.rb +55 -0
  46. data/lib/elastic_apm/span/context.rb +19 -3
  47. data/lib/elastic_apm/span.rb +3 -0
  48. data/lib/elastic_apm/span_helpers.rb +2 -2
  49. data/lib/elastic_apm/spies/elasticsearch.rb +11 -1
  50. data/lib/elastic_apm/spies/faraday.rb +13 -4
  51. data/lib/elastic_apm/spies/mongo.rb +5 -12
  52. data/lib/elastic_apm/spies/racecar.rb +77 -0
  53. data/lib/elastic_apm/spies/redis.rb +1 -1
  54. data/lib/elastic_apm/spies/sequel.rb +9 -0
  55. data/lib/elastic_apm/spies/sns.rb +1 -1
  56. data/lib/elastic_apm/spies/sqs.rb +1 -0
  57. data/lib/elastic_apm/trace_context/tracestate.rb +4 -2
  58. data/lib/elastic_apm/trace_context.rb +1 -1
  59. data/lib/elastic_apm/transport/base.rb +1 -3
  60. data/lib/elastic_apm/transport/connection/http.rb +9 -3
  61. data/lib/elastic_apm/transport/serializers/span_serializer.rb +25 -0
  62. data/lib/elastic_apm/version.rb +1 -1
  63. data/lib/elastic_apm.rb +1 -0
  64. metadata +32 -9
  65. data/.ci/.jenkins_master_framework.yml +0 -4
@@ -6,8 +6,23 @@ printf '\tTest %-30s %s\n' ${image}
6
6
 
7
7
  if [ -n "$version" ] ; then
8
8
  test_name="Test java -version '$version'"
9
- docker run -t --rm $image java -version | grep -q "openjdk version \"$version\|1.$version" && printf '\t\t%-40s %s\n' "${test_name}" "PASSED" || printf '\t\t%-40s %s\n' "${test_name}" "FAILED"
9
+ docker run -t --rm $image java -version | grep -q "openjdk version \"$version\|1.$version"
10
+ TEST_JAVA_VERSION_RESULT=$?
11
+ if [[ $TEST_JAVA_VERSION_RESULT -eq 0 ]]; then
12
+ printf '\t\t%-40s %s\n' "${test_name}" "PASSED"
13
+ else
14
+ printf '\t\t%-40s %s\n' "${test_name}" "FAILED"
15
+ fi
10
16
  fi
11
17
 
12
18
  test_name="Test Hello World"
13
- docker run -t --rm $image jruby -e "puts 'Hello World" | grep -q 'Hello World' && printf '\t\t%-40s %s\n' "${test_name}" "PASSED" || printf '\t\t%-40s %s\n' "${test_name}" "FAILED"
19
+ # random operation to verify that ruby evaluates the passed string correctly
20
+ docker run -t --rm $image jruby -e "foo = 3 * 4; puts foo" | grep -q '12'
21
+ TEST_HELLO_WORLD_RESULT=$?
22
+ if [[ $TEST_HELLO_WORLD_RESULT -eq 0 ]]; then
23
+ printf '\t\t%-40s %s\n' "${test_name}" "PASSED"
24
+ else
25
+ printf '\t\t%-40s %s\n' "${test_name}" "FAILED"
26
+ fi
27
+
28
+ ! (( $TEST_JAVA_VERSION_RESULT || $TEST_HELLO_WORLD_RESULT ))
@@ -15,7 +15,7 @@
15
15
  repo: apm-agent-ruby
16
16
  repo-owner: elastic
17
17
  credentials-id: 2a9602aa-ab9f-4e52-baf3-b71ca88469c7-UserAndToken
18
- head-filter-regex: '^(master|PR-.*|[3-4]\.x)$'
18
+ head-filter-regex: '^(main|PR-.*|[3-9]\.x|v4\.[5-9]+.*|v[5-9]+.*)$'
19
19
  ssh-checkout:
20
20
  credentials: f6c7695a-671e-4f4f-a331-acdce44ff9ba
21
21
  build-strategies:
data/.ci/snapshoty.yml ADDED
@@ -0,0 +1,34 @@
1
+ ---
2
+
3
+ # Version of configuration to use
4
+ version: '1.0'
5
+
6
+ # You can define a Google Cloud Account to use
7
+ account:
8
+ # Project id of the service account
9
+ project: '${GCS_PROJECT}'
10
+ # Private key id of the service account
11
+ private_key_id: '${GCS_PRIVATE_KEY_ID}'
12
+ # Private key of the service account
13
+ private_key: '${GCS_PRIVATE_KEY}'
14
+ # Email of the service account
15
+ client_email: '${GCS_CLIENT_EMAIL}'
16
+ # URI token
17
+ token_uri: 'https://oauth2.googleapis.com/token'
18
+
19
+ # List of artifacts
20
+ artifacts:
21
+ # Path to use for artifacts discovery
22
+ - path: './pkg'
23
+ # Files pattern to match
24
+ files_pattern: 'elastic-apm-(?P<app_version>\d+\.\d+\.\d+)\.gem'
25
+ # File layout on GCS bucket
26
+ output_pattern: '{project}/{jenkins_branch_name}/elastic-apm-ruby-{app_version}-{jenkins_git_commit_short}.gem'
27
+ # List of metadata processors to use.
28
+ metadata:
29
+ # Define static custom metadata
30
+ - name: 'custom'
31
+ data:
32
+ project: 'apm-agent-ruby'
33
+ # Add jenkins metadata
34
+ - name: 'jenkins'
@@ -0,0 +1,108 @@
1
+ name: update-specs
2
+
3
+ title: synchronize schema specs
4
+
5
+ scms:
6
+ default:
7
+ kind: github
8
+ spec:
9
+ user: '{{ requiredEnv "GIT_USER" }}'
10
+ email: '{{ requiredEnv "GIT_EMAIL" }}'
11
+ owner: elastic
12
+ repository: apm-agent-ruby
13
+ token: '{{ requiredEnv "GITHUB_TOKEN" }}'
14
+ username: '{{ requiredEnv "GIT_USER" }}'
15
+ branch: main
16
+
17
+ sources:
18
+ sha:
19
+ kind: file
20
+ spec:
21
+ file: 'https://github.com/elastic/apm-data/commit/main.patch'
22
+ matchpattern: "^From\\s([0-9a-f]{40})\\s"
23
+ transformers:
24
+ - findsubmatch:
25
+ pattern: "[0-9a-f]{40}"
26
+ error.json:
27
+ kind: file
28
+ spec:
29
+ file: https://raw.githubusercontent.com/elastic/apm-data/main/input/elasticapm/docs/spec/v2/error.json
30
+ metadata.json:
31
+ kind: file
32
+ spec:
33
+ file: https://raw.githubusercontent.com/elastic/apm-data/main/input/elasticapm/docs/spec/v2/metadata.json
34
+ metricset.json:
35
+ kind: file
36
+ spec:
37
+ file: https://raw.githubusercontent.com/elastic/apm-data/main/input/elasticapm/docs/spec/v2/metricset.json
38
+ span.json:
39
+ kind: file
40
+ spec:
41
+ file: https://raw.githubusercontent.com/elastic/apm-data/main/input/elasticapm/docs/spec/v2/span.json
42
+ transaction.json:
43
+ kind: file
44
+ spec:
45
+ file: https://raw.githubusercontent.com/elastic/apm-data/main/input/elasticapm/docs/spec/v2/transaction.json
46
+
47
+
48
+
49
+
50
+
51
+ actions:
52
+ pr:
53
+ kind: "github/pullrequest"
54
+ scmid: default
55
+ sourceid: sha
56
+ spec:
57
+ automerge: false
58
+ draft: false
59
+ labels:
60
+ - "automation"
61
+ description: |-
62
+ ### What
63
+ APM agent json schema automatic sync
64
+ ### Why
65
+ *Changeset*
66
+ * https://github.com/elastic/apm-data/commit/{{ source "sha" }}
67
+
68
+ targets:
69
+ error.json:
70
+ name: error.json
71
+ scmid: default
72
+ sourceid: error.json
73
+ kind: file
74
+ spec:
75
+ file: spec/fixtures/error.json
76
+ forcecreate: true
77
+ metadata.json:
78
+ name: metadata.json
79
+ scmid: default
80
+ sourceid: metadata.json
81
+ kind: file
82
+ spec:
83
+ file: spec/fixtures/metadata.json
84
+ forcecreate: true
85
+ metricset.json:
86
+ name: metricset.json
87
+ scmid: default
88
+ sourceid: metricset.json
89
+ kind: file
90
+ spec:
91
+ file: spec/fixtures/metricset.json
92
+ forcecreate: true
93
+ span.json:
94
+ name: span.json
95
+ scmid: default
96
+ sourceid: span.json
97
+ kind: file
98
+ spec:
99
+ file: spec/fixtures/span.json
100
+ forcecreate: true
101
+ transaction.json:
102
+ name: transaction.json
103
+ scmid: default
104
+ sourceid: transaction.json
105
+ kind: file
106
+ spec:
107
+ file: spec/fixtures/transaction.json
108
+ forcecreate: true
@@ -34,16 +34,16 @@ Add a checklist of things that are required to be reviewed in order to have the
34
34
  List here all the items you have verified BEFORE sending this PR. Please DO NOT remove any item, striking through those that do not apply. (Just in case, strikethrough uses two tildes. ~~Scratch this.~~)
35
35
  -->
36
36
 
37
- - [ ] I have signed the [Contributor License Agreement](https://www.elastic.co/contributor-agreement/).
37
+ - [ ] I have signed the [Contributor License Agreement](https://www.elastic.co/contributor-agreement/).
38
38
  - [ ] My code follows the style guidelines of this project (See `.rubocop.yml`)
39
- - [ ] I have rebased my changes on top of the latest master branch
39
+ - [ ] I have rebased my changes on top of the latest main branch
40
40
  <!--
41
- Update your local repository with the most recent code from the main repo, and rebase your branch on top of the latest master branch. We prefer your initial changes to be squashed into a single commit. Later, if we ask you to make changes, add them as separate commits. This makes them easier to review.
41
+ Update your local repository with the most recent code from the main repo, and rebase your branch on top of the latest main branch. We prefer your initial changes to be squashed into a single commit. Later, if we ask you to make changes, add them as separate commits. This makes them easier to review.
42
42
  -->
43
43
  - [ ] I have added tests that prove my fix is effective or that my feature works
44
- - [ ] New and existing [**unit** tests](https://github.com/elastic/apm-agent-ruby/blob/master/CONTRIBUTING.md#testing) pass locally with my changes
44
+ - [ ] New and existing [**unit** tests](https://github.com/elastic/apm-agent-ruby/blob/main/CONTRIBUTING.md#testing) pass locally with my changes
45
45
  <!--
46
- Run the test suite to make sure that nothing is broken. See https://github.com/elastic/apm-agent-ruby/blob/master/CONTRIBUTING.md#testing for details.
46
+ Run the test suite to make sure that nothing is broken. See https://github.com/elastic/apm-agent-ruby/blob/main/CONTRIBUTING.md#testing for details.
47
47
  -->
48
48
  - [ ] I have made corresponding changes to the documentation
49
49
  - [ ] I have updated [CHANGELOG.asciidoc](CHANGELOG.asciidoc)
@@ -0,0 +1,30 @@
1
+ name: update-specs
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
+ env:
18
+ BRANCH_NAME: ${{ github.ref_name }}
19
+ with:
20
+ vaultUrl: ${{ secrets.VAULT_ADDR }}
21
+ vaultRoleId: ${{ secrets.VAULT_ROLE_ID }}
22
+ vaultSecretId: ${{ secrets.VAULT_SECRET_ID }}
23
+ pipeline: ./.ci/update-specs.yml
24
+ - if: failure()
25
+ uses: elastic/apm-pipeline-library/.github/actions/notify-build-status@current
26
+ with:
27
+ vaultUrl: ${{ secrets.VAULT_ADDR }}
28
+ vaultRoleId: ${{ secrets.VAULT_ROLE_ID }}
29
+ vaultSecretId: ${{ secrets.VAULT_SECRET_ID }}
30
+ slackChannel: "#apm-agent-ruby"
@@ -1,5 +1,5 @@
1
1
  repos:
2
- - repo: git://github.com/pre-commit/pre-commit-hooks
2
+ - repo: https://github.com/pre-commit/pre-commit-hooks
3
3
  rev: v2.2.3
4
4
  hooks:
5
5
  - id: check-case-conflict
@@ -9,7 +9,7 @@ repos:
9
9
  - id: check-yaml
10
10
  - id: check-xml
11
11
 
12
- - repo: git@github.com:elastic/apm-pipeline-library
12
+ - repo: https://github.com/elastic/apm-pipeline-library
13
13
  rev: current
14
14
  hooks:
15
15
  - id: check-bash-syntax
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,61 @@ endif::[]
35
34
  [[release-notes-4.x]]
36
35
  === Ruby Agent version 4.x
37
36
 
37
+ [[release-notes-4.6.2]]
38
+ ==== 4.6.2
39
+
40
+ [float]
41
+ ===== Fixed
42
+ - Fix Faraday::RackBuilder::StackLocked {pull}1371[#1371]
43
+
44
+ [[release-notes-4.6.1]]
45
+ ==== 4.6.1
46
+
47
+ [float]
48
+ ===== Fixed
49
+
50
+ - Fix growing number of open file descriptors when HTTP request to APM is never sent {pull}1351[#1351]
51
+ - Fix setting span http status code when Faraday Middleware is used {pull}1368[#1368]
52
+ - Handle whitespace when splitting tracestate entries {pull}1353[#1353]
53
+
54
+ [[release-notes-4.6.0]]
55
+ ==== 4.6.0
56
+
57
+ [float]
58
+ ===== Added
59
+
60
+ - Added transaction_name to reported error to allow grouping by transaction name {pull}1267[#1267]
61
+ - Added ability to query server for version (useful in the future) {pull}1278[#1278]
62
+ - Added instrumentation for https://github.com/zendesk/racecar/ Racecar Kafka library {pull}1284[#1284]
63
+
64
+ ===== Changed
65
+
66
+ - Expanded filtering to sanitize any key that contains the string 'auth' {pull}1266[#1266]
67
+ - Rename `log_ecs_formatting` option to `log_ecs_reformatting`, deprecate old option name {pull}1248[#1248]
68
+ - 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]
69
+ - Only send tracestate header for distributed tracing when it has content {pull}1277[#1277]
70
+ - Use the hostname as the Kubernetes pod name in the Container Info metadata if the pod id is parsed from cgroup {pull}1314[#1314]
71
+
72
+ ====== Fixed
73
+
74
+ - Small change to Sidekiq tests to handle new configuration passing method {pull}1283[#1283]
75
+ - Set transaction sample rate to 0 when it's unsampled {pull}1339[#1339]
76
+ - Don't send unsampled transactions to APM server >= 8.0 {pull}1341[#1341]
77
+
78
+ [[release-notes-4.5.1]]
79
+ ==== 4.5.1
80
+
81
+ [float]
82
+ ===== Changed
83
+
84
+ - Update elasticsearch spy to use new transport gem name {pull}1257[#1257]
85
+ - Standardize placeholder for phone numbers as [PHONENUMBER] per https://github.com/elastic/apm/blob/main/specs/agents/tracing-instrumentation-aws.md {pull}1246[#1246]
86
+
87
+ ===== Fixed
88
+
89
+ - Fixed dependencies to allow CI to build successfully {pull}1259[#1259]
90
+ - Fixed warnings related to TimeTask timeouts {pull}1255[#1255]
91
+
38
92
  [[release-notes-4.5.0]]
39
93
  ==== 4.5.0
40
94
 
data/CONTRIBUTING.md CHANGED
@@ -20,7 +20,7 @@ or that there are particular issues that you should know about before implementi
20
20
 
21
21
  ### Workflow
22
22
 
23
- All feature development and most bug fixes hit the master branch first.
23
+ All feature development and most bug fixes hit the main branch first.
24
24
  Pull requests should be reviewed by someone with commit access.
25
25
  Once approved, the author of the pull request,
26
26
  or reviewer if the author does not have commit access,
@@ -42,11 +42,11 @@ To release a new version:
42
42
 
43
43
  1. Update `VERSION` in `lib/elastic_apm/version.rb` according to the changes (major, minor, patch).
44
44
  1. Update `CHANGELOG.md` to reflect the new version – change _Unreleased_ section to _Version (release date)_.
45
- 1. For Majors: Add a new row to the EOL table in `docs/upgrading.asciidoc`. The EOL date is the release date plus 18 months.
45
+ 1. For Majors: Add a new row to the EOL table in `docs/upgrading.asciidoc`. The EOL date is the release date plus 18 months.
46
46
  1. Make a new commit with the changes above, with a message in the style of `vX.X.X`.
47
47
  1. Run `rake release`. This will...
48
48
  1. Tag the current commit as 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
@@ -50,14 +50,14 @@ gem 'json'
50
50
  gem 'json-schema', require: nil
51
51
  gem 'mongo', require: nil
52
52
  gem 'opentracing', require: nil
53
- gem 'rake', require: nil
53
+ gem 'rake', '>= 13.0', require: nil
54
+ gem 'racecar', require: nil if !defined?(JRUBY_VERSION)
54
55
  gem 'resque', require: nil
55
56
  gem 'sequel', require: nil
56
57
  gem 'shoryuken', require: nil
57
58
  gem 'sidekiq', require: nil
58
59
  gem 'simplecov', require: false
59
60
  gem 'simplecov-cobertura', require: false
60
- gem 'sneakers', '~> 2.12', require: nil
61
61
  gem 'sucker_punch', '~> 2.0', require: nil
62
62
  gem 'yard', require: nil
63
63
  gem 'yarjuf'
@@ -78,10 +78,14 @@ frameworks_versions = parsed_frameworks.inject({}) do |frameworks, str|
78
78
  end
79
79
 
80
80
  frameworks_versions.each do |framework, version|
81
+ if framework =='rails' && RUBY_VERSION >= '3.1'
82
+ gem 'net-smtp', require: false
83
+ end
84
+
81
85
  case version
82
- when 'master' # sinatra, grape
86
+ when 'master' # grape
83
87
  gem framework, github: GITHUB_REPOS.fetch(framework)
84
- when 'main' # rails
88
+ when 'main' # sinatra, rails
85
89
  gem framework, github: GITHUB_REPOS.fetch(framework), branch: 'main'
86
90
  when /.+/
87
91
  gem framework, "~> #{version}.0"
@@ -112,10 +116,17 @@ if RUBY_PLATFORM == 'java'
112
116
  end
113
117
  elsif frameworks_versions['rails'] =~ /^(4|5)/
114
118
  gem 'sqlite3', '~> 1.3.6'
119
+ elsif RUBY_VERSION < '2.7'
120
+ gem 'sqlite3', '~> 1.4.4'
115
121
  else
116
122
  gem 'sqlite3'
117
123
  end
118
124
 
125
+ # sneakers main only supports >=2.5.0
126
+ if Gem::Version.create(RUBY_VERSION) >= Gem::Version.create('2.5.0') && !defined?(JRUBY_VERSION)
127
+ gem 'sneakers', github: 'jondot/sneakers', ref: 'd761dfe1493', require: nil
128
+ end
129
+
119
130
  group :bench do
120
131
  gem 'ruby-prof', require: nil, platforms: %i[ruby]
121
132
  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/master)](https://apm-ci.elastic.co/job/apm-agent-ruby/job/apm-agent-ruby-mbp/job/master/) [![Gem](https://img.shields.io/gem/v/elastic-apm.svg)](https://rubygems.org/gems/elastic-apm)
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)
6
6
 
7
7
  The official Rubygem for [Elastic][] [APM][].
8
8
 
data/Rakefile CHANGED
@@ -24,10 +24,10 @@ desc 'Post release action:'\
24
24
 
25
25
  namespace :release do
26
26
  task :update_branch do
27
- `git checkout 3.x &&
28
- git rebase master &&
29
- git push origin 3.x &&
30
- git checkout master`
27
+ `git checkout 4.x &&
28
+ git rebase main &&
29
+ git push origin 4.x &&
30
+ git checkout main`
31
31
  end
32
32
  end
33
33
 
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/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,16 @@ 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:
34
38
  MONGODB_URL: 'mongodb:27017'
35
39
  user: ${USER_ID}
40
+ security_opt:
41
+ - no-new-privileges
36
42
 
37
43
  volumes:
38
44
  vendor:
data/docs/api.asciidoc CHANGED
@@ -334,7 +334,7 @@ Labels are basic key-value pairs that are indexed in your Elasticsearch database
334
334
  The value can be a string, nil, numeric or boolean.
335
335
 
336
336
  TIP: Before using custom labels, ensure you understand the different types of
337
- {apm-overview-ref-v}/metadata.html[metadata] that are available.
337
+ {apm-guide-ref}/data-model-metadata.html[metadata] that are available.
338
338
 
339
339
  [source,ruby]
340
340
  ----
@@ -361,7 +361,7 @@ Use this to further specify a context that will help you track or diagnose what'
361
361
  going on inside your app.
362
362
 
363
363
  TIP: Before using custom context, ensure you understand the different types of
364
- {apm-overview-ref-v}/metadata.html[metadata] that are available.
364
+ {apm-guide-ref}/data-model-metadata.html[metadata] that are available.
365
365
 
366
366
  If called several times during a transaction the custom context will be destructively
367
367
  merged with `merge!`.
@@ -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-server-ref-v}/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
 
@@ -506,12 +506,12 @@ Elastic APM can instrument your Rake tasks. This is an opt-in field, as they are
506
506
 
507
507
  [float]
508
508
  [[config-log-ecs-formatting]]
509
- ==== `log_ecs_formatting`
509
+ ==== `log_ecs_reformatting`
510
510
 
511
511
  [options="header"]
512
512
  |============
513
513
  | Environment | `Config` key | Default
514
- | `ELASTIC_APM_LOG_ECS_FORMATTING` | `log_ecs_formatting` | `off`
514
+ | `ELASTIC_APM_LOG_ECS_REFORMATTING` | `log_ecs_reformatting` | `off`
515
515
  |============
516
516
 
517
517
  This is an experimental option that configures the agent to use the logger from the `ecs-logging` gem. The two
@@ -520,7 +520,7 @@ valid options are `off` and `override`.
520
520
  Setting this option to `override` will set the agent logger to a `EcsLogging::Logger` instance and all logged output
521
521
  will be in ECS-compatible json.
522
522
 
523
- The `ecs-logging` gem must be installed before the agent is started. If `log_ecs_formatting` is set to `override`,
523
+ The `ecs-logging` gem must be installed before the agent is started. If `log_ecs_reformatting` is set to `override`,
524
524
  the agent will attempt to require the gem and if it cannot be loaded, it will fall back to using the standard Ruby
525
525
  `::Logger` and log the load error.
526
526
 
@@ -556,6 +556,8 @@ A path to a log file.
556
556
 
557
557
  By default Elastic APM logs to `stdout` or uses `Rails.log` when used with Rails.
558
558
 
559
+ If `log_path` is specified, this will override `Rails.log` to point to that path instead.
560
+
559
561
  This should support both absolute and relative paths. Please be sure the directory exists.
560
562
 
561
563
  [float]
@@ -654,7 +656,7 @@ when this option is false.
654
656
  [options="header"]
655
657
  |============
656
658
  | 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`
659
+ | `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
660
  |============
659
661
 
660
662
  Sometimes it is necessary to sanitize the data sent to Elastic APM to remove sensitive values.
@@ -31,6 +31,6 @@ You can then use the APM app in Kibana to gain insight into latency issues and e
31
31
  [[additional-components]]
32
32
  === Additional Components
33
33
 
34
- APM Agents work in conjunction with the {apm-server-ref-v}/index.html[APM Server], {ref}/index.html[Elasticsearch], and {kibana-ref}/index.html[Kibana].
35
- The {apm-overview-ref-v}/index.html[APM Overview] provides details on how these components work together,
36
- and provides a matrix outlining {apm-overview-ref-v}/agent-server-compatibility.html[Agent and Server compatibility].
34
+ APM Agents work in conjunction with the {apm-guide-ref}/index.html[APM Server], {ref}/index.html[Elasticsearch], and {kibana-ref}/index.html[Kibana].
35
+ The {apm-guide-ref}/index.html[APM Guide] provides details on how these components work together,
36
+ and provides a matrix outlining {apm-guide-ref}/agent-server-compatibility.html[Agent and Server compatibility].
@@ -118,4 +118,4 @@ PUT _ingest/pipeline/extract_trace_id
118
118
  }
119
119
  ----
120
120
 
121
- Please see {apm-overview-ref-v}/observability-integrations.html[Observability integrations] for more information.
121
+ Please see {apm-guide-ref}/log-correlation.html[Observability integrations] for more information.
@@ -6,7 +6,7 @@ Upgrades that involve a major version bump often come with some backwards incomp
6
6
  Before upgrading the agent, be sure to review the:
7
7
 
8
8
  * <<release-notes,Agent release notes>>
9
- * {apm-overview-ref-v}/agent-server-compatibility.html[Agent and Server compatibility chart]
9
+ * {apm-guide-ref}/agent-server-compatibility.html[Agent and Server compatibility chart]
10
10
 
11
11
  [float]
12
12
  [[end-of-life-dates]]
data/elastic-apm.gemspec CHANGED
@@ -22,8 +22,8 @@ require 'elastic_apm/version'
22
22
  Gem::Specification.new do |spec|
23
23
  spec.name = 'elastic-apm'
24
24
  spec.version = ElasticAPM::VERSION
25
- spec.authors = ['Mikkel Malmberg']
26
- spec.email = ['mikkel@elastic.co']
25
+ spec.authors = ['Mikkel Malmberg', 'Emily Stolfo']
26
+ spec.email = ['info@elastic.co']
27
27
 
28
28
  spec.summary = 'The official Elastic APM agent for Ruby'
29
29
  spec.homepage = 'https://github.com/elastic/apm-agent-ruby'
@@ -37,6 +37,7 @@ Gem::Specification.new do |spec|
37
37
 
38
38
  spec.add_dependency('concurrent-ruby', '~> 1.0')
39
39
  spec.add_dependency('http', '>= 3.0')
40
+ spec.add_runtime_dependency('ruby2_keywords')
40
41
 
41
42
  spec.require_paths = ['lib']
42
43
  end
@@ -181,6 +181,11 @@ module ElasticAPM
181
181
  DEFAULT_MAX_AGE
182
182
  end
183
183
 
184
+ if seconds < 5
185
+ debug "Next fetch is too low (#{seconds}s) - increasing to default"
186
+ seconds = 5
187
+ end
188
+
184
189
  @scheduled_task =
185
190
  Concurrent::ScheduledTask
186
191
  .execute(seconds) { fetch_and_apply_config }
@@ -0,0 +1,50 @@
1
+ # Licensed to Elasticsearch B.V. under one or more contributor
2
+ # license agreements. See the NOTICE file distributed with
3
+ # this work for additional information regarding copyright
4
+ # ownership. Elasticsearch B.V. licenses this file to you under
5
+ # the Apache License, Version 2.0 (the "License"); you may
6
+ # not use this file except in compliance with the License.
7
+ # You may obtain a copy of the License at
8
+ #
9
+ # http://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing,
12
+ # software distributed under the License is distributed on an
13
+ # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14
+ # KIND, either express or implied. See the License for the
15
+ # specific language governing permissions and limitations
16
+ # under the License.
17
+
18
+ # frozen_string_literal: true
19
+
20
+ module ElasticAPM
21
+ class Config
22
+ # @api private
23
+ class ServerInfo
24
+ attr_reader :payload, :config, :http
25
+
26
+ VERSION_8_0 = '8.0'
27
+ VERSION_0 = '0'
28
+
29
+ def initialize(config)
30
+ @config = config
31
+ @http = Transport::Connection::Http.new(config)
32
+ end
33
+
34
+ def execute
35
+ resp = http.get(config.server_url)
36
+ @payload = JSON.parse(resp.body)
37
+ rescue
38
+ @payload = { "version" => VERSION_0 }
39
+ end
40
+
41
+ def version
42
+ @version ||= begin
43
+ execute
44
+ payload["version"] ? payload["version"].to_s : VERSION_0
45
+ end
46
+ end
47
+ end
48
+ end
49
+ end
50
+