# APM is not getting spans for https requests

**URL:** <https://discuss.elastic.co/t/apm-is-not-getting-spans-for-https-requests/148154>\
**Category:** APM\
**Created:** [September 11, 2018, 2:04pm UTC](https://discuss.elastic.co/t/apm-is-not-getting-spans-for-https-requests/148154 "2018-09-11T14:04:32Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Gerardo\_Pivotto](https://avatars.discourse-cdn.com/v4/letter/g/65b543/32.png) [@Gerardo\_Pivotto](https://discuss.elastic.co/u/Gerardo_Pivotto)\
**Post date:** [September 11, 2018, 2:04pm UTC](https://discuss.elastic.co/t/apm-is-not-getting-spans-for-https-requests/148154/1 "2018-09-11T14:04:32Z")

</div>

Hello,

I'm ind of new with Elastic APM, Starting working with it this week. I'm working with elastic-apm-node package, nodejs and express.

Package-version:"elastic-apm-node": "^1.12.0"

Code:  
const apm = require('elastic-apm-node');  
apm.start({  
serverUrl: 'http://apm\_server\_hostname:apm\_server\_port',  
logLevel: 'debug',  
});

The main issue I'm having is that APM is not being able to create the span in the current transaction.

APM Log example:  
adding hook to Node.js module loader  
shimming express@4.16.3 module  
shimming express.Router.process\_params function  
shimming express.Router.use function  
shimming express.static function  
copying property mime from express.static  
shimming http@9.11.2 module  
shimming http.Server.prototype.emit function  
shimming http.request function  
shimming http.ServerResponse.prototype.writeHead function  
shimming https@9.11.2 module  
shimming https.Server.prototype.emit function  
shimming https.request function  
shimming layer.handle\_request function (layer: router)  
skip shimming layer.handle\_request (layer: jsonParser, path: /)  
skip shimming layer.handle\_request (layer: , path: /)  
skip shimming layer.handle\_request (layer: router, path: /)  
skip shimming layer.handle\_request (layer: errorMiddleware, path: /)  
intercepted request event call to http.Server.prototype.emit  
setting transaction result { id: 'a60cf357-64fb-412e-a4b3-fbadb9516525',  
result: 'success' }  
start transaction { id: 'a60cf357-64fb-412e-a4b3-fbadb9516525',  
name: undefined,  
type: undefined }  
shimming express.Router.Layer.handle function  
shimming express.Router.Layer.handle function  
shimming express.Router.Layer.handle function  
shimming express.Router.Layer.handle function  
shimming express.Router.Layer.handle function  
shimming express.Router.Layer.handle function  
shimming express.Router.Layer.handle function  
no active transaction found - cannot build new span  
intercepted call to https.request { id: null }  
[2018-09-11 13:13:56.482] [INFO] Service call to settings profiler // call to another service  
type: http\_service\_profiler  
service: endpoint  
durationMs: 8025  
duration: 8025ms  
setting transaction result { id: 'a60cf357-64fb-412e-a4b3-fbadb9516525',  
result: 'HTTP 2xx' }  
[2018-09-11 13:13:56.492] [INFO] GET /endpoint/general 200 8035ms  
res:  
statusCode: 200  
req:  
url: /endpoint/general  
headers:  
host: localhost:3000  
user-agent: curl/7.47.0  
accept: _/_  
method: GET  
httpVersion: 1.1  
originalUrl: /endpoint/general  
query: {}  
responseTime: 8035  
message\_id: 89ccadb0-b5c4-11e8-9594-5f11febf4442  
setting default transaction name: GET /endpoint/general { id: 'a60cf357-64fb-412e-a4b3-fbadb9516525' }  
adding transaction to queue { id: 'a60cf357-64fb-412e-a4b3-fbadb9516525' }  
setting timer to flush queue: 5208ms  
ended transaction { id: 'a60cf357-64fb-412e-a4b3-fbadb9516525',  
type: 'request',  
result: 'HTTP 2xx',  
name: 'GET /endpoint/general' }  
flushing queue  
sending transactions payload  
no active transaction found - cannot build new span  
intercepted call to http.request { id: null }

I'll be glad if somebody already implemented this with node and solved this issue.

Thanks  
Gerardo

---

<div class="post-metadata">

**Author:** ![stephenbelanger](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/stephenbelanger/32/34880_2.png) [@stephenbelanger](https://discuss.elastic.co/u/stephenbelanger)\
**Post date:** [September 11, 2018, 4:36pm UTC](https://discuss.elastic.co/t/apm-is-not-getting-spans-for-https-requests/148154/2 "2018-09-11T16:36:55Z")

</div>

What modules are you using within that route? In particular, I want to know of anything that does async things.

It looks to me like the context is being lost, which could happen if something uses async code which we haven't specifically instrumented. The most common cause is callback queues like connection pooling.

---

<div class="post-metadata">

**Author:** ![ignaciocavina](https://avatars.discourse-cdn.com/v4/letter/i/848f3c/32.png) [@ignaciocavina](https://discuss.elastic.co/u/ignaciocavina)\
**Post date:** [September 12, 2018, 1:08pm UTC](https://discuss.elastic.co/t/apm-is-not-getting-spans-for-https-requests/148154/3 "2018-09-12T13:08:16Z")

</div>

May superagent be causing this issue?  
Here's some probably related piece: [https://github.com/visionmedia/superagent/blob/13ff9b3a1bec34020c7d5dfcf88bbb26d67b9ee1/lib/node/index.js#L150](https://github.com/visionmedia/superagent/blob/13ff9b3a1bec34020c7d5dfcf88bbb26d67b9ee1/lib/node/index.js#L150)  
I mention this cause I'm working with Gerardo on the same project, and know for a fact that library is being used, plus ran some tests that indicate the problem might be there...

---

<div class="post-metadata">

**Author:** ![stephenbelanger](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/stephenbelanger/32/34880_2.png) [@stephenbelanger](https://discuss.elastic.co/u/stephenbelanger)\
**Post date:** [September 12, 2018, 11:33pm UTC](https://discuss.elastic.co/t/apm-is-not-getting-spans-for-https-requests/148154/4 "2018-09-12T23:33:35Z")

</div>

I don't see any immediate issues, in a quick glance through the code, by I can try and find some time for some in-depth testing tomorrow. Can you share your package.json so I can see what specific versions of modules you are using?

---

<div class="post-metadata">

**Author:** ![Gerardo\_Pivotto](https://avatars.discourse-cdn.com/v4/letter/g/65b543/32.png) [@Gerardo\_Pivotto](https://discuss.elastic.co/u/Gerardo_Pivotto)\
**Post date:** [September 13, 2018, 12:02pm UTC](https://discuss.elastic.co/t/apm-is-not-getting-spans-for-https-requests/148154/5 "2018-09-13T12:02:18Z")

</div>

Stephen, Finally found the issue, we are overriding the http context to add some configuration ☹ !!!! Thanks to much for your help! I really appreciate it!

---

<div class="post-metadata">

**Author:** ![stephenbelanger](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/stephenbelanger/32/34880_2.png) [@stephenbelanger](https://discuss.elastic.co/u/stephenbelanger)\
**Post date:** [September 13, 2018, 3:44pm UTC](https://discuss.elastic.co/t/apm-is-not-getting-spans-for-https-requests/148154/6 "2018-09-13T15:44:30Z")

</div>

Oh, good. I'm glad you got it figured out. 👍

Is there anything you think we could do on our end to guard against something like that breaking the context?

---

<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:** [October 4, 2018, 11:44am UTC](https://discuss.elastic.co/t/apm-is-not-getting-spans-for-https-requests/148154/7 "2018-10-04T11:44:34Z")

</div>

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