lsslog 0.1.6 → 0.1.7.1

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of lsslog might be problematic. Click here for more details.

checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: fbddb05ebae4c811f7633a4c4324d70aa573cefdbff89f214466073aee2c14d0
4
- data.tar.gz: 963b1153ce2a32f2c5fc36f57819afa158187726e8970fa16e9df382ed7f0ad9
3
+ metadata.gz: 24b6c0d3edd020f2d9d8527691fed2e5cb7a820a26243a0cc1c8438dd97a900d
4
+ data.tar.gz: 2f6451ed62719c71a9981c335916ac79a369114b1c3b4be8cfdec5787bc7a1e5
5
5
  SHA512:
6
- metadata.gz: 5ff9e997c47852ee1277b8e716d204486c1613cef6c9986ecaa3d894d7c1cbb6d2bd231ea9d95d6bcc63f94d529d6a420298d352be122397e61d3a1d504e8962
7
- data.tar.gz: 6979b53ce59f7beb421ec86f486df1b51072cbd5b23382454014a066f071fc716a0488335c2543509d5e5d203fb95445337cb5c3c3be2185a7c141c7e78643b6
6
+ metadata.gz: 1e329ef42a2419c148a35e3f2fd976b9ac8c6fbacf102eb3e99e39527340dfb861f7e045136bd5c3d57e640b733e946c4707ca03dbff4aa682b522084766a5fd
7
+ data.tar.gz: b149a28e7aa28712cfbfbe0919c66ad8e814deb28e1b4a0f2daf04bc749374b9ab5168ac60c5069c0fa876e65a1195b5889828d90923b0d9b3a444be96f444a1
@@ -0,0 +1,64 @@
1
+ require 'grpc'
2
+ require 'lsslog_services_pb'
3
+
4
+ module Lsslog
5
+ module Services
6
+ class V2
7
+ def initialize
8
+ @stub = Lsslog::V2::Stub.new(lss_host, :this_channel_is_insecure)
9
+ end
10
+
11
+ def log(message_h:, severity:, component: '', api: '')
12
+ message_struct = hash_to_struct(message_h)
13
+
14
+ log_ver2 = Lsslog::LogVer2.new(
15
+ severity: severity,
16
+ timestamp: Time.now.utc.iso8601,
17
+ api: api,
18
+ component: component,
19
+ message: message_struct
20
+ )
21
+
22
+ Rails.logger.info("Sending LSS log. Message:[#{message_h}]")
23
+
24
+ response = @stub.log(log_ver2, deadline: Time.now + 5)
25
+ response
26
+ rescue GRPC::BadStatus => e
27
+ Rails.logger.error("Error sending LSS log: #{e.message}")
28
+ nil
29
+ end
30
+
31
+ private
32
+
33
+ def lss_host
34
+ @lss_host ||= ::Lsslog.configuration.lss_host
35
+ raise 'Lsslog.configuration.lss_host is missing' unless @lss_host
36
+
37
+ @lss_host
38
+ end
39
+
40
+ def hash_to_struct(hash)
41
+ Google::Protobuf::Struct.new(fields: hash.transform_values { |v| to_proto_value(v) })
42
+ end
43
+
44
+ def to_proto_value(value)
45
+ case value
46
+ when String
47
+ Google::Protobuf::Value.new(string_value: value)
48
+ when Numeric
49
+ Google::Protobuf::Value.new(number_value: value)
50
+ when TrueClass, FalseClass
51
+ Google::Protobuf::Value.new(bool_value: value)
52
+ when Hash
53
+ Google::Protobuf::Value.new(struct_value: hash_to_struct(value))
54
+ when Array
55
+ Google::Protobuf::Value.new(list_value: Google::Protobuf::ListValue.new(values: value.map { |v| to_proto_value(v) }))
56
+ when NilClass
57
+ Google::Protobuf::Value.new(null_value: :NULL_VALUE)
58
+ else
59
+ Google::Protobuf::Value.new(string_value: value.to_s)
60
+ end
61
+ end
62
+ end
63
+ end
64
+ end
@@ -0,0 +1,64 @@
1
+ require 'grpc'
2
+ require 'lsslog_services_pb'
3
+
4
+ module Lsslog
5
+ module V2
6
+ class Service
7
+ def initialize
8
+ @stub = Lsslog::V2::Stub.new(lss_host, :this_channel_is_insecure)
9
+ end
10
+
11
+ def log(message_h:, severity:, component: '', api: '')
12
+ message_struct = hash_to_struct(message_h)
13
+
14
+ log_ver2 = Lsslog::LogVer2.new(
15
+ severity: severity,
16
+ timestamp: Time.now.utc.iso8601,
17
+ api: api,
18
+ component: component,
19
+ message: message_struct
20
+ )
21
+
22
+ Rails.logger.info("Sending LSS log. Message:[#{message_h}]")
23
+
24
+ response = @stub.log(log_ver2, deadline: Time.now + 5)
25
+ response
26
+ rescue GRPC::BadStatus => e
27
+ Rails.logger.error("Error sending LSS log: #{e.message}")
28
+ nil
29
+ end
30
+
31
+ private
32
+
33
+ def lss_host
34
+ @lss_host ||= ::Lsslog.configuration.lss_host
35
+ raise 'Lsslog.configuration.lss_host is missing' unless @lss_host
36
+
37
+ @lss_host
38
+ end
39
+
40
+ def hash_to_struct(hash)
41
+ Google::Protobuf::Struct.new(fields: hash.transform_values { |v| to_proto_value(v) })
42
+ end
43
+
44
+ def to_proto_value(value)
45
+ case value
46
+ when String
47
+ Google::Protobuf::Value.new(string_value: value)
48
+ when Numeric
49
+ Google::Protobuf::Value.new(number_value: value)
50
+ when TrueClass, FalseClass
51
+ Google::Protobuf::Value.new(bool_value: value)
52
+ when Hash
53
+ Google::Protobuf::Value.new(struct_value: hash_to_struct(value))
54
+ when Array
55
+ Google::Protobuf::Value.new(list_value: Google::Protobuf::ListValue.new(values: value.map { |v| to_proto_value(v) }))
56
+ when NilClass
57
+ Google::Protobuf::Value.new(null_value: :NULL_VALUE)
58
+ else
59
+ Google::Protobuf::Value.new(string_value: value.to_s)
60
+ end
61
+ end
62
+ end
63
+ end
64
+ end
@@ -1,3 +1,3 @@
1
1
  module Lsslog
