Your data. Anywhere you go.

New Relic for iOS or Android


Download on the App Store    Android App on Google play


New Relic Insights App for iOS


Download on the App Store


Learn more

Close icon

External Segment not reported

golang
http-requests
go-agent

#1

Hello,

Long time NewRelic user here. I’ve got mainly experience with the Ruby agent and the Rails integration.

Now I’m using the Go agent version 1.11.0 in my Go application. The stack is gin-gonic/gin for the HTTP handler, gocraft/work for background processing, plus a few manually picked packages for the rest.

I’ve already integrated the agent with the application, and I can correctly report web and background transaction to NewRelic and inspect them in the application dashboard. Both throughput (web and background) and transaction breakdown are reported correctly. I’ve also got request queuing reporting working correctly.

I can’t, however, get External Segments to work. Normal Segments are fine. I can instrument functions and see the breakdown in the transaction details, but not for External segments. I’ve tried to instrument External Segments with both web and background transactions, and the result is the same.

My code, simplified (no error checking):

func exampleRequest(client *http.Client, txn newrelic.Transaction) *http.Response {
	req, err := http.NewRequest("GET", "https://foo.bar/baz/42", nil)

	segment := newrelic.StartExternalSegment(txn, req)

	resp, err := client.Do(req)

	segment.Response = resp
	segment.End()

	return resp
}

There, txn is defined and not null, and https://foo.bar is another non-go service also monitored with NewRelic under the same account.

The requests are executed correctly, and the correct data is returned. Synthetic tests show that the transaction is reported as taking longer than transactions with no HTTP requests, meaning that the time spent is being recorded, but there is no trace of the External Segment in the UI.

I cannot see:

  • anything in the “External Services” tab,
  • any green “web external” area in the Overview tab,
  • any trace of the External Segment in the transaction breakdown table (or colored graphs)

As an experiment, I’ve also tried to instrument it with a normal segment (one new defer statement at the beginning of the function):

func exampleRequest(client *http.Client, txn newrelic.Transaction) *http.Response {
	defer newrelic.StartSegment(txn, "outgoing HTTP request").End()

	req, err := http.NewRequest("GET", "https://foo.bar/baz/42", nil)

	segment := newrelic.StartExternalSegment(txn, req)

	resp, err := client.Do(req)

	segment.Response = resp
	segment.End()

	return resp
}

The result is that the outgoing HTTP request segment gets reported, but it’s too fast. Its reported time is always around 0.02ms, while the transaction is reported as taking 100ms, and I know for a fact that most of that time is spent executing the HTTP request.

Is there anything wrong with the code? Is there anything obvious I’ve missed?

Thanks.


#2

Hey @tomp_r! I see you are working with our Support And Software Engineers on this as well: any progress you want to share so far? Your experience will definitely help others in our community. Let us know what else you need—eager to see you get a solution here! :blush:


#3

Any update or solution?
I’m having the same issue, trying to see external services information when doing requests from a Go service using version 2.0 to Ruby service version 5.2

When downgrading Go agent to version 1.9, the requests are shown correctly.

Thanks in advance.


#4

Hi, I haven’t tried with version 1.9 of the Go agent, just 1.11 (as mentioned in the initial post) and then 2.0. The problem persisted.

In the end the support engineers suggested to try the “manual” way to create an external segment, the one that the docs say it’s going to be deprecated. That worked.

For clarity, it’s the one listed as “number 3”, here. I hope that helps.

@Linds, if 1.9 works, that’s possibly something you want to pass to your engineers.


#5

Hey @tomp_r -

Thank you so much for coming back to share your experience here to round out the conversation. We will follow up with the engineers on this as well!