fluent-plugin-postgresql-csvlog 0.8.0 → 0.9.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 47a1cb4850459062da5931ab99d4180d53caed98985096be75a485a688e386c1
4
- data.tar.gz: 3d529ac068bed5cebed3e8ac49bcfb2f6f1e9d2d4ea9427582d1bdfc26ae22d3
3
+ metadata.gz: 31b92e4a5c795b777632cb72a3981df1248564d3446133536dabedf4b5cce541
4
+ data.tar.gz: f79600c2b56f20744b8afeda9b1461d51e8dacd3901be9273cdb8a16cd71dd21
5
5
  SHA512:
6
- metadata.gz: 927aba45b777040f1c5cb8b1e2044b0c2b8aca3b8590f1a7499285b835adfd15f276ef3ca3740193da61925beb22e0374314c87c482983007d2dd6cec5910ae0
7
- data.tar.gz: 6e75b2674e449122ad5c991a7a39429c0f0bfeff0de37d7b059673f964baccbf8ba2249680d529332b3a40f2e369627d1813de378f9774fc07370cd884748749
6
+ metadata.gz: 0024223f3d954f0c3d7fe5789c23ad08ff901e4225a2ee8a23de1a85bb09330b8b26241c39c23853ec6c3c50d2dd0a655add67f24c551156a497c83d55219cb7
7
+ data.tar.gz: ea9eaa01530670cc3d7c38f370854bdb573dbd1d4cfaa41bc55c2ddefede29e2cf0d8ff7ba33af60fba7c4781afcd26eaa89fb99dade750d0da5902c974476e8
data/.gitlab-ci.yml CHANGED
@@ -1,16 +1,32 @@
1
- image: "ruby:2.7"
1
+ image: "ruby:${RUBY_VERSION}"
2
+
3
+ variables:
4
+ RUBY_VERSION: "3.2"
5
+
6
+ stages:
7
+ - test
8
+ - deploy
9
+
10
+ include:
11
+ - component: gitlab.com/gitlab-org/components/gem-release/gem-release@~latest
12
+ inputs:
13
+ smoke_test_script: "ruby -r 'fluent/plugin/filter_postgresql_slowlog'"
14
+ file_pattern_to_trigger_release: "fluent-plugin-postgresql-csvlog.gemspec"
2
15
 
3
16
  test:
17
+ stage: test
4
18
  before_script:
5
19
  - bundle config set path vendor
6
20
  - bundle install --jobs $(nproc)
7
21
  script:
8
22
  - bundle exec rake test
9
23
  cache:
24
+ key: ruby-${RUBY_VERSION}
10
25
  paths:
11
26
  - vendor/ruby
12
27
 
13
28
  .iteration_test:
29
+ stage: test
14
30
  services:
15
31
  - name: postgres:$POSTGRES_SERVER_VERSION
16
32
  alias: postgres
@@ -27,25 +43,15 @@ test:
27
43
  paths:
28
44
  - vendor/ruby
29
45
 
30
- # integration tests for postgres 12
31
- itest_pg12:
32
- extends: .iteration_test
33
- variables:
34
- POSTGRES_SERVER_VERSION: 12
35
-
36
- # integration tests for postgres 13
37
- itest_pg13:
46
+ # integration tests for PostgreSQL
47
+ itest:
38
48
  extends: .iteration_test
39
- variables:
40
- POSTGRES_SERVER_VERSION: 13
41
-
42
- # integration tests for postgres 14
43
- itest_pg14:
44
- extends: .iteration_test
45
- variables:
46
- POSTGRES_SERVER_VERSION: 14
49
+ parallel:
50
+ matrix:
51
+ - POSTGRES_SERVER_VERSION: ["12", "13", "14", "15", "16"]
47
52
 
48
53
  end_to_end_verification_test:
54
+ stage: test
49
55
  image: docker:20.10.16
50
56
  services:
51
57
  - docker:20.10.16-dind
