elastic-apm 4.5.1 → 4.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.ci/.jenkins_exclude.yml +73 -16
- data/.ci/.jenkins_framework.yml +3 -2
- data/.ci/.jenkins_ruby.yml +1 -1
- data/.ci/.jenkins_ruby_benchmarks.yml +6 -0
- data/.ci/Jenkinsfile +5 -27
- data/CHANGELOG.asciidoc +24 -0
- data/Gemfile +8 -3
- data/bench/report.rb +1 -1
- data/docs/configuration.asciidoc +6 -4
- data/elastic-apm.gemspec +3 -2
- data/lib/elastic_apm/central_config.rb +5 -0
- data/lib/elastic_apm/config/server_info.rb +50 -0
- data/lib/elastic_apm/config.rb +25 -4
- data/lib/elastic_apm/error.rb +2 -1
- data/lib/elastic_apm/error_builder.rb +1 -0
- data/lib/elastic_apm/instrumenter.rb +4 -2
- data/lib/elastic_apm/metadata/system_info/container_info.rb +4 -3
- data/lib/elastic_apm/metadata/system_info.rb +1 -1
- data/lib/elastic_apm/span/context/links.rb +32 -0
- data/lib/elastic_apm/span/context/service.rb +55 -0
- data/lib/elastic_apm/span/context.rb +19 -3
- data/lib/elastic_apm/span.rb +3 -0
- data/lib/elastic_apm/span_helpers.rb +2 -2
- data/lib/elastic_apm/spies/racecar.rb +77 -0
- data/lib/elastic_apm/spies/redis.rb +1 -1
- data/lib/elastic_apm/spies/sequel.rb +9 -0
- data/lib/elastic_apm/spies/sqs.rb +1 -0
- data/lib/elastic_apm/trace_context/tracestate.rb +1 -1
- data/lib/elastic_apm/trace_context.rb +1 -1
- data/lib/elastic_apm/transport/serializers/span_serializer.rb +25 -0
- data/lib/elastic_apm/version.rb +1 -1
- data/lib/elastic_apm.rb +1 -0
- metadata +23 -3
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: edae30dc148307b137e402a81ffed731cbe738ca7924f31c9440a9a6ea9a8eb4
|
|
4
|
+
data.tar.gz: ef860d2d783fd9351b0eea3106e96eafbadef339fa72a4b5979fbc38d4e3d46a
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 8e1543b7f39d5ba73eb30e34777ba07a8ae940ddd1aee2d84afc445642319304bd26036a9eb5b5e6d4d9c11bbc0323c7c17aa2bd18101bbfcfed1cdcf6bdc635
|
|
7
|
+
data.tar.gz: 971963f1d06a398c2af8f988e4386004b7fb176e67d6d8c35b9be8a781b8561fd8236395d89f51ef87e3cad4375f9c91c4105e550dc7f7b1e7b1142e1d0f7c17
|
data/.ci/.jenkins_exclude.yml
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
exclude:
|
|
2
2
|
# Ruby 2.4
|
|
3
|
-
# Only
|
|
3
|
+
# Only test on rails-5.2, sinatra-1.4
|
|
4
|
+
- RUBY_VERSION: ruby:2.4
|
|
5
|
+
FRAMEWORK: rails-7.0
|
|
4
6
|
- RUBY_VERSION: ruby:2.4
|
|
5
7
|
FRAMEWORK: rails-6.1
|
|
6
8
|
- RUBY_VERSION: ruby:2.4
|
|
@@ -8,11 +10,11 @@ exclude:
|
|
|
8
10
|
- RUBY_VERSION: ruby:2.4
|
|
9
11
|
FRAMEWORK: rails-4.2
|
|
10
12
|
- RUBY_VERSION: ruby:2.4
|
|
11
|
-
FRAMEWORK: sinatra-
|
|
13
|
+
FRAMEWORK: sinatra-2.2
|
|
12
14
|
- RUBY_VERSION: ruby:2.4
|
|
13
15
|
FRAMEWORK: grape-1.6
|
|
14
16
|
- RUBY_VERSION: ruby:2.4
|
|
15
|
-
FRAMEWORK: grape-1.6,sinatra-2.
|
|
17
|
+
FRAMEWORK: grape-1.6,sinatra-2.2,rails-6.0
|
|
16
18
|
- RUBY_VERSION: ruby:2.4
|
|
17
19
|
FRAMEWORK: rails-main
|
|
18
20
|
- RUBY_VERSION: ruby:2.4
|
|
@@ -21,7 +23,9 @@ exclude:
|
|
|
21
23
|
FRAMEWORK: grape-master
|
|
22
24
|
|
|
23
25
|
# rails-4.2 exclusions
|
|
24
|
-
# Only test on ruby 2.6, 2.5, 2.4
|
|
26
|
+
# Only test on ruby 2.6, 2.5, 2.4
|
|
27
|
+
- RUBY_VERSION: ruby:3.1
|
|
28
|
+
FRAMEWORK: rails-4.2
|
|
25
29
|
- RUBY_VERSION: ruby:3.0
|
|
26
30
|
FRAMEWORK: rails-4.2
|
|
27
31
|
- RUBY_VERSION: ruby:2.7
|
|
@@ -35,6 +39,8 @@ exclude:
|
|
|
35
39
|
- RUBY_VERSION: docker.elastic.co/observability-ci/jruby:9.2-8-jdk
|
|
36
40
|
FRAMEWORK: rails-4.2
|
|
37
41
|
# sinatra-1.4 exclusions
|
|
42
|
+
- RUBY_VERSION: ruby:3.1
|
|
43
|
+
FRAMEWORK: sinatra-1.4
|
|
38
44
|
- RUBY_VERSION: ruby:3.0
|
|
39
45
|
FRAMEWORK: sinatra-1.4
|
|
40
46
|
- RUBY_VERSION: ruby:2.7
|
|
@@ -55,7 +61,11 @@ exclude:
|
|
|
55
61
|
- RUBY_VERSION: ruby:2.4
|
|
56
62
|
FRAMEWORK: rails-6.0
|
|
57
63
|
|
|
58
|
-
# Only test rails master on ruby
|
|
64
|
+
# Only test rails master on ruby 3.1
|
|
65
|
+
- RUBY_VERSION: ruby:3.0
|
|
66
|
+
FRAMEWORK: rails-main
|
|
67
|
+
- RUBY_VERSION: ruby:2.7
|
|
68
|
+
FRAMEWORK: rails-main
|
|
59
69
|
- RUBY_VERSION: ruby:2.6
|
|
60
70
|
FRAMEWORK: rails-main
|
|
61
71
|
- RUBY_VERSION: ruby:2.5
|
|
@@ -71,7 +81,25 @@ exclude:
|
|
|
71
81
|
- RUBY_VERSION: docker.elastic.co/observability-ci/jruby:9.2-8-jdk
|
|
72
82
|
FRAMEWORK: rails-main
|
|
73
83
|
|
|
74
|
-
# Only test
|
|
84
|
+
# Only test rails 7.0 on ruby >= 2.7
|
|
85
|
+
- RUBY_VERSION: ruby:2.6
|
|
86
|
+
FRAMEWORK: rails-7.0
|
|
87
|
+
- RUBY_VERSION: ruby:2.5
|
|
88
|
+
FRAMEWORK: rails-7.0
|
|
89
|
+
- RUBY_VERSION: ruby:2.4
|
|
90
|
+
FRAMEWORK: rails-7.0
|
|
91
|
+
- RUBY_VERSION: jruby:9.2
|
|
92
|
+
FRAMEWORK: rails-7.0
|
|
93
|
+
- RUBY_VERSION: docker.elastic.co/observability-ci/jruby:9.2-13-jdk
|
|
94
|
+
FRAMEWORK: rails-7.0
|
|
95
|
+
- RUBY_VERSION: docker.elastic.co/observability-ci/jruby:9.2-11-jdk
|
|
96
|
+
FRAMEWORK: rails-7.0
|
|
97
|
+
- RUBY_VERSION: docker.elastic.co/observability-ci/jruby:9.2-8-jdk
|
|
98
|
+
FRAMEWORK: rails-7.0
|
|
99
|
+
|
|
100
|
+
# Only test sinatra master on ruby 2.7 and ruby 3.1
|
|
101
|
+
- RUBY_VERSION: ruby:3.0
|
|
102
|
+
FRAMEWORK: sinatra-master
|
|
75
103
|
- RUBY_VERSION: ruby:2.6
|
|
76
104
|
FRAMEWORK: sinatra-master
|
|
77
105
|
- RUBY_VERSION: ruby:2.5
|
|
@@ -104,31 +132,60 @@ exclude:
|
|
|
104
132
|
FRAMEWORK: grape-master
|
|
105
133
|
|
|
106
134
|
# grape 1.5 doesn't support ruby 3.0
|
|
135
|
+
- RUBY_VERSION: ruby:3.1
|
|
136
|
+
FRAMEWORK: grape-1.6
|
|
137
|
+
- RUBY_VERSION: ruby:3.1
|
|
138
|
+
FRAMEWORK: grape-1.6,sinatra-2.2,rails-7.0
|
|
139
|
+
- RUBY_VERSION: ruby:3.1
|
|
140
|
+
FRAMEWORK: grape-1.6,sinatra-2.2,rails-6.1
|
|
107
141
|
- RUBY_VERSION: ruby:3.0
|
|
108
142
|
FRAMEWORK: grape-1.6
|
|
109
143
|
- RUBY_VERSION: ruby:3.0
|
|
110
|
-
FRAMEWORK: grape-1.6,sinatra-2.
|
|
144
|
+
FRAMEWORK: grape-1.6,sinatra-2.2,rails-6.1
|
|
111
145
|
|
|
112
|
-
# only test ruby 3.0 with rails 6.0 and rails 6.1
|
|
146
|
+
# only test ruby >= 3.0 with rails 6.0 and rails 6.1
|
|
147
|
+
- RUBY_VERSION: ruby:3.1
|
|
148
|
+
FRAMEWORK: rails-5.2
|
|
149
|
+
- RUBY_VERSION: ruby:3.1
|
|
150
|
+
FRAMEWORK: rails-5.1
|
|
113
151
|
- RUBY_VERSION: ruby:3.0
|
|
114
152
|
FRAMEWORK: rails-5.2
|
|
115
153
|
- RUBY_VERSION: ruby:3.0
|
|
116
154
|
FRAMEWORK: rails-5.1
|
|
117
155
|
|
|
118
156
|
# Unsupported
|
|
157
|
+
# Ruby 2.6
|
|
119
158
|
- RUBY_VERSION: ruby:2.6
|
|
120
|
-
FRAMEWORK: grape-1.6,sinatra-2.
|
|
159
|
+
FRAMEWORK: grape-1.6,sinatra-2.2,rails-6.1
|
|
160
|
+
- RUBY_VERSION: ruby:2.6
|
|
161
|
+
FRAMEWORK: grape-1.6,sinatra-2.2,rails-7.0
|
|
162
|
+
# Ruby 2.5
|
|
163
|
+
- RUBY_VERSION: ruby:2.5
|
|
164
|
+
FRAMEWORK: grape-1.6,sinatra-2.2,rails-6.1
|
|
121
165
|
- RUBY_VERSION: ruby:2.5
|
|
122
|
-
FRAMEWORK: grape-1.6,sinatra-2.
|
|
166
|
+
FRAMEWORK: grape-1.6,sinatra-2.2,rails-7.0
|
|
167
|
+
# Ruby 2.4
|
|
123
168
|
- RUBY_VERSION: ruby:2.4
|
|
124
|
-
FRAMEWORK: grape-1.6,sinatra-2.
|
|
169
|
+
FRAMEWORK: grape-1.6,sinatra-2.2,rails-6.1
|
|
125
170
|
- RUBY_VERSION: ruby:2.4
|
|
126
|
-
FRAMEWORK: grape-1.6,sinatra-2.
|
|
171
|
+
FRAMEWORK: grape-1.6,sinatra-2.2,rails-7.0
|
|
172
|
+
# JRuby 9.2
|
|
173
|
+
- RUBY_VERSION: jruby:9.2
|
|
174
|
+
FRAMEWORK: grape-1.6,sinatra-2.2,rails-6.1
|
|
127
175
|
- RUBY_VERSION: jruby:9.2
|
|
128
|
-
FRAMEWORK: grape-1.6,sinatra-2.
|
|
176
|
+
FRAMEWORK: grape-1.6,sinatra-2.2,rails-7.0
|
|
177
|
+
# JRuby 9.2-13-jdk
|
|
129
178
|
- RUBY_VERSION: docker.elastic.co/observability-ci/jruby:9.2-13-jdk
|
|
130
|
-
FRAMEWORK: grape-1.6,sinatra-2.
|
|
179
|
+
FRAMEWORK: grape-1.6,sinatra-2.2,rails-6.1
|
|
180
|
+
- RUBY_VERSION: docker.elastic.co/observability-ci/jruby:9.2-13-jdk
|
|
181
|
+
FRAMEWORK: grape-1.6,sinatra-2.2,rails-7.0
|
|
182
|
+
# JRuby 9.2-11-jdk
|
|
183
|
+
- RUBY_VERSION: docker.elastic.co/observability-ci/jruby:9.2-11-jdk
|
|
184
|
+
FRAMEWORK: grape-1.6,sinatra-2.2,rails-6.1
|
|
131
185
|
- RUBY_VERSION: docker.elastic.co/observability-ci/jruby:9.2-11-jdk
|
|
132
|
-
FRAMEWORK: grape-1.6,sinatra-2.
|
|
186
|
+
FRAMEWORK: grape-1.6,sinatra-2.2,rails-7.0
|
|
187
|
+
# JRuby 9.2-8-jdk
|
|
188
|
+
- RUBY_VERSION: docker.elastic.co/observability-ci/jruby:9.2-8-jdk
|
|
189
|
+
FRAMEWORK: grape-1.6,sinatra-2.2,rails-6.1
|
|
133
190
|
- RUBY_VERSION: docker.elastic.co/observability-ci/jruby:9.2-8-jdk
|
|
134
|
-
FRAMEWORK: grape-1.6,sinatra-2.
|
|
191
|
+
FRAMEWORK: grape-1.6,sinatra-2.2,rails-7.0
|
data/.ci/.jenkins_framework.yml
CHANGED
data/.ci/.jenkins_ruby.yml
CHANGED
data/.ci/Jenkinsfile
CHANGED
|
@@ -21,8 +21,6 @@ pipeline {
|
|
|
21
21
|
CODECOV_SECRET = 'secret/apm-team/ci/apm-agent-ruby-codecov'
|
|
22
22
|
DOCKER_REGISTRY = 'docker.elastic.co'
|
|
23
23
|
DOCKER_SECRET = 'secret/apm-team/ci/docker-registry/prod'
|
|
24
|
-
GITHUB_CHECK_ITS_NAME = 'Integration Tests'
|
|
25
|
-
ITS_PIPELINE = 'apm-integration-tests-selector-mbp/main'
|
|
26
24
|
RELEASE_SECRET = 'secret/apm-team/ci/apm-agent-ruby-rubygems-release'
|
|
27
25
|
OPBEANS_REPO = 'opbeans-ruby'
|
|
28
26
|
REFERENCE_REPO = '/var/lib/jenkins/.git-references/apm-agent-ruby.git'
|
|
@@ -123,25 +121,6 @@ pipeline {
|
|
|
123
121
|
}
|
|
124
122
|
}
|
|
125
123
|
}
|
|
126
|
-
stage('Integration Tests') {
|
|
127
|
-
agent none
|
|
128
|
-
when {
|
|
129
|
-
beforeAgent true
|
|
130
|
-
anyOf {
|
|
131
|
-
changeRequest()
|
|
132
|
-
expression { return !params.Run_As_Main_Branch }
|
|
133
|
-
}
|
|
134
|
-
}
|
|
135
|
-
steps {
|
|
136
|
-
githubNotify(context: "${env.GITHUB_CHECK_ITS_NAME}", description: "${env.GITHUB_CHECK_ITS_NAME} ...", status: 'PENDING', targetUrl: "${env.JENKINS_URL}search/?q=${env.ITS_PIPELINE.replaceAll('/','+')}")
|
|
137
|
-
build(job: env.ITS_PIPELINE, propagate: false, wait: true,
|
|
138
|
-
parameters: [ string(name: 'INTEGRATION_TEST', value: 'Ruby'),
|
|
139
|
-
string(name: 'BUILD_OPTS', value: "--ruby-agent-version ${env.GIT_BASE_COMMIT} --ruby-agent-version-state ${env.GIT_BUILD_CAUSE} --ruby-agent-repo ${env.CHANGE_FORK?.trim() ?: 'elastic'}/${env.REPO} --opbeans-ruby-agent-branch ${env.GIT_BASE_COMMIT}"),
|
|
140
|
-
string(name: 'GITHUB_CHECK_NAME', value: env.GITHUB_CHECK_ITS_NAME),
|
|
141
|
-
string(name: 'GITHUB_CHECK_REPO', value: env.REPO),
|
|
142
|
-
string(name: 'GITHUB_CHECK_SHA1', value: env.GIT_BASE_COMMIT) ])
|
|
143
|
-
}
|
|
144
|
-
}
|
|
145
124
|
}
|
|
146
125
|
}
|
|
147
126
|
stage('Benchmarks') {
|
|
@@ -162,13 +141,13 @@ pipeline {
|
|
|
162
141
|
}
|
|
163
142
|
stages {
|
|
164
143
|
stage('Clean Workspace') {
|
|
165
|
-
agent { label '
|
|
144
|
+
agent { label 'microbenchmarks-pool' }
|
|
166
145
|
steps {
|
|
167
146
|
echo "Cleaning Workspace"
|
|
168
147
|
}
|
|
169
148
|
post {
|
|
170
149
|
always {
|
|
171
|
-
cleanWs()
|
|
150
|
+
cleanWs(notFailBuild: true)
|
|
172
151
|
}
|
|
173
152
|
}
|
|
174
153
|
}
|
|
@@ -183,7 +162,7 @@ pipeline {
|
|
|
183
162
|
unstash 'source'
|
|
184
163
|
dir("${BASE_DIR}"){
|
|
185
164
|
script {
|
|
186
|
-
def versions = readYaml(file: ".ci/.
|
|
165
|
+
def versions = readYaml(file: ".ci/.jenkins_ruby_benchmarks.yml")
|
|
187
166
|
def benchmarkTask = [:]
|
|
188
167
|
versions['RUBY_VERSION'].each{ v ->
|
|
189
168
|
benchmarkTask[v] = runBenchmark(v)
|
|
@@ -283,7 +262,7 @@ pipeline {
|
|
|
283
262
|
*/
|
|
284
263
|
def runBenchmark(version){
|
|
285
264
|
return {
|
|
286
|
-
node('
|
|
265
|
+
node('microbenchmarks-pool'){
|
|
287
266
|
// Transform the versions like:
|
|
288
267
|
// - docker.elastic.co/observability-ci/jruby:9.2-12-jdk to jruby-9.2-12-jdk
|
|
289
268
|
// - jruby:9.1 to jruby-9.1
|
|
@@ -299,8 +278,6 @@ def runBenchmark(version){
|
|
|
299
278
|
}
|
|
300
279
|
try{
|
|
301
280
|
sh """./spec/scripts/benchmarks.sh "${version}" "${REFERENCE_REPO}" """
|
|
302
|
-
} catch(e){
|
|
303
|
-
throw e
|
|
304
281
|
} finally {
|
|
305
282
|
archiveArtifacts(
|
|
306
283
|
allowEmptyArchive: true,
|
|
@@ -308,6 +285,7 @@ def runBenchmark(version){
|
|
|
308
285
|
onlyIfSuccessful: false)
|
|
309
286
|
sendBenchmarks(file: "benchmark-${transformedVersion}.bulk",
|
|
310
287
|
index: "benchmark-ruby", archive: true)
|
|
288
|
+
cleanWs(notFailBuild: true)
|
|
311
289
|
}
|
|
312
290
|
}
|
|
313
291
|
}
|
data/CHANGELOG.asciidoc
CHANGED
|
@@ -35,6 +35,30 @@ endif::[]
|
|
|
35
35
|
[[release-notes-4.x]]
|
|
36
36
|
=== Ruby Agent version 4.x
|
|
37
37
|
|
|
38
|
+
[[release-notes-4.6.0]]
|
|
39
|
+
==== 4.6.0
|
|
40
|
+
|
|
41
|
+
[float]
|
|
42
|
+
===== Added
|
|
43
|
+
|
|
44
|
+
- Added transaction_name to reported error to allow grouping by transaction name {pull}1267[#1267]
|
|
45
|
+
- Added ability to query server for version (useful in the future) {pull}1278[#1278]
|
|
46
|
+
- Added instrumentation for https://github.com/zendesk/racecar/ Racecar Kafka library {pull}1284[#1284]
|
|
47
|
+
|
|
48
|
+
===== Changed
|
|
49
|
+
|
|
50
|
+
- Expanded filtering to sanitize any key that contains the string 'auth' {pull}1266[#1266]
|
|
51
|
+
- Rename `log_ecs_formatting` option to `log_ecs_reformatting`, deprecate old option name {pull}1248[#1248]
|
|
52
|
+
- 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]
|
|
53
|
+
- Only send tracestate header for distributed tracing when it has content {pull}1277[#1277]
|
|
54
|
+
- Use the hostname as the Kubernetes pod name in the Container Info metadata if the pod id is parsed from cgroup {pull}1314[#1314]
|
|
55
|
+
|
|
56
|
+
====== Fixed
|
|
57
|
+
|
|
58
|
+
- Small change to Sidekiq tests to handle new configuration passing method {pull}1283[#1283]
|
|
59
|
+
- Set transaction sample rate to 0 when it's unsampled {pull}1339[#1339]
|
|
60
|
+
- Don't send unsampled transactions to APM server >= 8.0 {pull}1341[#1341]
|
|
61
|
+
|
|
38
62
|
[[release-notes-4.5.1]]
|
|
39
63
|
==== 4.5.1
|
|
40
64
|
|
data/Gemfile
CHANGED
|
@@ -46,11 +46,12 @@ if !defined?(JRUBY_VERSION) && RUBY_VERSION < '2.5'
|
|
|
46
46
|
gem 'google-protobuf', '< 3.12'
|
|
47
47
|
end
|
|
48
48
|
gem 'grpc' if !defined?(JRUBY_VERSION) && RUBY_VERSION < '3.0'
|
|
49
|
-
gem 'json'
|
|
49
|
+
gem 'json'
|
|
50
50
|
gem 'json-schema', require: nil
|
|
51
51
|
gem 'mongo', require: nil
|
|
52
52
|
gem 'opentracing', require: nil
|
|
53
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
|
|
@@ -77,6 +78,10 @@ frameworks_versions = parsed_frameworks.inject({}) do |frameworks, str|
|
|
|
77
78
|
end
|
|
78
79
|
|
|
79
80
|
frameworks_versions.each do |framework, version|
|
|
81
|
+
if framework =='rails' && RUBY_VERSION >= '3.1'
|
|
82
|
+
gem 'net-smtp', require: false
|
|
83
|
+
end
|
|
84
|
+
|
|
80
85
|
case version
|
|
81
86
|
when 'master' # sinatra, grape
|
|
82
87
|
gem framework, github: GITHUB_REPOS.fetch(framework)
|
|
@@ -115,8 +120,8 @@ else
|
|
|
115
120
|
gem 'sqlite3'
|
|
116
121
|
end
|
|
117
122
|
|
|
118
|
-
#
|
|
119
|
-
if Gem::Version.create(RUBY_VERSION) >= Gem::Version.create('2.5.0')
|
|
123
|
+
# sneakers main only supports >=2.5.0
|
|
124
|
+
if Gem::Version.create(RUBY_VERSION) >= Gem::Version.create('2.5.0') && !defined?(JRUBY_VERSION)
|
|
120
125
|
gem 'sneakers', github: 'jondot/sneakers', ref: 'd761dfe1493', require: nil
|
|
121
126
|
end
|
|
122
127
|
|
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"
|
|
14
|
+
puts({ index: { _index: "benchmark-ruby" } }.to_json)
|
|
15
15
|
puts(payload.to_json)
|
|
16
16
|
end
|
|
17
17
|
|
data/docs/configuration.asciidoc
CHANGED
|
@@ -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
|
-
==== `
|
|
509
|
+
==== `log_ecs_reformatting`
|
|
510
510
|
|
|
511
511
|
[options="header"]
|
|
512
512
|
|============
|
|
513
513
|
| Environment | `Config` key | Default
|
|
514
|
-
| `
|
|
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 `
|
|
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*,
|
|
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.
|
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 = ['
|
|
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
|
+
|
data/lib/elastic_apm/config.rb
CHANGED
|
@@ -24,14 +24,17 @@ require 'elastic_apm/config/options'
|
|
|
24
24
|
require 'elastic_apm/config/round_float'
|
|
25
25
|
require 'elastic_apm/config/regexp_list'
|
|
26
26
|
require 'elastic_apm/config/wildcard_pattern_list'
|
|
27
|
+
require 'elastic_apm/deprecations'
|
|
28
|
+
require 'elastic_apm/config/server_info'
|
|
27
29
|
|
|
28
30
|
module ElasticAPM
|
|
29
31
|
# @api private
|
|
30
32
|
class Config
|
|
31
33
|
extend Options
|
|
34
|
+
extend Deprecations
|
|
32
35
|
|
|
33
36
|
SANITIZE_FIELD_NAMES_DEFAULT =
|
|
34
|
-
%w[password passwd pwd secret *key *token* *session* *credit* *card*
|
|
37
|
+
%w[password passwd pwd secret *key *token* *session* *credit* *card* *auth* set-cookie].freeze
|
|
35
38
|
|
|
36
39
|
# rubocop:disable Layout/LineLength, Layout/ExtraSpacing
|
|
37
40
|
option :config_file, type: :string, default: 'config/elastic_apm.yml'
|
|
@@ -70,7 +73,7 @@ module ElasticAPM
|
|
|
70
73
|
option :ignore_url_patterns, type: :list, default: [], converter: RegexpList.new
|
|
71
74
|
option :instrument, type: :bool, default: true
|
|
72
75
|
option :instrumented_rake_tasks, type: :list, default: []
|
|
73
|
-
option :
|
|
76
|
+
option :log_ecs_reformatting, type: :string, default: 'off'
|
|
74
77
|
option :log_level, type: :int, default: Logger::INFO, converter: LogLevelMap.new
|
|
75
78
|
option :log_path, type: :string
|
|
76
79
|
option :metrics_interval, type: :int, default: '30s', converter: Duration.new
|
|
@@ -98,6 +101,16 @@ module ElasticAPM
|
|
|
98
101
|
option :use_elastic_traceparent_header, type: :bool, default: true
|
|
99
102
|
option :verify_server_cert, type: :bool, default: true
|
|
100
103
|
|
|
104
|
+
def log_ecs_formatting
|
|
105
|
+
log_ecs_reformatting
|
|
106
|
+
end
|
|
107
|
+
|
|
108
|
+
def log_ecs_formatting=(value)
|
|
109
|
+
@options[:log_ecs_reformatting].set(value)
|
|
110
|
+
end
|
|
111
|
+
|
|
112
|
+
deprecate :log_ecs_formatting, :log_ecs_reformatting
|
|
113
|
+
|
|
101
114
|
# rubocop:enable Layout/LineLength, Layout/ExtraSpacing
|
|
102
115
|
def initialize(options = {})
|
|
103
116
|
@options = load_schema
|
|
@@ -116,7 +129,9 @@ module ElasticAPM
|
|
|
116
129
|
|
|
117
130
|
yield self if block_given?
|
|
118
131
|
|
|
119
|
-
self.logger
|
|
132
|
+
if self.logger.nil? || self.log_path
|
|
133
|
+
self.logger = build_logger
|
|
134
|
+
end
|
|
120
135
|
|
|
121
136
|
@__view_paths ||= []
|
|
122
137
|
@__root_path ||= Dir.pwd
|
|
@@ -144,6 +159,7 @@ module ElasticAPM
|
|
|
144
159
|
mongo
|
|
145
160
|
net_http
|
|
146
161
|
rake
|
|
162
|
+
racecar
|
|
147
163
|
redis
|
|
148
164
|
resque
|
|
149
165
|
s3
|
|
@@ -229,6 +245,10 @@ module ElasticAPM
|
|
|
229
245
|
super.split.first + '>'
|
|
230
246
|
end
|
|
231
247
|
|
|
248
|
+
def version
|
|
249
|
+
@version ||= ServerInfo.new(self).version
|
|
250
|
+
end
|
|
251
|
+
|
|
232
252
|
private
|
|
233
253
|
|
|
234
254
|
def load_config_file
|
|
@@ -247,7 +267,7 @@ module ElasticAPM
|
|
|
247
267
|
end
|
|
248
268
|
|
|
249
269
|
def build_logger
|
|
250
|
-
if self.
|
|
270
|
+
if self.log_ecs_reformatting == 'override'
|
|
251
271
|
begin
|
|
252
272
|
return build_ecs_logger
|
|
253
273
|
rescue LoadError
|
|
@@ -294,6 +314,7 @@ module ElasticAPM
|
|
|
294
314
|
self.framework_name ||= 'Ruby on Rails'
|
|
295
315
|
self.framework_version ||= ::Rails::VERSION::STRING
|
|
296
316
|
self.logger ||= ::Rails.logger
|
|
317
|
+
self.log_level ||= ::Rails.logger.log_level
|
|
297
318
|
|
|
298
319
|
self.__root_path = ::Rails.root.to_s
|
|
299
320
|
self.__view_paths = app.config.paths['app/views'].existent +
|
data/lib/elastic_apm/error.rb
CHANGED
|
@@ -33,7 +33,7 @@ module ElasticAPM
|
|
|
33
33
|
end
|
|
34
34
|
|
|
35
35
|
attr_accessor :id, :culprit, :exception, :log, :transaction_id,
|
|
36
|
-
:transaction, :context, :parent_id, :trace_id
|
|
36
|
+
:transaction_name, :transaction, :context, :parent_id, :trace_id
|
|
37
37
|
attr_reader :timestamp
|
|
38
38
|
|
|
39
39
|
def inspect
|
|
@@ -41,6 +41,7 @@ module ElasticAPM
|
|
|
41
41
|
" culprit:#{culprit}" \
|
|
42
42
|
" timestamp:#{timestamp}" \
|
|
43
43
|
" transaction_id:#{transaction_id}" \
|
|
44
|
+
" transaction_name:#{transaction_name}" \
|
|
44
45
|
" trace_id:#{trace_id}" \
|
|
45
46
|
" exception:#{exception.inspect}" \
|
|
46
47
|
'>'
|
|
@@ -124,7 +124,7 @@ module ElasticAPM
|
|
|
124
124
|
sample_rate = trace_context.tracestate.sample_rate
|
|
125
125
|
else
|
|
126
126
|
sampled = random_sample?(config)
|
|
127
|
-
sample_rate = config.transaction_sample_rate
|
|
127
|
+
sample_rate = sampled ? config.transaction_sample_rate : 0
|
|
128
128
|
end
|
|
129
129
|
|
|
130
130
|
transaction =
|
|
@@ -150,7 +150,9 @@ module ElasticAPM
|
|
|
150
150
|
|
|
151
151
|
transaction.done result
|
|
152
152
|
|
|
153
|
-
|
|
153
|
+
if transaction.sampled? || @config.version < Config::ServerInfo::VERSION_8_0
|
|
154
|
+
enqueue.call transaction
|
|
155
|
+
end
|
|
154
156
|
|
|
155
157
|
update_transaction_metrics(transaction)
|
|
156
158
|
|
|
@@ -33,14 +33,15 @@ module ElasticAPM
|
|
|
33
33
|
|
|
34
34
|
attr_reader :cgroup_path
|
|
35
35
|
|
|
36
|
-
def read!
|
|
36
|
+
def read!(hostname)
|
|
37
37
|
read_from_cgroup!
|
|
38
|
+
self.kubernetes_pod_name = hostname if kubernetes_pod_uid
|
|
38
39
|
read_from_env!
|
|
39
40
|
self
|
|
40
41
|
end
|
|
41
42
|
|
|
42
|
-
def self.read!
|
|
43
|
-
new.read!
|
|
43
|
+
def self.read!(hostname)
|
|
44
|
+
new.read!(hostname)
|
|
44
45
|
end
|
|
45
46
|
|
|
46
47
|
def container
|
|
@@ -29,7 +29,7 @@ module ElasticAPM
|
|
|
29
29
|
@architecture = gem_platform.cpu
|
|
30
30
|
@platform = gem_platform.os
|
|
31
31
|
|
|
32
|
-
container_info = ContainerInfo.read!
|
|
32
|
+
container_info = ContainerInfo.read!(@detected_hostname)
|
|
33
33
|
@container = container_info.container
|
|
34
34
|
@kubernetes = container_info.kubernetes
|
|
35
35
|
end
|
|
@@ -0,0 +1,32 @@
|
|
|
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 Span
|
|
22
|
+
class Context
|
|
23
|
+
# @api private
|
|
24
|
+
class Links < Array
|
|
25
|
+
# @api private
|
|
26
|
+
class Link < Struct.new(:trace_id, :span_id)
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
|
|
@@ -0,0 +1,55 @@
|
|
|
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 Span
|
|
22
|
+
class Context
|
|
23
|
+
# @api private
|
|
24
|
+
class Service
|
|
25
|
+
include Fields
|
|
26
|
+
|
|
27
|
+
field :target
|
|
28
|
+
|
|
29
|
+
# @api private
|
|
30
|
+
class Target
|
|
31
|
+
include Fields
|
|
32
|
+
|
|
33
|
+
field :name, default: ''
|
|
34
|
+
field :type, default: ''
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
def initialize(target: nil, **attrs)
|
|
38
|
+
super(**attrs)
|
|
39
|
+
|
|
40
|
+
self.target = build_target(target)
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
private
|
|
44
|
+
|
|
45
|
+
def build_target(target = nil)
|
|
46
|
+
return Target.new unless target
|
|
47
|
+
return target if target.is_a?(Target)
|
|
48
|
+
|
|
49
|
+
Target.new(**target)
|
|
50
|
+
end
|
|
51
|
+
end
|
|
52
|
+
end
|
|
53
|
+
end
|
|
54
|
+
end
|
|
55
|
+
|
|
@@ -27,7 +27,9 @@ module ElasticAPM
|
|
|
27
27
|
http: nil,
|
|
28
28
|
labels: {},
|
|
29
29
|
sync: nil,
|
|
30
|
-
message: nil
|
|
30
|
+
message: nil,
|
|
31
|
+
service: nil,
|
|
32
|
+
links: nil
|
|
31
33
|
)
|
|
32
34
|
@sync = sync
|
|
33
35
|
@db = db && Db.new(**db)
|
|
@@ -43,6 +45,16 @@ module ElasticAPM
|
|
|
43
45
|
when Hash then Message.new(**message)
|
|
44
46
|
end
|
|
45
47
|
@labels = labels
|
|
48
|
+
@service =
|
|
49
|
+
case service
|
|
50
|
+
when Service then service
|
|
51
|
+
when Hash then Service.new(**service)
|
|
52
|
+
end
|
|
53
|
+
@links =
|
|
54
|
+
case links
|
|
55
|
+
when Links then links
|
|
56
|
+
when Array then Links.new(links)
|
|
57
|
+
end
|
|
46
58
|
end
|
|
47
59
|
|
|
48
60
|
attr_reader(
|
|
@@ -50,10 +62,11 @@ module ElasticAPM
|
|
|
50
62
|
:http,
|
|
51
63
|
:labels,
|
|
52
64
|
:sync,
|
|
53
|
-
:message
|
|
65
|
+
:message,
|
|
66
|
+
:links
|
|
54
67
|
)
|
|
55
68
|
|
|
56
|
-
attr_accessor :destination
|
|
69
|
+
attr_accessor :destination, :service
|
|
57
70
|
end
|
|
58
71
|
end
|
|
59
72
|
end
|
|
@@ -62,3 +75,6 @@ require 'elastic_apm/span/context/db'
|
|
|
62
75
|
require 'elastic_apm/span/context/http'
|
|
63
76
|
require 'elastic_apm/span/context/destination'
|
|
64
77
|
require 'elastic_apm/span/context/message'
|
|
78
|
+
require 'elastic_apm/span/context/service'
|
|
79
|
+
require 'elastic_apm/span/context/links'
|
|
80
|
+
|
data/lib/elastic_apm/span.rb
CHANGED
|
@@ -145,6 +145,9 @@ module ElasticAPM
|
|
|
145
145
|
service: service,
|
|
146
146
|
cloud: cloud
|
|
147
147
|
)
|
|
148
|
+
context.service = Span::Context::Service.new(
|
|
149
|
+
target: Span::Context::Service::Target.new(name: context.destination.service.name, type: context.destination.service.type )
|
|
150
|
+
)
|
|
148
151
|
end
|
|
149
152
|
|
|
150
153
|
def inspect
|
|
@@ -37,7 +37,7 @@ module ElasticAPM
|
|
|
37
37
|
type ||= Span::DEFAULT_TYPE
|
|
38
38
|
|
|
39
39
|
klass.prepend(Module.new do
|
|
40
|
-
define_method(method) do |*args, &block|
|
|
40
|
+
ruby2_keywords(define_method(method) do |*args, &block|
|
|
41
41
|
unless ElasticAPM.current_transaction
|
|
42
42
|
return super(*args, &block)
|
|
43
43
|
end
|
|
@@ -45,7 +45,7 @@ module ElasticAPM
|
|
|
45
45
|
ElasticAPM.with_span name.to_s, type.to_s do
|
|
46
46
|
super(*args, &block)
|
|
47
47
|
end
|
|
48
|
-
end
|
|
48
|
+
end)
|
|
49
49
|
end)
|
|
50
50
|
end
|
|
51
51
|
end
|
|
@@ -0,0 +1,77 @@
|
|
|
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
|
+
begin
|
|
19
|
+
require 'active_support/notifications'
|
|
20
|
+
require 'active_support/subscriber'
|
|
21
|
+
|
|
22
|
+
# frozen_string_literal: true
|
|
23
|
+
module ElasticAPM
|
|
24
|
+
# @api private
|
|
25
|
+
module Spies
|
|
26
|
+
# @api private
|
|
27
|
+
class RacecarSpy
|
|
28
|
+
TYPE = 'kafka'
|
|
29
|
+
SUBTYPE = 'racecar'
|
|
30
|
+
|
|
31
|
+
# @api private
|
|
32
|
+
class ConsumerSubscriber < ActiveSupport::Subscriber
|
|
33
|
+
def start_process_message(event)
|
|
34
|
+
start_process_transaction(event: event, kind: 'process_message')
|
|
35
|
+
end
|
|
36
|
+
def process_message(_event)
|
|
37
|
+
ElasticAPM.end_transaction
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
def start_process_batch(event)
|
|
41
|
+
start_process_transaction(event: event, kind: 'process_batch')
|
|
42
|
+
end
|
|
43
|
+
def process_batch(_event)
|
|
44
|
+
ElasticAPM.end_transaction
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
private # only public methods will be subscribed
|
|
48
|
+
|
|
49
|
+
def start_process_transaction(event:, kind:)
|
|
50
|
+
ElasticAPM.start_transaction(kind, TYPE)
|
|
51
|
+
ElasticAPM.current_transaction.context.set_service(framework_name: 'racecar', framework_version: Racecar::VERSION)
|
|
52
|
+
end
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
class ProducerSubscriber < ActiveSupport::Subscriber
|
|
56
|
+
def start_deliver_message(event)
|
|
57
|
+
ElasticAPM.start_transaction('deliver_message',TYPE)
|
|
58
|
+
ElasticAPM.current_transaction.context.set_service(framework_name: 'racecar', framework_version: Racecar::VERSION)
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
def deliver_message(_event)
|
|
62
|
+
ElasticAPM.end_transaction
|
|
63
|
+
end
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
def install
|
|
67
|
+
ConsumerSubscriber.attach_to(:racecar)
|
|
68
|
+
ProducerSubscriber.attach_to(:racecar)
|
|
69
|
+
end
|
|
70
|
+
end
|
|
71
|
+
register 'Racecar', 'racecar', RacecarSpy.new
|
|
72
|
+
end
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
rescue LoadError
|
|
76
|
+
# no active support available
|
|
77
|
+
end
|
|
@@ -44,8 +44,17 @@ module ElasticAPM
|
|
|
44
44
|
name =
|
|
45
45
|
ElasticAPM::Spies::SequelSpy.summarizer.summarize sql
|
|
46
46
|
|
|
47
|
+
db_name = ''
|
|
48
|
+
# postgresql shows current database
|
|
49
|
+
db_name = connection&.db.to_s if connection.respond_to?(:db)
|
|
50
|
+
# sqlite may expose a filename
|
|
51
|
+
db_name = connection&.filename.to_s if db_name == '' && connection.respond_to?(:filename)
|
|
52
|
+
# fall back to adapter class name
|
|
53
|
+
db_name = connection.class.to_s if db_name == ''
|
|
54
|
+
|
|
47
55
|
context = ElasticAPM::Span::Context.new(
|
|
48
56
|
db: { statement: sql, type: 'sql', user: opts[:user] },
|
|
57
|
+
service: {target: {type: subtype, name: db_name }},
|
|
49
58
|
destination: { service: { resource: subtype } }
|
|
50
59
|
)
|
|
51
60
|
|
|
@@ -69,6 +69,14 @@ module ElasticAPM
|
|
|
69
69
|
base[:message] = build_message(context.message)
|
|
70
70
|
end
|
|
71
71
|
|
|
72
|
+
if context.service
|
|
73
|
+
base[:service] = build_service(context.service)
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
if context.links && !context.links.empty?
|
|
77
|
+
base[:links] = build_links(context.links)
|
|
78
|
+
end
|
|
79
|
+
|
|
72
80
|
base
|
|
73
81
|
end
|
|
74
82
|
|
|
@@ -121,6 +129,23 @@ module ElasticAPM
|
|
|
121
129
|
}
|
|
122
130
|
}
|
|
123
131
|
end
|
|
132
|
+
|
|
133
|
+
def build_service(service)
|
|
134
|
+
{
|
|
135
|
+
target: {
|
|
136
|
+
name: keyword_field(service.target&.name),
|
|
137
|
+
type: keyword_field(service.target&.type)
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
end
|
|
141
|
+
|
|
142
|
+
def build_links(links)
|
|
143
|
+
{
|
|
144
|
+
links: links.map do |link|
|
|
145
|
+
{"trace_id" => link.trace_id, "span_id" => link.span_id}
|
|
146
|
+
end
|
|
147
|
+
}
|
|
148
|
+
end
|
|
124
149
|
end
|
|
125
150
|
|
|
126
151
|
private
|
data/lib/elastic_apm/version.rb
CHANGED
data/lib/elastic_apm.rb
CHANGED
metadata
CHANGED
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: elastic-apm
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 4.
|
|
4
|
+
version: 4.6.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Mikkel Malmberg
|
|
8
|
+
- Emily Stolfo
|
|
8
9
|
autorequire:
|
|
9
10
|
bindir: bin
|
|
10
11
|
cert_chain: []
|
|
11
|
-
date:
|
|
12
|
+
date: 2023-01-11 00:00:00.000000000 Z
|
|
12
13
|
dependencies:
|
|
13
14
|
- !ruby/object:Gem::Dependency
|
|
14
15
|
name: concurrent-ruby
|
|
@@ -38,9 +39,23 @@ dependencies:
|
|
|
38
39
|
- - ">="
|
|
39
40
|
- !ruby/object:Gem::Version
|
|
40
41
|
version: '3.0'
|
|
42
|
+
- !ruby/object:Gem::Dependency
|
|
43
|
+
name: ruby2_keywords
|
|
44
|
+
requirement: !ruby/object:Gem::Requirement
|
|
45
|
+
requirements:
|
|
46
|
+
- - ">="
|
|
47
|
+
- !ruby/object:Gem::Version
|
|
48
|
+
version: '0'
|
|
49
|
+
type: :runtime
|
|
50
|
+
prerelease: false
|
|
51
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
52
|
+
requirements:
|
|
53
|
+
- - ">="
|
|
54
|
+
- !ruby/object:Gem::Version
|
|
55
|
+
version: '0'
|
|
41
56
|
description:
|
|
42
57
|
email:
|
|
43
|
-
-
|
|
58
|
+
- info@elastic.co
|
|
44
59
|
executables: []
|
|
45
60
|
extensions: []
|
|
46
61
|
extra_rdoc_files: []
|
|
@@ -50,6 +65,7 @@ files:
|
|
|
50
65
|
- ".ci/.jenkins_framework.yml"
|
|
51
66
|
- ".ci/.jenkins_main_framework.yml"
|
|
52
67
|
- ".ci/.jenkins_ruby.yml"
|
|
68
|
+
- ".ci/.jenkins_ruby_benchmarks.yml"
|
|
53
69
|
- ".ci/Jenkinsfile"
|
|
54
70
|
- ".ci/docker/jruby/11-jdk/Dockerfile"
|
|
55
71
|
- ".ci/docker/jruby/12-jdk/Dockerfile"
|
|
@@ -136,6 +152,7 @@ files:
|
|
|
136
152
|
- lib/elastic_apm/config/options.rb
|
|
137
153
|
- lib/elastic_apm/config/regexp_list.rb
|
|
138
154
|
- lib/elastic_apm/config/round_float.rb
|
|
155
|
+
- lib/elastic_apm/config/server_info.rb
|
|
139
156
|
- lib/elastic_apm/config/wildcard_pattern_list.rb
|
|
140
157
|
- lib/elastic_apm/context.rb
|
|
141
158
|
- lib/elastic_apm/context/request.rb
|
|
@@ -192,7 +209,9 @@ files:
|
|
|
192
209
|
- lib/elastic_apm/span/context/db.rb
|
|
193
210
|
- lib/elastic_apm/span/context/destination.rb
|
|
194
211
|
- lib/elastic_apm/span/context/http.rb
|
|
212
|
+
- lib/elastic_apm/span/context/links.rb
|
|
195
213
|
- lib/elastic_apm/span/context/message.rb
|
|
214
|
+
- lib/elastic_apm/span/context/service.rb
|
|
196
215
|
- lib/elastic_apm/span_helpers.rb
|
|
197
216
|
- lib/elastic_apm/spies.rb
|
|
198
217
|
- lib/elastic_apm/spies/action_dispatch.rb
|
|
@@ -205,6 +224,7 @@ files:
|
|
|
205
224
|
- lib/elastic_apm/spies/json.rb
|
|
206
225
|
- lib/elastic_apm/spies/mongo.rb
|
|
207
226
|
- lib/elastic_apm/spies/net_http.rb
|
|
227
|
+
- lib/elastic_apm/spies/racecar.rb
|
|
208
228
|
- lib/elastic_apm/spies/rake.rb
|
|
209
229
|
- lib/elastic_apm/spies/redis.rb
|
|
210
230
|
- lib/elastic_apm/spies/resque.rb
|