elastic-apm 3.2.0 → 3.3.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.
Files changed (77) hide show
  1. checksums.yaml +4 -4
  2. data/.ci/.jenkins_exclude.yml +8 -1
  3. data/.ci/.jenkins_ruby.yml +1 -0
  4. data/.ci/Jenkinsfile +64 -31
  5. data/.github/workflows/main.yml +14 -0
  6. data/.pre-commit-config.yaml +1 -5
  7. data/.rubocop.yml +35 -29
  8. data/CHANGELOG.asciidoc +20 -4
  9. data/Gemfile +1 -0
  10. data/README.md +2 -2
  11. data/bin/dev +1 -1
  12. data/bin/run-tests +3 -0
  13. data/docs/api.asciidoc +0 -29
  14. data/docs/configuration.asciidoc +11 -0
  15. data/docs/context.asciidoc +4 -4
  16. data/lib/elastic_apm.rb +5 -9
  17. data/lib/elastic_apm/agent.rb +0 -9
  18. data/lib/elastic_apm/central_config.rb +10 -10
  19. data/lib/elastic_apm/central_config/cache_control.rb +1 -1
  20. data/lib/elastic_apm/config.rb +4 -11
  21. data/lib/elastic_apm/config/options.rb +2 -4
  22. data/lib/elastic_apm/config/wildcard_pattern_list.rb +35 -0
  23. data/lib/elastic_apm/context_builder.rb +0 -2
  24. data/lib/elastic_apm/error.rb +1 -1
  25. data/lib/elastic_apm/error/exception.rb +2 -2
  26. data/lib/elastic_apm/error_builder.rb +0 -2
  27. data/lib/elastic_apm/grape.rb +0 -3
  28. data/lib/elastic_apm/instrumenter.rb +3 -13
  29. data/lib/elastic_apm/metadata/service_info.rb +0 -5
  30. data/lib/elastic_apm/metadata/system_info/container_info.rb +4 -6
  31. data/lib/elastic_apm/metrics.rb +0 -3
  32. data/lib/elastic_apm/metrics/cpu_mem_set.rb +0 -10
  33. data/lib/elastic_apm/metrics/metric.rb +6 -2
  34. data/lib/elastic_apm/metrics/set.rb +4 -4
  35. data/lib/elastic_apm/metrics/span_scoped_set.rb +1 -1
  36. data/lib/elastic_apm/metrics/transaction_set.rb +0 -2
  37. data/lib/elastic_apm/metrics/vm_set.rb +0 -3
  38. data/lib/elastic_apm/middleware.rb +0 -2
  39. data/lib/elastic_apm/normalizers/grape/endpoint_run.rb +2 -1
  40. data/lib/elastic_apm/normalizers/rails/active_record.rb +1 -1
  41. data/lib/elastic_apm/opentracing.rb +6 -15
  42. data/lib/elastic_apm/rails.rb +2 -5
  43. data/lib/elastic_apm/sinatra.rb +1 -1
  44. data/lib/elastic_apm/span.rb +2 -2
  45. data/lib/elastic_apm/span/context.rb +17 -1
  46. data/lib/elastic_apm/spies/elasticsearch.rb +0 -3
  47. data/lib/elastic_apm/spies/faraday.rb +2 -4
  48. data/lib/elastic_apm/spies/http.rb +0 -3
  49. data/lib/elastic_apm/spies/mongo.rb +10 -5
  50. data/lib/elastic_apm/spies/net_http.rb +1 -4
  51. data/lib/elastic_apm/spies/rake.rb +0 -2
  52. data/lib/elastic_apm/spies/sequel.rb +0 -2
  53. data/lib/elastic_apm/spies/sidekiq.rb +2 -6
  54. data/lib/elastic_apm/spies/sinatra.rb +0 -2
  55. data/lib/elastic_apm/stacktrace/frame.rb +0 -3
  56. data/lib/elastic_apm/stacktrace_builder.rb +0 -2
  57. data/lib/elastic_apm/subscriber.rb +2 -3
  58. data/lib/elastic_apm/trace_context.rb +0 -3
  59. data/lib/elastic_apm/transaction.rb +2 -2
  60. data/lib/elastic_apm/transport/base.rb +0 -6
  61. data/lib/elastic_apm/transport/connection.rb +1 -4
  62. data/lib/elastic_apm/transport/connection/http.rb +0 -2
  63. data/lib/elastic_apm/transport/filters.rb +1 -1
  64. data/lib/elastic_apm/transport/filters/secrets_filter.rb +1 -3
  65. data/lib/elastic_apm/transport/serializers.rb +0 -3
  66. data/lib/elastic_apm/transport/serializers/context_serializer.rb +0 -2
  67. data/lib/elastic_apm/transport/serializers/error_serializer.rb +0 -2
  68. data/lib/elastic_apm/transport/serializers/metadata_serializer.rb +0 -2
  69. data/lib/elastic_apm/transport/serializers/metricset_serializer.rb +0 -2
  70. data/lib/elastic_apm/transport/serializers/span_serializer.rb +0 -3
  71. data/lib/elastic_apm/transport/serializers/transaction_serializer.rb +0 -2
  72. data/lib/elastic_apm/transport/worker.rb +10 -6
  73. data/lib/elastic_apm/util.rb +1 -1
  74. data/lib/elastic_apm/version.rb +1 -1
  75. metadata +5 -5
  76. data/.ci/bin/check_paths_for_matches.py +0 -80
  77. data/.hound.yml +0 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d6058bb61034dc14b1b22a3a5f45a592721b968d314bb5f63ca171c600bbb1bc
