Class: LogBrew::Client
- Inherits:
-
Object
- Object
- LogBrew::Client
- Includes:
- TraceClientMethods
- Defined in:
- lib/logbrew.rb
Class Method Summary collapse
Instance Method Summary collapse
- #action(id, timestamp, attributes) ⇒ Object
- #environment(id, timestamp, attributes) ⇒ Object
- #flush(transport) ⇒ Object
-
#initialize(api_key:, sdk:, max_retries:) ⇒ Client
constructor
A new instance of Client.
- #issue(id, timestamp, attributes) ⇒ Object
- #log(id, timestamp, attributes) ⇒ Object
- #metric(id, timestamp, attributes) ⇒ Object
- #pending_events ⇒ Object
- #preview_json ⇒ Object
- #release(id, timestamp, attributes) ⇒ Object
- #shutdown(transport) ⇒ Object
- #span(id, timestamp, attributes) ⇒ Object
Constructor Details
#initialize(api_key:, sdk:, max_retries:) ⇒ Client
Returns a new instance of Client.
755 756 757 758 759 760 761 |
# File 'lib/logbrew.rb', line 755 def initialize(api_key:, sdk:, max_retries:) @api_key = api_key @sdk = sdk @max_retries = max_retries @events = [] @closed = false end |
Class Method Details
.create(api_key:, sdk_name:, sdk_version:, max_retries: 2) ⇒ Object
742 743 744 745 746 747 748 749 750 751 752 753 |
# File 'lib/logbrew.rb', line 742 def self.create(api_key:, sdk_name:, sdk_version:, max_retries: 2) Validation.require_non_empty("api_key", api_key) Validation.require_non_empty("sdk_name", sdk_name) Validation.require_non_empty("sdk_version", sdk_version) raise SdkError.new("validation_error", "max_retries must be non-negative") if max_retries.negative? new( api_key: api_key, sdk: { "name" => sdk_name, "language" => "ruby", "version" => sdk_version }, max_retries: max_retries ) end |
Instance Method Details
#action(id, timestamp, attributes) ⇒ Object
795 796 797 |
# File 'lib/logbrew.rb', line 795 def action(id, , attributes) push_event("action", id, , validate_action(attributes)) end |
#environment(id, timestamp, attributes) ⇒ Object
775 776 777 |
# File 'lib/logbrew.rb', line 775 def environment(id, , attributes) push_event("environment", id, , validate_environment(attributes)) end |
#flush(transport) ⇒ Object
799 800 801 802 803 |
# File 'lib/logbrew.rb', line 799 def flush(transport) raise SdkError.new("shutdown_error", "client is already shut down") if @closed flush_internal(transport) end |
#issue(id, timestamp, attributes) ⇒ Object
779 780 781 |
# File 'lib/logbrew.rb', line 779 def issue(id, , attributes) push_event("issue", id, , validate_issue(attributes)) end |
#log(id, timestamp, attributes) ⇒ Object
783 784 785 |
# File 'lib/logbrew.rb', line 783 def log(id, , attributes) push_event("log", id, , validate_log(attributes)) end |
#metric(id, timestamp, attributes) ⇒ Object
791 792 793 |
# File 'lib/logbrew.rb', line 791 def metric(id, , attributes) push_event("metric", id, , validate_metric(attributes)) end |
#pending_events ⇒ Object
763 764 765 |
# File 'lib/logbrew.rb', line 763 def pending_events @events.length end |
#preview_json ⇒ Object
767 768 769 |
# File 'lib/logbrew.rb', line 767 def preview_json JSON.pretty_generate("sdk" => @sdk, "events" => @events) end |
#release(id, timestamp, attributes) ⇒ Object
771 772 773 |
# File 'lib/logbrew.rb', line 771 def release(id, , attributes) push_event("release", id, , validate_release(attributes)) end |
#shutdown(transport) ⇒ Object
805 806 807 808 809 810 811 |
# File 'lib/logbrew.rb', line 805 def shutdown(transport) raise SdkError.new("shutdown_error", "client is already shut down") if @closed response = flush_internal(transport) @closed = true response end |
#span(id, timestamp, attributes) ⇒ Object
787 788 789 |
# File 'lib/logbrew.rb', line 787 def span(id, , attributes) push_event("span", id, , validate_span(attributes)) end |