Skip to content

chore: make agent data port configurable independently from the agent connection port#2559

Open
abhilash-sivan wants to merge 1 commit into
mainfrom
fix-customizable-agent-data-port
Open

chore: make agent data port configurable independently from the agent connection port#2559
abhilash-sivan wants to merge 1 commit into
mainfrom
fix-customizable-agent-data-port

Conversation

@abhilash-sivan
Copy link
Copy Markdown
Contributor

This PR prepares the codebase for independently configurable agent ports, allowing a separate port to be used for sending telemetry data such as traces and metrics.

This addresses the dual-port setup use case where the agent connection and announce cycle continue to use the default agent port, while telemetry data is sent to a separately configured OTLP endpoint.

{
host: agentOpts.host,
port: agentOpts.port,
port: agentOpts.dataPort,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

If the customer sets AGENT_PORT, we will ignore the port or?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

We will continue using the customer-configured agent port for operations such as announcements and agent readiness checks etc.

For sending telemetry data, we will use a separate data port, which will be selected based on whether OTLP is enabled via configuration (yet to implement).

If the customer configures AGENT_PORT and OTLP is not enabled, then the same port will also be used for sending data.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Oki makes sense

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I have a question: if the customer has configured an agent port and enabled OTLP, what will be the data port?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

In this case, we will use the OTLP port as the data port because we will start communicating using OTLP, and currently only the dedicated OTLP ports can listen to and understand the OTLP format. So, we will use port 4318.

* @param {{ agentPort: number }} defaultConfig
* @returns {number}
*/
function normalizeAgentDataPort(userConfig, defaultConfig) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This method is same as normalizeAgentPort, is this intentional or is there something missing?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yes, this is currenlty same logic, but in future we will add logic for port switching here

// Future logic for OTLP enabled check can be added here to determine which port to use

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Could we simplify this by delegating to normalizeAgentPort when OTLP is not enabled?

if (userConfig.otlpEnabled) {
  return defaultConfig.otlpPort; // 4317 or 4318
}

return normalizeAgentPort(userConfig, defaults);

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yeah, this seems a clean approach.
But currently we don't have the logic

if (userConfig.otlpEnabled) {
return defaultConfig.otlpPort; // 4317 or 4318
}

so this will just return the normalizeAgentPort()

Also what if we allow the customers to configure data ports separately (in future). we can discuss this tomorrow

@abhilash-sivan abhilash-sivan marked this pull request as ready for review May 25, 2026 12:19
@abhilash-sivan abhilash-sivan requested a review from a team as a code owner May 25, 2026 12:19
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.

3 participants