@@ -2,7 +2,7 @@ $:.push File.expand_path('lib', __dir__)
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = 'fluent-plugin-postgresql-csvlog'
5
- s.version = '0.8.0'
5
+ s.version = '0.9.0'
6
6
  s.authors = ['stanhu']
7
7
  s.email = ['stanhu@gmail.com']
8
8
  s.homepage = 'https://gitlab.com/gitlab-org/fluent-plugins/fluent-plugin-postgresql-csvlog'
@@ -15,8 +15,8 @@ Gem::Specification.new do |s|
15
15
  s.require_paths = ['lib']
16
16
 
17
17
  s.add_dependency 'fluentd', ['>= 1.0', '< 2']
18
- s.add_dependency 'pg', '~> 1.1'
19
- s.add_dependency 'pg_query', '~> 2.0'
18
+ s.add_dependency 'pg', '~> 1.5'
19
+ s.add_dependency 'pg_query', '~> 5.0'
20
20
 
21
21
  s.add_development_dependency 'rake'
22
22
  s.add_development_dependency 'test-unit', '~> 3.2'
@@ -6,8 +6,8 @@ module Fluent::Plugin
6
6
  # MarginaliaExtractor provides the parse_marginalia_into_record
7
7
  # utility method, useful for extracting marginalia into fluentd records
8
8
  module MarginaliaExtractor
9
- MARGINALIA_PREPENDED_REGEXP = %r{^(?<comment>/\*.*\*/)(?<sql>.*)}m.freeze
10
- MARGINALIA_APPENDED_REGEXP = %r{(?<sql>.*)(?<comment>/\*.*\*/)\s*;?\s*$}m.freeze
9
+ MARGINALIA_PREPENDED_REGEXP = %r{^(?<comment>/\*.*?\*/)\s*(?<sql>.*)}m
10
+ MARGINALIA_APPENDED_REGEXP = %r{(?<sql>.*)(?<comment>/\*.*\*/)\s*;?\s*$}m
11
11
 
12
12
  # Injects marginalia into a fluentd record
13
13
  def parse_marginalia_into_record(record, key, strip_comment)
@@ -44,7 +44,7 @@ class PgStatStatementsInputTest < Test::Unit::TestCase
44
44
  d = create_driver
