Skip to content

Add transaction and span outcome#883

Merged
estolfo merged 20 commits intoelastic:masterfrom
estolfo:outcome
Nov 9, 2020
Merged

Add transaction and span outcome#883
estolfo merged 20 commits intoelastic:masterfrom
estolfo:outcome

Conversation

@estolfo
Copy link
Copy Markdown
Contributor

@estolfo estolfo commented Nov 2, 2020

Closes #852

Todo:

  • grpc
  • elasticsearch
  • sequel
  • Should the http_status_code argument be converted to an Integer or required to be an Integer in the above methods?

@ghost
Copy link
Copy Markdown

ghost commented Nov 2, 2020

❕ Build Aborted

There is a new build on-going so the previous on-going builds have been aborted.

the below badges are clickable and redirect to their specific view in the CI or DOCS
Pipeline View Test View Changes Artifacts

Expand to view the summary

Build stats

  • Build Cause: [Pull request #883 updated]

  • Reason: Aborted from #16

  • Start Time: 2020-11-09T09:06:33.886+0000

  • Duration: 123 min 50 sec

  • Commit: eb470b8

Test stats 🧪

Test Results
Failed 0
Passed 11842
Skipped 20
Total 11862

Steps errors 72

Expand to view the steps failures

> Show only the first 10 steps failures

  • Name: Print Message (took 0 min 0 sec) . View log details on here

  • Name: Recursively delete the current directory from the workspace (took 0 min 0 sec) . View log details on here

  • Name: Error signal (took 0 min 0 sec) . View log details on here

    • Description: Ruby:ruby:2.7#rails-6.0 tests failed : java.lang.NullPointerException
  • Name: Print Message (took 0 min 0 sec) . View log details on here

  • Name: Recursively delete the current directory from the workspace (took 0 min 0 sec) . View log details on here

  • Name: Error signal (took 0 min 0 sec) . View log details on here

    • Description: Ruby:ruby:2.7#rails-5.2 tests failed : java.lang.NullPointerException
  • Name: Print Message (took 0 min 0 sec) . View log details on here

  • Name: Recursively delete the current directory from the workspace (took 0 min 0 sec) . View log details on here

  • Name: Error signal (took 0 min 0 sec) . View log details on here

    • Description: Ruby:ruby:2.7#rails-5.1 tests failed : java.lang.NullPointerException
  • Name: Print Message (took 0 min 0 sec) . View log details on here

Log output

Expand to view the last 100 lines of log output

[2020-11-09T09:12:02.433Z] [INFO] Ruby:ruby:2.3#rails-5.2
[2020-11-09T09:12:02.469Z] [INFO] Ruby:docker.elastic.co/observability-ci/jruby:9.2-11-jdk#rails-5.0
[2020-11-09T09:12:02.986Z] [INFO] getVaultSecret: Getting secrets
[2020-11-09T09:12:03.047Z] [INFO] Ruby:docker.elastic.co/observability-ci/jruby:9.2-12-jdk#rails-5.0
[2020-11-09T09:12:03.281Z] Masking supported pattern matches of $VAULT_ADDR or $VAULT_ROLE_ID or $VAULT_SECRET_ID
[2020-11-09T09:12:03.543Z] Running on apm-ci-immutable-ubuntu-1804-1604913009531935238 in /var/lib/jenkins/workspace/t-ruby_apm-agent-ruby-mbp_PR-883
[2020-11-09T09:12:03.562Z] Running on apm-ci-immutable-ubuntu-1804-1604913009531855340 in /var/lib/jenkins/workspace/t-ruby_apm-agent-ruby-mbp_PR-883
[2020-11-09T09:12:03.702Z] + ./spec/scripts/spec.sh jruby:9.1 rails-5.2
[2020-11-09T09:12:03.703Z] + '[' 2 -lt 2 ']'
[2020-11-09T09:12:03.703Z] + IMAGE_NAME=jruby:9.1
[2020-11-09T09:12:03.703Z] + FRAMEWORK=rails-5.2
[2020-11-09T09:12:03.703Z] + TEST=
[2020-11-09T09:12:03.703Z] ++ echo jruby:9.1
[2020-11-09T09:12:03.703Z] ++ cut -d: -f2
[2020-11-09T09:12:03.703Z] + VERSION=9.1
[2020-11-09T09:12:03.703Z] + cd spec
[2020-11-09T09:12:03.703Z] + IMAGE_NAME=jruby:9.1
[2020-11-09T09:12:03.703Z] + RUBY_VERSION=9.1
[2020-11-09T09:12:03.703Z] ++ id -u
[2020-11-09T09:12:03.703Z] ++ id -g
[2020-11-09T09:12:03.703Z] + USER_ID=1155:1156
[2020-11-09T09:12:03.703Z] + docker-compose up -d mongodb
[2020-11-09T09:12:03.735Z] [INFO] Ruby:ruby:2.7#sinatra-1.4
[2020-11-09T09:12:03.752Z] [INFO] Ruby:docker.elastic.co/observability-ci/jruby:9.1-7-jdk#rails-5.1
[2020-11-09T09:12:03.880Z] Running in /var/lib/jenkins/workspace/t-ruby_apm-agent-ruby-mbp_PR-883/src/github.com/elastic/apm-agent-ruby
[2020-11-09T09:12:03.910Z] Sleeping for 10 sec
[2020-11-09T09:12:03.919Z] Running on apm-ci-immutable-ubuntu-1804-1604913009531955018 in /var/lib/jenkins/workspace/t-ruby_apm-agent-ruby-mbp_PR-883
[2020-11-09T09:12:03.983Z] Creating network "apm-agent-ruby_default" with the default driver
[2020-11-09T09:12:04.018Z] [INFO] Ruby:ruby:2.6#rails-4.2
[2020-11-09T09:12:04.256Z] Creating volume "apm-agent-ruby_vendor" with default driver
[2020-11-09T09:12:04.257Z] Creating volume "apm-agent-ruby_mongodata" with default driver
[2020-11-09T09:12:04.257Z] Creating apm-agent-ruby_mongodb_1 ... 
[2020-11-09T09:12:04.440Z] Running on apm-ci-immutable-ubuntu-1804-1604913009531973934 in /var/lib/jenkins/workspace/t-ruby_apm-agent-ruby-mbp_PR-883
[2020-11-09T09:12:04.961Z] 
Creating apm-agent-ruby_mongodb_1 ... done
+ JDK_JAVA_OPTIONS=
[2020-11-09T09:12:04.962Z] + JRUBY_OPTS=
[2020-11-09T09:12:04.962Z] + [[ '' == *\j\r\u\b\y* ]]
[2020-11-09T09:12:04.962Z] ++ echo jruby:9.1
[2020-11-09T09:12:04.962Z] ++ sed s/:/-/
[2020-11-09T09:12:04.962Z] + CLEAN_IMAGE_NAME=jruby-9.1
[2020-11-09T09:12:04.962Z] + docker build --build-arg RUBY_IMAGE=jruby:9.1 -t apm-agent-ruby:9.1 .
[2020-11-09T09:12:05.242Z] Sending build context to Docker daemon  549.4kB

[2020-11-09T09:12:05.242Z] Step 1/8 : ARG RUBY_IMAGE
[2020-11-09T09:12:05.242Z] Step 2/8 : FROM ${RUBY_IMAGE}
[2020-11-09T09:12:05.242Z]  ---> 2796cc3adc37
[2020-11-09T09:12:05.242Z] Step 3/8 : ENV CI "1"
[2020-11-09T09:12:05.242Z]  ---> Running in 48bb6736c780
[2020-11-09T09:12:05.371Z] Running on apm-ci-immutable-ubuntu-1804-1604913009531460375 in /var/lib/jenkins/workspace/t-ruby_apm-agent-ruby-mbp_PR-883
[2020-11-09T09:12:05.502Z] Running on apm-ci-immutable-ubuntu-1804-1604913009532130259 in /var/lib/jenkins/workspace/t-ruby_apm-agent-ruby-mbp_PR-883
[2020-11-09T09:12:05.519Z] Removing intermediate container 48bb6736c780
[2020-11-09T09:12:05.519Z]  ---> 94dad8a06d92
[2020-11-09T09:12:05.519Z] Step 4/8 : ENV INCLUDE_COVERAGE "1"
[2020-11-09T09:12:05.519Z]  ---> Running in 68ad463f00a5
[2020-11-09T09:12:05.519Z] Removing intermediate container 68ad463f00a5
[2020-11-09T09:12:05.519Z]  ---> e2611f19e87d
[2020-11-09T09:12:05.519Z] Step 5/8 : ENV DEBIAN_FRONTEND=noninteractive
[2020-11-09T09:12:05.519Z]  ---> Running in fa5806343e94
[2020-11-09T09:12:05.791Z] Removing intermediate container fa5806343e94
[2020-11-09T09:12:05.791Z]  ---> 9812451b0f3d
[2020-11-09T09:12:05.791Z] Step 6/8 : RUN [ apt-get ]     && ( apt-get update -qq         && apt-get install -qq -y build-essential libpq-dev git tzdata)     || true
[2020-11-09T09:12:05.791Z]  ---> Running in f686140117aa
[2020-11-09T09:12:06.056Z] Running on apm-ci-immutable-ubuntu-1804-1604913020747887330 in /var/lib/jenkins/workspace/t-ruby_apm-agent-ruby-mbp_PR-883
[2020-11-09T09:12:06.286Z] Running on apm-ci-immutable-ubuntu-1804-1604913020747694076 in /var/lib/jenkins/workspace/t-ruby_apm-agent-ruby-mbp_PR-883
[2020-11-09T09:12:06.535Z] Running on apm-ci-immutable-ubuntu-1804-1604913020747813890 in /var/lib/jenkins/workspace/t-ruby_apm-agent-ruby-mbp_PR-883
[2020-11-09T09:12:07.124Z] Running on apm-ci-immutable-ubuntu-1804-1604913020747980175 in /var/lib/jenkins/workspace/t-ruby_apm-agent-ruby-mbp_PR-883
[2020-11-09T09:12:07.773Z] Running in /var/lib/jenkins/workspace/t-ruby_apm-agent-ruby-mbp_PR-883/src/github.com/elastic/apm-agent-ruby
[2020-11-09T09:12:07.820Z] Running in /var/lib/jenkins/workspace/t-ruby_apm-agent-ruby-mbp_PR-883/src/github.com/elastic/apm-agent-ruby
[2020-11-09T09:12:07.881Z] Running in /var/lib/jenkins/workspace/t-ruby_apm-agent-ruby-mbp_PR-883/src/github.com/elastic/apm-agent-ruby
[2020-11-09T09:12:07.918Z] + set +x
[2020-11-09T09:12:07.955Z] Running in /var/lib/jenkins/workspace/t-ruby_apm-agent-ruby-mbp_PR-883/src/github.com/elastic/apm-agent-ruby
[2020-11-09T09:12:08.099Z] Running in /var/lib/jenkins/workspace/t-ruby_apm-agent-ruby-mbp_PR-883/src/github.com/elastic/apm-agent-ruby
[2020-11-09T09:12:08.203Z] Running in /var/lib/jenkins/workspace/t-ruby_apm-agent-ruby-mbp_PR-883/src/github.com/elastic/apm-agent-ruby
[2020-11-09T09:12:08.256Z] Login Succeeded
[2020-11-09T09:12:08.266Z] Running in /var/lib/jenkins/workspace/t-ruby_apm-agent-ruby-mbp_PR-883/src/github.com/elastic/apm-agent-ruby
[2020-11-09T09:12:08.297Z] Running in /var/lib/jenkins/workspace/t-ruby_apm-agent-ruby-mbp_PR-883/src/github.com/elastic/apm-agent-ruby
[2020-11-09T09:12:08.335Z] Running in /var/lib/jenkins/workspace/t-ruby_apm-agent-ruby-mbp_PR-883/src/github.com/elastic/apm-agent-ruby
[2020-11-09T09:12:08.357Z] Running in /var/lib/jenkins/workspace/t-ruby_apm-agent-ruby-mbp_PR-883/src/github.com/elastic/apm-agent-ruby
[2020-11-09T09:12:08.377Z] Running in /var/lib/jenkins/workspace/t-ruby_apm-agent-ruby-mbp_PR-883/src/github.com/elastic/apm-agent-ruby
[2020-11-09T09:12:08.514Z] Sleeping for 17 sec
[2020-11-09T09:12:08.520Z] Sleeping for 29 sec
[2020-11-09T09:12:08.527Z] Sleeping for 10 sec
[2020-11-09T09:12:08.534Z] Sleeping for 36 sec
[2020-11-09T09:12:08.538Z] Sleeping for 32 sec
[2020-11-09T09:12:08.542Z] Sleeping for 15 sec
[2020-11-09T09:12:08.546Z] Sleeping for 26 sec
[2020-11-09T09:12:08.553Z] Sleeping for 19 sec
[2020-11-09T09:12:08.558Z] Sleeping for 16 sec
[2020-11-09T09:12:08.561Z] Sleeping for 25 sec
[2020-11-09T09:12:08.570Z] Sleeping for 10 sec
[2020-11-09T09:12:08.591Z] [INFO] Ruby:ruby:2.6#rails-6.0
[2020-11-09T09:12:08.599Z] [INFO] Ruby:ruby:2.6#sinatra-master
[2020-11-09T09:12:08.629Z] [INFO] Ruby:jruby:9.2#sinatra-2.0
[2020-11-09T09:12:08.637Z] [INFO] Ruby:docker.elastic.co/observability-ci/jruby:9.1-7-jdk#rails-5.0
[2020-11-09T09:12:08.645Z] [INFO] Ruby:jruby:9.2#rails-6.0
[2020-11-09T09:12:08.652Z] [INFO] Ruby:ruby:2.5#sinatra-2.0
[2020-11-09T09:12:08.688Z] [INFO] Ruby:docker.elastic.co/observability-ci/jruby:9.2-12-jdk#grape-1.3
[2020-11-09T09:12:08.696Z] [INFO] getVaultSecret: Getting secrets
[2020-11-09T09:12:08.700Z] [INFO] getVaultSecret: Getting secrets
[2020-11-09T09:12:09.010Z] [INFO] getVaultSecret: Getting secrets
[2020-11-09T09:12:09.087Z] Masking supported pattern matches of $VAULT_ADDR or $VAULT_ROLE_ID or $VAULT_SECRET_ID
[2020-11-09T09:12:09.515Z] Masking supported pattern matches of $VAULT_ADDR or $VAULT_ROLE_ID or $VAULT_SECRET_ID

Copy link
Copy Markdown
Contributor

@mikker mikker left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm a little bit confused by this approach.

How about something like

class Transaction
  SUCCESS = 'success'
  FAILURE = 'failure'

  # ...

  def success!
    self.outcome = SUCCESS
  end

  def failure!
    self.outcome = FAILURE
  end
end

This ties the details of how to signify the two values into the class itself. That way we don't have to throw around the magic strings success and failure in the whole lib.

@mikker
Copy link
Copy Markdown
Contributor

mikker commented Nov 4, 2020

Could even be something like

class Transaction
  class Outcome
    def initialize(value)
      @value = value
    end

    def self.success
      new('success')
    end

    def self.failure
      new('failure')
    end
    
    def self.from_status_code(code)
      new(code >= 500 ? 'failure' : 'success')
    end
  end

  def success!
    self.outcome = Outcome.success
  end

  def failure!
    self.outcome = Outcome.failure
  end
end

Such OO, very message passing 😅

Copy link
Copy Markdown
Contributor

@mikker mikker left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

estolfo and others added 4 commits November 5, 2020 15:14
Co-authored-by: Mikkel Malmberg <mikkel@brnbw.com>
Co-authored-by: Mikkel Malmberg <mikkel@brnbw.com>
@estolfo estolfo marked this pull request as ready for review November 5, 2020 14:27
@estolfo estolfo requested a review from mikker November 5, 2020 14:27
Copy link
Copy Markdown
Contributor

@mikker mikker left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Generally looks good!

We're a bit inconsistent about whether or not we allow users to set the outcome themselves. Sometimes we take it into account, sometimes only when 'success', sometimes not.

Is there a reason we couldn't always let the user set it themselves? What does the spec suggest?

estolfo and others added 7 commits November 6, 2020 10:48
Co-authored-by: Mikkel Malmberg <mikkel@brnbw.com>
Co-authored-by: Mikkel Malmberg <mikkel@brnbw.com>
Co-authored-by: Mikkel Malmberg <mikkel@brnbw.com>
Co-authored-by: Mikkel Malmberg <mikkel@brnbw.com>
@estolfo
Copy link
Copy Markdown
Contributor Author

estolfo commented Nov 6, 2020

Originally, I only took into account whether outcome was already set in with_transaction and with_span because the user would run their own code and could determine themselves what was a success or failure. I don't think it's necessary to check whether the outcome is already set for spans or transactions we create ourselves in the spies. Unless you disagree?

Edit: Also, we have to check if the outcome is already set in with_transaction and with_span because something like the Faraday spy will set the outcome based on the http status code before the block completes.

@estolfo estolfo requested a review from mikker November 9, 2020 09:47
Copy link
Copy Markdown
Contributor

@mikker mikker left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚀

@estolfo estolfo merged commit 61c3bff into elastic:master Nov 9, 2020
@ghost
Copy link
Copy Markdown

ghost commented Nov 9, 2020

💚 Build Succeeded

the below badges are clickable and redirect to their specific view in the CI or DOCS
Pipeline View Test View Changes Artifacts preview

Expand to view the summary

Build stats

  • Build Cause: [Started by user Mikkel Malmberg, Replayed #16]

  • Start Time: 2020-11-09T12:14:38.627+0000

  • Duration: 27 min 1 sec

Test stats 🧪

Test Results
Failed 0
Passed 69667
Skipped 129
Total 69796

Steps errors 4

Expand to view the steps failures

  • Name: Shell Script (took 6 min 44 sec) . View log details on here

    • Description: ./spec/scripts/spec.sh jruby:9.2 rails-5.1
  • Name: Shell Script (took 3 min 1 sec) . View log details on here

    • Description: [2020-11-09T12:21:58.707Z] + ./spec/scripts/spec.sh docker.elastic.co/observability-ci/jruby:9.2-11-
  • Name: Shell Script (took 5 min 15 sec) . View log details on here

    • Description: [2020-11-09T12:20:15.615Z] + ./spec/scripts/spec.sh docker.elastic.co/observability-ci/jruby:9.2-8-j
  • Name: Shell Script (took 8 min 38 sec) . View log details on here

    • Description: [2020-11-09T12:21:52.624Z] + ./spec/scripts/spec.sh docker.elastic.co/observability-ci/jruby:9.2-8-j

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add outcome to transactions and spans

2 participants