Ruby: APM not sending any data

Hi everyone,

we already integrated APM in 3 projects with a total of 6 environments, all Rails.
However, we have another project (fairly old) in Sinatra with a lot of Sidekiq Workers that we like to monitor.

I followed this guides for Sinatra https://www.elastic.co/guide/en/apm/agent/ruby/2.x/getting-started-rack.html and also integrated this code inside the main file of our workers, where all dependencies are loaded:

# init.rb
ElasticAPM.start(YAML.load_file("config/elastic_apm.yml"))
# config/elastic_apm.yml
service_name: "api staging"
secret_token: "XXXX"
server_url: "https://XXXX.apm.eu-central-1.aws.cloud.es.io:443"

After a staging deployment I triggered some workers and requests in the Sinatra app, but no data is showing, even after 1-2 hours.

I logged in on a pry session to see if the configurations are correct:

[5] pry(main)> ElasticAPM.running?
=> true

[9] pry(main)> ElasticAPM.agent
=> #<ElasticAPM::Agent:0x007f1024771330
 @config=
  #<ElasticAPM::Config:0x007f102477eda0
   @active=true,
   @api_buffer_size=256,
   @api_request_size=768000,
   @api_request_time=10,
   @capture_body="off",
   @capture_env=true,
   @capture_headers=true,
   @config_file="config/elastic_apm.yml",
...
 @context_builder=
  #<ElasticAPM::ContextBuilder:0x007f10247709a8
   @config=
    #<ElasticAPM::Config:0x007f102477eda0
     @active=true,
     @api_buffer_size=256,
     @api_request_size=768000,
     @api_request_time=10,
     @capture_body="off",
     @capture_env=true,
     @capture_headers=true,
     @config_file="config/elastic_apm.yml",
     @current_user_email_method=:email,
     @current_user_id_method=:id,
     @current_user_username_method=:username,
     @custom_key_filters=[],
     @default_tags={},
     @disable_send=false,
     @disable_start_message=false,
     @disabled_spies=["json"],
     @environment="staging",
     @filter_exception_types=[],
     @http_compression=true,
     @ignore_url_patterns=[],
     @instrument=true,
     @instrumented_rake_tasks=[],
     @log_level=1,
     @log_path=nil,
...
     @root_path="/var/www/api/releases/20190705060553",
     @secret_token="XXXX",
     @server_url="https://XXXX.apm.eu-central-1.aws.cloud.es.io:443",
     @service_name="api staging",

I also tried to send some data with ElasticAPM.with_transaction but nothing seems to be reported.

Any ideas on how to debug this, or what I'm doing wrong?

Kibana version:
v6.5.4

Elasticsearch version:
v6.5.4

APM Server version:
v6.5.4

APM Agent language and version:
Ruby, 2.9.1

Original install method (e.g. download page, yum, deb, from source, etc.) and version:
bundler via Gemfile

Or is there a way to get a debug output of the response sent to APM?

Hi! You can increase the verbosity of the agent by setting the log level.
Like this for example:

log_level: <%= Logger::DEBUG %>

Let me know if that gives us a hint of what could be going wrong.

1 Like

@mikker thanks for the hint! I changed the log_level and now I get some errors in our logs

"Problem validating JSON document against schema: I[#] S[#] doesn't validate with \"metadata#\"\n  I[#/service/framework/version] S[#/properties/service/properties/framework/properties/version/type] expected string, but got null [{\"metadata\":{\"service\":{\"name\":\"api staging\",\"environment\":\"staging\",\"version\":null,\"agent\":{\"name\":\"ruby\",\"version\":\"2.9.1\"},\"framework\":{\"name\":\"Sinatra\",\"version\":null},\"language\":{\"name\":\"ruby\",\"version\":\"2.4.1\"},\"runtime\":{\"name\":\"ruby\",\"version\":\"2.4.1\"}},\"process\":{\"pid\":28438,\"title\":\"/var/www/api_staging/shared/bundle/ruby/2.4.0/bin/sidekiq\",\"argv\":[]},\"system\":{\"hostname\":\"Ubuntu-1204-precise-64-minimal\",\"architecture\":\"x86_64\",\"platform\":\"linux\",\"kubernetes\":{\"namespace\":null,\"node\":{\"name\":null},\"pod\":{\"name\":null,\"uid\":null}}}}}]"

I tried setting the framework_name to Sinatra but still the same error. Any idea what config I have to set? I found this issue on github https://github.com/elastic/apm-agent-ruby/issues/390 but I have the service_name set as you can see above.

ok, i just found out you also have to set the framework_version by hand, otherwise it throws an error. Thanks anyway!

Actually the recommended way to start the agent will do this for you with Sinatra.

Per the docs:

ElasticAPM.start(app: YourSinatraBaseSubclass)

This topic was automatically closed 20 days after the last reply. New replies are no longer allowed.