2
- VERSION = "0.1.6"
2
+ VERSION = "0.1.7.1"
3
3
  end
data/lib/lsslog_pb.rb CHANGED
@@ -1,96 +1,16 @@
1
+ # frozen_string_literal: true
1
2
  # Generated by the protocol buffer compiler. DO NOT EDIT!
2
3
  # source: lsslog.proto
3
4
 
4
5
  require 'google/protobuf'
5
6
 
6
- Google::Protobuf::DescriptorPool.generated_pool.build do
7
- add_file("lsslog.proto", :syntax => :proto3) do
8
- add_message "lsslog.LssLog" do
9
- optional :transaction_id, :string, 1
10
- optional :flow_id, :string, 3
11
- optional :subflow_id, :string, 4
12
- optional :flow_dir, :enum, 2, "lsslog.FlowDirection"
13
- optional :flow_depth, :int32, 5
14
- optional :system_id, :string, 6
15
- optional :flow_body, :string, 7
16
- optional :request_method, :string, 8
17
- optional :request_url, :string, 9
18
- optional :status, :int32, 10
19
- optional :response_size, :int64, 11
20
- optional :user_agent, :string, 12
21
- optional :remote_ip, :string, 13
22
- optional :server_ip, :string, 14
23
- optional :latency, :int32, 15
24
- optional :protocol, :string, 16
25
- optional :start_time, :int64, 17
26
- optional :end_time, :int64, 18
27
- optional :created_at, :int64, 19
28
- optional :recevied_at, :int64, 20
29
- optional :is_completed, :bool, 21
30
- optional :tenant_id, :string, 22
31
- end
32
- add_message "lsslog.LssRes" do
33
- optional :body, :string, 1
34
- optional :code, :int32, 2
35
- end
36
- add_message "lsslog.VersionOut" do
37
- optional :api_verion, :string, 1
38
- optional :branch, :string, 2
39
- optional :commit, :string, 3
40
- optional :date, :string, 4
41
- optional :go_version, :string, 5
42
- optional :os_arch, :string, 6
43
- end
44
- add_message "lsslog.EmptyIn" do
45
- end
46
- add_message "lsslog.TransExpTime" do
47
- optional :flow_exp_time, :int32, 1
48
- optional :subflow_exp_time, :int32, 2
49
- end
50
- add_message "lsslog.LssConfig" do
51
- optional :flow_id, :string, 1
52
- optional :flow_name, :string, 2
53
- optional :enforce_sequence, :bool, 3
54
- optional :number_subflow, :int32, 4
55
- end
56
- add_message "lsslog.LssConfigRes" do
57
- repeated :data, :message, 1, "lsslog.LssConfig"
58
- optional :trans_exp_time, :message, 2, "lsslog.TransExpTime"
59
- end
60
- add_message "lsslog.ProdDetails" do
61
- optional :sku, :string, 1
62
- optional :vm_id, :string, 2
63
- optional :stg_id, :string, 3
64
- optional :nat_gw_id, :string, 4
65
- optional :peer_id, :string, 5
66
- optional :ec_id, :string, 6
67
- optional :subnet_id, :string, 7
68
- optional :elastic_ipa, :string, 8
69
- optional :nic_id, :string, 9
70
- optional :workload_id, :string, 10
71
- end
72
- add_message "lsslog.PurchasedItem" do
73
- optional :zone_id, :string, 1
74
- optional :region_id, :string, 2
75
- optional :item_cnt, :string, 3
76
- repeated :skus, :string, 5
77
- optional :detail, :message, 6, "lsslog.ProdDetails"
78
- end
79
- add_message "lsslog.ProdTransaction" do
80
- optional :transaction_id, :string, 1
81
- optional :tenant_id, :string, 2
82
- repeated :details, :message, 3, "lsslog.PurchasedItem"
83
- optional :region_id, :string, 4
84
- optional :zone_id, :string, 5
85
- optional :provisioned_at, :int64, 6
86
- optional :created_at, :int64, 7
87
- end
88
- add_enum "lsslog.FlowDirection" do
89
- value :REQUEST, 0
90
- value :RESPONSE, 1
91
- end
92
- end
93
- end
7
+ require 'google/protobuf/struct_pb'
8
+
9
+
10
+ descriptor_data = "\n\x0clsslog.proto\x12\x06lsslog\x1a\x1cgoogle/protobuf/struct.proto\"\xd1\x03\n\x06LssLog\x12\x16\n\x0etransaction_id\x18\x01 \x01(\t\x12\x0f\n\x07\x66low_id\x18\x03 \x01(\t\x12\x12\n\nsubflow_id\x18\x04 \x01(\t\x12\'\n\x08\x66low_dir\x18\x02 \x01(\x0e\x32\x15.lsslog.FlowDirection\x12\x12\n\nflow_depth\x18\x05 \x01(\x05\x12\x11\n\tsystem_id\x18\x06 \x01(\t\x12\x11\n\tflow_body\x18\x07 \x01(\t\x12\x16\n\x0erequest_method\x18\x08 \x01(\t\x12\x13\n\x0brequest_url\x18\t \x01(\t\x12\x0e\n\x06status\x18\n \x01(\x05\x12\x15\n\rresponse_size\x18\x0b \x01(\x03\x12\x12\n\nuser_agent\x18\x0c \x01(\t\x12\x11\n\tremote_ip\x18\r \x01(\t\x12\x11\n\tserver_ip\x18\x0e \x01(\t\x12\x0f\n\x07latency\x18\x0f \x01(\x05\x12\x10\n\x08protocol\x18\x10 \x01(\t\x12\x12\n\nstart_time\x18\x11 \x01(\x03\x12\x10\n\x08\x65nd_time\x18\x12 \x01(\x03\x12\x12\n\ncreated_at\x18\x13 \x01(\x03\x12\x13\n\x0brecevied_at\x18\x14 \x01(\x03\x12\x14\n\x0cis_completed\x18\x15 \x01(\x08\x12\x11\n\ttenant_id\x18\x16 \x01(\t\"$\n\x06LssRes\x12\x0c\n\x04\x62ody\x18\x01 \x01(\t\x12\x0c\n\x04\x63ode\x18\x02 \x01(\x05\"s\n\nVersionOut\x12\x12\n\napi_verion\x18\x01 \x01(\t\x12\x0e\n\x06\x62ranch\x18\x02 \x01(\t\x12\x0e\n\x06\x63ommit\x18\x03 \x01(\t\x12\x0c\n\x04\x64\x61te\x18\x04 \x01(\t\x12\x12\n\ngo_version\x18\x05 \x01(\t\x12\x0f\n\x07os_arch\x18\x06 \x01(\t\"\t\n\x07\x45mptyIn\"?\n\x0cTransExpTime\x12\x15\n\rflow_exp_time\x18\x01 \x01(\x05\x12\x18\n\x10subflow_exp_time\x18\x02 \x01(\x05\"a\n\tLssConfig\x12\x0f\n\x07\x66low_id\x18\x01 \x01(\t\x12\x11\n\tflow_name\x18\x02 \x01(\t\x12\x18\n\x10\x65nforce_sequence\x18\x03 \x01(\x08\x12\x16\n\x0enumber_subflow\x18\x04 \x01(\x05\"]\n\x0cLssConfigRes\x12\x1f\n\x04\x64\x61ta\x18\x01 \x03(\x0b\x32\x11.lsslog.LssConfig\x12,\n\x0etrans_exp_time\x18\x02 \x01(\x0b\x32\x14.lsslog.TransExpTime\"\xb9\x01\n\x0bProdDetails\x12\x0b\n\x03sku\x18\x01 \x01(\t\x12\r\n\x05vm_id\x18\x02 \x01(\t\x12\x0e\n\x06stg_id\x18\x03 \x01(\t\x12\x11\n\tnat_gw_id\x18\x04 \x01(\t\x12\x0f\n\x07peer_id\x18\x05 \x01(\t\x12\r\n\x05\x65\x63_id\x18\x06 \x01(\t\x12\x11\n\tsubnet_id\x18\x07 \x01(\t\x12\x13\n\x0b\x65lastic_ipa\x18\x08 \x01(\t\x12\x0e\n\x06nic_id\x18\t \x01(\t\x12\x13\n\x0bworkload_id\x18\n \x01(\t\"x\n\rPurchasedItem\x12\x0f\n\x07zone_id\x18\x01 \x01(\t\x12\x11\n\tregion_id\x18\x02 \x01(\t\x12\x10\n\x08item_cnt\x18\x03 \x01(\t\x12\x0c\n\x04skus\x18\x05 \x03(\t\x12#\n\x06\x64\x65tail\x18\x06 \x01(\x0b\x32\x13.lsslog.ProdDetails\"\xb4\x01\n\x0fProdTransaction\x12\x16\n\x0etransaction_id\x18\x01 \x01(\t\x12\x11\n\ttenant_id\x18\x02 \x01(\t\x12&\n\x07\x64\x65tails\x18\x03 \x03(\x0b\x32\x15.lsslog.PurchasedItem\x12\x11\n\tregion_id\x18\x04 \x01(\t\x12\x0f\n\x07zone_id\x18\x05 \x01(\t\x12\x16\n\x0eprovisioned_at\x18\x06 \x01(\x03\x12\x12\n\ncreated_at\x18\x07 \x01(\x03\"x\n\x07LogVer2\x12\x10\n\x08severity\x18\x01 \x01(\t\x12\x11\n\ttimestamp\x18\x02 \x01(\t\x12\x0b\n\x03\x61pi\x18\x03 \x01(\t\x12\x11\n\tcomponent\x18\x04 \x01(\t\x12(\n\x07message\x18\x05 \x01(\x0b\x32\x17.google.protobuf.Struct\"0\n\x0fLogResponseVer2\x12\n\n\x02id\x18\x01 \x01(\t\x12\x11\n\ttimestamp\x18\x02 \x01(\r**\n\rFlowDirection\x12\x0b\n\x07REQUEST\x10\x00\x12\x0c\n\x08RESPONSE\x10\x01\x32\x98\x03\n\rLssLogService\x12,\n\x08WriteLog\x12\x0e.lsslog.LssLog\x1a\x0e.lsslog.LssRes\"\x00\x12\x33\n\nGetVersion\x12\x0f.lsslog.EmptyIn\x1a\x12.lsslog.VersionOut\"\x00\x12\x33\n\x0cSetLssConfig\x12\x11.lsslog.LssConfig\x1a\x0e.lsslog.LssRes\"\x00\x12\x39\n\x0cGetLssConfig\x12\x11.lsslog.LssConfig\x1a\x14.lsslog.LssConfigRes\"\x00\x12\x36\n\x0fRemoveLssConfig\x12\x11.lsslog.LssConfig\x1a\x0e.lsslog.LssRes\"\x00\x12\x39\n\x0fSetTransExpTime\x12\x14.lsslog.TransExpTime\x1a\x0e.lsslog.LssRes\"\x00\x12\x41\n\x14WriteProdTransaction\x12\x17.lsslog.ProdTransaction\x1a\x0e.lsslog.LssRes\"\x00\x32\x37\n\x02V2\x12\x31\n\x03Log\x12\x0f.lsslog.LogVer2\x1a\x17.lsslog.LogResponseVer2\"\x00\x62\x06proto3"
11
+
12
+ pool = Google::Protobuf::DescriptorPool.generated_pool
13
+ pool.add_serialized_file(descriptor_data)
94
14
 