45
45
  row = {
46
46
  'queryid' => '1234',
47
- 'query' => 'SELECT * FROM users WHERE user_id = ?',
47
+ 'query' => 'SELECT * FROM users WHERE user_id = 123',
48
48
  'calls' => 22,
49
49
  'rows' => 333,
50
50
  'total_time' => 44.44
@@ -54,8 +54,8 @@ class PgStatStatementsInputTest < Test::Unit::TestCase
54
54
 
55
55
  expected = {
56
56
  'fingerprint' => 'c071dee80d466e7d',
57
- 'query' => 'SELECT * FROM users WHERE user_id = ?',
58
- 'query_length' => 37,
57
+ 'query' => 'SELECT * FROM users WHERE user_id = $1',
58
+ 'query_length' => 39,
59
59
  'queryid' => '1234',
60
60
  'calls' => 22,
61
61
  'rows' => 333,
@@ -48,6 +48,19 @@ class Marginalia < Test::Unit::TestCase
48
48
  test_parse(sql, {}, 'sql', true, expected)
49
49
  end
50
50
 
51
+ test 'marginalia appended with other comments in SQL' do
52
+ sql = %(INSERT INTO "p_ci_builds_metadata" ("project_id", "config_options", "config_variables", "has_exposed_artifacts", "build_id", "partition_id") VALUES (40163635, '{"image":{"name":"$AWS_AMAZONLINUX_IMAGE"},"artifacts":{"paths":["${ASSET_NAME}/out"]},"before_script":["yum install -y python3 python3-pip zip findutils","cd ${ASSET_NAME}"],"script":["mkdir -p venv","cd venv","python3 -m venv pyspark_venvsource","source pyspark_venvsource/bin/activate","pip3 install -r ../scripts/requirements.txt","pip3 install venv-pack","venv-pack -f -o pyspark_venv.tar.gz","cd ..; mkdir -p out/lib","cd src/step/; cp -r --parents ./*/*main*.py ../../out"],"retry":{"max":2}}', '[{"key":"ASSET_NAME","value":"data-pipeline"}]', FALSE, 6269937106, 101) RETURNING "id" /*application:sidekiq,correlation_id:01HQNQAHYZF4Q294P59R7RP71H,jid:047ecd6920dc27ccd49b0aef,endpoint_id:PostReceive,db_config_name:ci*/)
53
+ expected = {
54
+ 'application' => 'sidekiq',
55
+ 'correlation_id' => '01HQNQAHYZF4Q294P59R7RP71H',
56
+ 'jid' => '047ecd6920dc27ccd49b0aef',
57
+ 'db_config_name' => 'ci',
58
+ 'endpoint_id' => 'PostReceive',
59
+ 'sql' => %(INSERT INTO "p_ci_builds_metadata" ("project_id", "config_options", "config_variables", "has_exposed_artifacts", "build_id", "partition_id") VALUES (40163635, '{"image":{"name":"$AWS_AMAZONLINUX_IMAGE"},"artifacts":{"paths":["${ASSET_NAME}/out"]},"before_script":["yum install -y python3 python3-pip zip findutils","cd ${ASSET_NAME}"],"script":["mkdir -p venv","cd venv","python3 -m venv pyspark_venvsource","source pyspark_venvsource/bin/activate","pip3 install -r ../scripts/requirements.txt","pip3 install venv-pack","venv-pack -f -o pyspark_venv.tar.gz","cd ..; mkdir -p out/lib","cd src/step/; cp -r --parents ./*/*main*.py ../../out"],"retry":{"max":2}}', '[{"key":"ASSET_NAME","value":"data-pipeline"}]', FALSE, 6269937106, 101) RETURNING "id")
60
+ }
61
+ test_parse(sql, {}, 'sql', true, expected)
62
+ end
63
+
51
64
  test 'normal comment prepended' do
52
65
  sql = '/* this is just a comment */ SELECT COUNT(*) FROM "projects"'
53
66
  expected = {
@@ -87,6 +100,19 @@ class Marginalia < Test::Unit::TestCase
87
100
  test_parse(sql, {}, 'sql', true, expected)
88
101
  end
89
102
 
103
+ test 'marginalia prepended with other comments in SQL' do
104
+ sql = %(/*application:sidekiq,correlation_id:01HQNQAHYZF4Q294P59R7RP71H,jid:047ecd6920dc27ccd49b0aef,endpoint_id:PostReceive,db_config_name:ci*/ INSERT INTO "p_ci_builds_metadata" ("project_id", "config_options", "config_variables", "has_exposed_artifacts", "build_id", "partition_id") VALUES (40163635, '{"image":{"name":"$AWS_AMAZONLINUX_IMAGE"},"artifacts":{"paths":["${ASSET_NAME}/out"]},"before_script":["yum install -y python3 python3-pip zip findutils","cd ${ASSET_NAME}"],"script":["mkdir -p venv","cd venv","python3 -m venv pyspark_venvsource","source pyspark_venvsource/bin/activate","pip3 install -r ../scripts/requirements.txt","pip3 install venv-pack","venv-pack -f -o pyspark_venv.tar.gz","cd ..; mkdir -p out/lib","cd src/step/; cp -r --parents ./*/*main*.py ../../out"],"retry":{"max":2}}', '[{"key":"ASSET_NAME","value":"data-pipeline"}]', FALSE, 6269937106, 101) RETURNING "id")
105
+ expected = {
106
+ 'application' => 'sidekiq',
107
+ 'correlation_id' => '01HQNQAHYZF4Q294P59R7RP71H',
108
+ 'jid' => '047ecd6920dc27ccd49b0aef',
109
+ 'db_config_name' => 'ci',
110
+ 'endpoint_id' => 'PostReceive',
111
+ 'sql' => %(INSERT INTO "p_ci_builds_metadata" ("project_id", "config_options", "config_variables", "has_exposed_artifacts", "build_id", "partition_id") VALUES (40163635, '{"image":{"name":"$AWS_AMAZONLINUX_IMAGE"},"artifacts":{"paths":["${ASSET_NAME}/out"]},"before_script":["yum install -y python3 python3-pip zip findutils","cd ${ASSET_NAME}"],"script":["mkdir -p venv","cd venv","python3 -m venv pyspark_venvsource","source pyspark_venvsource/bin/activate","pip3 install -r ../scripts/requirements.txt","pip3 install venv-pack","venv-pack -f -o pyspark_venv.tar.gz","cd ..; mkdir -p out/lib","cd src/step/; cp -r --parents ./*/*main*.py ../../out"],"retry":{"max":2}}', '[{"key":"ASSET_NAME","value":"data-pipeline"}]', FALSE, 6269937106, 101) RETURNING "id")
112
+ }
113
+ test_parse(sql, {}, 'sql', true, expected)
114
+ end
115
+
90
116
  test 'marginalia prepended for web, comment_strip disabled' do
91
117
  sql = 'SELECT COUNT(*) FROM "projects" /*application:sidekiq,correlation_id:d67cae54c169e0cab7d73389e2934f0e,jid:52a1c8a9e4c555ea573f20f0,job_class:Geo::MetricsUpdateWorker*/'
92
118
  expected = {
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fluent-plugin-postgresql-csvlog
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.0
4
+ version: 0.9.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - stanhu
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-08-27 00:00:00.000000000 Z
11
+ date: 2024-05-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: fluentd
@@ -36,28 +36,28 @@ dependencies:
36
36
  requirements:
37
37
  - - "~>"
38
38
  - !ruby/object:Gem::Version
39
- version: '1.1'
39
+ version: '1.5'
40
40
  type: :runtime
41
41
  prerelease: false
42
42
  version_requirements: !ruby/object:Gem::Requirement
43
43
  requirements:
44
44
  - - "~>"
45
45
  - !ruby/object:Gem::Version
46
- version: '1.1'
46
+ version: '1.5'
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: pg_query
49
49
  requirement: !ruby/object:Gem::Requirement
50
50
  requirements:
51
51
  - - "~>"
52
52
  - !ruby/object:Gem::Version
53
- version: '2.0'
53
+ version: '5.0'
54
54
  type: :runtime
55
55
  prerelease: false
56
56
  version_requirements: !ruby/object:Gem::Requirement
57
57
  requirements:
58
58
  - - "~>"
59
59
  - !ruby/object:Gem::Version
60
- version: '2.0'
60
+ version: '5.0'
61
61
  - !ruby/object:Gem::Dependency
62
62
  name: rake
63
63
  requirement: !ruby/object:Gem::Requirement
@@ -140,18 +140,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
140
140
  - !ruby/object:Gem::Version
141
141
  version: '0'
142
142
  requirements: []
143
- rubygems_version: 3.4.19
143
+ rubygems_version: 3.3.27
144
144
  signing_key:
145
145
  specification_version: 4
146
146
  summary: fluentd plugins to work with PostgreSQL CSV logs
147
- test_files:
148
- - test/helper.rb
149
- - test/plugin/itest_in_pg_stat_activity.rb
150
- - test/plugin/itest_in_pg_stat_statements.rb
151
- - test/plugin/test_filter_marginalia.rb
152
- - test/plugin/test_filter_postgresql_redactor.rb
153
- - test/plugin/test_filter_postgresql_slowlog.rb
154
- - test/plugin/test_in_pg_stat_activity.rb
155
- - test/plugin/test_in_pg_stat_statements.rb
156
- - test/plugin/test_marginalia_extractor.rb
157
- - test/verify-docker-compose.sh
147
+ test_files: []