ecs-logging 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: '09ee8625220e820c133ae35f6661de4059c2e02632c87056b413edd76f39169f'
4
- data.tar.gz: 8452e4c8337b15a993af3ca361b22a40796a8f3bc7fa8121722621681ca99d50
3
+ metadata.gz: 43b9e37dc57c2eadf7ea3e27ba6ee4060d94e814dc4921e1262702927b9a8a12
4
+ data.tar.gz: a255a92fc7cf973b266ecc8e8eec64f599cba52c45b033c15920280ef590fd2d
5
5
  SHA512:
6
- metadata.gz: 12bc623be8c801b44ce8b313363c9ea4051175056af681eff37482df44f436820259581f025ca968a03e852c1a7766879a5d5dc58b66d8b30d4b3a6517709564
7
- data.tar.gz: ee7f1febaf0773fc62616fe920e92d6080ef2ad10487f123cb06b1a93cc0c091f8c447aa60ad6adda8e237b455a507b9b54137f6f82effd468b740594b7f995d
6
+ metadata.gz: 0d47468fc499ebd03c1335a55a2d7c4f0b0dac14a92865d6a847c9c7dc10035ba067ae2c5c9a5469545483dc62d4f3f0429ac2232bbf054a64e97da258f87863
7
+ data.tar.gz: 37353532f52a56192916c791871eed288b57001a44df012f2a582cfb06f78c3dbe535f0fe478071e0a7dded74896679163f9d5b8388d7709e0504578b1cda7ef
@@ -0,0 +1,84 @@
1
+ #!/usr/bin/env groovy
2
+ @Library('apm@current') _
3
+
4
+ pipeline {
5
+ agent { label 'linux && immutable' }
6
+ environment {
7
+ REPO = 'ecs-logging-ruby'
8
+ BASE_DIR = "src/github.com/elastic/${env.REPO}"
9
+ DOCKER_REGISTRY = 'docker.elastic.co'
10
+ DOCKER_SECRET = 'secret/apm-team/ci/docker-registry/prod'
11
+ PIPELINE_LOG_LEVEL = 'INFO'
12
+ NOTIFY_TO = credentials('notify-to')
13
+ JOB_GCS_BUCKET = credentials('gcs-bucket')
14
+ VERSION = '2.7.2'
15
+ HOME = "${WORKSPACE}"
16
+ PATH = "${WORKSPACE}/.rbenv/bin:${WORKSPACE}/.rbenv/versions/${VERSION}/bin:${PATH}"
17
+ }
18
+ options {
19
+ timeout(time: 2, unit: 'HOURS')
20
+ buildDiscarder(logRotator(numToKeepStr: '20', artifactNumToKeepStr: '20', daysToKeepStr: '30'))
21
+ timestamps()
22
+ ansiColor('xterm')
23
+ disableResume()
24
+ durabilityHint('PERFORMANCE_OPTIMIZED')
25
+ rateLimitBuilds(throttle: [count: 60, durationName: 'hour', userBoost: true])
26
+ quietPeriod(10)
27
+ }
28
+ triggers {
29
+ issueCommentTrigger('(?i).*(?:jenkins\\W+)?run\\W+(?:the\\W+)?tests(?:\\W+please)?.*')
30
+ }
31
+ stages {
32
+ stage('Checkout') {
33
+ options { skipDefaultCheckout() }
34
+ steps {
35
+ pipelineManager([ cancelPreviousRunningBuilds: [ when: 'PR' ] ])
36
+ deleteDir()
37
+ gitCheckout(basedir: "${BASE_DIR}", githubNotifyFirstTimeContributor: true)
38
+ stash allowEmpty: true, name: 'source', useDefaultExcludes: false
39
+ }
40
+ }
41
+ stage('Tests') {
42
+ failFast false
43
+ matrix {
44
+ agent { label 'linux && docker && ubuntu-18.04 && immutable' }
45
+ options { skipDefaultCheckout() }
46
+ axes {
47
+ axis {
48
+ name 'RUBY_VERSION'
49
+ values 'ruby:2.7', 'ruby:2.6', 'ruby:2.5', 'ruby:2.4', 'ruby:2.3', 'jruby:9.2', 'jruby:9.1'
50
+ }
51
+ axis {
52
+ name 'FRAMEWORK'
53
+ values 'rails-6.0', 'rails-5.2', 'rails-5.1', 'sinatra-2.0'
54
+ }
55
+ }
56
+ stages {
57
+ stage('Tests') {
58
+ steps {
59
+ withGithubNotify(context: "Tests-${RUBY_VERSION}-${FRAMEWORK}") {
60
+ deleteDir()
61
+ unstash 'source'
62
+ dir("${BASE_DIR}"){
63
+ dockerLogin(secret: "${DOCKER_SECRET}", registry: "${DOCKER_REGISTRY}")
64
+ sh(label: 'install rbenv', script: '.ci/install-rbenv.sh "${VERSION}"')
65
+ sh("bin/dev -i${RUBY_VERSION} -f${FRAMEWORK}")
66
+ }
67
+ }
68
+ }
69
+ post {
70
+ always {
71
+ junit(allowEmptyResults: true, keepLongStdio: true, testResults: "${BASE_DIR}/spec/junit-reports/**/*-junit.xml")
72
+ }
73
+ }
74
+ }
75
+ }
76
+ }
77
+ }
78
+ }
79
+ post {
80
+ cleanup {
81
+ notifyBuildResult()
82
+ }
83
+ }
84
+ }
@@ -0,0 +1,7 @@
1
+ #!/usr/bin/env bash
2
+ VERSION=${1:-"2.7.2"}
3
+ export PATH="$HOME/.rbenv/bin:$PATH"
4
+ git clone https://github.com/rbenv/rbenv.git ~/.rbenv
5
+ git clone git@github.com:rbenv/ruby-build.git ~/.rbenv/plugins/ruby-buildCloning
6
+ eval "$(rbenv init -)"
7
+ rbenv install "${VERSION}"
@@ -0,0 +1,4 @@
1
+ ---
2
+ - job:
3
+ name: apm-agent-ruby
4
+ project-type: folder
@@ -0,0 +1,24 @@
1
+ ---
2
+
3
+ ##### GLOBAL METADATA
4
+
5
+ - meta:
6
+ cluster: apm-ci
7
+
8
+ ##### JOB DEFAULTS
9
+
10
+ - job:
11
+ view: APM-CI
12
+ project-type: multibranch
13
+ logrotate:
14
+ daysToKeep: 30
15
+ numToKeep: 300
16
+ number-to-keep: '100'
17
+ days-to-keep: '30'
18
+ concurrent: true
19
+ node: linux
20
+ periodic-folder-trigger: 1w
21
+ prune-dead-branches: true
22
+ publishers:
23
+ - email:
24
+ recipients: infra-root+build@elastic.co
@@ -0,0 +1,42 @@
1
+ ---
2
+ - job:
3
+ name: apm-agent-ruby/ecs-logging-ruby-mbp
4
+ display-name: ECS logging Ruby
5
+ description: ECS logging Ruby
6
+ script-path: .ci/Jenkinsfile
7
+ scm:
8
+ - github:
9
+ branch-discovery: no-pr
10
+ discover-pr-forks-strategy: merge-current
11
+ discover-pr-forks-trust: permission
12
+ discover-pr-origin: merge-current
13
+ discover-tags: true
14
+ notification-context: 'apm-ci'
15
+ repo: ecs-logging-ruby
16
+ repo-owner: elastic
17
+ credentials-id: 2a9602aa-ab9f-4e52-baf3-b71ca88469c7-UserAndToken
18
+ ssh-checkout:
19
+ credentials: f6c7695a-671e-4f4f-a331-acdce44ff9ba
20
+ build-strategies:
21
+ - tags:
22
+ ignore-tags-older-than: -1
23
+ ignore-tags-newer-than: -1
24
+ - regular-branches: true
25
+ - change-request:
26
+ ignore-target-only-changes: false
27
+ clean:
28
+ after: true
29
+ before: true
30
+ prune: true
31
+ shallow-clone: true
32
+ depth: 3
33
+ do-not-fetch-tags: true
34
+ submodule:
35
+ disable: false
36
+ recursive: true
37
+ parent-credentials: true
38
+ timeout: 100
39
+ reference-repo: /var/lib/jenkins/.git-references/ecs-logging-ruby.git
40
+ timeout: '15'
41
+ use-author: true
42
+ wipe-workspace: 'True'
@@ -0,0 +1,3 @@
1
+ # add 'agent-ruby' label to all new issues
2
+ agent-ruby:
3
+ - '.*'
@@ -0,0 +1,16 @@
1
+ name: "Issue Labeler"
2
+ on:
3
+ issues:
4
+ types: [opened]
5
+ pull_request_target:
6
+ types: [opened]
7
+
8
+ jobs:
9
+ triage:
10
+ runs-on: ubuntu-latest
11
+ steps:
12
+ - uses: AlexanderWert/issue-labeler@v2.3
13
+ with:
14
+ repo-token: "${{ secrets.GITHUB_TOKEN }}"
15
+ configuration-path: .github/labeler-config.yml
16
+ enable-versioned-regex: 0
data/.gitignore CHANGED
@@ -4,8 +4,15 @@
4
4
  /coverage/
