Ruby: APM custom intrumentation not showing span in cronilogical order

If you are asking about a problem you are experiencing, please use the following template, as it will help us help you. If you have a different problem, please delete all of this text :slight_smile:

Kibana version: 7.5

Elasticsearch version: 7.5

APM Server version: 7.5

APM Agent language and version: Ruby 3.2.0

Browser version: Firefox

Fresh install or upgraded from other version?
Fresh install

Is there anything special in your setup? For example, are you using the Logstash or Kafka outputs? Are you using a load balancer in front of the APM Servers? Have you changed index pattern, generated custom templates, changed agent configuration etc.
We added a custom span for Typhoeus, as well as we had to add the transaction to any threads we spawn in our Rails transaction. We are using ConcurrentRuby for the threading.

Description of the problem including expected versus actual behavior. Please include screenshots (if relevant):

View in Timeline shows spans out of order. It looks like the spans that are out of order are in the spans that come from the new threads. The main Rails thread shows all the span with a gap where the spawned threads are. Then after the Rails spans the threaded spans are shown. The environment in which this is happening does not allow me to take screenshots.
I can add more information if needed. Also this could be the way I set up the Transaction in the thread. Is there any information for how to pass on the transaction?

We add the transaction to the thread as follows
ElasticAPM.agent.instrumenter.current_transaction = current_transaction
Where current_transaction is
current_transaction = ElasticAPM.current_transaction

Support for multi-threaded spans was just merged actually, https://github.com/elastic/apm-agent-ruby/pull/571.

Can you try setting it up with the master branch of the agent and see if it solves your problem?

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