Class: LogBrew::Client
- Inherits:
-
Object
- Object
- LogBrew::Client
- 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
- #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.
731 732 733 734 735 736 737 |
# File 'lib/logbrew.rb', line 731 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
718 719 720 721 722 723 724 725 726 727 728 729 |
# File 'lib/logbrew.rb', line 718 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
767 768 769 |
# File 'lib/logbrew.rb', line 767 def action(id, , attributes) push_event("action", id, , validate_action(attributes)) end |
#environment(id, timestamp, attributes) ⇒ Object
751 752 753 |
# File 'lib/logbrew.rb', line 751 def environment(id, , attributes) push_event("environment", id, , validate_environment(attributes)) end |
#flush(transport) ⇒ Object
771 772 773 774 775 |
# File 'lib/logbrew.rb', line 771 def flush(transport) raise SdkError.new("shutdown_error", "client is already shut down") if @closed flush_internal(transport) end |
#issue(id, timestamp, attributes) ⇒ Object
755 756 757 |
# File 'lib/logbrew.rb', line 755 def issue(id, , attributes) push_event("issue", id, , validate_issue(attributes)) end |
#log(id, timestamp, attributes) ⇒ Object
759 760 761 |
# File 'lib/logbrew.rb', line 759 def log(id, , attributes) push_event("log", id, , validate_log(attributes)) end |
#pending_events ⇒ Object
739 740 741 |
# File 'lib/logbrew.rb', line 739 def pending_events @events.length end |
#preview_json ⇒ Object
743 744 745 |
# File 'lib/logbrew.rb', line 743 def preview_json JSON.pretty_generate("sdk" => @sdk, "events" => @events) end |
#release(id, timestamp, attributes) ⇒ Object
747 748 749 |
# File 'lib/logbrew.rb', line 747 def release(id, , attributes) push_event("release", id, , validate_release(attributes)) end |
#shutdown(transport) ⇒ Object
777 778 779 780 781 782 783 |
# File 'lib/logbrew.rb', line 777 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
763 764 765 |
# File 'lib/logbrew.rb', line 763 def span(id, , attributes) push_event("span", id, , validate_span(attributes)) end |