Apm-agent-go/echo not catch custom span

Hi everyone,

I am trying to configure APM agent on top of echo webframework. Everything is working, transaction, PostgreSQL span, etc..

but when tried to create a custom span, its not working
here's how I tried to achieve it

func blocker(c echo.Context) {
	span, _ := apm.StartSpan(c.Request().Context(), "work", "custom")
	defer span.End()

	fmt.Printf("=====================\nACTION=%s, span.Name=%s, span.Outcome=%s, span.Type=%s \n====================",
		span.Action, span.Name, span.Outcome, span.Type)

	time.Sleep(3000 * time.Millisecond)
}

and every value in the log is empty. What did I do wrong?

Hi @ggalihpp-jubelio, welcome to the forum!

Can you share which packages you're importing for apmecho and apm? This is a bit of a wild guess, but I'm wondering if you're mixing v1 and v2 package paths. If that were the case, then apm.StartSpan will not find the transaction in the context, and the returned span will be a no-op span.

Hi @axw sorry for this late response

YES! that's why... I dumbly import "go.elastic.co/apm" while using "go.elastic.co/apm/module/apmechov4/v2"

Thank you so much!

1 Like

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