4
- data.tar.gz: fffcd9160ec251a5ad51aae149dbfc3f50cf16b3fc866385f24f83f555b8b804
3
+ metadata.gz: aaf3f0eada3b3bfe036dc55802688666e3df0ee48848b45dd73aa6861e625dc6
4
+ data.tar.gz: feb50b6f3d2da29af6591f31a62ea95189ab64868fb5403e3d85ceec548868d8
5
5
  SHA512:
6
- metadata.gz: f7a8bd72f34f7158619c124e4eff24c9b5d57e68c3b5761b1a6305e632f3aff549be7ed37924775d8ad61119f99a87081567969c0e386641b8789662ff3f54ca
7
- data.tar.gz: a8ce8dc0c3a3def4e08ca68b33d73c288bb6ca1fe6a6ff5fd0bbfe5e03f695848855c91b024e28e2ad0872895afa5659c8ff07f06b16277ea9755c0598d711b9
6
+ metadata.gz: b7bcd197586b7782f25fa814ec0430c33f7b21abaa6b79c81fe93ee07654df1448eea4257f8c29b6f6dce1b7778c0b88f6e825a1338bdba591fd4934b9bcaa09
7
+ data.tar.gz: 181bf8aa045473ef55cb794199638722e1bd7f142e558077928a94e03ca75812d21633c6781e734d7029b12e9b4d54232498f604a6be26f70daaffcd1e91f03e
@@ -1,5 +1,6 @@
1
1
  exclude:
2
- # Tests fail, but we don't care
2
+ - RUBY_VERSION: ruby:2.7-rc
3
+ FRAMEWORK: rails-4.2
3
4
  - RUBY_VERSION: jruby:9.2
4
5
  FRAMEWORK: rails-4.2
5
6
  - RUBY_VERSION: jruby:9.1
@@ -25,6 +26,8 @@ exclude:
25
26
  FRAMEWORK: rails-6.0
26
27
 
27
28
  # Only test master on newest ruby
29
+ - RUBY_VERSION: ruby:2.7-rc
30
+ FRAMEWORK: rails-master
28
31
  - RUBY_VERSION: ruby:2.5
29
32
  FRAMEWORK: rails-master
30
33
  - RUBY_VERSION: ruby:2.4
@@ -67,6 +70,8 @@ exclude:
67
70
  - RUBY_VERSION: docker.elastic.co/observability-ci/jruby:9.1-7-jdk
68
71
  FRAMEWORK: sinatra-master
69
72
 
73
+ - RUBY_VERSION: ruby:2.7-rc
74
+ FRAMEWORK: grape-master
70
75
  - RUBY_VERSION: ruby:2.5
71
76
  FRAMEWORK: grape-master
72
77
  - RUBY_VERSION: ruby:2.4
@@ -88,6 +93,8 @@ exclude:
88
93
  - RUBY_VERSION: docker.elastic.co/observability-ci/jruby:9.1-7-jdk
89
94
  FRAMEWORK: grape-master
90
95
 
96
+ - RUBY_VERSION: ruby:2.7-rc
97
+ FRAMEWORK: grape-1.2,sinatra-2.0,rails-6.0
91
98
  - RUBY_VERSION: ruby:2.5
92
99
  FRAMEWORK: grape-1.2,sinatra-2.0,rails-6.0
