# APM Go Agent doesn't sends any requests to APM-server

**URL:** https://discuss.elastic.co/t/apm-go-agent-doesnt-sends-any-requests-to-apm-server/158332
**Category:** APM
**Created:** [November 27, 2018, 11:50am UTC](https://discuss.elastic.co/t/apm-go-agent-doesnt-sends-any-requests-to-apm-server/158332 "2018-11-27T11:50:04Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![Arsalan\_Rabdanov](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/arsalan_rabdanov/32/38625_2.png) [@Arsalan\_Rabdanov](https://discuss.elastic.co/u/Arsalan_Rabdanov)
#### Post date: [November 27, 2018, 11:50am UTC](https://discuss.elastic.co/t/apm-go-agent-doesnt-sends-any-requests-to-apm-server/158332/1 "2018-11-27T11:50:04Z")

</div>

Trying to configure APM Go Agent with a simple example:

**main.go**

```
package main

import (
	"errors"
	"log"

	"github.com/joho/godotenv"
	"go.elastic.co/apm"
)

func main() {
	err := godotenv.Load()
	if err != nil {
		log.Println("Error loading .env file")
	}
	tx := apm.DefaultTracer.StartTransaction("GET /api/v1", "request")
	tx.Result = "HTTP 2xx"
	tx.Context.SetTag("region", "us-east-1")
	defer tx.End()

	e := apm.DefaultTracer.NewError(errors.New("error"))
	e.Send()
}

```

**.dotenv**

```
ELASTIC_APM_SERVER_URL=http://192.168.1.52:8200
ELASTIC_APM_SERVICE_NAME=go-apm-test

```

No requests, no logs. I have looked net packets with Wireshark. No packets with dst port 8200 on client machine

---

<div class="post-metadata">

### Author: ![axw](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/axw/32/28197_2.png) [@axw](https://discuss.elastic.co/u/axw)
#### Post date: [November 27, 2018, 1:28pm UTC](https://discuss.elastic.co/t/apm-go-agent-doesnt-sends-any-requests-to-apm-server/158332/2 "2018-11-27T13:28:28Z")

</div>

Hi Arsalan, thanks for trying out the Elastic APM Go agent!

The Go agent starts a background goroutine to send events to the APM Server. What's happening here is that your process is exiting before the goroutine has a chance to send them.

For testing purposes, Tracer has a method called Flush, which you can call to force any enqueued events to be flushed to the server. Tracer.Flush takes a single argument, a channel which will abort the flush (you can pass nil to wait until the flush completes, successfully or not.)

So just add this to the end of your main function:

```auto
apm.DefaultTracer.Flush(nil)

```

---

<div class="post-metadata">

### Author: ![Arsalan\_Rabdanov](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/arsalan_rabdanov/32/38625_2.png) [@Arsalan\_Rabdanov](https://discuss.elastic.co/u/Arsalan_Rabdanov)
#### Post date: [December 10, 2018, 9:24am UTC](https://discuss.elastic.co/t/apm-go-agent-doesnt-sends-any-requests-to-apm-server/158332/3 "2018-12-10T09:24:33Z")

</div>

Thanks!

---

<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: [December 31, 2018, 5:24am UTC](https://discuss.elastic.co/t/apm-go-agent-doesnt-sends-any-requests-to-apm-server/158332/4 "2018-12-31T05:24:39Z")

</div>

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