5
5
  /doc/
6
6
  /pkg/
7
+
8
+ Gemfile.lock
9
+
7
10
  /spec/reports/
8
11
  /tmp/
9
12
 
10
13
  # rspec failure tracking
11
14
  .rspec_status
15
+ /vendor
16
+
17
+ # junit reports folder
18
+ spec/junit-reports
@@ -0,0 +1,49 @@
1
+ ifdef::env-github[]
2
+ NOTE: Release notes are best read in our documentation at
3
+ https://www.elastic.co/guide/en/apm/agent/ruby/current/release-notes.html[elastic.co]
4
+ endif::[]
5
+
6
+ ////
7
+ [[release-notes-x.x.x]]
8
+ ==== x.x.x (YYYY-MM-DD)
9
+
10
+ [float]
11
+ ===== Breaking changes
12
+ - Breaking change
13
+
14
+ [float]
15
+ ===== Deprecated
16
+ - Deprecation {pull}2526[#2526]
17
+
18
+ [float]
19
+ ===== Added
20
+ - Feature {pull}2526[#2526]
21
+
22
+ [float]
23
+ ===== Changed
24
+ - Change {pull}2526[#2526]
25
+
26
+ [float]
27
+ ===== Fixed
28
+ - Fix {pull}2526[#2526]
29
+
30
+ [float]
31
+ [[unreleased]]
32
+ ==== Unreleased
33
+ ////
34
+
35
+ [[release-notes-0.x]]
36
+ === ECS logging Ruby 0.x
37
+
38
+ [[release-notes-0.2.0]]
39
+ ==== 0.2.0 (2020-12-09)
40
+
41
+ ===== Added
42
+
43
+ - Use `include_origin` to attach stack traces to logs {pull}1[#1]
44
+ - More fields logged when using Rack middleware {pull}6[#6]
45
+
46
+ [[release-notes-0.1.0]]
47
+ ==== 0.1.0 (2020-11-25)
48
+
49
+ Initial release
@@ -0,0 +1,40 @@
1
+ ARG RUBY_IMAGE
2
+ FROM ${RUBY_IMAGE}
3
+
4
+ ARG USER_ID_GROUP
5
+ ARG FRAMEWORKS
6
+ ARG VENDOR_PATH
7
+ ARG BUNDLER_VERSION
8
+
9
+ RUN apt-get update -qq \
10
+ && apt-get install -qq -y --no-install-recommends \
11
+ build-essential libpq-dev git \
12
+ && rm -rf /var/lib/apt/lists/*
13
+
14
+ # Configure bundler and PATH
15
+ ENV LANG=C.UTF-8
16
+
17
+ ENV GEM_HOME=$VENDOR_PATH
18
+ ENV BUNDLE_PATH=$GEM_HOME \
19
+ BUNDLE_JOBS=4 BUNDLE_RETRY=3
20
+ ENV BUNDLE_APP_CONFIG=$BUNDLE_PATH \
21
+ BUNDLE_BIN=$BUNDLE_PATH/bin
22
+ ENV PATH=/app/bin:$BUNDLE_BIN:$PATH
23
+
24
+ ENV FRAMEWORKS $FRAMEWORKS
25
+ ENV RUBY_IMAGE $RUBY_IMAGE
26
+
27
+ # Copy cached folder to speed up docker containers
28
+ COPY vendor /vendor
29
+ RUN chown -R $USER_ID_GROUP /vendor
30
+ USER $USER_ID_GROUP
31
+
32
+ # Upgrade RubyGems and install required Bundler version
33
+ RUN gem update --system && \
34
+ gem install bundler:$BUNDLER_VERSION
35
+
36
+ # Use unpatched, system version for more speed over less security
37
+ RUN gem install nokogiri -- --use-system-libraries
38
+
39
+ WORKDIR /app
40
+
data/Gemfile CHANGED
@@ -4,6 +4,7 @@ gemspec
4
4
 
5
5
  gem "rake"
6
6
  gem "rspec"
7
+ gem 'yarjuf'
7
8
 
8
9
  gem "rack-test", require: nil
9
10
  gem "sinatra", require: nil
data/README.md CHANGED
@@ -1,12 +1,14 @@
1
1
  # ecs-logging-ruby
2
2
 
3
+ [![Jenkins](https://apm-ci.elastic.co/buildStatus/icon?job=apm-agent-ruby/ecs-logging-ruby-mbp/master)](https://apm-ci.elastic.co/job/apm-agent-ruby/job/ecs-logging-ruby-mbp/job/master/) [![Gem](https://img.shields.io/gem/v/ecs-logging.svg)](https://rubygems.org/gems/ecs-logging)
4
+
3
5
  This set of libraries allows you to transform your application logs to structured logs that comply with the [Elastic Common Schema (ECS)](https://www.elastic.co/guide/en/ecs/current/ecs-reference.html).
4
6
  In combination with [filebeat](https://www.elastic.co/products/beats/filebeat) you can send your logs directly to Elasticsearch and leverage [Kibana's Logs UI](https://www.elastic.co/guide/en/infrastructure/guide/current/logs-ui-overview.html) to inspect all logs in one single place.
5
7
  See [ecs-logging](https://github.com/elastic/ecs-logging) for other ECS logging libraries and more resources about ECS & logging.
6
8
 
7
9
  ---
8
10
 
9
- **Please note** that this library is in a <del><strong>beta</strong></del> **in development** version and backwards-incompatible changes might be introduced in future releases. While we strive to comply to [semver](https://semver.org/), we can not guarantee to avoid breaking changes in minor releases.
11
+ **Please note** that this library is in a <strong>pre-1.0</strong> version and backwards-incompatible changes might be introduced in future releases. While we strive to comply to [semver](https://semver.org/), we can not guarantee to avoid breaking changes in minor releases.
10
12
 
11
13
  ## Installation
12
14
 
@@ -32,7 +34,7 @@ Or install it yourself as:
32
34
  require 'ecs/logger'
33
35
 
34
36
  logger = Ecs::Logger.new($stdout)
35
- logger.info 'my informative message'
37
+ logger.info('my informative message')
36
38
  logger.warn { 'be aware that…' }
37
39
  logger.error('a_progname') { 'oh no!' }
38
40
  ```
@@ -48,7 +50,7 @@ Logs the following JSON to `$stdout`:
48
50
  Additionally, it allows for adding additional keys to messages, eg:
49
51
 
50
52
  ```ruby
51
- logger.info 'ok', labels: { my_label: 'value' }, 'trace.id': 'abc-xyz'
53
+ logger.info('ok', labels: { my_label: 'value' }, 'trace.id': 'abc-xyz')
52
54
  ```
53
55
 
54
56
  Logs:
@@ -64,6 +66,28 @@ Logs:
64
66
  }
65
67
  ```
66
68
 
69
+ To include info about where the log was called, call the methods with `include_origin: true`, like:
70
+
71
+ ```ruby
72
+ logger.warn('Hello!', include_origin: true)
73
+ ```
74
+
75
+ Resulting in
76
+
77
+ ```json
78
+ {
79
+ "@timestamp":"2020-11-24T13:32:21.331Z",
80
+ "log.level":"WARN",
81
+ "message":"Hello!",
82
+ "ecs.version":"1.4.0",
83
+ "log.origin": {
84
+ "file.line": 123,
85
+ "file.name": "my_file.rb",
86
+ "function": "call"
87
+ }
88
+ }
89
+ ```
90
+
67
91
  ## Usage with Rack
68
92
 
69
93
  ```ruby
@@ -74,13 +98,17 @@ Example output:
74
98
 
75
99
  ```json
76
100
  {
77
- "@timestamp":"2020-11-24T20:00:22.707Z",
101
+ "@timestamp":"2020-12-07T13:44:04.568Z",
78
102
  "log.level":"INFO",
79
103
  "message":"GET /",
80
104
  "ecs.version":"1.4.0",
105
+ "client":{
106
+ "address":"127.0.0.1"
107
+ },
81
108
  "http":{
82
109
  "request":{
83
- "method":"GET"
110
+ "method":"GET",
111
+ "body.bytes":"0"
84
112
  }
85
113
  },
86
114
  "url":{
data/bin/dev ADDED
@@ -0,0 +1,55 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ require 'optparse'
5
+
6
+ options = {}
7
+ OptionParser.new do |opts|
8
+ opts.banner = 'Usage: bin/dev [options] [command]'
9
+
10
+ opts.on(
11
+ '-iIMAGE', '--image=IMAGE',
12
+ 'Specify Docker image (eg. ruby:latest)'
13
+ ) { |val| options[:image] = val }
14
+
15
+ opts.on(
16
+ '-fFRAMEWORKS', '--frameworks=FRAMEWORKS',
17
+ 'Specify frameworks to test (eg. rails:master,sinatra)'
18
+ ) { |val| options[:frameworks] = val }
19
+
20
+ opts.on(
21
+ '-s', '--skip-build',
22
+ 'Skip building image'
23
+ ) { |val| options[:skip_build] = val }
24
+ end.parse!
25
+
26
+ USER_ID_GROUP = %w[u g].map { |f| `id -#{f}`.chomp }.join(':')
27
+
28
+ RUBY_IMAGE = options.fetch(:image, 'ruby:latest')
29
+ FRAMEWORKS = options.fetch(:frameworks, 'rails')
30
+
31
+ IMAGE_PATH_SAFE = RUBY_IMAGE.tr(':', '_')
32
+ IMAGE_NAME = "apm-agent-ruby:#{IMAGE_PATH_SAFE}"
33
+ VENDOR_PATH = "/vendor/#{IMAGE_PATH_SAFE}"
34
+
35
+ def run(cmd)
36
+ "IMAGE_NAME=#{IMAGE_NAME} USER_ID_GROUP=#{USER_ID_GROUP} #{cmd}".tap do |str|
37
+ puts str
38
+ system str
39
+ end
40
+ end
41
+
42
+ unless options[:skip_build]
43
+ run 'docker-compose build ' \
44
+ " --build-arg RUBY_IMAGE=#{RUBY_IMAGE}" \
45
+ " --build-arg USER_ID_GROUP=#{USER_ID_GROUP}" \
46
+ " --build-arg FRAMEWORKS=#{FRAMEWORKS}" \
47
+ " --build-arg VENDOR_PATH=#{VENDOR_PATH}"
48
+ exit $?.exitstatus unless $?.success?
49
+ end
50
+
51
+ run 'docker-compose run' \
52
+ ' --rm' \
53
+ " specs #{ARGV.join}"
54
+
55
+ exit $?.exitstatus unless $?.success?
@@ -0,0 +1,28 @@
1
+ ---
2
+ version: '3.4'
3
+
4
+ services:
5
+ specs:
6
+ build:
7
+ context: .
8
+ args:
9
+ BUNDLER_VERSION: '2.0.2'
10
+ image: '$IMAGE_NAME'
11
+ environment:
12
+ HOME: '/tmp'
13
+ entrypoint:
14
+ 'docker/entrypoint.sh'
15
+ tty: true
16
+ volumes:
17
+ - .:/app:cached
18
+ tmpfs:
19
+ - /tmp:exec,mode=1777
20
+ user: ${USER_ID_GROUP}
21
+
22
+ ruby_rspec:
23
+ image: apm-agent-ruby:${RUBY_VERSION}
24
+ user: ${USER_ID_GROUP}
25
+
26
+ volumes:
27
+ vendor:
28
+
@@ -0,0 +1,38 @@
1
+ #!/bin/bash
2
+ set -x
3
+
4
+ runRspec(){
5
+ local case=${1:-""}
6
+ local bn=${case}
7
+
8
+ if [ -n "${case}" ]; then
9
+ bn="$(basename "${case}")/"
10
+ fi
11
+ if [ -n "${RUBY_VERSION}" ]; then
12
+ bn="$RUBY_VERSION-$bn"
13
+ fi
14
+ if [ -n "${FRAMEWORKS}" ]; then
15
+ bn="$FRAMEWORKS-$bn"
16
+ fi
17
+ bundle exec rspec \
18
+ -f progress \
19
+ -r yarjuf -f JUnit -o "spec/junit-reports/${bn}ruby-agent-junit.xml" ${case}
20
+ }
21
+
22
+ bundle check || (rm -f Gemfile.lock && bundle)
23
+
24
+ # If first arg is a spec path, run spec(s)
25
+ if [[ $1 == spec/* ]]; then
26
+ runRspec $@
27
+ exit $?
28
+ fi
29
+
30
+ # If no arguments, run all specs
31
+ if [[ $# == 0 ]]; then
32
+ runRspec
33
+ exit $?
34
+ fi
35
+
36
+ # Otherwise, run args as command
37
+ $@
38
+
@@ -17,6 +17,9 @@
17
17
 
18
18
  # frozen_string_literal: true
19
19
 
20
+ require 'time'
21
+ require 'json'
22
+
20
23
  module EcsLogging
21
24
  class Formatter
22
25
  def call(severity, time, progname, msg, **extras)
@@ -27,7 +30,7 @@ module EcsLogging
27
30
  "ecs.version": "1.4.0"
28
31
  }
29
32
 
30
- base['process.title'] = progname if progname
33
+ base['log.logger'] = progname if progname
31
34
 
32
35
  base.merge!(extras) if extras
33
36
 
@@ -19,6 +19,7 @@
19
19
 
20
20
  require "logger"
21
21
  require "ecs_logging/formatter"
22
+ require 'pp'
22
23
 
23
24
  module EcsLogging
24
25
  class Logger < ::Logger
@@ -27,7 +28,7 @@ module EcsLogging
27
28
  self.formatter = Formatter.new
28
29
  end
29
30
 
30
- def add(severity, message = nil, progname = nil, **extras)
31
+ def add(severity, message = nil, progname = nil, include_origin: false, **extras)
31
32
  severity ||= UNKNOWN
32
33
 
33
34
  return true if @logdev.nil? or severity < level
@@ -55,12 +56,34 @@ module EcsLogging
55
56
  true
56
57
  end
57
58
 
58
- def info(progname, **extras, &block)
59
- add(INFO, nil, progname, **extras, &block)
59
+ %w[unknown fatal error warn info debug].each do |severity|
60
+ define_method(severity) do |progname, include_origin: false, **extras, &block|
61
+ if include_origin && origin = origin_from_caller(caller)
62
+ extras[:"log.origin"] = origin
63
+ end
64
+
65
+ name = severity.upcase.to_sym
66
+ cnst = self.class.const_get(name)
67
+ add(cnst, nil, progname, **extras, &block)
68
+ end
60
69
  end
61
70
 
62
71
  private
63
72
 
73
+ RUBY_FORMAT = /^(.+?):(\d+)(?::in `(.+?)')?$/.freeze
74
+
75
+ def origin_from_caller(stack)
76
+ return unless (ruby_match = stack.first.match(RUBY_FORMAT))
77
+
78
+ _, file, number, method = ruby_match.to_a
79
+
80
+ {
81
+ 'file.name': File.basename(file),
82
+ 'file.line': number.to_i,
83
+ function: method
84
+ }
85
+ end
86
+
64
87
  def format_message(severity, datetime, progname, msg, **extras)
65
88
  formatter.call(severity, datetime, progname, msg, **extras)
66
89
  end
@@ -43,11 +43,8 @@ module EcsLogging
43
43
  severity = status >= 500 ? Logger::ERROR : Logger::INFO
44
44
 
45
45
  extras = {
46
- http: {
47
- request: {
48
- method: req_method
49
- }
50
- },
46
+ client: { address: env["REMOTE_ADDR"] },
47
+ http: { request: { method: req_method } },
51
48
  url: {
52
49
  domain: env['HTTP_HOST'],
53
50
  path: path,
@@ -56,6 +53,14 @@ module EcsLogging
56
53
  }
57
54
  }
58
55
 
56
+ if content_length = env["CONTENT_LENGTH"]
57
+ extras[:http][:request][:'body.bytes'] = content_length
58
+ end
59
+
60
+ if user_agent = env['HTTP_USER_AGENT']
61
+ extras[:user_agent] = { original: user_agent }
62
+ end
63
+
59
64
  @logger.add(severity, message, **extras)
60
65
  end
61
66
  end
@@ -18,5 +18,5 @@
18
18
  # frozen_string_literal: true
19
19
 
20
20
  module EcsLogging
21
- VERSION = "0.1.0"
21
+ VERSION = "0.2.0"
22
22
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ecs-logging
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.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: 2020-11-25 00:00:00.000000000 Z
11
+ date: 2020-12-09 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Write a longer description or delete this line.
14
14
  email:
@@ -17,14 +17,25 @@ executables: []
17
17
  extensions: []
18
18
  extra_rdoc_files: []
19
19
  files:
20
+ - ".ci/Jenkinsfile"
21
+ - ".ci/install-rbenv.sh"
22
+ - ".ci/jobs/apm-agent-ruby.yml"
23
+ - ".ci/jobs/defaults.yml"
24
+ - ".ci/jobs/ecs-logging-ruby-mbp.yml"
25
+ - ".github/labeler-config.yml"
26
+ - ".github/workflows/labeler.yml"
20
27
  - ".gitignore"
21
28
  - ".rspec"
22
29
  - ".travis.yml"
30
+ - CHANGELOG.asciidoc
31
+ - Dockerfile
23
32
  - Gemfile
24
- - Gemfile.lock
25
33
  - LICENSE
26
34
  - README.md
27
35
  - Rakefile
36
+ - bin/dev
37
+ - docker-compose.yml
38
+ - docker/entrypoint.sh
28
39
  - ecs-logging.gemspec
29
40
  - lib/ecs-logging.rb
30
41
  - lib/ecs_logging.rb
@@ -33,6 +44,7 @@ files:
33
44
  - lib/ecs_logging/logger.rb
34
45
  - lib/ecs_logging/middleware.rb
35
46
  - lib/ecs_logging/version.rb
47
+ - vendor/.gitkeep
36
48
  homepage: https://github.com/elastic/ecs-logging-ruby
37
49
  licenses:
38
50
  - Apache-2.0
@@ -1,50 +0,0 @@
1
- PATH
2
- remote: .
3
- specs:
4
- ecs-logging (0.1.0)
5
-
6
- GEM
7
- remote: https://rubygems.org/
8
- specs:
9
- diff-lcs (1.4.4)
10
- mustermann (1.1.1)
11
- ruby2_keywords (~> 0.0.1)
12
- rack (2.2.3)
13
- rack-protection (2.1.0)
14
- rack
15
- rack-test (1.1.0)
16
- rack (>= 1.0, < 3)
17
- rake (13.0.1)
18
- rspec (3.10.0)
19
- rspec-core (~> 3.10.0)
20
- rspec-expectations (~> 3.10.0)
21
- rspec-mocks (~> 3.10.0)
22
- rspec-core (3.10.0)
23
- rspec-support (~> 3.10.0)
24
- rspec-expectations (3.10.0)
25
- diff-lcs (>= 1.2.0, < 2.0)
26
- rspec-support (~> 3.10.0)
27
- rspec-mocks (3.10.0)
28
- diff-lcs (>= 1.2.0, < 2.0)
29
- rspec-support (~> 3.10.0)
30
- rspec-support (3.10.0)
31
- ruby2_keywords (0.0.2)
32
- sinatra (2.1.0)
33
- mustermann (~> 1.0)
34
- rack (~> 2.2)
35
- rack-protection (= 2.1.0)
36
- tilt (~> 2.0)
37
- tilt (2.0.10)
38
-
39
- PLATFORMS
40
- ruby
41
-
42
- DEPENDENCIES
43
- ecs-logging!
44
- rack-test
45
- rake
46
- rspec
47
- sinatra
48
-
49
- BUNDLED WITH
50
- 2.1.4