# Go agent does not seem to send any trace to APM

**URL:** <https://discuss.elastic.co/t/go-agent-does-not-seem-to-send-any-trace-to-apm/168610>\
**Category:** APM\
**Created:** [February 15, 2019, 3:00pm UTC](https://discuss.elastic.co/t/go-agent-does-not-seem-to-send-any-trace-to-apm/168610 "2019-02-15T15:00:26Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![cabrinoob](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/cabrinoob/32/36043_2.png) [@cabrinoob](https://discuss.elastic.co/u/cabrinoob)\
**Post date:** [February 15, 2019, 3:00pm UTC](https://discuss.elastic.co/t/go-agent-does-not-seem-to-send-any-trace-to-apm/168610/1 "2019-02-15T15:00:26Z")

</div>

Hi, I'am using [elastic.co](http://elastic.co) SAAS and trying to test the APM instrumenting a sample golang app. (it's actually working good with nodeJS app)

In this sample I'am using the lastest version of the gorilla/mux router (1.7.0). I followed this quick tutorial here : [https://www.codementor.io/codehakase/building-a-restful-api-with-golang-a6yivzqdo](https://www.codementor.io/codehakase/building-a-restful-api-with-golang-a6yivzqdo)

Here is my golang code :

```
package main

import (
	"encoding/json"
	"log"
	"net/http"
	"os"

	"github.com/gorilla/mux"
	"go.elastic.co/apm"
	"go.elastic.co/apm/module/apmgorilla"
)

// The person Type (more like an object)
type Person struct {
	ID string `json:"id,omitempty"`
	Firstname string `json:"firstname,omitempty"`
	Lastname string `json:"lastname,omitempty"`
	Address *Address `json:"address,omitempty"`
}
type Address struct {
	City string `json:"city,omitempty"`
	State string `json:"state,omitempty"`
}

var people []Person

// Display all from the people var
func GetPeople(w http.ResponseWriter, r *http.Request) {
	json.NewEncoder(w).Encode(people)
}

// Display a single data
func GetPerson(w http.ResponseWriter, r *http.Request) {
	params := mux.Vars(r)
	for _, item := range people {
		if item.ID == params["id"] {
			json.NewEncoder(w).Encode(item)
			return
		}
	}
	json.NewEncoder(w).Encode(&Person{})
}

// create a new item
func CreatePerson(w http.ResponseWriter, r *http.Request) {
	params := mux.Vars(r)
	var person Person
	_ = json.NewDecoder(r.Body).Decode(&person)
	person.ID = params["id"]
	people = append(people, person)
	json.NewEncoder(w).Encode(people)
}

// Delete an item
func DeletePerson(w http.ResponseWriter, r *http.Request) {
	params := mux.Vars(r)
	for index, item := range people {
		if item.ID == params["id"] {
			people = append(people[:index], people[index+1:]...)
			break
		}
		json.NewEncoder(w).Encode(people)
	}
}

// main function to boot up everything
func main() {

	log.Print("ELASTIC_APM_SERVICE_NAME:", os.Getenv("ELASTIC_APM_SERVICE_NAME"))
	log.Print("ELASTIC_APM_SERVER_URL:", os.Getenv("ELASTIC_APM_SERVER_URL"))
	log.Print("ELASTIC_APM_SECRET_TOKEN:", os.Getenv("ELASTIC_APM_SECRET_TOKEN"))

	router := mux.NewRouter()
	router.Use(apmgorilla.Middleware())
	people = append(people, Person{ID: "1", Firstname: "John", Lastname: "Doe", Address: &Address{City: "City X", State: "State X"}})
	people = append(people, Person{ID: "2", Firstname: "Koko", Lastname: "Doe", Address: &Address{City: "City Z", State: "State Y"}})
	people = append(people, Person{ID: "3", Firstname: "Kiki", Lastname: "Doe", Address: &Address{City: "City Z", State: "State Z"}})
	router.HandleFunc("/people", GetPeople).Methods("GET")
	router.HandleFunc("/people/{id}", GetPerson).Methods("GET")
	router.HandleFunc("/people/{id}", CreatePerson).Methods("POST")
	router.HandleFunc("/people/{id}", DeletePerson).Methods("DELETE")
	log.Fatal(http.ListenAndServe(":8000", router))
}

```

Environment variables are well displayed when I print them in the main function, the service responds fine, but I have no trace in the APM and no error in log.

Thank you for your help.

---

<div class="post-metadata">

**Author:** ![cabrinoob](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/cabrinoob/32/36043_2.png) [@cabrinoob](https://discuss.elastic.co/u/cabrinoob)\
**Post date:** [February 15, 2019, 4:35pm UTC](https://discuss.elastic.co/t/go-agent-does-not-seem-to-send-any-trace-to-apm/168610/2 "2019-02-15T16:35:08Z")

</div>

Ok, I solved my problem so I post the solution here in case other people experience the same :

We are using Elastic Cloud (the SaaS version of elasticsearch). So we have an HTTPS endpoint which looks like `https://0732555c72f...`

Following the documentation I had configured 3 environment variables :

ELASTIC\_APM\_SECRET\_TOKEN  
ELASTIC\_APM\_SERVICE\_NAME  
ELASTIC\_APM\_SERVER\_URL

It was not working.

So I just set a 4th one :

ELASTIC\_APM\_VERIFY\_SERVER\_CERT=false

And it worked.

---

<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:** [February 18, 2019, 3:25am UTC](https://discuss.elastic.co/t/go-agent-does-not-seem-to-send-any-trace-to-apm/168610/3 "2019-02-18T03:25:24Z")

</div>

Hi @cabrinoob,

That's unusual. I would not recommend setting `ELASTIC_APM_VERIFY_SERVER_CERT`, as it will make your data susceptible to [MITM attacks](https://en.wikipedia.org/wiki/Man-in-the-middle_attack)/snooping.

I've just created a cloud deployment and confirmed that the Go agent can successfully communicate with the server without disabling certificate verification. It's probably something about your environment.

What operating system are you running? Is your app containerised? What happens if you run `curl https://0732555c72f...` from the same host as your Go application? It may be helpful to see the errors that the Go agent is experiencing, which you can log to a file by setting

```
ELASTIC_APM_LOG_FILE=<path/to/file>
ELASTIC_APM_LOG_LEVEL=debug

```

You can alternatively set `ELASTIC_APM_LOG_FILE=stderr` to send to stderr.

---

<div class="post-metadata">

**Author:** ![cabrinoob](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/cabrinoob/32/36043_2.png) [@cabrinoob](https://discuss.elastic.co/u/cabrinoob)\
**Post date:** [February 18, 2019, 8:17am UTC](https://discuss.elastic.co/t/go-agent-does-not-seem-to-send-any-trace-to-apm/168610/4 "2019-02-18T08:17:05Z")

</div>

Hi, my application is containerised and deployed on K8S.  
I activated the APM log traces and I have this error :

```
{"level":"debug","time":"2019-02-18T08:15:12Z","message":"request failed: sending request failed: Post https://0732555c72....cloud.es.io:443/intake/v2/events: x509: certificate signed by unknown authority (next request in ~0s)"}
```

---

<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:** [February 18, 2019, 8:32am UTC](https://discuss.elastic.co/t/go-agent-does-not-seem-to-send-any-trace-to-apm/168610/5 "2019-02-18T08:32:47Z")

</div>

> Hi, my application is containerised and deployed on K8S.

I suspect you need to update CA certificates in the container image. If you're using Alpine as the base image, try adding this to your Dockerfile:

```
RUN apk update && apk add ca-certificates && rm -rf /var/cache/apk/*

```

(As mentioned in [Install Certificates in Alpine Image to establish Secured Communication (SSL/TLS) | HackerNoon](https://hackernoon.com/alpine-docker-image-with-secured-communication-ssl-tls-go-restful-api-128eb6b54f1f))

---

<div class="post-metadata">

**Author:** ![cabrinoob](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/cabrinoob/32/36043_2.png) [@cabrinoob](https://discuss.elastic.co/u/cabrinoob)\
**Post date:** [February 18, 2019, 8:39am UTC](https://discuss.elastic.co/t/go-agent-does-not-seem-to-send-any-trace-to-apm/168610/6 "2019-02-18T08:39:46Z")

</div>

That works! Thank you!

---

<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:** [March 11, 2019, 4:39am UTC](https://discuss.elastic.co/t/go-agent-does-not-seem-to-send-any-trace-to-apm/168610/7 "2019-03-11T04:39:49Z")

</div>

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