Kibana: Service map not display connections

I am using Kibana/ElasticSearch/APM 7.11.1.
And I am not working on http server, so I am using nodejs agent to create the custom transactions. I have two services, producer and consumer.
The trace sequence is:

  1. producer startTransaction trace006.
  2. producer startSpan request222.
  3. producer send traceparent to consumder
  4. consumer startTransaction request224 with childOf traceparent from producer.
  5. consumer startTransaction request334 with childOf traceparent from producer.

And the timeline displayed correctly,

, the relationship of producer and consumer can be displayed in the timeline graph.

But the service map didn't show the connections between the producer and the consumer services. Only two standalone service nodes.

Is there any other settings or special code I need to do?

I found another issue here Service Map not linking services - #4 by GregKalapos,
and I think the problem is the same.
I am writing some simulation nodejs app to generate transaction/span data. So is there any doc or code sample to set span.destination correctly?

Here is my code:

  1. NodeJS app1 acts as producer service.
const agent =
       require('elastic-apm-node').start({'producer', serverUrl: 'http://localhost:8200'});
const startTime =;
const tran = createTransaction(producer, 'trace006', startTime);

const traceparent = producer.currentTraceparent;
const req1 =
    tran.startSpan('request222', 'custom', {startTime: startTime + 10});
    {service: {name: 'consumer', resource: 'db', type: req1.type}});
// use ipc communication channel to send the traceparent to another nodejs process.
  1. NodeJS app2 acts as consumer service.
const agent =
       require('elastic-apm-node').start({'consumer', serverUrl: 'http://localhost:8200'});
ipc.on('message', traceparent => {
  const startTime =;
  const req2 =
      agent.startTransaction('request224', {startTime, childOf: traceParent});
   req2.end(startTime + 100);
  const req3 =
      agent.startTransaction('request334', {startTime, childOf: traceParent});
  req3.end(startTime + 200);

So I am trying to use req1.setDestinationContext( {service: {name: 'consumer', resource: 'db', type: req1.type}}); to set destionation, but not working...

I tried to set the span.type to external, now the link is displayed, but not producer -> consumer, it is producer -> db, where the db is the resource of the destination context.

Thank you.

Finally I copied the code and data from http-shared code of nodejs-agent to simulate the data and behavior, now the link is working.