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
@@ -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,35 @@ endif::[]
35
34
  [[release-notes-4.x]]
36
35
  === Ruby Agent version 4.x
37
36
 
37
+ [[release-notes-4.7.0]]
38
+ ==== 4.7.0
39
+
40
+ [float]
41
+ ===== Fixed
42
+ - Handle Faraday response being nil {pull}1382[#1382]
43
+ - Fix error with invalid %-encoding {pull}1400[#1400]
44
+
45
+ [float]
46
+ ===== Added
47
+ - Add keyword args for span_method helper {pull}1395[#1395]
48
+
49
+ [[release-notes-4.6.2]]
50
+ ==== 4.6.2
51
+
52
+ [float]
53
+ ===== Fixed
54
+ - Fix Faraday::RackBuilder::StackLocked {pull}1371[#1371]
55
+
56
+ [[release-notes-4.6.1]]
57
+ ==== 4.6.1
58
+
59
+ [float]
60
+ ===== Fixed
61
+
62
+ - Fix growing number of open file descriptors when HTTP request to APM is never sent {pull}1351[#1351]
63
+ - Fix setting span http status code when Faraday Middleware is used {pull}1368[#1368]
64
+ - Handle whitespace when splitting tracestate entries {pull}1353[#1353]
65
+
38
66
  [[release-notes-4.6.0]]
39
67
  ==== 4.6.0
40
68
 
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
@@ -62,6 +62,10 @@ gem 'sucker_punch', '~> 2.0', require: nil
62
62
  gem 'yard', require: nil
63
63
  gem 'yarjuf'
64
64
 
65
+ if RUBY_VERSION < '2.5'
66
+ gem 'loofah', '~> 2.20.0', require: nil
67
+ end
68
+
65
69
  ## Install Framework
66
70
  GITHUB_REPOS = {
67
71
  'grape' => 'ruby-grape/grape',
@@ -83,9 +87,9 @@ frameworks_versions.each do |framework, version|
83
87
  end
84
88
 
85
89
  case version
86
- when 'master' # sinatra, grape
90
+ when 'master' # grape
87
91
  gem framework, github: GITHUB_REPOS.fetch(framework)
88
- when 'main' # rails
92
+ when 'main' # sinatra, rails
89
93
  gem framework, github: GITHUB_REPOS.fetch(framework), branch: 'main'
90
94
  when /.+/
91
95
  gem framework, "~> #{version}.0"
@@ -116,6 +120,8 @@ if RUBY_PLATFORM == 'java'
116
120
  end
117
121
  elsif frameworks_versions['rails'] =~ /^(4|5)/
118
122
  gem 'sqlite3', '~> 1.3.6'
123
+ elsif RUBY_VERSION < '2.7'
124
+ gem 'sqlite3', '~> 1.4.4'
119
125
  else
120
126
  gem 'sqlite3'
121
127
  end
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/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]]
@@ -701,7 +702,7 @@ The name of the given service node. This is optional, and if omitted, the APM
701
702
  Server will fall back on `system.container.id` if available, and
702
703
  `host.name` if necessary.
703
704
 
704
- 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.
705
706
 
706
707
  [float]
707
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>>.
@@ -44,7 +44,7 @@ module ElasticAPM
44
44
  request = context.request
45
45
 
46
46
  request.socket = Context::Request::Socket.new(req)
47
- request.http_version = build_http_version rack_env
47
+ request.http_version = build_http_version req
48
48
  request.method = req.request_method
49
49
  request.url = Context::Request::Url.new(req)
50
50
 
@@ -104,8 +104,8 @@ module ElasticAPM
104
104
  key.gsub(/^HTTP_/, '').split('_').map(&:capitalize).join('-')
105
105
  end
106
106
 
107
- def build_http_version(rack_env)
108
- return unless (http_version = rack_env['HTTP_VERSION'])
107
+ def build_http_version(req)
108
+ return unless (http_version = req.env['HTTP_VERSION'])
109
109
  http_version.gsub(%r{HTTP/}, '')
110
110
  end
111
111
  end
@@ -50,27 +50,9 @@ module ElasticAPM
50
50
  return
51
51
  end
52
52
 
53
- debug 'Starting metrics'
54
-
55
- # Only set the @sets once, in case we stop
56
- # and start again.
57
- if @sets.nil?
58
- sets = {
59
- system: CpuMemSet,
60
- vm: VMSet,
61
- breakdown: BreakdownSet,
62
- transaction: TransactionSet
63
- }
64
- if defined?(JVMSet)
65
- debug "Enabling JVM metrics collection"
66
- sets[:jvm] = JVMSet
67
- end
53
+ define_sets
68
54
 
69
- @sets = sets.each_with_object({}) do |(key, kls), _sets_|
70
- debug "Adding metrics collector '#{kls}'"
71
- _sets_[key] = kls.new(config)
72
- end
73
- end
55
+ debug 'Starting metrics'
74
56
 
75
57
  @timer_task = Concurrent::TimerTask.execute(
76
58
  run_now: true,
@@ -135,6 +117,28 @@ module ElasticAPM
135
117
  arr.concat(samples)
136
118
  end
137
119
  end
120
+
121
+ def define_sets
122
+ # Only set the @sets once, in case we stop
123
+ # and start again.
124
+ return unless @sets.nil?
125
+
126
+ sets = {
127
+ system: CpuMemSet,
128
+ vm: VMSet,
129
+ breakdown: BreakdownSet,
130
+ transaction: TransactionSet
131
+ }
132
+ if defined?(JVMSet)
133
+ debug "Enabling JVM metrics collection"
134
+ sets[:jvm] = JVMSet
135
+ end
136
+
137
+ @sets = sets.each_with_object({}) do |(key, kls), _sets_|
138
+ debug "Adding metrics collector '#{kls}'"
139
+ _sets_[key] = kls.new(config)
140
+ end
141
+ end
138
142
  end
139
143
  end
140
144
  end
@@ -22,17 +22,17 @@ module ElasticAPM
22
22
  module SpanHelpers
23
23
  # @api private
24
24
  module ClassMethods
25
- def span_class_method(method, name = nil, type = nil)
26
- __span_method_on(singleton_class, method, name, type)
25
+ def span_class_method(method, name = nil, type = nil, **kwargs)
26
+ __span_method_on(singleton_class, method, name, type, **kwargs)
27
27
  end
28
28
 
29
- def span_method(method, name = nil, type = nil)
30
- __span_method_on(self, method, name, type)
29
+ def span_method(method, name = nil, type = nil, **kwargs)
30
+ __span_method_on(self, method, name, type, **kwargs)
31
31
  end
32
32
 
33
33
  private
34
34
 
35
- def __span_method_on(klass, method, name = nil, type = nil)
35
+ def __span_method_on(klass, method, name = nil, type = nil, **kwargs)
36
36
  name ||= method.to_s
37
37
  type ||= Span::DEFAULT_TYPE
38
38
 
@@ -42,7 +42,7 @@ module ElasticAPM
42
42
  return super(*args, &block)
43
43
  end
44
44
 
45
- ElasticAPM.with_span name.to_s, type.to_s do
45
+ ElasticAPM.with_span name.to_s, type.to_s, **kwargs do
46
46
  super(*args, &block)
47
47
  end
48
48
  end)
@@ -103,10 +103,19 @@ module ElasticAPM
103
103
  ElasticAPM::Spies.without_net_http do
104
104
  trace_context = span&.trace_context || transaction.trace_context
105
105
 
106
- result = super(method, url, body, headers) do |req|
107
- trace_context.apply_headers { |k, v| req[k] = v }
108
-
109
- yield req if block
106
+ begin
107
+ result = super(method, url, body, headers) do |req|
108
+ trace_context.apply_headers { |k, v| req[k] = v }
109
+ yield req if block
110
+ end
111
+ rescue Faraday::ClientError, Faraday::ServerError => e # Faraday::Response::RaiseError
112
+ status = e.response_status
113
+ http = span&.context&.http
114
+ if http && status
115
+ http.status_code = status.to_s
116
+ span.outcome = Span::Outcome.from_http_status(status)
117
+ end
118
+ raise e
110
119
  end
111
120
 
112
121
  if (http = span&.context&.http)
@@ -92,6 +92,8 @@ module ElasticAPM
92
92
 
93
93
  extend Forwardable
94
94
 
95
+ ENTRY_SPLIT_REGEX = /\s*[\n,]+\s*/
96
+
95
97
  def initialize(entries: {}, sample_rate: nil)
96
98
  @entries = entries
97
99
 
@@ -140,7 +142,7 @@ module ElasticAPM
140
142
  # Rack handles this by joining the headers under the same key,
141
143
  # separated by newlines.
142
144
  # See https://www.rubydoc.info/github/rack/rack/file/SPEC
143
- String(str).split("\n").map { |s| s.split(',') }.flatten
145
+ String(str).split(ENTRY_SPLIT_REGEX).flatten
144
146
  end
145
147
  end
146
148
  end
@@ -75,7 +75,15 @@ module ElasticAPM
75
75
  @closed.make_true
76
76
 
77
77
  @wr&.close
78
- return if @request.nil? || @request&.join(5)
78
+
79
+ if @request&.join(5)
80
+ @rd&.close
81
+ return
82
+ end
83
+
84
+ @rd&.close
85
+
86
+ return if @request.nil?
79
87
 
80
88
  error(
81
89
  '%s: APM Server not responding in time, terminating request',
@@ -117,8 +125,6 @@ module ElasticAPM
117
125
  error(
118
126
  "Couldn't establish connection to APM Server:\n%p", e.inspect
119
127
  )
120
- ensure
121
- @rd&.close
122
128
  end
123
129
  end
124
130
  end
@@ -18,5 +18,5 @@
18
18
  # frozen_string_literal: true
19
19
 
20
20
  module ElasticAPM
21
- VERSION = '4.6.0'
21
+ VERSION = '4.7.0'
22
22
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: elastic-apm
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.6.0
4
+ version: 4.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mikkel Malmberg
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2023-01-11 00:00:00.000000000 Z
12
+ date: 2023-08-17 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: concurrent-ruby
@@ -60,13 +60,11 @@ executables: []
60
60
  extensions: []
61
61
  extra_rdoc_files: []
62
62
  files:
63
- - ".ci/.jenkins_codecov.yml"
64
- - ".ci/.jenkins_exclude.yml"
65
- - ".ci/.jenkins_framework.yml"
66
- - ".ci/.jenkins_main_framework.yml"
67
- - ".ci/.jenkins_ruby.yml"
68
- - ".ci/.jenkins_ruby_benchmarks.yml"
69
- - ".ci/Jenkinsfile"
63
+ - ".ci/.codecov.yml"
64
+ - ".ci/.exclude.yml"
65
+ - ".ci/.framework.yml"
66
+ - ".ci/.main_framework.yml"
67
+ - ".ci/.ruby.yml"
70
68
  - ".ci/docker/jruby/11-jdk/Dockerfile"
71
69
  - ".ci/docker/jruby/12-jdk/Dockerfile"
72
70
  - ".ci/docker/jruby/13-jdk/Dockerfile"
@@ -75,20 +73,29 @@ files:
75
73
  - ".ci/docker/jruby/README.md"
76
74
  - ".ci/docker/jruby/run.sh"
77
75
  - ".ci/docker/jruby/test.sh"
78
- - ".ci/jobs/apm-agent-ruby-downstream.yml"
79
- - ".ci/jobs/apm-agent-ruby-linting-mbp.yml"
80
- - ".ci/jobs/apm-agent-ruby-mbp.yml"
81
- - ".ci/jobs/apm-agent-ruby.yml"
82
- - ".ci/jobs/defaults.yml"
83
- - ".ci/linting.groovy"
84
- - ".ci/packer_cache.sh"
76
+ - ".ci/scripts/bench.sh"
77
+ - ".ci/scripts/install-build-system.sh"
78
+ - ".ci/snapshoty.yml"
79
+ - ".ci/updatecli.d/update-gherkin-specs.yml"
80
+ - ".ci/updatecli.d/update-json-specs.yml"
81
+ - ".ci/updatecli.d/update-specs.yml"
85
82
  - ".github/ISSUE_TEMPLATE/Bug_report.md"
86
83
  - ".github/ISSUE_TEMPLATE/Feature_request.md"
87
84
  - ".github/PULL_REQUEST_TEMPLATE.md"
88
85
  - ".github/dependabot.yml"
89
86
  - ".github/labeler-config.yml"
90
87
  - ".github/workflows/addToProject.yml"
88
+ - ".github/workflows/ci-docs.yml"
89
+ - ".github/workflows/ci.yml"
90
+ - ".github/workflows/coverage-reporter.yml"
91
91
  - ".github/workflows/labeler.yml"
92
+ - ".github/workflows/microbenchmark.yml"
93
+ - ".github/workflows/opentelemetry.yml"
94
+ - ".github/workflows/release.yml"
95
+ - ".github/workflows/run-matrix.yml"
96
+ - ".github/workflows/snapshoty.yml"
97
+ - ".github/workflows/test-reporter.yml"
98
+ - ".github/workflows/updatecli.yml"
92
99
  - ".gitignore"
93
100
  - ".pre-commit-config.yaml"
94
101
  - ".rspec"
@@ -130,10 +137,11 @@ files:
130
137
  - docs/images/dynamic-config.svg
131
138
  - docs/index.asciidoc
132
139
  - docs/introduction.asciidoc
133
- - docs/log-correlation.asciidoc
140
+ - docs/logs.asciidoc
134
141
  - docs/metrics.asciidoc
135
142
  - docs/opentracing.asciidoc
136
143
  - docs/performance-tuning.asciidoc
144
+ - docs/redirects.asciidoc
137
145
  - docs/release-notes.asciidoc
138
146
  - docs/set-up.asciidoc
139
147
  - docs/supported-technologies.asciidoc