# Apm-agent doesn't sending transactions

**URL:** <https://discuss.elastic.co/t/apm-agent-doesnt-sending-transactions/178966>\
**Category:** APM\
**Created:** [April 29, 2019, 5:07pm UTC](https://discuss.elastic.co/t/apm-agent-doesnt-sending-transactions/178966 "2019-04-29T17:07:58Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![gustavo\_lopes](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/gustavo_lopes/32/44643_2.png) [@gustavo\_lopes](https://discuss.elastic.co/u/gustavo_lopes)\
**Post date:** [April 29, 2019, 5:07pm UTC](https://discuss.elastic.co/t/apm-agent-doesnt-sending-transactions/178966/1 "2019-04-29T17:07:58Z")

</div>

I'm trying to analyse a query made to a sql server through the tedious driver, in the apm server on kibana i can see the errors and the metrics, but i can't see any transactions, I'm running the apm agent in the top of a node js application. Please tell me if i am doing something wrong. Here is my apm agent configuration:

```javascript
var apm = require('elastic-apm-node').start({
    serviceName: 'sqlserver',
    serverUrl: 'xxx:8200'
})

var Connection = require('tedious').Connection;

var config = {
    server : "myserver",
    authentication: {
        type: "default",
        options: {
            userName: 'sa',
            password: 'mypass',
        }
    },
    options: {
        database: 'myDb'
    }
};

    var connection = new Connection(config);

    connection.on('connect', function (err) {
        console.log("Connected");
        executeStatement();
    }
);

var Request = require('tedious').Request;

function executeStatement() {
    request = new Request("select * from mytable", function (err, rowCount) {
        if (err) {
            console.log(err);
        } else {
            console.log(rowCount + ' rows');
        }
    });

    request.on('row', function (columns) {
        columns.forEach(function (column) {
            console.log(column.value);
        });
    });

    connection.execSql(request);
}

```

---

<div class="post-metadata">

**Author:** ![wa7son](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/wa7son/32/21259_2.png) [@wa7son](https://discuss.elastic.co/u/wa7son)\
**Post date:** [May 7, 2019, 3:06pm UTC](https://discuss.elastic.co/t/apm-agent-doesnt-sending-transactions/178966/2 "2019-05-07T15:06:56Z")

</div>

Is the application exiting right after the query finishes?

If so, you need to use [`agent.flush(callback)`](https://www.elastic.co/guide/en/apm/agent/nodejs/current/agent-api.html#apm-flush) to flush the internal data to the APM Server.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [May 28, 2019, 11:06am UTC](https://discuss.elastic.co/t/apm-agent-doesnt-sending-transactions/178966/3 "2019-05-28T11:06:57Z")

</div>

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