Skip to content

refactor: improve telemetry api receiver listener initialization logic#2096

Open
herin049 wants to merge 1 commit intoopen-telemetry:mainfrom
herin049:refactor/improve-telemetryreceiver-listener
Open

refactor: improve telemetry api receiver listener initialization logic#2096
herin049 wants to merge 1 commit intoopen-telemetry:mainfrom
herin049:refactor/improve-telemetryreceiver-listener

Conversation

@herin049
Copy link
Contributor

Improves the Telemetry API receiver listener initialization logic to more closely match the logic used elsewhere in the layer. Updated the default behavior to listen on :0 by default to eliminate the need of manually specifying ports and eliminate the possibility of encountering Error: address already in use errors that are very rare and difficult to debug. The listener now handles shutdown properly by closing the HTTP listener, and several incorrect log statements have been updated with a few additional ones added.

@herin049 herin049 requested a review from a team as a code owner December 26, 2025 19:51
if err != nil {
return nil, "", err
}
addr := fmt.Sprintf("%s:%d", l.Addr().Network(), l.Addr().(*net.TCPAddr).Port)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like l.Addr().Network() returns the network type string "tcp". So wouldn't this produce an address like tcp:53421 instead of sandbox.localdomain:53421?

That would mean the subscribe URI passed to the Telemetry API ends up as http://tcp:53421/, which Lambda wouldn't be able to resolve to deliver events to I think?

For reference, the internal listener at internal/telemetryapi/listener.go uses the listenerAddr variable directly for this and I think a lot of the logic we already have there is directly applicable here as well.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch, this must have been a typo, or I made this change very late at night. I can update this, and add a test, since I'm surprised this managed to slip through.

Comment on lines 122 to 125
func (r *telemetryAPIReceiver) Shutdown(ctx context.Context) error {
return nil
err := r.httpServer.Shutdown(ctx)
return err
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Again looking at some "prior art" in internal/telemetryapi/listener.go it looks like just to be safe we might want to also nil check r.httpServer here before calling the Shutdown method on it?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants