Module: Lescopr
- Defined in:
- lib/lescopr.rb,
lib/lescopr/version.rb,
lib/lescopr/core/client.rb,
lib/lescopr/modes/direct.rb,
lib/lescopr/core/log_queue.rb,
lib/lescopr/modes/detector.rb,
lib/lescopr/modes/embedded.rb,
lib/lescopr/monitoring/logger.rb,
lib/lescopr/core/daemon_runner.rb,
lib/lescopr/transport/http_client.rb,
lib/lescopr/filesystem/config_manager.rb,
lib/lescopr/integrations/rails/railtie.rb,
lib/lescopr/filesystem/project_analyzer.rb,
lib/lescopr/integrations/rack/middleware.rb,
lib/lescopr/integrations/sinatra/extension.rb
Overview
Lescopr — zero-configuration Ruby monitoring SDK.
Defined Under Namespace
Modules: Core, Filesystem, Integrations, Modes, Monitoring, Transport Classes: Configuration
Constant Summary collapse
- BASE_URL =
"https://api.lescopr.com/api/v1"- VERSION =
"1.0.2"
Class Attribute Summary collapse
-
.client ⇒ Lescopr::Core::Client
readonly
The active SDK client instance.
Class Method Summary collapse
- .configuration ⇒ Lescopr::Configuration
-
.configure {|config| ... } ⇒ Object
Configure the SDK via a block.
-
.init!(opts = {}) ⇒ Object
Shorthand initialiser — accepts a hash or keyword args.
-
.log(level, message, metadata = {}) ⇒ Object
Send a log entry manually.
-
.logs ⇒ Lescopr::Core::Client?
Zero-config init — loads SDK keys from .lescopr/config.json and auto-detects the best transport mode (daemon / embedded / direct).
-
.reset! ⇒ Object
Reset the SDK (useful in tests).
Class Attribute Details
.client ⇒ Lescopr::Core::Client (readonly)
Returns the active SDK client instance.
52 53 54 |
# File 'lib/lescopr.rb', line 52 def client @client end |
Class Method Details
.configuration ⇒ Lescopr::Configuration
112 113 114 |
# File 'lib/lescopr.rb', line 112 def configuration @configuration ||= Configuration.new end |
.configure {|config| ... } ⇒ Object
Configure the SDK via a block.
57 58 59 60 61 62 |
# File 'lib/lescopr.rb', line 57 def configure yield(configuration) @client = Core::Client.new(configuration) @client.setup_auto_logging! @client end |
.init!(opts = {}) ⇒ Object
Shorthand initialiser — accepts a hash or keyword args.
93 94 95 96 97 98 |
# File 'lib/lescopr.rb', line 93 def init!(opts = {}) configuration.sdk_key = opts[:sdk_key] if opts[:sdk_key] configuration.api_key = opts[:api_key] if opts[:api_key] configuration.environment = opts[:environment] if opts[:environment] configure { |_c| } # trigger setup end |
.log(level, message, metadata = {}) ⇒ Object
Send a log entry manually.
105 106 107 108 109 |
# File 'lib/lescopr.rb', line 105 def log(level, , = {}) return unless client&.ready? client.send_log(level.to_s.upcase, , ) end |
.logs ⇒ Lescopr::Core::Client?
Zero-config init — loads SDK keys from .lescopr/config.json and auto-detects the best transport mode (daemon / embedded / direct).
Usage (e.g. config/initializers/lescopr.rb or top of application.rb):
Lescopr.logs
71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 |
# File 'lib/lescopr.rb', line 71 def logs return @client if @client config_mgr = Filesystem::ConfigManager.new saved = config_mgr.load return nil unless saved && saved[:sdk_key] configuration.sdk_key = saved[:sdk_key] configuration.api_key = saved[:api_key] configuration.environment = saved[:environment] || "development" @client = Core::Client.new(configuration) @client.setup_auto_logging! @client end |
.reset! ⇒ Object
Reset the SDK (useful in tests).
117 118 119 120 121 |
# File 'lib/lescopr.rb', line 117 def reset! @client&.shutdown! @client = nil @configuration = nil end |