93
100
  - RUBY_VERSION: ruby:2.4
@@ -1,4 +1,5 @@
1
1
  RUBY_VERSION:
2
+ - ruby:2.7-rc
2
3
  - ruby:2.6
3
4
  - ruby:2.5
4
5
  - ruby:2.4
@@ -5,10 +5,9 @@ import co.elastic.matrix.*
5
5
  import groovy.transform.Field
6
6
 
7
7
  /**
8
- This is the parallel tasks generator,
9
- it is need as field to store the results of the tests.
8
+ This is required to store the results of the tests.
10
9
  */
11
- @Field def rubyTasksGen
10
+ @Field def rubyTasksFailed = false
12
11
 
13
12
  pipeline {
14
13
  agent { label 'linux && immutable' }
@@ -24,6 +23,7 @@ pipeline {
24
23
  GITHUB_CHECK_ITS_NAME = 'Integration Tests'
25
24
  ITS_PIPELINE = 'apm-integration-tests-selector-mbp/master'
26
25
  RELEASE_SECRET = 'secret/apm-team/ci/apm-agent-ruby-rubygems-release'
26
+ OPBEANS_REPO = 'opbeans-ruby'
27
27
  }
28
28
  options {
29
29
  timeout(time: 2, unit: 'HOURS')
@@ -49,6 +49,7 @@ pipeline {
49
49
  stage('Checkout') {
50
50
  options { skipDefaultCheckout() }
51
51
  steps {
52
+ pipelineManager([ cancelPreviousRunningBuilds: [ when: 'PR' ] ])
52
53
  deleteDir()
53
54
  gitCheckout(basedir: "${BASE_DIR}", githubNotifyFirstTimeContributor: true)
54
55
  stash allowEmpty: true, name: 'source', useDefaultExcludes: false
@@ -155,15 +156,21 @@ pipeline {
155
156
  }
156
157
  }
157
158
  }
159
+ stage('Populate Test failures') {
160
+ when {
161
+ expression { return rubyTasksFailed }
162
+ }
163
+ steps {
164
+ error('There were some failures when running the "Test" stage')
165
+ }
166
+ }
158
167
  stage('Integration Tests') {
159
168
  agent none
160
169
  when {
161
170
  beforeAgent true
162
- allOf {
163
- anyOf {
164
- environment name: 'GIT_BUILD_CAUSE', value: 'pr'
165
- expression { return !params.Run_As_Master_Branch }
166
- }
171
+ anyOf {
172
+ changeRequest()
173
+ expression { return !params.Run_As_Master_Branch }
167
174
  }
168
175
  }
169
176
  steps {
@@ -186,23 +193,25 @@ pipeline {
186
193
  }
187
194
  when {
188
195
  beforeAgent true
189
- anyOf {
190
- tag pattern: 'v\\d+.*', comparator: 'REGEXP'
191
- }
196
+ tag pattern: 'v\\d+.*', comparator: 'REGEXP'
192
197
  }
193
- steps {
194
- withGithubNotify(context: 'Release') {
195
- deleteDir()
196
- unstash 'source'
197
- script {
198
- dir(BASE_DIR){
199
- docker.image("${env.RUBY_DOCKER_TAG}").inside('-v /etc/passwd:/etc/passwd -v ${HOME}/.ssh:${HOME}/.ssh') {
200
- withEnv(["HOME=${env.WORKSPACE}/${env.BASE_DIR ?: ''}"]) {
201
- rubygemsLogin.withApi(secret: "${env.RELEASE_SECRET}") {
202
- sshagent(['f6c7695a-671e-4f4f-a331-acdce44ff9ba']) {
203
- sh '.ci/prepare-git-context.sh'
204
- sh 'gem install rake yard rspec'
205
- sh 'rake release'
198
+ stages {
199
+ stage('Release') {
200
+ steps {
201
+ withGithubNotify(context: 'Release') {
202
+ deleteDir()
203
+ unstash 'source'
204
+ script {
205
+ dir(BASE_DIR){
206
+ docker.image("${env.RUBY_DOCKER_TAG}").inside('-v /etc/passwd:/etc/passwd -v ${HOME}/.ssh:${HOME}/.ssh') {
207
+ withEnv(["HOME=${env.WORKSPACE}/${env.BASE_DIR ?: ''}"]) {
208
+ rubygemsLogin.withApi(secret: "${env.RELEASE_SECRET}") {
209
+ sshagent(['f6c7695a-671e-4f4f-a331-acdce44ff9ba']) {
210
+ sh '.ci/prepare-git-context.sh'
211
+ sh 'gem install rake yard rspec'
212
+ sh 'rake release'
213
+ }
214
+ }
206
215
  }
207
216
  }
208
217
  }
@@ -210,6 +219,23 @@ pipeline {
210
219
  }
211
220
  }
212
221
  }
222
+ stage('Opbeans') {
223
+ environment {
224
+ REPO_NAME = "${OPBEANS_REPO}"
225
+ }
226
+ steps {
227
+ deleteDir()
228
+ dir("${OPBEANS_REPO}"){
229
+ git credentialsId: 'f6c7695a-671e-4f4f-a331-acdce44ff9ba',
230
+ url: "git@github.com:elastic/${OPBEANS_REPO}.git"
231
+ sh script: ".ci/bump-version.sh ${env.BRANCH_NAME}", label: 'Bump version'
232
+ // The opbeans pipeline will trigger a release for the master branch
233
+ gitPush()
234
+ // The opbeans pipeline will trigger a release for the release tag
235
+ gitCreateTag(tag: "${env.BRANCH_NAME}")
236
+ }
237
+ }
238
+ }
213
239
  }
214
240
  }
215
241
  }
@@ -258,11 +284,18 @@ def runBenchmark(version){
258
284
  }
259
285
 
260
286
  def runJob(rubyVersion){
261
- build( job: "apm-agent-ruby/apm-agent-ruby-downstream/${env.BRANCH_NAME}",
262
- parameters: [
263
- string(name: 'RUBY_VERSION', value: "${rubyVersion}"),
264
- string(name: 'BRANCH_SPECIFIER', value: "${env.GIT_BASE_COMMIT}")
265
- ],
266
- quietPeriod: 15
267
- )
287
+ try {
288
+ build( job: "apm-agent-ruby/apm-agent-ruby-downstream/${env.BRANCH_NAME}",
289
+ parameters: [
290
+ string(name: 'RUBY_VERSION', value: "${rubyVersion}"),
291
+ string(name: 'BRANCH_SPECIFIER', value: "${env.GIT_BASE_COMMIT}")
292
+ ],
293
+ quietPeriod: 15
294
+ )
295
+ } catch(e) {
296
+ rubyTasksFailed = true
297
+ warnError('Test Failures') {
298
+ error("Downstream job for '${rubyVersion}' failed")
299
+ }
300
+ }
268
301
  }
@@ -0,0 +1,14 @@
1
+ name: Lint
2
+
3
+ on: [push]
4
+
5
+ jobs:
6
+ build:
7
+ name: Rubocop
8
+ runs-on: ubuntu-latest
9
+ steps:
10
+ - uses: actions/checkout@v1
11
+ - name: Rubocop checks
12
+ uses: mikker/rubocop-action@master
13
+ env:
14
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
@@ -8,15 +8,11 @@ repos:
8
8
  - id: check-merge-conflict
9
9
  - id: check-yaml
10
10
  - id: check-xml
11
- - id: end-of-file-fixer
12
11
 
13
12
  - repo: git@github.com:elastic/apm-pipeline-library
14
13
  rev: current
15
14
  hooks:
16
15
  - id: check-bash-syntax
17
- - id: check-abstract-classes-and-trait
18
- - id: check-jsonslurper-class
19
16
  - id: check-jenkins-pipelines
20
- - id: check-unicode-non-breaking-spaces
21
- - id: remove-unicode-non-breaking-spaces
22
17
  - id: check-jjbb
18
+ - id: check-unicode-non-breaking-spaces
@@ -5,49 +5,67 @@ AllCops:
5
5
  - 'vendor/**/*'
6
6
  - 'bench/*'
7
7
 
8
- Layout/AlignArguments:
8
+ require:
9
+ - rubocop-performance
10
+
11
+ # Layout/
12
+
13
+ Layout/ArgumentAlignment:
9
14
  EnforcedStyle: with_fixed_indentation
10
15
 
11
- Layout/AlignParameters:
16
+ Layout/ParameterAlignment:
12
17
  EnforcedStyle: with_fixed_indentation
13
18
 
14
- Layout/IndentFirstParameter:
19
+ Layout/EmptyLineAfterGuardClause:
15
20
  Enabled: false
16
21
 
17
- Layout/AlignHash:
18
- Exclude:
19
- - 'Gemfile'
20
-
21
- Layout/EmptyLinesAroundArguments:
22
+ Layout/FirstParameterIndentation:
22
23
  Enabled: false
23
24
 
25
+ # Lint/
26
+
24
27
  Lint/RescueException:
25
28
  Enabled: false
26
29
 
27
- Lint/HandleExceptions:
30
+ Lint/SuppressedException:
28
31
  Enabled: false
29
32
 
30
- Lint/NonLocalExitFromIterator:
33
+ # Metrics /
34
+
35
+ Metrics/AbcSize:
31
36
  Enabled: false
32
37
 
33
- Metrics/BlockLength:
34
- Exclude:
35
- - 'spec/**/*.rb'
38
+ Metrics/ClassLength:
39
+ Enabled: false
36
40
 
37
41
  Metrics/ModuleLength:
38
- Exclude:
39
- - 'spec/**/*.rb'
42
+ Enabled: false
43
+
44
+ Metrics/BlockLength:
45
+ Enabled: false
46
+
47
+ Metrics/MethodLength:
48
+ Enabled: false
49
+
50
+ # Naming/
40
51
 
41
52
  Naming/PredicateName:
42
53
  Enabled: false
43
54
 
44
55
  Naming/FileName:
45
- Exclude:
46
- - 'lib/elastic-apm.rb'
56
+ Exclude: ['lib/elastic-apm.rb']
47
57
 
48
58
  Naming/AccessorMethodName:
49
59
  Enabled: false
50
60
 
61
+ Naming/MemoizedInstanceVariableName:
62
+ Enabled: false
63
+
64
+ Naming/MethodParameterName:
65
+ Enabled: false
66
+
67
+ # Style/
68
+
51
69
  Style/Alias:
52
70
  Enabled: false
53
71
 
@@ -57,9 +75,6 @@ Style/IfUnlessModifier:
57
75
  Style/FormatStringToken:
58
76
  Enabled: false
59
77
 
60
- Style/SafeNavigation:
61
- Enabled: false
62
-
63
78
  Style/DoubleNegation:
64
79
  Enabled: false
65
80
 
@@ -72,15 +87,6 @@ Style/NumericPredicate:
72
87
  Style/PerlBackrefs:
73
88
  Enabled: false
74
89
 
75
- Layout/EmptyLineAfterGuardClause:
76
- Enabled: false
77
-
78
- Naming/MemoizedInstanceVariableName:
79
- Enabled: false
80
-
81
- Naming/UncommunicativeMethodParamName:
82
- Enabled: false
83
-
84
90
  Style/SpecialGlobalVars:
85
91
  Enabled: false
86
92
 
@@ -26,11 +26,31 @@ endif::[]
26
26
  [float]
27
27
  ===== Fixed
28
28
  - Fix {pull}2526[#2526]
29
+
30
+ [float]
31
+ [[unreleased]]
32
+ ==== Unreleased
29
33
  ////
30
34
 
31
35
  [[release-notes-3.x]]
32
36
  === Ruby Agent version 3.x
33
37
 
38
+ [[release-notes-3.3.0]]
39
+ ==== 3.2.0 (2019-12-05)
40
+
41
+ [float]
42
+ ===== Added
43
+
44
+ - Add option `disable_metrics` {pull}625[#625]
45
+
46
+ [float]
47
+ ===== Fixed
48
+
49
+ - Make Filters thread-safe {pull}624[#624]
50
+ - Omit passwords in outgoing urls {pull}629[#629]
51
+ - Add missing mutex to Counter metrics {pull}636[#636]
52
+ - Correct span context collection name for Mongo getMore commands {pull}637[#637]
53
+
34
54
  [[release-notes-3.2.0]]
35
55
  ==== 3.2.0 (2019-11-19)
36
56
 
@@ -51,10 +71,6 @@ endif::[]
51
71
  - Fixed pulling config from Kibana {pull}594[#594]
52
72
  - Fixed a bug where the agent would alter the original cookies hash {pull}616[#616]
53
73
 
54
-
55
- [[release-notes-3.x]]
56
- === Ruby Agent version 3.x
57
-
58
74
  [[release-notes-3.1.0]]
59
75
  ==== 3.1.0 (2019-10-21)
60
76
 
data/Gemfile CHANGED
@@ -11,6 +11,7 @@ gem 'rack-test'
11
11
  gem 'rspec', '~> 3'
12
12
  gem 'rspec-its'
13
13
  gem 'rubocop', require: nil
14
+ gem 'rubocop-performance', require: nil
14
15
  gem 'timecop'
15
16
  gem 'webmock'
16
17
 
data/README.md CHANGED
@@ -1,7 +1,7 @@
1
1
  # elastic-apm
2
2
  ## Elastic APM agent for Ruby
3
3
 
4
- [![Jenkins](https://apm-ci.elastic.co/buildStatus/icon?job=apm-agent-ruby/apm-agent-ruby-mbp/master)](https://apm-ci.elastic.co/job/apm-agent-ruby/job/apm-agent-ruby-mbp/job/master/) [![Gem](https://img.shields.io/gem/v/elastic-apm.svg)](https://rubygems.org/gems/elastic-apm) [![codecov](https://codecov.io/gh/elastic/apm-agent-ruby/branch/master/graph/badge.svg)](https://codecov.io/gh/elastic/apm-agent-ruby)
4
+ [![Jenkins](https://apm-ci.elastic.co/buildStatus/icon?job=apm-agent-ruby/apm-agent-ruby-mbp/master)](https://apm-ci.elastic.co/job/apm-agent-ruby/job/apm-agent-ruby-mbp/job/master/) [![Gem](https://img.shields.io/gem/v/elastic-apm.svg)](https://rubygems.org/gems/elastic-apm)
5
5
 
6
6
  The official Rubygem for [Elastic][] [APM][].
7
7
 
@@ -48,7 +48,7 @@ $ bin/dev
48
48
  To pick a specific Ruby version, specify it with the `-i` flag:
49
49
 
50
50
  ```sh
51
- $ bin/dev -i jruby:9.2
51
+ $ bin/dev -i jruby:9.2
52
52
  ```
53
53
 
54
54
  If the first argument is a path starting with `spec/`, the passed specs will be run. Otherwise any arguments passed will be run as a command inside the container:
data/bin/dev CHANGED
@@ -28,7 +28,7 @@ USER_ID_GROUP = %w[u g].map { |f| `id -#{f}`.chomp }.join(':')
28
28
  RUBY_IMAGE = options.fetch(:image, 'ruby:latest')
29
29
  FRAMEWORKS = options.fetch(:frameworks, 'rails,sinatra,grape')
30
30
 
31
- IMAGE_PATH_SAFE = RUBY_IMAGE.gsub(':', '_')
31
+ IMAGE_PATH_SAFE = RUBY_IMAGE.tr(':', '_')
32
32
  IMAGE_NAME = "apm-agent-ruby:#{IMAGE_PATH_SAFE}"
33
33
  VENDOR_PATH = "/vendor/#{IMAGE_PATH_SAFE}"
34
34
 
@@ -18,6 +18,9 @@ if [[ $specific_spec = '' ]]; then
18
18
  runRspec
19
19
  for i in $(find spec/integration -name '*_spec.rb')
20
20
  do
21
+ echo "========================================"
22
+ echo $i
23
+ echo "========================================"
21
24
  runRspec "$i"
22
25
  done
23
26
  else
@@ -276,35 +276,6 @@ Returns `[String]` ID of the generated `[ElasticAPM::Error]` object.
276
276
  [[api-context]]
277
277
  === Context
278
278
 
279
- [float]
280
- [[api-agent-set-tag]]
281
- ==== `ElasticAPM.set_tag`
282
-
283
- Add a tag to the current transaction.
284
- Tags are basic key-value pairs that are indexed in your Elasticsearch database
285
- and therefore searchable. The value will always be converted to a String.
286
-
287
- TIP: Before using custom tags, ensure you understand the different types of
288
- {apm-overview-ref-v}/metadata.html[metadata] that are available.
289
-
290
- [source,ruby]
291
- ----
292
- before_action do
293
- ElasticAPM.set_tag(:company_id, current_user.company.id)
294
- end
295
- ----
296
-
297
- Arguments:
298
-
299
- * `key`: A string key. Note that `.`, `*` or `"` will be converted to `_`.
300
- * `value`: A string value.
301
-
302
- Returns the set `value`.
303
-
304
- WARNING: Be aware that tags are indexed in Elasticsearch. Using too many unique keys will result in *https://www.elastic.co/blog/found-crash-elasticsearch#mapping-explosion[Mapping explosion]*.
305
-
306
- NOTE: This method has been deprecated in favor of `set_label`, which does not convert values to Strings.
307
-
308
279
  [float]
309
280
  [[api-agent-set-label]]
310
281
  ==== `ElasticAPM.set_label`