95
15
  module Lsslog
96
16
  LssLog = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("lsslog.LssLog").msgclass
@@ -103,5 +23,7 @@ module Lsslog
103
23
  ProdDetails = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("lsslog.ProdDetails").msgclass
104
24
  PurchasedItem = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("lsslog.PurchasedItem").msgclass
105
25
  ProdTransaction = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("lsslog.ProdTransaction").msgclass
26
+ LogVer2 = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("lsslog.LogVer2").msgclass
27
+ LogResponseVer2 = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("lsslog.LogResponseVer2").msgclass
106
28
  FlowDirection = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("lsslog.FlowDirection").enummodule
107
29
  end
@@ -8,7 +8,7 @@ module Lsslog
8
8
  module LssLogService
9
9
  class Service
10
10
 
11
- include GRPC::GenericService
11
+ include ::GRPC::GenericService
12
12
 
13
13
  self.marshal_class_method = :encode
14
14
  self.unmarshal_class_method = :decode
@@ -23,6 +23,20 @@ module Lsslog
23
23
  rpc :WriteProdTransaction, ::Lsslog::ProdTransaction, ::Lsslog::LssRes
24
24
  end
25
25
 
26
+ Stub = Service.rpc_stub_class
27
+ end
28
+ module V2
29
+ class Service
30
+
31
+ include ::GRPC::GenericService
32
+
33
+ self.marshal_class_method = :encode
34
+ self.unmarshal_class_method = :decode
35
+ self.service_name = 'lsslog.V2'
36
+
37
+ rpc :Log, ::Lsslog::LogVer2, ::Lsslog::LogResponseVer2
38
+ end
39
+
26
40
  Stub = Service.rpc_stub_class
