anmol_2_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: e8805db665aa0d6ccdf03809018140356e4371a2fdb5dbdb42b5565081a61212
4
+ data.tar.gz: d4c6468093c0457336f829c466fd690a252c5c16a255455443defb8236514e6a
5
+ SHA512:
6
+ metadata.gz: 7a4ead8846165b51437fb9a500ec9c3c6569bbafca814e78e7084aeb445c7947228d3969c4dd805cc0da9f933b44895143faa398eead1a8f2bc66e25a0d51f05
7
+ data.tar.gz: 299c076f49fded0d5363e374d456e13b25dd77bbd25d8f0f8fabf0a7a7fe46a7f79fffced8ea04abcdad7ff7a1107138cf33d3a8ec95df0b899a34c8caf884b7
@@ -0,0 +1,38 @@
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
+ release:
28
+ runs-on: ubuntu-latest
29
+ needs: test
30
+ steps:
31
+ - uses: actions/checkout@v2
32
+ - name: Release Gem
33
+ if: contains(github.ref, 'refs/tags/v')
34
+ uses: cadwallion/publish-rubygems-action@master
35
+ env:
36
+ GITHUB_TOKEN: ${{secrets.GH_TOKEN}}
37
+ RUBYGEMS_API_KEY: ${{secrets.RUBYGEMS_API_KEY}}
38
+ RELEASE_COMMAND: sh push-gem.sh
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/CONTRIBUTORS.md ADDED
@@ -0,0 +1,4 @@
1
+ ## Contributors
2
+
3
+ * Anmol Vijaywargiya [anmol1vw13](http://github.com/anmol1vw13)
4
+ * Bhumika Goyal [bhumika.goyal](http://github.com/bhumika.goyal)
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_2_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_2_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,30 @@
1
+ # Cortex Client
2
+ [![Build Status] (https://github.com/anmol1vw13/cortex-client-ruby/workflows/Push%20Cortex%20Client/badge.svg?branch=master)]
3
+
4
+ ## About
5
+ It is a ruby library to push timeseries metrics to cortex.
6
+
7
+ ## Prerequisites
8
+ ruby - 2.5.0
9
+
10
+ ## Usage
11
+ #### Step1: Configure the client
12
+
13
+ ```
14
+ CortexClient.configure do |config|
15
+ config.host = '<host>'
16
+ config.metrics_push_api_path = '<metrics-api>'
17
+ config.token = "sample_token"
18
+ end
19
+ ```
20
+ #### Step2: Push a timeseries based metric
21
+
22
+ ```
23
+ metric = CortexClient::Metric.new('test_usage')
24
+ response = metric.
25
+ add_label(name: "label1", value: "value1").
26
+ add_label(name: "label2", value: "value2").add_sample(value: 1).push
27
+
28
+ The metric instance has the error appended if there's any and if there's no error, then the instance
29
+ has a prom_message in it.
30
+ ```
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,32 @@
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_2_cortex_client_ruby'
7
+ spec.version = CortexClient::VERSION
8
+ spec.authors = ['Anmol Vijaywargiya', 'Bhumika Goyal']
9
+ spec.email = ['anmol.vijaywargiya@gojek.com', 'bhumika.goyal@gojek.com']
10
+
11
+ spec.summary = 'Client to push resource to cortex'
12
+ spec.description = ''
13
+ spec.license = 'MIT'
14
+
15
+ # Specify which files should be added to the gem when it is released.
16
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
17
+ spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
18
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
19
+ end
20
+ spec.bindir = 'exe'
21
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
22
+ spec.require_paths = ['lib']
23
+
24
+ spec.add_development_dependency 'bundler', '~> 2.0'
25
+ spec.add_development_dependency 'rake', '~> 10.0'
26
+ spec.add_development_dependency 'rspec', '~> 3.0'
27
+ spec.add_development_dependency 'rubocop-airbnb', '1.0.0'
28
+ spec.add_runtime_dependency 'google-protobuf', '3.11.4'
29
+ spec.add_development_dependency 'webmock', '~> 3'
30
+ spec.add_runtime_dependency 'snappy_ext', '0.1.2'
31
+ spec.add_runtime_dependency 'http', '~> 4.1'
32
+ 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,7 @@
1
+ #!/bin/bash
2
+
3
+ gem install bundler -v 2.0.2
4
+ bundle install
5
+ bundle exec rake install
6
+ GEM_NAME=$(ls ./pkg/*.gem)
7
+ gem push ${GEM_NAME}
metadata ADDED
@@ -0,0 +1,184 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: anmol_2_cortex_client_ruby
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Anmol Vijaywargiya
8
+ - Bhumika Goyal
9
+ autorequire:
10
+ bindir: exe
11
+ cert_chain: []
12
+ date: 2021-02-19 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: bundler
16
+ requirement: !ruby/object:Gem::Requirement
17
+ requirements:
18
+ - - "~>"
19
+ - !ruby/object:Gem::Version
20
+ version: '2.0'
21
+ type: :development
22
+ prerelease: false
23
+ version_requirements: !ruby/object:Gem::Requirement
24
+ requirements:
25
+ - - "~>"
26
+ - !ruby/object:Gem::Version
27
+ version: '2.0'
28
+ - !ruby/object:Gem::Dependency
29
+ name: rake
30
+ requirement: !ruby/object:Gem::Requirement
31
+ requirements:
32
+ - - "~>"
33
+ - !ruby/object:Gem::Version
34
+ version: '10.0'
35
+ type: :development
36
+ prerelease: false
37
+ version_requirements: !ruby/object:Gem::Requirement
38
+ requirements:
39
+ - - "~>"
40
+ - !ruby/object:Gem::Version
41
+ version: '10.0'
42
+ - !ruby/object:Gem::Dependency
43
+ name: rspec
44
+ requirement: !ruby/object:Gem::Requirement
45
+ requirements:
46
+ - - "~>"
47
+ - !ruby/object:Gem::Version
48
+ version: '3.0'
49
+ type: :development
50
+ prerelease: false
51
+ version_requirements: !ruby/object:Gem::Requirement
52
+ requirements:
53
+ - - "~>"
54
+ - !ruby/object:Gem::Version
55
+ version: '3.0'
56
+ - !ruby/object:Gem::Dependency
57
+ name: rubocop-airbnb
58
+ requirement: !ruby/object:Gem::Requirement
59
+ requirements:
60
+ - - '='
61
+ - !ruby/object:Gem::Version
62
+ version: 1.0.0
63
+ type: :development
64
+ prerelease: false
65
+ version_requirements: !ruby/object:Gem::Requirement
66
+ requirements:
67
+ - - '='
68
+ - !ruby/object:Gem::Version
69
+ version: 1.0.0
70
+ - !ruby/object:Gem::Dependency
71
+ name: google-protobuf
72
+ requirement: !ruby/object:Gem::Requirement
73
+ requirements:
74
+ - - '='
75
+ - !ruby/object:Gem::Version
76
+ version: 3.11.4
77
+ type: :runtime
78
+ prerelease: false
79
+ version_requirements: !ruby/object:Gem::Requirement
80
+ requirements:
81
+ - - '='
82
+ - !ruby/object:Gem::Version
83
+ version: 3.11.4
84
+ - !ruby/object:Gem::Dependency
85
+ name: webmock
86
+ requirement: !ruby/object:Gem::Requirement
87
+ requirements:
88
+ - - "~>"
89
+ - !ruby/object:Gem::Version
90
+ version: '3'
91
+ type: :development
92
+ prerelease: false
93
+ version_requirements: !ruby/object:Gem::Requirement
94
+ requirements:
95
+ - - "~>"
96
+ - !ruby/object:Gem::Version
97
+ version: '3'
98
+ - !ruby/object:Gem::Dependency
99
+ name: snappy_ext
100
+ requirement: !ruby/object:Gem::Requirement
101
+ requirements:
102
+ - - '='
103
+ - !ruby/object:Gem::Version
104
+ version: 0.1.2
105
+ type: :runtime
106
+ prerelease: false
107
+ version_requirements: !ruby/object:Gem::Requirement
108
+ requirements:
109
+ - - '='
110
+ - !ruby/object:Gem::Version
111
+ version: 0.1.2
112
+ - !ruby/object:Gem::Dependency
113
+ name: http
114
+ requirement: !ruby/object:Gem::Requirement
115
+ requirements:
116
+ - - "~>"
117
+ - !ruby/object:Gem::Version
118
+ version: '4.1'
119
+ type: :runtime
120
+ prerelease: false
121
+ version_requirements: !ruby/object:Gem::Requirement
122
+ requirements:
123
+ - - "~>"
124
+ - !ruby/object:Gem::Version
125
+ version: '4.1'
126
+ description: ''
127
+ email:
128
+ - anmol.vijaywargiya@gojek.com
129
+ - bhumika.goyal@gojek.com
130
+ executables: []
131
+ extensions: []
132
+ extra_rdoc_files: []
133
+ files:
134
+ - ".github/workflows/build-push.yml"
135
+ - ".gitignore"
136
+ - ".rspec"
137
+ - ".rubocop.yml"
138
+ - ".rubocop_airbnb.yml"
139
+ - ".rubocop_cortex.yml"
140
+ - ".ruby-version"
141
+ - CHANGELOG.md
142
+ - CONTRIBUTORS.md
143
+ - Gemfile
144
+ - Gemfile.lock
145
+ - README.md
146
+ - Rakefile
147
+ - bin/console
148
+ - bin/setup
149
+ - cortex_client.gemspec
150
+ - lib/cortex_client.rb
151
+ - lib/cortex_client/configuration.rb
152
+ - lib/cortex_client/exception.rb
153
+ - lib/cortex_client/http/agent.rb
154
+ - lib/cortex_client/http/request.rb
155
+ - lib/cortex_client/http/response.rb
156
+ - lib/cortex_client/metric/metric.rb
157
+ - lib/cortex_client/version.rb
158
+ - lib/proto/remote_pb.rb
159
+ - lib/proto/types_pb.rb
160
+ - push-gem.sh
161
+ homepage:
162
+ licenses:
163
+ - MIT
164
+ metadata: {}
165
+ post_install_message:
166
+ rdoc_options: []
167
+ require_paths:
168
+ - lib
169
+ required_ruby_version: !ruby/object:Gem::Requirement
170
+ requirements:
171
+ - - ">="
172
+ - !ruby/object:Gem::Version
173
+ version: '0'
174
+ required_rubygems_version: !ruby/object:Gem::Requirement
175
+ requirements:
176
+ - - ">="
177
+ - !ruby/object:Gem::Version
178
+ version: '0'
179
+ requirements: []
180
+ rubygems_version: 3.0.3
181
+ signing_key:
182
+ specification_version: 4
183
+ summary: Client to push resource to cortex
184
+ test_files: []