Skip to content

feat: report integration errors #187

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

Draft
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

dmehala
Copy link
Contributor

@dmehala dmehala commented Mar 31, 2025

Resolves AIDM-394

@dmehala dmehala marked this pull request as ready for review April 1, 2025 16:26
@dmehala dmehala requested a review from a team as a code owner April 1, 2025 16:26
Copy link
Collaborator

@pablomartinezbernardo pablomartinezbernardo left a comment

Choose a reason for hiding this comment

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

Do you know why tests might be failing?

@dmehala dmehala force-pushed the dmehala/send-integration-errors branch from 3b9d7d1 to eeeef60 Compare April 3, 2025 21:42
@cataphract
Copy link
Contributor

On amazonlinux:2.0.20230418.0 there's a failure:

AssertionError: 1 != 0 : ['nginx: [emerg] dlopen() "/datadog-tests/ngx_http_datadog_module.so" failed (/datadog-tests/ngx_http_datadog_module.so: undefined symbol: memfd_create) in /tmp/fastcgi_auto.conf:5', 'nginx: configuration file /tmp/fastcgi_auto.conf test failed', '']

memfd_create was added in glibc 2.27 (and linux 3.17), but that image uses 2.26... You'll need to either provide the function (using syscall) (see a table with the number for amd64/arm64) or remove that call.

@dmehala
Copy link
Contributor Author

dmehala commented Apr 7, 2025

Thank you @cataphract , I'll need to provide the function because it's part of a new feature relying on memfd.

@@ -53,7 +54,8 @@ ngx_int_t on_enter_block(ngx_http_request_t *request) noexcept try {
} else {
try {
context->on_change_block(request, core_loc_conf, loc_conf);
} catch (...) {
} catch (const std::exception &e) {
telemetry::report_error_log(e.what(), CURRENT_FRAME(request));
Copy link
Contributor

Choose a reason for hiding this comment

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

Using directly e.what() are we sure we are not taking any risks or leaking PII ?

Copy link
Contributor Author

@dmehala dmehala Apr 8, 2025

Choose a reason for hiding this comment

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

In the entire codebase, exceptions can only be thrown by our integrations or dependencies we use. Unless we throw exceptions with PIIs, which we don't at the moment, I believe we are ok. Follow up question, how do you handle PIIs for other languages?

Copy link
Contributor

Choose a reason for hiding this comment

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

PHP is in the same case as you so we are not handling them (and I will have to check this is safe).
In python i'm ensuring the log message is constant.

If you know that we are not throwing exceptions with PIIs we don't have to make any changes.

std::string_view file, size_t line,
std::string_view function) {
// clang-format off
return std::format("Exception catched:\n"
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
return std::format("Exception catched:\n"
return std::format("Exception caught:\n"

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That's an interesting one. catched is actually valid English and commonly used before 19th century, which is when caught started to replaced it.

Copy link
Contributor

Choose a reason for hiding this comment

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

Oh, so every time I said catched I was not making any mistake. Nice to know haha

constexpr std::string_view prefix = "nginx-datadog";
size_t pos = absolute_filepath.find(prefix);
return pos != std::string_view::npos ? absolute_filepath.substr(pos)
: absolute_filepath;
Copy link
Contributor

@dubloom dubloom Apr 8, 2025

Choose a reason for hiding this comment

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

The problem with this method is, if nginx-datadog is not in the string (which I agree with you should not happen), we will leak the full_path, can we add a safe guard please ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Could you clarify what the potential risks are of exposing the full path? (which is highly improbable unless the repo change name or the ci building the project is cloning the repo under another name). Also, could you elaborate on what you mean by safeguard? Do you have any suggestions or proposals in mind?

Copy link
Contributor

@dubloom dubloom Apr 8, 2025

Choose a reason for hiding this comment

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

For instance, i have my name.surname in my full_path, which is PII. In PHP, I did this:
https://github.com/DataDog/dd-trace-php/blob/0e702530af821f358ccd1dbdecd9535728eed459/ext/telemetry.c#L50

I agree that is a bit overkill and I could accept to not include that but it does not add runtime overhead so I think "prevention is better than cure" is the way to go.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Interesting 🤔 Make sense. I'll adjust the method to return only the name of the file instead of the full path. Thanks for raising your concerns.

@dmehala dmehala marked this pull request as draft April 15, 2025 12:33
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.

4 participants