# Full trace with custom integration

**URL:** <https://discuss.elastic.co/t/full-trace-with-custom-integration/185996>\
**Category:** APM\
**Tags:** nodejs\
**Created:** [June 17, 2019, 5:58am UTC](https://discuss.elastic.co/t/full-trace-with-custom-integration/185996 "2019-06-17T05:58:55Z")\
**Posts on this page:** 1\
**Showing post:** 2

<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:** [June 17, 2019, 7:57am UTC](https://discuss.elastic.co/t/full-trace-with-custom-integration/185996/2 "2019-06-17T07:57:51Z")

</div>

Welcome to the forum 🙂

Yes, you can link the two transactions together into _one_ trace by ensuring that you pass on the current `traceparent` from the outgoing service (service A) and read it again in the receiving service (service B). This happens automatically with HTTP based services, but if you use raw TCP or UDP, you need to pass this information along manually.

I assume you use the agent API to manually start a new transaction in service A. During an active transaction, you can always call [`agent.currentTraceparent`](https://www.elastic.co/guide/en/apm/agent/nodejs/current/agent-api.html#apm-current-traceparent), to get the current `traceparent` string. You need to send this to service B inside your regular UDP request. Then when you start a new transaction in service B using [`agent.startTransaction()`](https://www.elastic.co/guide/en/apm/agent/nodejs/current/agent-api.html#apm-start-transaction), you need to pass in the `traceparent` as a `childOf` option.

Service A example:

```auto
agent.startTransaction('my-service-a-transaction')
const traceparent = agent.currentTraceparent

// Somehow send the traceparent as a "header" to service B
sendMetadata(`traceparent: ${traceparent}\n`)

```

Service B example:

```auto
// Somehow read the traceparent from the incoming request
const traceparent = readTraceparentFromUDPPacket()

// Use the traceparent to initialize the new transaction
agent.startTransaction('my-service-b-transaction', { childOf: traceparent })

// continue program as normal...

```

---

_[View the full topic](https://discuss.elastic.co/t/full-trace-with-custom-integration/185996)._
