Skip to content

APM gem causes many warning logs for deprecated JSON.fast_generate #1587

@Devocado

Description

@Devocado

Using APM gem causes many warning logs for deprecated JSON.fast_generate

Expected behaviour

No output from the gem

Current behaviour

elastic-apm spews out warning messages, even when config.elastic_apm.enabled = false

For example, this is a portion of the output when running RSpec tests (with enabled set to false for test):

/usr/local/bundle/gems/elastic-apm-4.8.0/lib/elastic_apm/transport/worker.rb:90: warning: JSON.fast_generate is deprecated and will be removed in json 3.0.0, just use JSON.generate
/usr/local/bundle/gems/elastic-apm-4.8.0/lib/elastic_apm/transport/worker.rb:90: warning: JSON.fast_generate is deprecated and will be removed in json 3.0.0, just use JSON.generate
/usr/local/bundle/gems/elastic-apm-4.8.0/lib/elastic_apm/transport/worker.rb:90: warning: JSON.fast_generate is deprecated and will be removed in json 3.0.0, just use JSON.generate
        responds with a 404 status
/usr/local/bundle/gems/elastic-apm-4.8.0/lib/elastic_apm/transport/worker.rb:90: warning: JSON.fast_generate is deprecated and will be removed in json 3.0.0, just use JSON.generate
/usr/local/bundle/gems/elastic-apm-4.8.0/lib/elastic_apm/transport/worker.rb:90: warning: JSON.fast_generate is deprecated and will be removed in json 3.0.0, just use JSON.generate
        responds with a message
    behaves like an authenticated customer with
      with a xxx role on the account
/usr/local/bundle/gems/elastic-apm-4.8.0/lib/elastic_apm/transport/worker.rb:90: warning: JSON.fast_generate is deprecated and will be removed in json 3.0.0, just use JSON.generate
/usr/local/bundle/gems/elastic-apm-4.8.0/lib/elastic_apm/transport/worker.rb:90: warning: JSON.fast_generate is deprecated and will be removed in json 3.0.0, just use JSON.generate
        allows access
    behaves like an authenticated customer
      with a yyy role on the account
/usr/local/bundle/gems/elastic-apm-4.8.0/lib/elastic_apm/transport/worker.rb:90: warning: JSON.fast_generate is deprecated and will be removed in json 3.0.0, just use JSON.generate
/usr/local/bundle/gems/elastic-apm-4.8.0/lib/elastic_apm/transport/worker.rb:90: warning: JSON.fast_generate is deprecated and will be removed in json 3.0.0, just use JSON.generate
        does not allow access
    behaves like an authenticated customer
      with a zzz role with access to a single product
/usr/local/bundle/gems/elastic-apm-4.8.0/lib/elastic_apm/transport/worker.rb:90: warning: JSON.fast_generate is deprecated and will be removed in json 3.0.0, just use JSON.generate
/usr/local/bundle/gems/elastic-apm-4.8.0/lib/elastic_apm/transport/worker.rb:90: warning: JSON.fast_generate is deprecated and will be removed in json 3.0.0, just use JSON.generate
        allows access

Fix

Replace JSON.fast_generate with JSON.generate in elastic_apm/transport/worker.rb

Environment

Rails: 8.0.2
Ruby: 3.4.5
Elastic-apm: 4.8.0

  • Agent config options

    Click to expand
        config.elastic_apm.enabled = false
        config.elastic_apm.service_name = APM_CONFIG[:name]
        config.elastic_apm.server_url = APM_CONFIG[:url]
        config.elastic_apm.api_key = APM_CONFIG[:api_key]
        config.elastic_apm.environment = environment
        config.elastic_apm.verify_server_cert = false
    

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions