elastic-apm 3.5.0 → 3.6.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,40 @@
1
+ FROM openjdk:8-jdk
2
+
3
+ RUN apt-get update \
4
+ && apt-get install -y libc6-dev --no-install-recommends \
5
+ && rm -rf /var/lib/apt/lists/*
6
+
7
+ ENV JRUBY_VERSION 9.2.10.0
8
+ ENV JRUBY_SHA256 9199707712c683c525252ccb1de5cb8e75f53b790c5b57a18f6367039ec79553
9
+
10
+ RUN mkdir -p /opt/jruby \
11
+ && curl -fSL https://repo1.maven.org/maven2/org/jruby/jruby-dist/${JRUBY_VERSION}/jruby-dist-${JRUBY_VERSION}-bin.tar.gz -o /tmp/jruby.tar.gz \
12
+ && echo "$JRUBY_SHA256 */tmp/jruby.tar.gz" | sha256sum -c - \
13
+ && tar -zx --strip-components=1 -f /tmp/jruby.tar.gz -C /opt/jruby \
14
+ && update-alternatives --install /usr/local/bin/ruby ruby /opt/jruby/bin/jruby 1
15
+
16
+ # set the jruby binaries in the path
17
+ ENV PATH /opt/jruby/bin:$PATH
18
+
19
+ # skip installing gem documentation
20
+ RUN mkdir -p /opt/jruby/etc \
21
+ && { \
22
+ echo 'install: --no-document'; \
23
+ echo 'update: --no-document'; \
24
+ } >> /opt/jruby/etc/gemrc
25
+
26
+ # install bundler, gem requires bash to work
27
+ RUN gem install bundler rake net-telnet xmlrpc tzinfo-data
28
+
29
+ # install things globally, for great justice
30
+ # and don't create ".bundle" in all our apps
31
+ ENV GEM_HOME /usr/local/bundle
32
+ ENV BUNDLE_PATH="$GEM_HOME" \
33
+ BUNDLE_BIN="$GEM_HOME/bin" \
34
+ BUNDLE_SILENCE_ROOT_WARNING=1 \
35
+ BUNDLE_APP_CONFIG="$GEM_HOME"
36
+ ENV PATH $BUNDLE_BIN:$PATH
37
+ RUN mkdir -p "$GEM_HOME" "$BUNDLE_BIN" \
38
+ && chmod 777 "$GEM_HOME" "$BUNDLE_BIN"
39
+
40
+ CMD [ "irb" ]
@@ -0,0 +1,31 @@
1
+ # JRuby docker images
2
+
3
+ Builds jruby docker images.
4
+
5
+ ## Build
6
+
7
+ To build the images run
8
+
9
+ ```bash
10
+ ./run.sh --action build
11
+ ```
12
+
13
+ You can set your own docker registry with the flag `--registry x.y.z/org`
14
+
15
+ You can exclude what images can be built with the flag `--exclude jdk-7`
16
+
17
+ ## Test
18
+
19
+ To test the images run
20
+
21
+ ```bash
22
+ ./run.sh --action test
23
+ ```
24
+
25
+ ## Push
26
+
27
+ To push the images run
28
+
29
+ ```bash
30
+ ./run.sh --action push
31
+ ```
@@ -0,0 +1,73 @@
1
+ #!/usr/bin/env bash
2
+
3
+ while (( "$#" )); do
4
+ case "$1" in
5
+ -r|--registry)
6
+ REGISTRY=$2
7
+ shift 2
8
+ ;;
9
+ -e|--exclude)
10
+ EXCLUDE=$2
11
+ shift 2
12
+ ;;
13
+ -a|--action)
14
+ ACTION=$2
15
+ shift 2
16
+ ;;
17
+ --) # end argument parsing
18
+ shift
19
+ break
20
+ ;;
21
+ -*|--*=) # unsupported flags
22
+ echo "Error: Unsupported flag $1" >&2
23
+ exit 1
24
+ ;;
25
+ *) # preserve positional arguments
26
+ shift
27
+ ;;
28
+ esac
29
+ done
30
+
31
+
32
+ if [ -n "$EXCLUDE" ] ; then
33
+ search=$(find . -path ./$EXCLUDE -prune -o -name 'Dockerfile' -print)
34
+ else
35
+ search=$(find . -name 'Dockerfile' -print)
36
+ fi
37
+
38
+ function report {
39
+ if [ $1 -eq 0 ] ; then
40
+ printf '\tImage %-60s %-10s\n' "${2}" "GENERATED"
41
+ else
42
+ printf '\tImage %-60s %-10s\n' "${2}" "FAILED"
43
+ fi
44
+ }
45
+
46
+ echo "${ACTION} docker images"
47
+ for i in ${search}; do
48
+ jdk_image=$(basename `dirname "$i"`)
49
+ jdk_version=$(echo "$jdk_image" | cut -d'-' -f1)
50
+ jruby=$(grep "JRUBY_VERSION" $i | cut -d" " -f 3)
51
+ if [ "${jdk_image}" == "onbuild" ] ; then
52
+ short=$(grep "FROM" "$i" | cut -d":" -f 2 | cut -d'-' -f1)
53
+ jdk_version=
54
+ else
55
+ short=$(echo "$jruby" | cut -d'.' -f1-2)
56
+ fi
57
+
58
+ if [ -n "${REGISTRY}" ] ; then
59
+ name="${REGISTRY}/jruby:${short}-${jdk_image}"
60
+ else
61
+ name="jruby:${short}-${jdk_image}"
62
+ fi
63
+
64
+ if [ "${ACTION}" == "build" ] ; then
65
+ docker build --tag "${name}" -< $i >> output.log 2>&1
66
+ report $? "${name}"
67
+ elif [ "${ACTION}" == "push" ] ; then
68
+ docker push "${name}" >> output.log 2>&1
69
+ report $? "${name}"
70
+ else
71
+ ./test.sh "${name}" $jdk_version
72
+ fi
73
+ done
@@ -0,0 +1,13 @@
1
+ #!/usr/bin/env bash
2
+ image=${1?image is required}
3
+ version=${2}
4
+
5
+ printf '\tTest %-30s %s\n' ${image}
6
+
7
+ if [ -n "$version" ] ; then
8
+ test_name="Test java -version '$version'"
9
+ docker run -t --rm $image java -version | grep -q "openjdk version \"$version\|1.$version" && printf '\t\t%-40s %s\n' "${test_name}" "PASSED" || printf '\t\t%-40s %s\n' "${test_name}" "FAILED"
10
+ fi
11
+
12
+ test_name="Test Hello World"
13
+ docker run -t --rm $image jruby -e "puts 'Hello World" | grep -q 'Hello World' && printf '\t\t%-40s %s\n' "${test_name}" "PASSED" || printf '\t\t%-40s %s\n' "${test_name}" "FAILED"
data/.gitignore CHANGED
@@ -22,4 +22,6 @@ vendor/
22
22
  log/
23
23
 
24
24
  benchmark-*.error
25
- benchmark-*.raw
25
+ benchmark-*.raw
26
+
27
+ .ci/docker/jruby/output.log
data/.rubocop.yml CHANGED
@@ -4,6 +4,8 @@ AllCops:
4
4
  - 'elastic-apm.gemspec'
5
5
  - 'vendor/**/*'
6
6
  - 'bench/*'
7
+ - 'spec/support/helloworld_pb.rb'
8
+ - 'spec/support/helloworld_services_pb.rb'
7
9
 
8
10
  require:
9
11
  - rubocop-performance
@@ -96,5 +98,12 @@ Style/SpecialGlobalVars:
96
98
  Style/MissingRespondToMissing:
97
99
  Enabled: false
98
100
 
99
- Style/BracesAroundHashParameters:
100
- Enabled: false
101
+ Style/HashEachMethods:
102
+ Enabled: true
103
+
104
+ Style/HashTransformKeys:
105
+ Enabled: true
106
+
107
+ Style/HashTransformValues:
108
+ Enabled: true
109
+
data/CHANGELOG.asciidoc CHANGED
@@ -35,6 +35,22 @@ endif::[]
35
35
  [[release-notes-3.x]]
36
36
  === Ruby Agent version 3.x
37
37
 