27
41
  end
28
42
  end
data/lsslog-0.1.6.gem ADDED
Binary file
data/lsslog-0.1.7.gem ADDED
Binary file
data/lsslog.gemspec CHANGED
@@ -1,9 +1,7 @@
1
-
2
1
  lib = File.expand_path("../lib", __FILE__)
3
2
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
3
  require "lsslog/version"
5
4
 
6
-
7
5
  Gem::Specification.new do |spec|
8
6
  spec.name = "lsslog"
9
7
  spec.version = Lsslog::VERSION
@@ -26,7 +24,7 @@ Gem::Specification.new do |spec|
26
24
  # Specify which files should be added to the gem when it is released.
27
25
  # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
28
26
  spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
29
- `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
27
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) || f == "lsslog-#{Lsslog::VERSION}.gem" }
30
28
  end
31
29
  spec.bindir = "exe"
32
30
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
data/proto/lsslog.proto CHANGED
@@ -1,5 +1,6 @@
1
1
  syntax = "proto3";
2
2
  package lsslog;
3
+ import "google/protobuf/struct.proto";
3
4
 
4
5
  enum FlowDirection {
5
6
  REQUEST = 0;
@@ -104,3 +105,20 @@ service LssLogService {
104
105
  rpc SetTransExpTime(TransExpTime) returns (LssRes) {};
105
106
  rpc WriteProdTransaction(ProdTransaction) returns (LssRes) {};
106
107
  }
108
+
109
+ message LogVer2 {
110
+ string severity = 1;
111
+ string timestamp = 2;
112
+ string api = 3;
113
+ string component = 4;
114
+ google.protobuf.Struct message = 5;
115
+ }
116
+
117
+ message LogResponseVer2 {
118
+ string id = 1;
119
+ uint32 timestamp = 2;
120
+ }
121
+
122
+ service V2 {
123
+ rpc Log(LogVer2) returns (LogResponseVer2) {};
124
+ }
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lsslog
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.6
4
+ version: 0.1.7.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Thanh Ngo
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-04-25 00:00:00.000000000 Z
11
+ date: 2024-07-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: google-protobuf
@@ -101,8 +101,10 @@ files:
101
101
  - lib/lsslog/services/remove_lss_config.rb
102
102
  - lib/lsslog/services/set_lss_config.rb
103
103
  - lib/lsslog/services/set_trans_exp_time.rb
104
+ - lib/lsslog/services/v2.rb
104
105
  - lib/lsslog/services/write_log.rb
105
106
  - lib/lsslog/services/write_prod_transaction.rb
107
+ - lib/lsslog/v2/log.rb
106
108
  - lib/lsslog/version.rb
107
109
  - lib/lsslog_pb.rb
108
110
  - lib/lsslog_services_pb.rb
@@ -111,6 +113,8 @@ files:
111
113
  - lsslog-0.1.3.gem
112
114
  - lsslog-0.1.3.pre.rc1.gem
113
115
  - lsslog-0.1.5.gem
116
+ - lsslog-0.1.6.gem
117
+ - lsslog-0.1.7.gem
114
118
  - lsslog.gemspec
115
119
  - proto/README.md
116
120
  - proto/lsslog.proto