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

Enable UDS settings #233

Merged
merged 3 commits into from
Mar 23, 2023
Merged

Enable UDS settings #233

merged 3 commits into from
Mar 23, 2023

Conversation

r1viollet
Copy link
Collaborator

@r1viollet r1viollet commented Mar 23, 2023

What does this PR do?

Ensure UDS settings are allowed by the exporter

Motivation

Allow usage of UDS.
#232

Testing

Testing is ongoing

Ensure UDS settings are allowed by the exporter
Parameter is now written directly to the exporter.
@r1viollet r1viollet marked this pull request as ready for review March 23, 2023 14:16
@@ -91,20 +115,43 @@ DDRes ddprof_exporter_init(const ExporterInput *exporter_input,
}

if (exporter->_agent) {
exporter->_url =
alloc_url_agent("http://", exporter_input->host, exporter_input->port);
const char *port_str = exporter_input->port;
Copy link
Collaborator

@nsavoire nsavoire Mar 23, 2023

Choose a reason for hiding this comment

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

This should be probably be extracted to its own function.
I would simplify the logic by stopping mixing url and port:

  • either a url is given in input, in that case it's expected to be a full url (with protocol and port). In this case host and port are just ignored.
  • either no url is given in input and url is built from 'http', host and port.

That way you can even stop distinguishing between agent and agentless.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This is a good idea, though we would need to check if endpoint is reachable on startup,
Adding this permissive config might be bad for reverting it later.

Copy link
Collaborator

@nsavoire nsavoire Mar 24, 2023

Choose a reason for hiding this comment

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

Not sure to understand, why would this be permissive ?

Copy link
Collaborator

@sanchda sanchda left a comment

Choose a reason for hiding this comment

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

I think this looks good. At some point we should probably change the input stuff to using std::string or something instead of raw C strings, but I don't think this is really the time or the place for that. :)

Good stuff! Thank you! UDS support may not improve performance substantially, since we use async, but it's still a configuration users will want!

XX(DD_TRACE_AGENT_PORT, port, P, 'P', 1, input, NULL, "8126", exp_input.) \
XX(DD_TRACE_AGENT_URL, url, U, 'U', 1, input, NULL, "", ) \
XX(DD_TRACE_AGENT_URL, url, U, 'U', 1, input, NULL, "", exp_input.) \
Copy link
Collaborator

Choose a reason for hiding this comment

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

Ah, makes sense to move this 👍

if (!strncasecmp(exporter_input->url, "unix", 4)) {
port_str = nullptr;
}
// already port -> no port
Copy link
Collaborator

Choose a reason for hiding this comment

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

yup, agreed

res = ddprof_exporter_init(&exporter_input, &exporter);
EXPECT_TRUE(IsDDResOK(res));
EXPECT_EQ(strcmp(exporter._url, "25.04.1988.0"), 0);
EXPECT_EQ(strcmp(exporter._url, "http://25.04.1988.0:1234"), 0);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Considering that the previous test uses a hostname without an explicit protocol, I think it's fine to convert this to a protocol-bearing statement.

@@ -73,6 +82,21 @@ static DDRes write_pprof_file(const ddog_EncodedProfile *encoded_profile,
return {};
}

bool contains_port(const char *url) {
const char *port_ptr = strrchr(url, ':');
Copy link
Collaborator

Choose a reason for hiding this comment

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

Making a completely irrelevant comment.

Strictly speaking, I don't know whether strrchr() can be used for this purpose, but I don't think it matters for us in any substantial way. Currently we don't allow users to specify a resource as part of the URI, so : would only be valid to tokenize the port.

@r1viollet
Copy link
Collaborator Author

Merging as is for now, I agree there should be a follow up on this.
The way to configure this is not really explicit as of now. The documentation needs some love. FYI:

unix:///run/apm.sock

@r1viollet r1viollet merged commit 639da62 into main Mar 23, 2023
@r1viollet r1viollet deleted the r1viollet/enable_uds branch March 23, 2023 21:18
r1viollet added a commit that referenced this pull request May 17, 2023
* Enable UDS settings
Ensure UDS settings are allowed by the exporter
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