38
+ [[release-notes-3.6.0]]
39
+ ==== 3.6.0 (2020-03-10)
40
+
41
+ [float]
42
+ ===== Added
43
+
44
+ - Support for gRPC using the `grpc` gem (Experimental) {pull}669[#669]
45
+ - GraphQL support (experimental) {pull}721[#721]
46
+ - Add `span.context.destination.address` and `span.context.destination.port` when available. {pull}722[#722]
47
+ - Add support for Resque. {pull}729[#729]
48
+
49
+ [float]
50
+ ===== Changed
51
+
52
+ - The new SQL parser is used by default {pull}730[#730]
53
+
38
54
  [[release-notes-3.5.0]]
39
55
  ==== 3.5.0 (2020-02-12)
40
56
 
data/CONTRIBUTING.md CHANGED
@@ -41,10 +41,12 @@ $ spec/scripts/spec.sh ruby:2.6 rails-5.2
41
41
  To release a new version:
42
42
 
43
43
  1. Update `VERSION` in `lib/elastic_apm/version.rb` according to the changes (major, minor, patch).
44
- 2. Update `CHANGELOG.md` to reflect the new version – change _Unreleased_ section to _Version (release date)_.
45
- 3. Make a new commit with the changes above, with a message in the style of `vX.X.X`.
46
- 4. Run `rake release`. This will...
44
+ 1. Update `CHANGELOG.md` to reflect the new version – change _Unreleased_ section to _Version (release date)_.
45
+ 1. For Majors: Add a new row to the EOL table in `docs/upgrading.asciidoc`. The EOL date is the release date plus 18 months.
46
+ 1. Make a new commit with the changes above, with a message in the style of `vX.X.X`.
47
+ 1. Run `rake release`. This will...
47
48
  1. Tag the current commit as new version.
48
49
  2. Push the tag to GitHub.
49
50
  3. Build the gem and upload to Rubygems (local user needs to be signed in and authorized.)
50
- 4. Update `2.x` branch to be at released commit and push it to GitHub.
51
+ 1. Run `rake release:update_branch`. This will...
52
+ 1. Update `3.x` branch to be at released commit and push it to GitHub.
data/Gemfile CHANGED
@@ -21,26 +21,22 @@ gem 'aws-sdk-sqs', require: nil
21
21
  gem 'elasticsearch', require: nil
22
22
  gem 'fakeredis', require: nil
23
23
  gem 'faraday', require: nil
24
+ gem 'graphql', require: nil
25
+ gem 'grpc' if !defined?(JRUBY_VERSION) && RUBY_VERSION < '2.7'
24
26
  gem 'json-schema', require: nil
25
27
  gem 'mongo', require: nil
26
28
  gem 'opentracing', require: nil
27
29
  gem 'rake', require: nil
30
+ gem 'resque', require: nil
28
31
  gem 'sequel', require: nil
29
32
  gem 'shoryuken', require: nil
30
33
  gem 'sidekiq', require: nil
31
- gem 'sneakers', '~> 2.12', require: nil
32
34
  gem 'simplecov', require: false
33
35
  gem 'simplecov-cobertura', require: false
36
+ gem 'sneakers', '~> 2.12', require: nil
34
37
  gem 'yard', require: nil
35
38
  gem 'yarjuf'
36
39
 
37
- if RUBY_PLATFORM == 'java'
38
- gem 'activerecord-jdbcsqlite3-adapter'
39
- gem 'jdbc-sqlite3'
40
- else
41
- gem 'sqlite3'
42
- end
43
-
44
40
  ## Install Framework
45
41
  GITHUB_REPOS = {
46
42
  'grape' => 'ruby-grape/grape',
@@ -59,7 +55,7 @@ end
59
55
  frameworks_versions.each do |framework, version|
60
56
  case version
61
57
  when 'master'
62
- gem framework, github: GITHUB_REPOS.fetch[framework]
58
+ gem framework, github: GITHUB_REPOS.fetch(framework)
63
59
  when /.+/
64
60
  gem framework, "~> #{version}.0"
65
61
  else
@@ -73,6 +69,15 @@ if frameworks_versions.key?('rails')
73
69
  end
74
70
  end
75
71
 
72
+ if RUBY_PLATFORM == 'java'
73
+ gem 'activerecord-jdbcsqlite3-adapter'
74
+ gem 'jdbc-sqlite3'
75
+ elsif frameworks_versions['rails'] =~ /^(4|5)/
76
+ gem 'sqlite3', '~> 1.3.6'
77
+ else
78
+ gem 'sqlite3' # rubocop:disable Bundler/DuplicatedGem
79
+ end
80
+
76
81
  group :bench do
77
82
  gem 'ruby-prof', require: nil, platforms: %i[ruby]
78
83
  gem 'stackprof', require: nil, platforms: %i[ruby]
data/Rakefile CHANGED
@@ -2,11 +2,16 @@
2
2
 
3
3
  require 'bundler/gem_tasks'
4
4
 
5
- Rake::Task[:release].enhance do
6
- `git checkout 3.x &&
7
- git rebase master &&
8
- git push origin 3.x &&
9
- git checkout master`
5
+ desc """Post release action:
6
+ Update `3.x` branch to be at released commit and push it to GitHub.
7
+ """
8
+ namespace :release do
9
+ task :update_branch do
10
+ `echo hi && false && git checkout 3.x &&
11
+ git rebase master &&
12
+ git push origin 3.x &&
13
+ git checkout master`
14
+ end
10
15
  end
11
16
 
12
17
  require 'rspec/core/rake_task'
data/docker-compose.yml CHANGED
@@ -27,6 +27,11 @@ services:
27
27
  depends_on:
28
28
  - mongodb
29
29
 
30
+ ruby_rspec:
31
+ image: apm-agent-ruby:${RUBY_VERSION}
32
+ environment:
33
+ MONGODB_URL: 'mongodb:27017'
34
+
30
35
  volumes:
31
36
  vendor:
32
37
  mongodata:
data/docs/api.asciidoc CHANGED
@@ -42,6 +42,18 @@ If you're not using Rails, see <<getting-started-rack,Getting started with Rack>
42
42
  Stop the currently running agent. Use this inside `at_exit` in your
43
43
  <<getting-started-rack,Rack app>> to gracefully shut down.
44
44
 
45
+ [float]
46
+ [[api-agent-restart]]
47
+ ==== `ElasticAPM.restart`
48
+
49
+ If the agent is already running, this method will stop and start the agent.
50
+
51
+ If the agent is not already running, this method will start the agent.
52
+
53
+ A config can be passed to the method that will be used to start the agent. If the agent
54
+ is already running and no config is passed to the `#restart` method, the running agent's
55
+ config will be used.
56
+
45
57
  [float]
46
58
  [[api-agent-running]]
47
59
  ==== `ElasticAPM.running?`
@@ -425,13 +437,13 @@ end
425
437
 
426
438
  [float]
427
439
  [[api-transaction-sampled_]]
428
- ==== #sampled?
440
+ ==== `#sampled?`
429
441
 
430
442
  Whether the transaction is _sampled_ eg. it includes stacktraces for its spans.
431
443
 
432
444
  [float]
433
445
  [[api-transaction-ensure_parent_id]]
434
- ==== #ensure_parent_id
446
+ ==== `#ensure_parent_id`
435
447
 
436
448
  If the transaction does not have a parent-ID yet, calling this method generates
437
449
  a new ID, sets it as the parent-ID of this transaction, and returns it as a
@@ -765,20 +765,14 @@ context information, tags, or spans.
765
765
 
766
766
  [float]
767
767
  [[config-use-experimental-sql-parser]]
768
- ==== `use_experimental_sql_parser`
768
+ ==== `use_legacy_sql_parser`
769
769
  |============
770
- | Environment | `Config` key | Default
771
- | `ELASTIC_APM_USE_EXPERIMENTAL_SQL_PARSER` | `use_experimental_sql_parser` | `false`
770
+ | Environment | `Config` key | Default
771
+ | `ELASTIC_APM_USE_LEGACY_SQL_PARSER` | `use_legacy_sql_parser` | `false`
772
772
  |============
773
773
 
774
- Use a newer, more precise but still experimental approach to generating summaries of
775
- your app's SQL statements.
776
- Without this, your SQL statements will still be summarized albeit less accurately.
777
-
778
- The summaries become the spans' names -- what it says in the waterfall view in Kibana.
779
-
780
- NOTE: This should work just fine but is still deamed experimental. That means it is
781
- subject to change. Please let us know if you come across any issues.
774
+ Use the older, less precise approach to generating summaries of your app's SQL statements.
775
+ Try this if you're experiencing trouble using the new default.
782
776
 
783
777
  [float]
784
778
  [[config-verify-server-cert]]
@@ -0,0 +1,23 @@
1
+ ifdef::env-github[]
2
+ NOTE: For the best reading experience,
3
+ please view this documentation at https://www.elastic.co/guide/en/apm/agent/ruby[elastic.co]
4
+ endif::[]
5
+
6
+ [[graphql]]
7
+ == GraphQL (experimental)
8
+
9
+ The agent comes with support for GraphQL based APIs.
10
+
11
+ This slightly alters how transactions are named when they relate to GraphQL
12
+ queries, so they are easier to tell apart and debug.
13
+
14
+ To enable GraphQL support, add the included Tracer to your schema:
15
+
16
+ [source,ruby]
17
+ ----
18
+ class MySchema < GraphQL::Schema
19
+ # ...
20
+
21
+ tracer ElasticAPM::GraphQL # <-- include this
22
+ end
23
+ ----
data/docs/index.asciidoc CHANGED
@@ -25,9 +25,13 @@ include::./metrics.asciidoc[]
25
25
 
26
26
  include::./opentracing.asciidoc[]
27
27
 
28
+ include::./graphql.asciidoc[]
29
+
28
30
  include::./log-correlation.asciidoc[]
29
31
 
30
32
  include::./debugging.asciidoc[]
31
33
 
34
+ include::./upgrading.asciidoc[]
35
+
32
36
  include::./release-notes.asciidoc[]
33
37
 
@@ -85,4 +85,54 @@ We automatically instrument background processing using:
85
85
  - DelayedJob
86
86
  - Sidekiq
87
87
  - Shoryuken
88
- - Sneakers (v2.12.0+) (Experimental, see {pull}676[#676])
88
+ - Sneakers (v2.12.0+) (Experimental, see https://github.com/elastic/apm-agent-ruby/pull/676[#676])
89
+ - Resque (v2.0.0+)
90
+
91
+ [float]
92
+ [[supported-technologies-resque]]
93
+ === Resque
94
+
95
+ To make the agent work with Resque, you need to require `elastic_apm/resque` before you boot your Resque worker process.
96
+
97
+ For example in your `Rakefile`:
98
+
99
+ [source,ruby]
100
+ ----
101
+ require 'resque'
102
+ require 'elastic_apm'
103
+ require 'elastic_apm/resque'
104
+ ----
105
+
106
+ When you start Resque, you should see a series of messages like the following in the Resque logs:
107
+
108
+ [source,ruby]
109
+ ----
110
+ I, [XXX #81227] INFO -- : Starting worker main
111
+ D, [XXX #81227] DEBUG -- : Registered signals
112
+ I, [XXX #81227] INFO -- : Running before_first_fork hooks
113
+ D, [XXX #81227] DEBUG -- : Starting ElasticAPM agent
114
+ ----
115
+
116
+ [float]
117
+ [[supported-technologies-grpc]]
118
+ === gRPC
119
+
120
+ We automatically instrument gRPC using the `grpc` gem. Note that this is experimental, as the `grpc` gem's
121
+ support for `Interceptors` is experimental as of version 1.27.0.
122
+
123
+ To instrument a client, add the `ElasticAPM::GRPC::ClientInterceptor` as an `interceptor` at Stub creation.
124
+
125
+ [source,ruby]
126
+ ----
127
+ Helloworld::Greeter::Stub.new(
128
+ 'localhost:50051',
129
+ interceptors: [ElasticAPM::GRPC::ClientInterceptor.new]
130
+ )
131
+ ----
132
+
133
+ To instrument a server, add the `ElasticAPM::GRPC::ServerInterceptor`.
134
+
135
+ [source,ruby]
136
+ ----
137
+ GRPC::RpcServer.new(interceptors: [ElasticAPM::GRPC::ServerInterceptor.new])
138
+ ----