elastic-apm 2.12.0 → 3.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.ci/Jenkinsfile +1 -4
- data/.ci/downstreamTests.groovy +0 -3
- data/.ci/prepare-git-context.sh +2 -1
- data/.rubocop.yml +3 -0
- data/CHANGELOG.md +14 -0
- data/docs/log-correlation.asciidoc +25 -0
- data/lib/elastic_apm.rb +2 -99
- data/lib/elastic_apm/config.rb +2 -87
- data/lib/elastic_apm/error/exception.rb +16 -9
- data/lib/elastic_apm/error_builder.rb +2 -1
- data/lib/elastic_apm/opentracing.rb +10 -2
- data/lib/elastic_apm/span.rb +8 -7
- data/lib/elastic_apm/spies/sidekiq.rb +1 -2
- data/lib/elastic_apm/trace_context.rb +0 -14
- data/lib/elastic_apm/transaction.rb +7 -13
- data/lib/elastic_apm/util.rb +4 -4
- data/lib/elastic_apm/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 77a4cbfd5c5c3031b8d83865203a8b0fa2d4b7146b98e1b52828a3ac9513765d
|
4
|
+
data.tar.gz: bbed03cae2b396e1967a82036d67feaf00d86cc07d8d0eef51a5bb9bb5cf9607
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9621a7cf92e596e45a26d863f781e4ad9f8f9122bc976d0906f78e1c1d5e80801aec4ab402677f542022769f4ef7c101aec77fa80f8cb7e40d486ea76a977a58
|
7
|
+
data.tar.gz: f32184577052ee7be8f72b24cb9d41445bd072f945541080d08edffe980549d4eb2807a7909ae30676a0620890140f8022a49fd11d903abece0ac267baa44588
|
data/.ci/Jenkinsfile
CHANGED
@@ -47,7 +47,6 @@ pipeline {
|
|
47
47
|
Checkout the code and stash it, to use it on other stages.
|
48
48
|
*/
|
49
49
|
stage('Checkout') {
|
50
|
-
agent { label 'immutable' }
|
51
50
|
options { skipDefaultCheckout() }
|
52
51
|
steps {
|
53
52
|
deleteDir()
|
@@ -56,7 +55,6 @@ pipeline {
|
|
56
55
|
}
|
57
56
|
}
|
58
57
|
stage('Sanity checks') {
|
59
|
-
agent { label 'linux && immutable && docker' }
|
60
58
|
when {
|
61
59
|
beforeAgent true
|
62
60
|
anyOf {
|
@@ -85,7 +83,6 @@ pipeline {
|
|
85
83
|
Execute unit tests.
|
86
84
|
*/
|
87
85
|
stage('Test') {
|
88
|
-
agent { label 'linux && immutable' }
|
89
86
|
options { skipDefaultCheckout() }
|
90
87
|
steps {
|
91
88
|
withGithubNotify(context: 'Tests', tab: 'tests') {
|
@@ -136,7 +133,6 @@ pipeline {
|
|
136
133
|
The result JSON files are also archive into Jenkins.
|
137
134
|
*/
|
138
135
|
stage('Run Benchmarks') {
|
139
|
-
agent { label 'linux && immutable' }
|
140
136
|
steps {
|
141
137
|
withGithubNotify(context: 'Run Benchmarks') {
|
142
138
|
deleteDir()
|
@@ -183,6 +179,7 @@ pipeline {
|
|
183
179
|
options { skipDefaultCheckout() }
|
184
180
|
environment {
|
185
181
|
RUBY_DOCKER_TAG = 'ruby:2.6'
|
182
|
+
HOME = '/var/lib/jenkins'
|
186
183
|
}
|
187
184
|
when {
|
188
185
|
beforeAgent true
|
data/.ci/downstreamTests.groovy
CHANGED
@@ -42,7 +42,6 @@ pipeline {
|
|
42
42
|
Checkout the code and stash it, to use it on other stages.
|
43
43
|
*/
|
44
44
|
stage('Checkout') {
|
45
|
-
agent { label 'immutable' }
|
46
45
|
options { skipDefaultCheckout() }
|
47
46
|
steps {
|
48
47
|
deleteDir()
|
@@ -54,14 +53,12 @@ pipeline {
|
|
54
53
|
}
|
55
54
|
}
|
56
55
|
stage('Test') {
|
57
|
-
agent { label 'linux && immutable' }
|
58
56
|
options { skipDefaultCheckout() }
|
59
57
|
steps {
|
60
58
|
runTests('.ci/.jenkins_framework.yml')
|
61
59
|
}
|
62
60
|
}
|
63
61
|
stage('Master Test') {
|
64
|
-
agent { label 'linux && immutable' }
|
65
62
|
options { skipDefaultCheckout() }
|
66
63
|
steps {
|
67
64
|
catchError(buildResult: 'SUCCESS', stageResult: 'UNSTABLE', message: "The tests for the master framework have failed. Let's warn instead.") {
|
data/.ci/prepare-git-context.sh
CHANGED
@@ -20,4 +20,5 @@ git checkout "${BRANCH_NAME}"
|
|
20
20
|
|
21
21
|
# Ensure the master branch points to the original commit to avoid commit injection
|
22
22
|
# when running the release pipeline.
|
23
|
-
|
23
|
+
# used GIT_BASE_COMMIT instead GIT_COMMIT to support the MultiBranchPipelines.
|
24
|
+
git reset --hard "${GIT_BASE_COMMIT}"
|
data/.rubocop.yml
CHANGED
data/CHANGELOG.md
CHANGED
@@ -4,6 +4,20 @@ All notable changes to this project will be documented in this file.
|
|
4
4
|
|
5
5
|
This project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
|
6
6
|
|
7
|
+
## 3.0.0 (2019-10-08)
|
8
|
+
|
9
|
+
### Breaking Changes
|
10
|
+
|
11
|
+
The following changes are breaking, as they may change the way data is grouped or shown in Kibana or how your app
|
12
|
+
defines agent settings.
|
13
|
+
|
14
|
+
- Decrease stack_trace_limit to 50 ([#515](https://github.com/elastic/apm-agent-ruby/pull/515))
|
15
|
+
- Errors' `message` no longer include their `type` ([#323](https://github.com/elastic/apm-agent-ruby/pull/323/files))
|
16
|
+
- External request spans now have type `external.http.{library}` ([#514](https://github.com/elastic/apm-agent-ruby/pull/514))
|
17
|
+
- Durations are measured using monotonic time ([#550](https://github.com/elastic/apm-agent-ruby/pull/550))
|
18
|
+
- Rename set_tag to set_label ([#543](https://github.com/elastic/apm-agent-ruby/pull/543))
|
19
|
+
- Rename disabled_spies to disabled_instrumentations ([#539](https://github.com/elastic/apm-agent-ruby/pull/539))
|
20
|
+
|
7
21
|
## 2.12.0 (2019-10-01)
|
8
22
|
|
9
23
|
### Changed
|
@@ -94,3 +94,28 @@ end
|
|
94
94
|
# [2019-09-16 11:54:59 +0200][RailsTestApp][INFO][transaction.id=3b92edcccc0a6d1e span.id=f3d7e32f176d4c93 trace.id=1275686e35de91f776557637e799651e] Rendered text template (Duration: 0.1ms | Allocations: 17)
|
95
95
|
# [2019-09-16 11:54:59 +0200][RailsTestApp][INFO][transaction.id=3b92edcccc0a6d1e span.id=3bde4e9c85ab359c trace.id=1275686e35de91f776557637e799651e] Completed 200 OK in 1ms (Views: 0.3ms | Allocations: 187)
|
96
96
|
----
|
97
|
+
|
98
|
+
[float]
|
99
|
+
==== Extracting trace IDs from the logs
|
100
|
+
|
101
|
+
For log correlation to work, the trace IDs must be extracted from the log message and stored in separate fields in the Elasticsearch document. There are many ways to achieve this, for example by using ingest node and defining a pipeline with a grok processor.
|
102
|
+
You can extract the trace id from the Lograge output generated above like this:
|
103
|
+
|
104
|
+
[source,json]
|
105
|
+
----
|
106
|
+
PUT _ingest/pipeline/extract_trace_id
|
107
|
+
{
|
108
|
+
"description": "Extract trace id from Lograge logs",
|
109
|
+
"processors": [
|
110
|
+
{
|
111
|
+
"grok": {
|
112
|
+
"field": "message",
|
113
|
+
"patterns": ["%{TIME}.*\\| [A-Z]\\, \\[%{TIMESTAMP_ISO8601}.*\\] %{LOGLEVEL:log.level} [-]{2} \\: \\[[0-9A-Fa-f\\-]{36}\\] \\{.*\\\"trace\\.id\\\"\\:\\\"%{TRACE_ID:trace.id}.*\\}"],
|
114
|
+
"pattern_definitions": { "TRACE_ID": "[0-9A-Fa-f]{32}" }
|
115
|
+
}
|
116
|
+
}
|
117
|
+
]
|
118
|
+
}
|
119
|
+
----
|
120
|
+
|
121
|
+
Please see {apm-overview-ref-v}/observability-integrations.html[Observability integrations] for more information.
|
data/lib/elastic_apm.rb
CHANGED
@@ -3,7 +3,6 @@
|
|
3
3
|
require 'elastic_apm/version'
|
4
4
|
require 'elastic_apm/internal_error'
|
5
5
|
require 'elastic_apm/logging'
|
6
|
-
require 'elastic_apm/deprecations'
|
7
6
|
|
8
7
|
# Core
|
9
8
|
require 'elastic_apm/agent'
|
@@ -19,8 +18,6 @@ require 'elastic_apm/railtie' if defined?(::Rails::Railtie)
|
|
19
18
|
# ElasticAPM
|
20
19
|
module ElasticAPM # rubocop:disable Metrics/ModuleLength
|
21
20
|
class << self
|
22
|
-
extend ElasticAPM::Deprecations
|
23
|
-
|
24
21
|
### Life cycle
|
25
22
|
|
26
23
|
# Starts the ElasticAPM Agent
|
@@ -83,28 +80,6 @@ module ElasticAPM # rubocop:disable Metrics/ModuleLength
|
|
83
80
|
end
|
84
81
|
# rubocop:enable Metrics/AbcSize
|
85
82
|
|
86
|
-
# Start a new transaction or return the currently running
|
87
|
-
#
|
88
|
-
# @param name [String] A description of the transaction, eg
|
89
|
-
# `ExamplesController#index`
|
90
|
-
# @param type [String] The kind of the transaction, eg `app.request.get` or
|
91
|
-
# `db.mysql2.query`
|
92
|
-
# @param context [Context] An optional [Context]
|
93
|
-
# @yield [Transaction] Optional block encapsulating transaction
|
94
|
-
# @return [Transaction] Unless block given
|
95
|
-
# @deprecated See `with_transaction` or `start_transaction`
|
96
|
-
def transaction(name = nil, type = nil, context: nil, &block)
|
97
|
-
return (block_given? ? yield : nil) unless agent
|
98
|
-
|
99
|
-
if block_given?
|
100
|
-
with_transaction(name, type, context: context, &block)
|
101
|
-
else
|
102
|
-
start_transaction(name, type, context: context)
|
103
|
-
end
|
104
|
-
end
|
105
|
-
|
106
|
-
deprecate :transaction, :with_transaction
|
107
|
-
|
108
83
|
# rubocop:disable Metrics/MethodLength
|
109
84
|
# Start a new transaction
|
110
85
|
#
|
@@ -118,15 +93,8 @@ module ElasticAPM # rubocop:disable Metrics/ModuleLength
|
|
118
93
|
name = nil,
|
119
94
|
type = nil,
|
120
95
|
context: nil,
|
121
|
-
trace_context: nil
|
122
|
-
traceparent: nil
|
96
|
+
trace_context: nil
|
123
97
|
)
|
124
|
-
if traceparent
|
125
|
-
trace_context ||= traceparent
|
126
|
-
warn "[ElasticAPM] [DEPRECATED] `start_transaction' with" \
|
127
|
-
"`traceparent:' has been renamed. Use `trace_context:' instead."
|
128
|
-
end
|
129
|
-
|
130
98
|
agent&.start_transaction(
|
131
99
|
name,
|
132
100
|
type,
|
@@ -158,20 +126,13 @@ module ElasticAPM # rubocop:disable Metrics/ModuleLength
|
|
158
126
|
name = nil,
|
159
127
|
type = nil,
|
160
128
|
context: nil,
|
161
|
-
trace_context: nil
|
162
|
-
traceparent: nil
|
129
|
+
trace_context: nil
|
163
130
|
)
|
164
131
|
unless block_given?
|
165
132
|
raise ArgumentError,
|
166
133
|
'expected a block. Do you want `start_transaction\' instead?'
|
167
134
|
end
|
168
135
|
|
169
|
-
if traceparent
|
170
|
-
trace_context ||= traceparent
|
171
|
-
warn "[ElasticAPM] [DEPRECATED] `with_transaction' with " \
|
172
|
-
"`traceparent:' has been renamed. Use `trace_context:' instead."
|
173
|
-
end
|
174
|
-
|
175
136
|
return yield(nil) unless agent
|
176
137
|
|
177
138
|
begin
|
@@ -189,46 +150,6 @@ module ElasticAPM # rubocop:disable Metrics/ModuleLength
|
|
189
150
|
end
|
190
151
|
# rubocop:enable Metrics/MethodLength
|
191
152
|
|
192
|
-
# rubocop:disable Metrics/MethodLength
|
193
|
-
# Start a new span
|
194
|
-
#
|
195
|
-
# @param name [String] A description of the span, eq `SELECT FROM "users"`
|
196
|
-
# @param type [String] The kind of span, eq `db.mysql2.query`
|
197
|
-
# @param context [Span::Context] Context information about the span
|
198
|
-
# @yield [Span] Optional block encapsulating span
|
199
|
-
# @return [Span] Unless block given
|
200
|
-
# @deprecated See `with_span` or `start_span`
|
201
|
-
def span(
|
202
|
-
name,
|
203
|
-
type = nil,
|
204
|
-
context: nil,
|
205
|
-
include_stacktrace: true,
|
206
|
-
&block
|
207
|
-
)
|
208
|
-
return (block_given? ? yield : nil) unless agent
|
209
|
-
|
210
|
-
if block_given?
|
211
|
-
with_span(
|
212
|
-
name,
|
213
|
-
type,
|
214
|
-
context: context,
|
215
|
-
include_stacktrace: include_stacktrace,
|
216
|
-
&block
|
217
|
-
)
|
218
|
-
else
|
219
|
-
start_span(
|
220
|
-
name,
|
221
|
-
type,
|
222
|
-
context: context,
|
223
|
-
include_stacktrace: include_stacktrace
|
224
|
-
)
|
225
|
-
end
|
226
|
-
end
|
227
|
-
# rubocop:enable Metrics/MethodLength
|
228
|
-
|
229
|
-
deprecate :span, :with_span
|
230
|
-
|
231
|
-
# rubocop:disable Metrics/MethodLength, Metrics/ParameterLists
|
232
153
|
# Start a new span
|
233
154
|
#
|
234
155
|
# @param name [String] A description of the span, eq `SELECT FROM "users"`
|
@@ -319,15 +240,9 @@ module ElasticAPM # rubocop:disable Metrics/ModuleLength
|
|
319
240
|
# @param rack_env [Rack::Env] A Rack env
|
320
241
|
# @return [Context] The built context
|
321
242
|
def build_context(
|
322
|
-
deprecated_env = nil,
|
323
243
|
rack_env: nil,
|
324
244
|
for_type: :transaction
|
325
245
|
)
|
326
|
-
if !rack_env && (rack_env = deprecated_env)
|
327
|
-
warn "[ElasticAPM] [DEPRECATED] `build_context' expects two keyword" \
|
328
|
-
"arguments, `rack_env:' and `for_type:'"
|
329
|
-
end
|
330
|
-
|
331
246
|
agent&.build_context(rack_env: rack_env, for_type: for_type)
|
332
247
|
end
|
333
248
|
|
@@ -359,18 +274,6 @@ module ElasticAPM # rubocop:disable Metrics/ModuleLength
|
|
359
274
|
|
360
275
|
### Context
|
361
276
|
|
362
|
-
# Set a _tag_ value for the current transaction
|
363
|
-
#
|
364
|
-
# @param key [String,Symbol] A key
|
365
|
-
# @param value [Object] A value (will be converted to string)
|
366
|
-
# @return [Object] The given value
|
367
|
-
# @deprecated See `set_label` instead
|
368
|
-
def set_tag(key, value)
|
369
|
-
set_label(key, value.to_s)
|
370
|
-
end
|
371
|
-
|
372
|
-
deprecate :set_tag, :set_label
|
373
|
-
|
374
277
|
# Set a _label_ value for the current transaction
|
375
278
|
#
|
376
279
|
# @param key [String,Symbol] A key
|
data/lib/elastic_apm/config.rb
CHANGED
@@ -16,19 +16,8 @@ module ElasticAPM
|
|
16
16
|
# @api private
|
17
17
|
class Config
|
18
18
|
extend Options
|
19
|
-
|
20
|
-
|
21
|
-
DEPRECATED_OPTIONS = %i[
|
22
|
-
compression_level=
|
23
|
-
compression_minimum_size=
|
24
|
-
debug_http=
|
25
|
-
debug_transactions=
|
26
|
-
flush_interval=
|
27
|
-
http_open_timeout=
|
28
|
-
http_read_timeout=
|
29
|
-
enabled_environments=
|
30
|
-
disable_environment_warning=
|
31
|
-
].freeze
|
19
|
+
|
20
|
+
DEPRECATED_OPTIONS = %i[].freeze
|
32
21
|
|
33
22
|
# rubocop:disable Metrics/LineLength, Layout/ExtraSpacing
|
34
23
|
option :config_file, type: :string, default: 'config/elastic_apm.yml'
|
@@ -188,80 +177,6 @@ module ElasticAPM
|
|
188
177
|
super.split.first + '>'
|
189
178
|
end
|
190
179
|
|
191
|
-
# DEPRECATED
|
192
|
-
# rubocop:disable Metrics/MethodLength
|
193
|
-
def capture_body=(value)
|
194
|
-
if value =~ /(all|transactions|errors|off)/
|
195
|
-
set(:capture_body, value)
|
196
|
-
return
|
197
|
-
end
|
198
|
-
|
199
|
-
case value
|
200
|
-
when true
|
201
|
-
warn "Boolean value for option `capture_body' has " \
|
202
|
-
"been deprecated. Setting to 'all'"
|
203
|
-
self.capture_body = 'all'
|
204
|
-
when false
|
205
|
-
warn "Boolean value for option `capture_body' has " \
|
206
|
-
"been deprecated. Setting to 'off'"
|
207
|
-
self.capture_body = 'off'
|
208
|
-
else
|
209
|
-
default = options[:capture_body].default
|
210
|
-
warn "Unknown value `#{value}' for option "\
|
211
|
-
"`capture_body'. Defaulting to `#{default}'"
|
212
|
-
self.capture_body = default
|
213
|
-
end
|
214
|
-
end
|
215
|
-
# rubocop:enable Metrics/MethodLength
|
216
|
-
|
217
|
-
# DEPRECATED
|
218
|
-
# The spies methods are only somewhat public and only mentioned briefly in
|
219
|
-
# the docs.
|
220
|
-
|
221
|
-
def disabled_spies=(list)
|
222
|
-
self.disabled_instrumentations = list
|
223
|
-
end
|
224
|
-
|
225
|
-
def disabled_spies
|
226
|
-
disabled_instrumentations
|
227
|
-
end
|
228
|
-
|
229
|
-
def enabled_spies
|
230
|
-
enabled_instrumentations
|
231
|
-
end
|
232
|
-
|
233
|
-
def available_spies
|
234
|
-
available_instrumentations
|
235
|
-
end
|
236
|
-
|
237
|
-
deprecate :disabled_spies=, :disabled_instrumentations=
|
238
|
-
deprecate :disabled_spies, :disabled_instrumentations
|
239
|
-
deprecate :enabled_spies, :enabled_instrumentations
|
240
|
-
deprecate :available_spies, :available_instrumentations
|
241
|
-
|
242
|
-
LABELS_AND_TAGS_CONFLICT = 'You have both \'default_labels\' and ' \
|
243
|
-
'\'default_tags\' set. \'default_tags\' has been deprecated in favor '\
|
244
|
-
'of \'default_labels\'. Please consider upgrading.'.freeze
|
245
|
-
|
246
|
-
def default_labels=(labels)
|
247
|
-
@options[:default_tags].value.empty? || (raise LABELS_AND_TAGS_CONFLICT)
|
248
|
-
super
|
249
|
-
end
|
250
|
-
|
251
|
-
# DEPRECATED
|
252
|
-
|
253
|
-
def default_tags=(tags)
|
254
|
-
@options[:default_labels].value.empty? || (raise LABELS_AND_TAGS_CONFLICT)
|
255
|
-
super
|
256
|
-
@options[:default_labels].set(tags)
|
257
|
-
end
|
258
|
-
|
259
|
-
def default_tags
|
260
|
-
default_labels
|
261
|
-
end
|
262
|
-
|
263
|
-
deprecate :default_tags=, :default_labels=
|
264
|
-
|
265
180
|
private
|
266
181
|
|
267
182
|
def load_config_file
|
@@ -6,18 +6,23 @@ module ElasticAPM
|
|
6
6
|
class Exception
|
7
7
|
MOD_SPLIT = '::'
|
8
8
|
|
9
|
-
def initialize(
|
10
|
-
|
11
|
-
"#{exception.class}: #{exception.message}"
|
12
|
-
@type = exception.class.to_s
|
13
|
-
@module = format_module exception
|
14
|
-
@cause = exception.cause && Exception.new(exception.cause)
|
9
|
+
def initialize(attrs = nil)
|
10
|
+
return unless attrs
|
15
11
|
|
16
12
|
attrs.each do |key, val|
|
17
13
|
send(:"#{key}=", val)
|
18
14
|
end
|
19
15
|
end
|
20
16
|
|
17
|
+
def self.from_exception(exception, **attrs)
|
18
|
+
new({
|
19
|
+
message: exception.message.to_s,
|
20
|
+
type: exception.class.to_s,
|
21
|
+
module: format_module(exception),
|
22
|
+
cause: exception.cause && Exception.from_exception(exception.cause)
|
23
|
+
}.merge(attrs))
|
24
|
+
end
|
25
|
+
|
21
26
|
attr_accessor(
|
22
27
|
:attributes,
|
23
28
|
:code,
|
@@ -29,10 +34,12 @@ module ElasticAPM
|
|
29
34
|
:cause
|
30
35
|
)
|
31
36
|
|
32
|
-
|
37
|
+
class << self
|
38
|
+
private
|
33
39
|
|
34
|
-
|
35
|
-
|
40
|
+
def format_module(exception)
|
41
|
+
exception.class.to_s.split(MOD_SPLIT)[0...-1].join(MOD_SPLIT)
|
42
|
+
end
|
36
43
|
end
|
37
44
|
end
|
38
45
|
end
|
@@ -9,7 +9,8 @@ module ElasticAPM
|
|
9
9
|
|
10
10
|
def build_exception(exception, context: nil, handled: true)
|
11
11
|
error = Error.new context: context || Context.new
|
12
|
-
error.exception =
|
12
|
+
error.exception =
|
13
|
+
Error::Exception.from_exception(exception, handled: handled)
|
13
14
|
|
14
15
|
Util.reverse_merge!(error.context.labels, @agent.config.default_labels)
|
15
16
|
|
@@ -65,10 +65,17 @@ module ElasticAPM
|
|
65
65
|
end
|
66
66
|
# rubocop:enable Lint/UnusedMethodArgument
|
67
67
|
|
68
|
-
|
68
|
+
# rubocop:disable Metrics/MethodLength
|
69
|
+
def finish(clock_end: Util.monotonic_micros, end_time: nil)
|
69
70
|
return unless (instrumenter = ElasticAPM.agent&.instrumenter)
|
70
71
|
|
71
|
-
|
72
|
+
if end_time
|
73
|
+
warn '[ElasticAPM] DEPRECATED: Setting a custom end time as a ' \
|
74
|
+
'`Time` is deprecated. Use `clock_end:` and monotonic time instead.'
|
75
|
+
clock_end = end_time
|
76
|
+
end
|
77
|
+
|
78
|
+
elastic_span.done clock_end: clock_end
|
72
79
|
|
73
80
|
case elastic_span
|
74
81
|
when ElasticAPM::Transaction
|
@@ -79,6 +86,7 @@ module ElasticAPM
|
|
79
86
|
|
80
87
|
instrumenter.enqueue.call elastic_span
|
81
88
|
end
|
89
|
+
# rubocop:enable Metrics/MethodLength
|
82
90
|
|
83
91
|
private
|
84
92
|
|
data/lib/elastic_apm/span.rb
CHANGED
@@ -61,18 +61,19 @@ module ElasticAPM
|
|
61
61
|
|
62
62
|
# life cycle
|
63
63
|
|
64
|
-
def start(
|
65
|
-
@timestamp =
|
66
|
-
|
64
|
+
def start(clock_start = Util.monotonic_micros)
|
65
|
+
@timestamp = Util.micros
|
66
|
+
@clock_start = clock_start
|
67
67
|
self
|
68
68
|
end
|
69
69
|
|
70
|
-
def stop(
|
71
|
-
@duration ||= (
|
70
|
+
def stop(clock_end = Util.monotonic_micros)
|
71
|
+
@duration ||= (clock_end - @clock_start)
|
72
|
+
self
|
72
73
|
end
|
73
74
|
|
74
|
-
def done(
|
75
|
-
stop
|
75
|
+
def done(clock_end: Util.monotonic_micros)
|
76
|
+
stop clock_end
|
76
77
|
|
77
78
|
build_stacktrace! if should_build_stacktrace?
|
78
79
|
self.original_backtrace = nil # release original
|
@@ -14,8 +14,7 @@ module ElasticAPM
|
|
14
14
|
def call(_worker, job, queue)
|
15
15
|
name = SidekiqSpy.name_for(job)
|
16
16
|
transaction = ElasticAPM.start_transaction(name, 'Sidekiq')
|
17
|
-
|
18
|
-
ElasticAPM.set_label(:queue, queue.to_s)
|
17
|
+
ElasticAPM.set_label(:queue, queue)
|
19
18
|
|
20
19
|
yield
|
21
20
|
|
@@ -3,7 +3,6 @@
|
|
3
3
|
module ElasticAPM
|
4
4
|
# @api private
|
5
5
|
class TraceContext
|
6
|
-
extend Deprecations
|
7
6
|
class InvalidTraceparentHeader < StandardError; end
|
8
7
|
|
9
8
|
VERSION = '00'
|
@@ -77,19 +76,6 @@ module ElasticAPM
|
|
77
76
|
format('%s-%s-%s-%s', version, trace_id, id, hex_flags)
|
78
77
|
end
|
79
78
|
|
80
|
-
# @deprecated Use parent_id instead
|
81
|
-
def span_id
|
82
|
-
@parent_id
|
83
|
-
end
|
84
|
-
|
85
|
-
# @deprecated Use parent_id instead
|
86
|
-
def span_id=(span_id)
|
87
|
-
@parent_id = span_id
|
88
|
-
end
|
89
|
-
|
90
|
-
deprecate :span_id, :parent_id
|
91
|
-
deprecate :span_id=, :parent_id=
|
92
|
-
|
93
79
|
private
|
94
80
|
|
95
81
|
def hex(len)
|
@@ -6,7 +6,6 @@ require 'forwardable'
|
|
6
6
|
module ElasticAPM
|
7
7
|
# @api private
|
8
8
|
class Transaction
|
9
|
-
extend Deprecations
|
10
9
|
extend Forwardable
|
11
10
|
|
12
11
|
def_delegators :@trace_context,
|
@@ -53,27 +52,22 @@ module ElasticAPM
|
|
53
52
|
!!duration
|
54
53
|
end
|
55
54
|
|
56
|
-
def done?
|
57
|
-
stopped?
|
58
|
-
end
|
59
|
-
|
60
|
-
deprecate :done?, :stopped?
|
61
|
-
|
62
55
|
# life cycle
|
63
56
|
|
64
|
-
def start(
|
65
|
-
@timestamp =
|
57
|
+
def start(clock_start = Util.monotonic_micros)
|
58
|
+
@timestamp = Util.micros
|
59
|
+
@clock_start = clock_start
|
66
60
|
self
|
67
61
|
end
|
68
62
|
|
69
|
-
def stop(
|
63
|
+
def stop(clock_end = Util.monotonic_micros)
|
70
64
|
raise 'Transaction not yet start' unless timestamp
|
71
|
-
@duration =
|
65
|
+
@duration = clock_end - @clock_start
|
72
66
|
self
|
73
67
|
end
|
74
68
|
|
75
|
-
def done(result = nil,
|
76
|
-
stop
|
69
|
+
def done(result = nil, clock_end: Util.monotonic_micros)
|
70
|
+
stop clock_end
|
77
71
|
self.result = result if result
|
78
72
|
self
|
79
73
|
end
|
data/lib/elastic_apm/util.rb
CHANGED
@@ -3,15 +3,15 @@
|
|
3
3
|
module ElasticAPM
|
4
4
|
# @api private
|
5
5
|
module Util
|
6
|
-
def self.nearest_minute(target = Time.now.utc)
|
7
|
-
target - target.to_i % 60
|
8
|
-
end
|
9
|
-
|
10
6
|
def self.micros(target = Time.now)
|
11
7
|
utc = target.utc
|
12
8
|
utc.to_i * 1_000_000 + utc.usec
|
13
9
|
end
|
14
10
|
|
11
|
+
def self.monotonic_micros
|
12
|
+
Process.clock_gettime(Process::CLOCK_MONOTONIC, :microsecond)
|
13
|
+
end
|
14
|
+
|
15
15
|
def self.git_sha
|
16
16
|
sha = `git rev-parse --verify HEAD 2>&1`.chomp
|
17
17
|
$? && $?.success? ? sha : nil
|
data/lib/elastic_apm/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: elastic-apm
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 3.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mikkel Malmberg
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-10-
|
11
|
+
date: 2019-10-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: concurrent-ruby
|