anmol_cortex_client_ruby 0.1.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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 8072fc60b05b8c37147c03226ab75120259e0a5471bc353d8a31881f6e19c7ed
4
+ data.tar.gz: eacf39d70c6d749c27cbc411147e3b796b872f17ea29f3cdf0b7dd58ddaf06b3
5
+ SHA512:
6
+ metadata.gz: df8a6d77c6a67a540ab5892c2d1c4935afaac16c92c46df79e5cd7cc2da68230b3f5659fe3028f2f4ab06b3b90b5cb8913cb47ec761bd67b026ac09a59ed40e4
7
+ data.tar.gz: c6b8cd4947a2b2e6182ec5f33f1ab9934697e84bef5e0b24839bd91822386071ea8899d4145fd2ae1401c56ff6d7ab8a96ac48d2950332a0e5050546f823190f
@@ -0,0 +1,54 @@
1
+
2
+ name: push-cortex-client
3
+ on: [push]
4
+ jobs:
5
+ test:
6
+ runs-on: ubuntu-latest
7
+
8
+ steps:
9
+ - uses: actions/checkout@v2
10
+ # - name: Setup Ruby
11
+ # uses: ruby/setup-ruby@v1.64.1
12
+ # with:
13
+ # ruby-version: 2.5.0
14
+ #
15
+ # - name: Install Dependencies
16
+ # run: gem install bundler -v 2.0.2
17
+ #
18
+ # - name: Install Gems
19
+ # run: bundle install
20
+ #
21
+ # - name: Run Tests
22
+ # run: rspec
23
+ #
24
+ # - name: Lint check
25
+ # run: rubocop
26
+
27
+ - name: Release Gem
28
+ #if: contains(github.ref, 'refs/tags/v')
29
+ uses: cadwallion/publish-rubygems-action@master
30
+ env:
31
+ GITHUB_TOKEN: ${{secrets.GH_TOKEN}}
32
+ RUBYGEMS_API_KEY: ${{secrets.RUBYGEMS_API_KEY}}
33
+ RELEASE_COMMAND: sh push-gem.sh
34
+
35
+
36
+
37
+
38
+
39
+ # release:
40
+ # runs-on: ubuntu-latest
41
+ # needs: test
42
+ #
43
+ # steps:
44
+ # - uses: actions/checkout@v2
45
+ # - name: Release Gem
46
+ # #if: contains(github.ref, 'refs/tags/v')
47
+ # uses: cadwallion/publish-rubygems-action@master
48
+ # env:
49
+ # GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
50
+ # RUBYGEMS_API_KEY: ${{secrets.RUBYGEMS_API_KEY}}
51
+ # RELEASE_COMMAND: rake release
52
+
53
+
54
+
data/.gitignore ADDED
@@ -0,0 +1,22 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
9
+ *.gem
10
+ /.idea
11
+ *.swp
12
+ .history/*
13
+ .gitlab-ci.yml.bck
14
+
15
+ # rspec failure tracking
16
+ .rspec_status
17
+
18
+ # VSCode settings
19
+ settings.json
20
+
21
+ # ctags
22
+ tags
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
data/.rubocop.yml ADDED
@@ -0,0 +1,3 @@
1
+ inherit_from:
2
+ - .rubocop_airbnb.yml
3
+ - .rubocop_cortex.yml
@@ -0,0 +1,2 @@
1
+ require:
2
+ - rubocop-airbnb
@@ -0,0 +1,22 @@
1
+ Metrics/LineLength:
2
+ Max: 500
3
+
4
+ Style/RedundantSelf:
5
+ Enabled: false
6
+
7
+ Style/AndOr:
8
+ Enabled: false
9
+
10
+ Style/RaiseArgs:
11
+ Enabled: false
12
+
13
+ Airbnb/ModuleMethodInWrongFile:
14
+ Enabled: false
15
+
16
+ Airbnb/OptArgParameters:
17
+ Enabled: false
18
+
19
+ AllCops:
20
+ Exclude:
21
+ - 'bin/**/*'
22
+ - './lib/proto/*'
data/.ruby-version ADDED
@@ -0,0 +1 @@
1
+ 2.5.0
data/CHANGELOG.md ADDED
@@ -0,0 +1,9 @@
1
+ # Release
2
+
3
+ ### v0.1.0 14th May 2020
4
+ #### Added
5
+ - functionality to push metrics to cortex
6
+
7
+ ### v0.1.1 14th May 2020
8
+ #### Changed
9
+ - Use a different gem for snappy based compressed
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source 'https://rubygems.org'
2
+ # Specify your gem's dependencies in cortex_client-client-ruby.gemspec
3
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,92 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ anmol_cortex_client_ruby (0.1.0)
5
+ google-protobuf (= 3.11.4)
6
+ http (~> 4.1)
7
+ snappy_ext (= 0.1.2)
8
+
9
+ GEM
10
+ remote: https://rubygems.org/
11
+ specs:
12
+ addressable (2.7.0)
13
+ public_suffix (>= 2.0.2, < 5.0)
14
+ ast (2.4.0)
15
+ crack (0.4.3)
16
+ safe_yaml (~> 1.0.0)
17
+ diff-lcs (1.3)
18
+ domain_name (0.5.20190701)
19
+ unf (>= 0.0.5, < 1.0.0)
20
+ ffi (1.14.2)
21
+ ffi-compiler (1.0.1)
22
+ ffi (>= 1.0.0)
23
+ rake
24
+ google-protobuf (3.11.4)
25
+ hashdiff (1.0.1)
26
+ http (4.4.1)
27
+ addressable (~> 2.3)
28
+ http-cookie (~> 1.0)
29
+ http-form_data (~> 2.2)
30
+ http-parser (~> 1.2.0)
31
+ http-cookie (1.0.3)
32
+ domain_name (~> 0.5)
33
+ http-form_data (2.3.0)
34
+ http-parser (1.2.3)
35
+ ffi-compiler (>= 1.0, < 2.0)
36
+ parallel (1.19.1)
37
+ parser (2.7.1.2)
38
+ ast (~> 2.4.0)
39
+ powerpack (0.1.2)
40
+ public_suffix (4.0.4)
41
+ rainbow (3.0.0)
42
+ rake (10.5.0)
43
+ rspec (3.9.0)
44
+ rspec-core (~> 3.9.0)
45
+ rspec-expectations (~> 3.9.0)
46
+ rspec-mocks (~> 3.9.0)
47
+ rspec-core (3.9.2)
48
+ rspec-support (~> 3.9.3)
49
+ rspec-expectations (3.9.2)
50
+ diff-lcs (>= 1.2.0, < 2.0)
51
+ rspec-support (~> 3.9.0)
52
+ rspec-mocks (3.9.1)
53
+ diff-lcs (>= 1.2.0, < 2.0)
54
+ rspec-support (~> 3.9.0)
55
+ rspec-support (3.9.3)
56
+ rubocop (0.52.1)
57
+ parallel (~> 1.10)
58
+ parser (>= 2.4.0.2, < 3.0)
59
+ powerpack (~> 0.1)
60
+ rainbow (>= 2.2.2, < 4.0)
61
+ ruby-progressbar (~> 1.7)
62
+ unicode-display_width (~> 1.0, >= 1.0.1)
63
+ rubocop-airbnb (1.0.0)
64
+ rubocop (= 0.52.1)
65
+ rubocop-rspec (= 1.22.1)
66
+ rubocop-rspec (1.22.1)
67
+ rubocop (>= 0.52.1)
68
+ ruby-progressbar (1.10.1)
69
+ safe_yaml (1.0.5)
70
+ snappy_ext (0.1.2)
71
+ unf (0.1.4)
72
+ unf_ext
73
+ unf_ext (0.0.7.7)
74
+ unicode-display_width (1.7.0)
75
+ webmock (3.8.3)
76
+ addressable (>= 2.3.6)
77
+ crack (>= 0.3.2)
78
+ hashdiff (>= 0.4.0, < 2.0.0)
79
+
80
+ PLATFORMS
81
+ ruby
82
+
83
+ DEPENDENCIES
84
+ anmol_cortex_client_ruby!
85
+ bundler (~> 2.0)
86
+ rake (~> 10.0)
87
+ rspec (~> 3.0)
88
+ rubocop-airbnb (= 1.0.0)
89
+ webmock (~> 3)
90
+
91
+ BUNDLED WITH
92
+ 2.0.2
data/README.md ADDED
@@ -0,0 +1,31 @@
1
+ # Cortex Client
2
+
3
+ ## About
4
+ It is a ruby library to push timeseries metrics to cortex.
5
+
6
+ ## Prerequisites
7
+ ruby - 2.5.0
8
+
9
+ ## Usage
10
+ #### Step1: Configure the client
11
+
12
+ ```
13
+ CortexClient.configure do |config|
14
+ config.host = 'https://lens.golabs.io'
15
+ config.metrics_push_api_path = 'v1/prom/metrics'
16
+ config.token = "sample_token"
17
+ end
18
+ ```
19
+ #### Step2: Push a timeseries based metric
20
+
21
+ To push synchronously
22
+
23
+ ```
24
+ metric = CortexClient::Metric.new('test_usage')
25
+ response = metric.
26
+ add_label(name: "team_name", value: "kernel_ux").
27
+ add_label(name: "email", value: "name@go-jek.com").add_sample(value: 1).push
28
+
29
+ The metric instance has the error appended if there's any and if there's no error, then the instance
30
+ has a prom_message in it.
31
+ ```
data/Rakefile ADDED
@@ -0,0 +1,6 @@
1
+ require 'bundler/gem_tasks'
2
+ require 'rspec/core/rake_task'
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task default: :spec
data/bin/console ADDED
@@ -0,0 +1,13 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'bundler/setup'
4
+ require 'cortex_client'
5
+ # You can add fixtures and/or initialization code here to make experimenting
6
+ # with your gem easier. You can also use a different console, if you like.
7
+
8
+ # (If you use this, don't forget to add pry to your Gemfile!)
9
+ # require "pry"
10
+ # Pry.start
11
+
12
+ require 'irb'
13
+ IRB.start(__FILE__)
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,33 @@
1
+ lib = File.expand_path('lib', __dir__)
2
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
+ require 'cortex_client/version'
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = 'anmol_cortex_client_ruby'
7
+ spec.version = CortexClient::VERSION
8
+ spec.authors = ['Kernel Plus']
9
+ spec.email = ['kernel-user-experience@go-jek.com']
10
+
11
+ spec.summary = 'Client to push resource to cortex'
12
+ spec.description = ''
13
+ spec.homepage = 'https://kernel.gojek.dev'
14
+ spec.license = 'MIT'
15
+
16
+ # Specify which files should be added to the gem when it is released.
17
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
18
+ spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
19
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
20
+ end
21
+ spec.bindir = 'exe'
22
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
23
+ spec.require_paths = ['lib']
24
+
25
+ spec.add_development_dependency 'bundler', '~> 2.0'
26
+ spec.add_development_dependency 'rake', '~> 10.0'
27
+ spec.add_development_dependency 'rspec', '~> 3.0'
28
+ spec.add_development_dependency 'rubocop-airbnb', '1.0.0'
29
+ spec.add_runtime_dependency 'google-protobuf', '3.11.4'
30
+ spec.add_development_dependency 'webmock', '~> 3'
31
+ spec.add_runtime_dependency 'snappy_ext', '0.1.2'
32
+ spec.add_runtime_dependency 'http', '~> 4.1'
33
+ end
@@ -0,0 +1,15 @@
1
+ require 'snappy_ext'
2
+ require 'http'
3
+
4
+ module CortexClient
5
+ end
6
+
7
+ require 'cortex_client/configuration'
8
+ require 'cortex_client/exception'
9
+ require 'cortex_client/http/agent'
10
+ require 'cortex_client/http/request'
11
+ require 'cortex_client/http/response'
12
+ require 'cortex_client/metric/metric'
13
+ require 'cortex_client/version'
14
+ require 'proto/remote_pb'
15
+ require 'proto/types_pb'
@@ -0,0 +1,41 @@
1
+ module CortexClient
2
+ class Configuration
3
+ attr_accessor :token, :host, :metrics_push_api_path
4
+ attr_reader :read_timeout, :connect_timeout, :write_timeout, :agents
5
+
6
+ def initialize
7
+ @host = ''
8
+ @token = ''
9
+ @metrics_push_api_path = ''
10
+ @read_timeout = 75
11
+ @connect_timeout = 10
12
+ @write_timeout = 75
13
+ @agents = [Http::Agent.new(name: CortexClient.name, version: CortexClient::VERSION)]
14
+ end
15
+
16
+ def valid?
17
+ !@token.empty? &&
18
+ !@host.empty? &&
19
+ !@host.end_with?('/') &&
20
+ !@metrics_push_api_path.empty? &&
21
+ !@metrics_push_api_path.start_with?('/')
22
+ end
23
+
24
+ def agent=(agent_attributes)
25
+ @agents.push(Http::Agent.new(agent_attributes))
26
+ end
27
+
28
+ def agent
29
+ Http::Agent.list_to_s(@agents)
30
+ end
31
+ end
32
+
33
+ def self.configuration
34
+ @configuration ||= Configuration.new
35
+ end
36
+
37
+ def self.configure
38
+ yield(configuration)
39
+ raise Exception::Configuration unless configuration.valid?
40
+ end
41
+ end
@@ -0,0 +1,18 @@
1
+ module CortexClient
2
+ module Exception
3
+ class Configuration < StandardError
4
+ end
5
+
6
+ class ConnectionRefused < StandardError
7
+ end
8
+
9
+ class ConnectionError < StandardError
10
+ end
11
+
12
+ class Timeout < StandardError
13
+ end
14
+
15
+ class NetworkError < StandardError
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,20 @@
1
+ module CortexClient
2
+ module Http
3
+ class Agent
4
+ attr_reader :name, :version
5
+
6
+ def initialize(name:, version:)
7
+ @name = name
8
+ @version = version
9
+ end
10
+
11
+ def self.list_to_s(agents)
12
+ agents.collect(&:to_s).join(" ")
13
+ end
14
+
15
+ def to_s
16
+ "#{name}/#{version}".freeze
17
+ end
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,51 @@
1
+ module CortexClient
2
+ module Http
3
+ class Request
4
+ def initialize
5
+ @config = CortexClient.configuration
6
+ @host = @config.host
7
+ @client = http
8
+ end
9
+
10
+ def post(path, body)
11
+ wrap_failure do
12
+ Response.new(@client.post(uri(@host, path), :body => body))
13
+ end
14
+ end
15
+
16
+ private
17
+
18
+ def uri(base_uri, path)
19
+ File.join(base_uri, path)
20
+ end
21
+
22
+ def wrap_failure(&block)
23
+ yield(block)
24
+ rescue Errno::ECONNREFUSED => e
25
+ raise Exception::ConnectionRefused.new(e.message)
26
+ rescue HTTP::ConnectionError => e
27
+ raise Exception::ConnectionError.new(e.message)
28
+ rescue HTTP::TimeoutError => e
29
+ raise Exception::Timeout.new(e.message)
30
+ end
31
+
32
+ def headers
33
+ {
34
+ 'Content-Encoding' => 'snappy',
35
+ 'Content-Type' => 'application/x-protobuf',
36
+ 'X-Prometheus-Remote-Write-Version' => '0.1.0',
37
+ 'Authorization' => "Bearer #{@config.token}",
38
+ 'User-Agent' => @config.agent,
39
+ }
40
+ end
41
+
42
+ def http
43
+ HTTP.timeout(
44
+ connect: @config.connect_timeout,
45
+ read: @config.read_timeout,
46
+ write: @config.write_timeout
47
+ ).headers(headers)
48
+ end
49
+ end
50
+ end
51
+ end
@@ -0,0 +1,62 @@
1
+ module CortexClient
2
+ module Http
3
+ class Response
4
+ attr_reader :body, :response_code
5
+
6
+ def initialize(http_response)
7
+ @response_code = http_response.code
8
+ @body = http_response.body
9
+ @http_response = http_response
10
+ end
11
+
12
+ def ok?
13
+ @response_code == 200
14
+ end
15
+
16
+ def created?
17
+ @response_code == 201
18
+ end
19
+
20
+ def accepted?
21
+ @response_code == 202
22
+ end
23
+
24
+ def bad_request?
25
+ @response_code == 400
26
+ end
27
+
28
+ def forbidden?
29
+ @response_code == 403
30
+ end
31
+
32
+ def unauthorized?
33
+ @response_code == 401
34
+ end
35
+
36
+ def not_found?
37
+ @response_code == 404
38
+ end
39
+
40
+ def unprocessable_entity?
41
+ @response_code == 422
42
+ end
43
+
44
+ def successful?
45
+ successful_codes = [200, 201, 202]
46
+ successful_codes.include?(@response_code)
47
+ end
48
+
49
+ def server_error?
50
+ server_error_codes = [500, 502, 503, 504]
51
+
52
+ server_error_codes.include?(@response_code)
53
+ end
54
+
55
+ def network_error?
56
+ server_error_codes = [502, 503, 504]
57
+
58
+ server_error_codes.include?(@response_code)
59
+ end
60
+ end
61
+ end
62
+ end
@@ -0,0 +1,57 @@
1
+ module CortexClient
2
+ class Metric
3
+ attr_reader :labels, :samples, :prom_message, :error, :custom_error_message
4
+ def initialize(metric_name)
5
+ @config = CortexClient.configuration
6
+ @labels = []
7
+ @samples = []
8
+ @error = nil
9
+ @prom_message = nil
10
+ # a label with __name__ is required by cortex
11
+ # to identify the metric name
12
+ add_label(name: '__name__', value: metric_name)
13
+ end
14
+
15
+ def add_label(name:, value:)
16
+ label = Prometheus::Label.new(name: name, value: value)
17
+ @labels.push(label)
18
+ self
19
+ end
20
+
21
+ def add_sample(value: 1)
22
+ time = (Time.now.to_f * 1000).to_i
23
+ sample = Prometheus::Sample.new(timestamp: time, value: value)
24
+ @samples.push(sample)
25
+ self
26
+ end
27
+
28
+ def push
29
+ if @labels.size <= 1 || @samples.size == 0
30
+ @error = 'Use add_label and add_sample at-least once'
31
+ return
32
+ end
33
+
34
+ timeseries = Prometheus::TimeSeries.new(labels: @labels, samples: @samples)
35
+ writerequest = Prometheus::WriteRequest.new(timeseries: [].push(timeseries))
36
+ compressed_data = Snappy.compress(Prometheus::WriteRequest.encode(writerequest))
37
+ response = CortexClient::Http::Request.new.post(@config.metrics_push_api_path, compressed_data)
38
+ if response.ok?
39
+ @prom_message = response.body.to_s
40
+ @error = nil
41
+ else
42
+ @prom_message = nil
43
+ @error = response_formatter(response: response, custom_message: 'Metric couldn\'t be posted')
44
+ end
45
+ end
46
+
47
+ private
48
+
49
+ def response_formatter(response:, custom_message:)
50
+ if response.body.empty?
51
+ custom_message
52
+ else
53
+ response.body.to_s
54
+ end
55
+ end
56
+ end
57
+ end
@@ -0,0 +1,3 @@
1
+ module CortexClient
2
+ VERSION = '0.1.0'.freeze
3
+ end
@@ -0,0 +1,47 @@
1
+ # Generated by the protocol buffer compiler. DO NOT EDIT!
2
+ # source: remote.proto
3
+
4
+ require 'google/protobuf'
5
+ require_relative 'types_pb'
6
+
7
+ Google::Protobuf::DescriptorPool.generated_pool.build do
8
+ add_file("remote.proto", :syntax => :proto3) do
9
+ add_message "prometheus.WriteRequest" do
10
+ repeated :timeseries, :message, 1, "prometheus.TimeSeries"
11
+ end
12
+ add_message "prometheus.ReadRequest" do
13
+ repeated :queries, :message, 1, "prometheus.Query"
14
+ repeated :accepted_response_types, :enum, 2, "prometheus.ReadRequest.ResponseType"
15
+ end
16
+ add_enum "prometheus.ReadRequest.ResponseType" do
17
+ value :SAMPLES, 0
18
+ value :STREAMED_XOR_CHUNKS, 1
19
+ end
20
+ add_message "prometheus.ReadResponse" do
21
+ repeated :results, :message, 1, "prometheus.QueryResult"
22
+ end
23
+ add_message "prometheus.Query" do
24
+ optional :start_timestamp_ms, :int64, 1
25
+ optional :end_timestamp_ms, :int64, 2
26
+ repeated :matchers, :message, 3, "prometheus.LabelMatcher"
27
+ optional :hints, :message, 4, "prometheus.ReadHints"
28
+ end
29
+ add_message "prometheus.QueryResult" do
30
+ repeated :timeseries, :message, 1, "prometheus.TimeSeries"
31
+ end
32
+ add_message "prometheus.ChunkedReadResponse" do
33
+ repeated :chunked_series, :message, 1, "prometheus.ChunkedSeries"
34
+ optional :query_index, :int64, 2
35
+ end
36
+ end
37
+ end
38
+
39
+ module Prometheus
40
+ WriteRequest = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("prometheus.WriteRequest").msgclass
41
+ ReadRequest = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("prometheus.ReadRequest").msgclass
42
+ ReadRequest::ResponseType = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("prometheus.ReadRequest.ResponseType").enummodule
43
+ ReadResponse = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("prometheus.ReadResponse").msgclass
44
+ Query = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("prometheus.Query").msgclass
45
+ QueryResult = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("prometheus.QueryResult").msgclass
46
+ ChunkedReadResponse = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("prometheus.ChunkedReadResponse").msgclass
47
+ end
@@ -0,0 +1,71 @@
1
+ # Generated by the protocol buffer compiler. DO NOT EDIT!
2
+ # source: types.proto
3
+
4
+ require 'google/protobuf'
5
+
6
+ Google::Protobuf::DescriptorPool.generated_pool.build do
7
+ add_file("types.proto", :syntax => :proto3) do
8
+ add_message "prometheus.Sample" do
9
+ optional :value, :double, 1
10
+ optional :timestamp, :int64, 2
11
+ end
12
+ add_message "prometheus.TimeSeries" do
13
+ repeated :labels, :message, 1, "prometheus.Label"
14
+ repeated :samples, :message, 2, "prometheus.Sample"
15
+ end
16
+ add_message "prometheus.Label" do
17
+ optional :name, :string, 1
18
+ optional :value, :string, 2
19
+ end
20
+ add_message "prometheus.Labels" do
21
+ repeated :labels, :message, 1, "prometheus.Label"
22
+ end
23
+ add_message "prometheus.LabelMatcher" do
24
+ optional :type, :enum, 1, "prometheus.LabelMatcher.Type"
25
+ optional :name, :string, 2
26
+ optional :value, :string, 3
27
+ end
28
+ add_enum "prometheus.LabelMatcher.Type" do
29
+ value :EQ, 0
30
+ value :NEQ, 1
31
+ value :RE, 2
32
+ value :NRE, 3
33
+ end
34
+ add_message "prometheus.ReadHints" do
35
+ optional :step_ms, :int64, 1
36
+ optional :func, :string, 2
37
+ optional :start_ms, :int64, 3
38
+ optional :end_ms, :int64, 4
39
+ repeated :grouping, :string, 5
40
+ optional :by, :bool, 6
41
+ optional :range_ms, :int64, 7
42
+ end
43
+ add_message "prometheus.Chunk" do
44
+ optional :min_time_ms, :int64, 1
45
+ optional :max_time_ms, :int64, 2
46
+ optional :type, :enum, 3, "prometheus.Chunk.Encoding"
47
+ optional :data, :bytes, 4
48
+ end
49
+ add_enum "prometheus.Chunk.Encoding" do
50
+ value :UNKNOWN, 0
51
+ value :XOR, 1
52
+ end
53
+ add_message "prometheus.ChunkedSeries" do
54
+ repeated :labels, :message, 1, "prometheus.Label"
55
+ repeated :chunks, :message, 2, "prometheus.Chunk"
56
+ end
57
+ end
58
+ end
59
+
60
+ module Prometheus
61
+ Sample = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("prometheus.Sample").msgclass
62
+ TimeSeries = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("prometheus.TimeSeries").msgclass
63
+ Label = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("prometheus.Label").msgclass
64
+ Labels = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("prometheus.Labels").msgclass
65
+ LabelMatcher = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("prometheus.LabelMatcher").msgclass
66
+ LabelMatcher::Type = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("prometheus.LabelMatcher.Type").enummodule
67
+ ReadHints = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("prometheus.ReadHints").msgclass
68
+ Chunk = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("prometheus.Chunk").msgclass
69
+ Chunk::Encoding = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("prometheus.Chunk.Encoding").enummodule
70
+ ChunkedSeries = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("prometheus.ChunkedSeries").msgclass
71
+ end
data/push-gem.sh ADDED
@@ -0,0 +1,10 @@
1
+ #!/bin/bash
2
+
3
+ gem install bundler -v 2.0.2
4
+ bundle install
5
+ bundle exec rake install
6
+ pwd
7
+ ls
8
+ ls ./pkg/
9
+ GEM_NAME=$(ls ./pkg/*.gem)
10
+ gem push ${GEM_NAME}
metadata ADDED
@@ -0,0 +1,181 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: anmol_cortex_client_ruby
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Kernel Plus
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2021-02-12 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '2.0'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '2.0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '3.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '3.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rubocop-airbnb
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - '='
60
+ - !ruby/object:Gem::Version
61
+ version: 1.0.0
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - '='
67
+ - !ruby/object:Gem::Version
68
+ version: 1.0.0
69
+ - !ruby/object:Gem::Dependency
70
+ name: google-protobuf
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - '='
74
+ - !ruby/object:Gem::Version
75
+ version: 3.11.4
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - '='
81
+ - !ruby/object:Gem::Version
82
+ version: 3.11.4
83
+ - !ruby/object:Gem::Dependency
84
+ name: webmock
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: '3'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: '3'
97
+ - !ruby/object:Gem::Dependency
98
+ name: snappy_ext
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - '='
102
+ - !ruby/object:Gem::Version
103
+ version: 0.1.2
104
+ type: :runtime
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - '='
109
+ - !ruby/object:Gem::Version
110
+ version: 0.1.2
111
+ - !ruby/object:Gem::Dependency
112
+ name: http
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - "~>"
116
+ - !ruby/object:Gem::Version
117
+ version: '4.1'
118
+ type: :runtime
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - "~>"
123
+ - !ruby/object:Gem::Version
124
+ version: '4.1'
125
+ description: ''
126
+ email:
127
+ - kernel-user-experience@go-jek.com
128
+ executables: []
129
+ extensions: []
130
+ extra_rdoc_files: []
131
+ files:
132
+ - ".github/workflows/build-push.yml"
133
+ - ".gitignore"
134
+ - ".rspec"
135
+ - ".rubocop.yml"
136
+ - ".rubocop_airbnb.yml"
137
+ - ".rubocop_cortex.yml"
138
+ - ".ruby-version"
139
+ - CHANGELOG.md
140
+ - Gemfile
141
+ - Gemfile.lock
142
+ - README.md
143
+ - Rakefile
144
+ - bin/console
145
+ - bin/setup
146
+ - cortex_client.gemspec
147
+ - lib/cortex_client.rb
148
+ - lib/cortex_client/configuration.rb
149
+ - lib/cortex_client/exception.rb
150
+ - lib/cortex_client/http/agent.rb
151
+ - lib/cortex_client/http/request.rb
152
+ - lib/cortex_client/http/response.rb
153
+ - lib/cortex_client/metric/metric.rb
154
+ - lib/cortex_client/version.rb
155
+ - lib/proto/remote_pb.rb
156
+ - lib/proto/types_pb.rb
157
+ - push-gem.sh
158
+ homepage: https://kernel.gojek.dev
159
+ licenses:
160
+ - MIT
161
+ metadata: {}
162
+ post_install_message:
163
+ rdoc_options: []
164
+ require_paths:
165
+ - lib
166
+ required_ruby_version: !ruby/object:Gem::Requirement
167
+ requirements:
168
+ - - ">="
169
+ - !ruby/object:Gem::Version
170
+ version: '0'
171
+ required_rubygems_version: !ruby/object:Gem::Requirement
172
+ requirements:
173
+ - - ">="
174
+ - !ruby/object:Gem::Version
175
+ version: '0'
176
+ requirements: []
177
+ rubygems_version: 3.0.3
178
+ signing_key:
179
+ specification_version: 4
180
+ summary: Client to push resource to cortex
181
+ test_files: []