Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

capture_headers option ignored with remote agent cfg #1427

Open
kruskall opened this issue May 4, 2023 · 0 comments
Open

capture_headers option ignored with remote agent cfg #1427

kruskall opened this issue May 4, 2023 · 0 comments
Labels

Comments

@kruskall
Copy link
Member

kruskall commented May 4, 2023

Describe the bug
While testing elastic/apm-server#10467 an issue was discovered in which the go agent was ignoring the capture_headers option. The test was carried out with a test application and and Elastic Agent managed APM Server (without fleet).

app:

package main

import (
	"fmt"
	"net/http"

	"golang.org/x/net/context/ctxhttp"

	"go.elastic.co/apm/module/apmhttp/v2"
	"go.elastic.co/apm/v2"
)

var tracingClient = apmhttp.WrapClient(http.DefaultClient)

func serverHandler(w http.ResponseWriter, req *http.Request) {
	resp, err := ctxhttp.Get(req.Context(), tracingClient, "http://example.com")
	if err != nil {
		apm.CaptureError(req.Context(), err).Send()
		http.Error(w, "failed to query backend", 500)
		return
	}
	defer resp.Body.Close()
	fmt.Println(resp.Status)
}

func main() {
	http.ListenAndServe(":8080", apmhttp.Wrap(http.HandlerFunc(serverHandler)))
}

To Reproduce
Steps to reproduce the behavior:

  1. Create an EA managed APM Server (you might want to reduce the agent config cache)
  2. Run the example app: ELASTIC_APM_LOG_FILE=out.log ELASTIC_APM_LOG_LEVEL=debug ELASTIC_APM_SERVER_URL=<apm_server_url> ELASTIC_APM_SECRET_TOKEN=<token> go run main.go
  3. Send a request to localhost:8080
  4. Make sure the agent is working and you can see APM data in kibana
  5. Update the agent settings in kibana to enable capture headers
  6. Send a request to localhost:8080
  7. stop the example app
  8. open out.log and look at the warning:
{"level":"debug","message":"central config update: updated capture_body to all"}
{"level":"warning","message":"central config failure: unsupported config: capture_headers"}
{"level":"debug","message":"central config update: updated log_level to debug"}

Expected behavior
A clear and concise description of what you expected to happen.

No warning

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant