Where to go in Kibana to see Span details for APM?

I'm trying to learn how spans work with Elasticsearch 8.8 + APM + PHP.

So far it seems my Fleet Server, APM, ELK stack is working. I also got PHP to submit transactions, exceptions and errors to the APM.

The only thing I don't know if I'm doing right is using spans with PHP. Here's my PHP code for a file called span.php

<?php

use Elastic\Apm\ElasticApm;

$transaction = ElasticApm::beginCurrentTransaction(
    'transaction_name',
    'transaction_type'
);

$span = $transaction->beginCurrentSpan(
    'spangled_banner',
    'span_type',
    'span_sub-type', // optional
    'span_action' // optional
);
try {
    // do your thing ...
    echo 'start sleep';
    sleep(3);
    echo 'done sleeping';
} finally {
    $span->end();
}

I run this script by visiting http://localhost/span.php.

I'm wondering where in Kibana do I go to see this span information? I was hoping to see the word "spangled_banner" somewhere, but where do I click to?

Here's all that I'm seeing so far:


Am I missing something?

Can you click on GET /span.php in Transactions tab and scroll down to bottom of the page. You should able to see trace sample in timeline fashion.

@ashishtiwari1993

Thanks, I clicked as you suggsted but don't see the word spangled_banner anywhere.

here's what i see so far under the transactions>timeline>GET /span.php

If I click on GET /span.php or if I click on Metadata and I see this:

Let me know where else I should look? Or maybe my PHP code is wrong and I haven't transmitted the span information yet?

The reason for this issue might be the fact that the transaction is begun but not ended.
There is actually no need to start a transaction since there's always a default transaction that is automatically started (Public API | APM PHP Agent Reference [1.x] | Elastic) and ended by Elastic APM PHP agent itself.
So one way to fix it:

<?php

use Elastic\Apm\ElasticApm;

$transaction = ElasticApm::getCurrentTransaction();

$span = $transaction->beginCurrentSpan(
    'spangled_banner',
    'span_type',
    'span_sub-type', // optional
    'span_action' // optional
);
try {
    // do your thing ...
    echo 'start sleep';
    sleep(3);
    echo 'done sleeping';
} finally {
    $span->end();
}

2 Likes