elastic-apm 4.6.0 → 4.6.1

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: edae30dc148307b137e402a81ffed731cbe738ca7924f31c9440a9a6ea9a8eb4
4
- data.tar.gz: ef860d2d783fd9351b0eea3106e96eafbadef339fa72a4b5979fbc38d4e3d46a
3
+ metadata.gz: 49b381ca37784473aef9bf3462b37eb77b3d263dfd402adf929c866153f81af3
4
+ data.tar.gz: 51f9290d7cace3428273171484ab6f6526e1309bdb2d27a101d9e74a17f9f619
5
5
  SHA512:
6
- metadata.gz: 8e1543b7f39d5ba73eb30e34777ba07a8ae940ddd1aee2d84afc445642319304bd26036a9eb5b5e6d4d9c11bbc0323c7c17aa2bd18101bbfcfed1cdcf6bdc635
7
- data.tar.gz: 971963f1d06a398c2af8f988e4386004b7fb176e67d6d8c35b9be8a781b8561fd8236395d89f51ef87e3cad4375f9c91c4105e550dc7f7b1e7b1142e1d0f7c17
6
+ metadata.gz: 55c315cf52ce113f032b471f64d6662d4e5b9d85577bf228913da82c3f114cdc1846c70a8078de2fc7e1362c89f2cff2559b6e6b046007667feeb0c194223e75
7
+ data.tar.gz: 9962145d110f552e1beb449e721389cefe17bb862b3e255f48ef236170fa04523c29654f11fb3e1cc89cc5b8f69e14f0678cab51431b86a501ec016631278992
data/.ci/Jenkinsfile CHANGED
@@ -25,6 +25,7 @@ pipeline {
25
25
  OPBEANS_REPO = 'opbeans-ruby'
26
26
  REFERENCE_REPO = '/var/lib/jenkins/.git-references/apm-agent-ruby.git'
27
27
  SLACK_CHANNEL = '#apm-agent-ruby'
28
+ RUBY_DOCKER_TAG = 'ruby:2.6'
28
29
  }
29
30
  options {
30
31
  timeout(time: 2, unit: 'HOURS')
@@ -123,6 +124,37 @@ pipeline {
123
124
  }
124
125
  }
125
126
  }
