Module: Apidepth
- Defined in:
- lib/apidepth/event.rb,
lib/apidepth.rb,
lib/apidepth/railtie.rb,
lib/apidepth/version.rb,
lib/apidepth/collector.rb,
lib/apidepth/configuration.rb,
lib/apidepth/registry_loader.rb,
lib/apidepth/vendor_registry.rb,
lib/apidepth/rate_limit_headers.rb,
lib/apidepth/net_http_instrumentation.rb
Overview
lib/apidepth/net_http_instrumentation.rb
Defined Under Namespace
Modules: Event, NetHTTPInstrumentation, RateLimitHeaders, VendorRegistry Classes: Collector, Configuration, Railtie, RegistryLoader
Constant Summary collapse
- VERSION =
"0.2.0".freeze
Class Attribute Summary collapse
Class Method Summary collapse
- .configuration ⇒ Object
- .configure {|configuration| ... } ⇒ Object
- .detect_app_server ⇒ Object
-
.sanitize_log(str) ⇒ Object
Strips line-break characters from untrusted strings before they reach log output.
-
.sdk_metadata ⇒ Object
Computed once and frozen.
Class Attribute Details
.logger ⇒ Object
28 29 30 |
# File 'lib/apidepth.rb', line 28 def logger @logger ||= Logger.new($stdout) end |
Class Method Details
.configuration ⇒ Object
36 37 38 |
# File 'lib/apidepth.rb', line 36 def configuration @configuration ||= Configuration.new end |
.configure {|configuration| ... } ⇒ Object
32 33 34 |
# File 'lib/apidepth.rb', line 32 def configure yield(configuration) end |
.detect_app_server ⇒ Object
54 55 56 57 58 59 60 |
# File 'lib/apidepth.rb', line 54 def detect_app_server return "puma" if defined?(Puma) return "unicorn" if defined?(Unicorn) return "passenger" if defined?(PhusionPassenger) "unknown" end |
.sanitize_log(str) ⇒ Object
Strips line-break characters from untrusted strings before they reach log output. Prevents log injection (CVE-2025-27111 class of attack).
64 65 66 |
# File 'lib/apidepth.rb', line 64 def sanitize_log(str) str.to_s.gsub(/[\r\n\t]/, " ").slice(0, 200) end |
.sdk_metadata ⇒ Object
Computed once and frozen. Included in every batch payload so the collector can correlate data quality issues with specific SDK versions, Ruby runtimes, and app servers without needing the customer to file a support ticket.
43 44 45 46 47 48 49 50 51 52 |
# File 'lib/apidepth.rb', line 43 def @sdk_metadata ||= { name: "apidepth-ruby", version: VERSION, ruby_version: RUBY_VERSION, ruby_platform: RUBY_PLATFORM, rails_version: (defined?(Rails) ? Rails.version : nil), app_server: detect_app_server }.compact.freeze end |