What are the criteria for transaction&span?

Kibana version: 7.5.2

Elasticsearch version: 7.5.2

APM Server version: 7.5.2

APM Agent language and version: java agent 1.12

  1. I know that one transaction is generated for every http request.
    So how is a transaction created with batch processing without external requests?
    Should I use a public API?
    Or is there a way to collect them automatically in this case?

  2. What are the criteria for span?
    My app consists of spring, and when a user request comes in, it proceeds in the order of controller-> service-> query-> service-> query-> view rendering.
    Three spans are generated in this process. 2 queries, 1 view rendering.
    What are the criteria for dividing the span?

1 Like

Hi @Yungyoung_Ok,

  1. For batch processing, we don't have any plugin that supports that out-of-the-box yet, thus you have to use agent API to manually wrap your batch execution in a transaction. Do you use any batch framework (like spring- batch) or is it a plain java program where everything is in a main method ?

  2. For spans and transactions, there are two ways to define their boundaries:

  • if there is a relevant plugin in agent to auto-instrument a known framework or API like JDBC, agent will automatically create transactions & spans for them
  • if agent API is called explicitly from application code, for example to cover the use-case you mentioned above with batches.

How can I tell what range I am measuring automatically?
For example, in the case of spring framework, the service component is not measured in span, only view rendering is measured in span. What is the difference?

Transactions and spans created automatically by the agent are defined by agent plugins, and you can have a good overview of what is being monitored by looking at the list of supported technologies.

In your case view rendering using Spring MVC is something that we instrument out-of-the box, which explains why this part is being monitored as a separate span.

In the agent code, support for all those are provided using plugins, and are embedded in the agent binary. For things that aren't supported out of the box, there are a few alternatives:

  • create a new plugin for it, all pull-requests are welcome.
  • create an ad-hoc instrumentation using agent API directly within your application.

I have seen the supported technologies documentation already.
In this document, we found the creation criteria of'transaction', but we could not find the creation criteria of 'span'.
If 'span of Spring MVC' is automatically measured by the agent, is there a document on that list or criteria?
If I don't use the public API, I want to know exactly the scope and criteria of how much is collected.

The short answer is that everything that we instrument that is not a transaction is a span, I agree with you that our documentation is not really explicit about this.

Apart from that we now have some inferred spans that are created using a sampling profiler (will ship in 1.14.0), those do not come from instrumented code and do not imply any extra overhead.

If you need to get into the low level details of what is captured, you ca look at a few things:

  • our plugins source code provides definitions of what is instrumented, for example a method named doWork on a class named a.b.c.WorkerService, this will provide you the answer to "what do we instrument in your application", those are stored in classes whose name matches the *Instrumentation pattern.
  • if you are more interested about the "what is being captured in your application", searching on data directly on Kibana should probably a good idea.

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