127
+ stage('Publish snapshot packages') {
128
+ options { skipDefaultCheckout() }
129
+ environment {
130
+ PATH = "${env.WORKSPACE}/.local/bin:${env.WORKSPACE}/bin:${env.PATH}"
131
+ BUCKET_NAME = 'oblt-artifacts'
132
+ DOCKER_REGISTRY = 'docker.elastic.co'
133
+ DOCKER_REGISTRY_SECRET = 'secret/observability-team/ci/docker-registry/prod'
134
+ GCS_ACCOUNT_SECRET = 'secret/observability-team/ci/snapshoty'
135
+ }
136
+ when { branch 'main' }
137
+ steps {
138
+ withGithubNotify(context: 'Publish snapshot packages') {
139
+ deleteDir()
140
+ unstash 'source'
141
+ dir(env.BASE_DIR) {
142
+ script {
143
+ docker.image(env.RUBY_DOCKER_TAG).inside() {
144
+ sh(label: 'install build system', script: 'gem install rake yard rspec')
145
+ sh(label: 'create gem', script: 'rake build')
146
+ }
147
+ snapshoty(
148
+ bucket: env.BUCKET_NAME,
149
+ gcsAccountSecret: env.GCS_ACCOUNT_SECRET,
150
+ dockerRegistry: env.DOCKER_REGISTRY,
151
+ dockerSecret: env.DOCKER_REGISTRY_SECRET
152
+ )
153
+ }
154
+ }
155
+ }
156
+ }
157
+ }
126
158
  stage('Benchmarks') {
127
159
  options { skipDefaultCheckout() }
128
160
  when {
@@ -178,7 +210,6 @@ pipeline {
178
210
  stage('Release') {
179
211
  options { skipDefaultCheckout() }
180
212
  environment {
181
- RUBY_DOCKER_TAG = 'ruby:2.6'
182
213
  HOME = '/var/lib/jenkins'
183
214
  }
184
215
  when {
@@ -389,7 +420,7 @@ def convergeCoverage() {
389
420
 
390
421
  def prepareRelease(Closure body){
391
422
  dir("${env.BASE_DIR}"){
392
- docker.image("${env.RUBY_DOCKER_TAG}").inside('-v ${REFERENCE_REPO}:${REFERENCE_REPO} -v /etc/passwd:/etc/passwd -v ${HOME}/.ssh:${HOME}/.ssh') {
423
+ docker.image(env.RUBY_DOCKER_TAG).inside('-v ${REFERENCE_REPO}:${REFERENCE_REPO} -v /etc/passwd:/etc/passwd -v ${HOME}/.ssh:${HOME}/.ssh') {
393
424
  withEnv(["HOME=${env.WORKSPACE}/${env.BASE_DIR ?: ''}"]) {
394
425
  rubygemsLogin.withApi(secret: "${env.RELEASE_SECRET}") {
395
426
  withGitRelease(credentialsId: '2a9602aa-ab9f-4e52-baf3-b71ca88469c7-UserAndToken') {
@@ -38,4 +38,7 @@ ENV PATH $BUNDLE_BIN:$PATH
38
38
  RUN mkdir -p "$GEM_HOME" "$BUNDLE_BIN" \
39
39
  && chmod 777 "$GEM_HOME" "$BUNDLE_BIN"
40
40
 
41
+ RUN useradd -rm -d /home/jruby -u 1001 jruby
42
+ USER jruby
43
+ WORKDIR /home/jruby
41
44
  CMD [ "irb" ]
@@ -38,4 +38,7 @@ ENV PATH $BUNDLE_BIN:$PATH
38
38
  RUN mkdir -p "$GEM_HOME" "$BUNDLE_BIN" \
39
39
  && chmod 777 "$GEM_HOME" "$BUNDLE_BIN"
40
40
 
41
+ RUN useradd -rm -d /home/jruby -u 1001 jruby
42
+ USER jruby
43
+ WORKDIR /home/jruby
41
44
  CMD [ "irb" ]
@@ -38,4 +38,7 @@ ENV PATH $BUNDLE_BIN:$PATH
38
38
  RUN mkdir -p "$GEM_HOME" "$BUNDLE_BIN" \
39
39
  && chmod 777 "$GEM_HOME" "$BUNDLE_BIN"
40
40
 
41
+ RUN useradd -rm -d /home/jruby -u 1001 jruby
42
+ USER jruby
43
+ WORKDIR /home/jruby
41
44
  CMD [ "irb" ]
@@ -38,4 +38,7 @@ ENV PATH $BUNDLE_BIN:$PATH
38
38
  RUN mkdir -p "$GEM_HOME" "$BUNDLE_BIN" \
39
39
  && chmod 777 "$GEM_HOME" "$BUNDLE_BIN"
40
40
 
41
+ RUN useradd -rm -d /home/jruby -u 1001 jruby
42
+ USER jruby
43
+ WORKDIR /home/jruby
41
44
  CMD [ "irb" ]
@@ -38,4 +38,7 @@ ENV PATH $BUNDLE_BIN:$PATH
38
38
  RUN mkdir -p "$GEM_HOME" "$BUNDLE_BIN" \
39
39
  && chmod 777 "$GEM_HOME" "$BUNDLE_BIN"
40
40
 
41
+ RUN useradd -rm -d /home/jruby -u 1001 jruby
42
+ USER jruby
43
+ WORKDIR /home/jruby
41
44
  CMD [ "irb" ]
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
@@ -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"
data/CHANGELOG.asciidoc CHANGED
@@ -35,6 +35,16 @@ endif::[]
35
35
  [[release-notes-4.x]]
36
36
  === Ruby Agent version 4.x
37
37
 
38
+ [[release-notes-4.6.1]]
39
+ ==== 4.6.1
40
+
41
+ [float]
42
+ ===== Fixed
43
+
44
+ - Fix growing number of open file descriptors when HTTP request to APM is never sent {pull}1351[#1351]
45
+ - Fix setting span http status code when Faraday Middleware is used {pull}1368[#1368]
46
+ - Handle whitespace when splitting tracestate entries {pull}1353[#1353]
47
+
38
48
  [[release-notes-4.6.0]]
39
49
  ==== 4.6.0
40
50
 
data/Gemfile CHANGED
@@ -116,6 +116,8 @@ if RUBY_PLATFORM == 'java'
116
116
  end
117
117
  elsif frameworks_versions['rails'] =~ /^(4|5)/
118
118
  gem 'sqlite3', '~> 1.3.6'
119
+ elsif RUBY_VERSION < '2.7'
120
+ gem 'sqlite3', '~> 1.4.4'
119
121
  else
120
122
  gem 'sqlite3'
121
123
  end
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:
@@ -102,6 +102,7 @@ module ElasticAPM
102
102
  ) do |span|
103
103
  ElasticAPM::Spies.without_net_http do
104
104
  trace_context = span&.trace_context || transaction.trace_context
105
+ self.response :elastic_apm_middleware, span # middleware
105
106
 
106
107
  result = super(method, url, body, headers) do |req|
107
108
  trace_context.apply_headers { |k, v| req[k] = v }
@@ -122,6 +123,28 @@ module ElasticAPM
122
123
  # rubocop:enable Metrics/PerceivedComplexity, Metrics/CyclomaticComplexity
123
124
 
124
125
  def install
126
+ # This middleware class has to be defined here because it inherits from
127
+ # ::Faraday::Middleware, which isn't defined when this file loads.
128
+ tracing_middleware = Class.new ::Faraday::Middleware do
129
+ attr_reader :span
130
+
131
+ def initialize(app, span = nil, options = {})
132
+ super(app)
133
+ @span = span
134
+ end
135
+
136
+ def on_complete(env)
137
+ status = env[:status]
138
+ http = span&.context&.http
139
+ if http && status
140
+ http.status_code = status.to_s
141
+ span.outcome = Span::Outcome.from_http_status(status)
142
+ end
143
+ end
144
+ end
145
+ ::Faraday::Response.register_middleware(
146
+ elastic_apm_middleware: -> { tracing_middleware }
147
+ )
125
148
  ::Faraday::Connection.prepend(Ext)
126
149
  end
127
150
  end
@@ -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.6.1'
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.6.1
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-03-01 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: concurrent-ruby
@@ -82,6 +82,8 @@ files:
82
82
  - ".ci/jobs/defaults.yml"
83
83
  - ".ci/linting.groovy"
84
84
  - ".ci/packer_cache.sh"
85
+ - ".ci/snapshoty.yml"
86
+ - ".ci/update-specs.yml"
85
87
  - ".github/ISSUE_TEMPLATE/Bug_report.md"
86
88
  - ".github/ISSUE_TEMPLATE/Feature_request.md"
87
89
  - ".github/PULL_REQUEST_TEMPLATE.md"
@@ -89,6 +91,7 @@ files:
89
91
  - ".github/labeler-config.yml"
90
92
  - ".github/workflows/addToProject.yml"
91
93
  - ".github/workflows/labeler.yml"
94
+ - ".github/workflows/update-specs.yml"
92
95
  - ".gitignore"
93
96
  - ".pre-commit-config.yaml"
94
97
  - ".rspec"