Created
December 9, 2025 18:43
-
-
Save mikecarroll/97b116feb7e1522762372d58eb4fb70a to your computer and use it in GitHub Desktop.
Datadog / Coolhand stack level test
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env ruby | |
| # Test with Rack environment to see if that changes the Datadog behavior | |
| puts "π§ͺ Testing with Rack environment simulation..." | |
| # Simulate a Rack environment like what would exist during a web request | |
| ENV['RACK_ENV'] = 'production' | |
| require 'rack' | |
| require 'faraday' | |
| # Load and configure Datadog with Rack present | |
| require 'datadog' | |
| Datadog.configure do |c| | |
| c.tracing.instrument :faraday | |
| c.tracing.instrument :rack # Add Rack instrumentation | |
| c.service = 'test-app' | |
| c.env = 'production' | |
| c.tracing.enabled = true | |
| c.tracing.sampling.default_rate = 1.0 | |
| end | |
| puts "β Datadog configured with Rack instrumentation" | |
| # Now load Coolhand | |
| require 'coolhand/ruby' | |
| Coolhand.configure do |config| | |
| config.api_key = 'test-key' | |
| config.silent = false | |
| config.intercept_addresses = ["api.anthropic.com"] | |
| end | |
| puts "β Coolhand configured" | |
| # Check middleware on default connection | |
| puts "\nπ Checking default Faraday connection middleware:" | |
| default_conn = Faraday.default_connection | |
| puts " Handlers: #{default_conn.builder.handlers.map(&:klass)}" | |
| puts "\nπ₯ Testing new connection creation (like in background jobs)..." | |
| begin | |
| # This simulates what happens in a background job when making an API call | |
| conn = Faraday.new('https://api.anthropic.com') do |f| | |
| f.request :url_encoded | |
| f.adapter :net_http | |
| end | |
| puts "β SUCCESS: New connection created" | |
| puts " New connection handlers: #{conn.builder.handlers.map(&:klass)}" | |
| # Try making an actual request to see if middleware conflicts | |
| puts "\nπ Testing actual HTTP request..." | |
| response = conn.get('/status/200') rescue nil | |
| puts "β Request completed (or failed safely)" | |
| rescue SystemStackError => e | |
| puts "π₯ STACK OVERFLOW: #{e.message}" | |
| puts " This is the conflict we're looking for!" | |
| exit 1 | |
| rescue => e | |
| puts "β Other error: #{e.class}: #{e.message}" | |
| end | |
| puts "\nπ Test completed - no stack overflow with Rack environment" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment