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

feat(agent): Adds label forwarding to log events #1027

Open
wants to merge 46 commits into
base: dev
Choose a base branch
from

Conversation

mfulb
Copy link
Contributor

@mfulb mfulb commented Feb 20, 2025

This PR adds the ability for labels to be forwarded with any log messages forwarded by the PHP agent.

@newrelic-php-agent-bot
Copy link

newrelic-php-agent-bot commented Feb 20, 2025

Test Suite Status Result
Multiverse 0/8 passing
SOAK 75/79 passing

@mfulb mfulb changed the base branch from main to dev February 20, 2025 21:25
@codecov-commenter
Copy link

codecov-commenter commented Feb 24, 2025

Codecov Report

Attention: Patch coverage is 97.26027% with 2 lines in your changes missing coverage. Please review.

Project coverage is 77.63%. Comparing base (11b67fa) to head (df096d7).
Report is 1 commits behind head on dev.

Files with missing lines Patch % Lines
agent/php_txn.c 98.14% 1 Missing ⚠️
axiom/cmd_txndata_transmit.c 92.30% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##              dev    #1027      +/-   ##
==========================================
+ Coverage   77.58%   77.63%   +0.05%     
==========================================
  Files         198      198              
  Lines       27715    27786      +71     
==========================================
+ Hits        21503    21573      +70     
- Misses       6212     6213       +1     
Flag Coverage Δ
agent-for-php-7.2 77.78% <97.26%> (+0.05%) ⬆️
agent-for-php-7.3 77.80% <97.26%> (+0.05%) ⬆️
agent-for-php-7.4 77.51% <97.26%> (+0.05%) ⬆️
agent-for-php-8.0 76.90% <97.26%> (+0.05%) ⬆️
agent-for-php-8.1 77.40% <97.26%> (+0.05%) ⬆️
agent-for-php-8.2 77.01% <97.26%> (+0.05%) ⬆️
agent-for-php-8.3 77.01% <97.26%> (+0.05%) ⬆️
agent-for-php-8.4 77.03% <97.26%> (+0.05%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@mfulb mfulb marked this pull request as ready for review February 25, 2025 15:29
mfulb added 24 commits February 25, 2025 10:47
The function nr_txn_begin() now accepts a nrobj_t *log_labels
parameter which contains the logging labels to be associated
with log events.
mfulb added 22 commits February 25, 2025 10:47
- added PHP5 tests - these are not for PHP 5 but are intended
  to run on PHP5+!
nrl_debug(NRL_INIT, "unable to begin transaction: app '%.128s' is unknown",
appnames ? appnames : "");
return NR_FAILURE;
}

attribute_config = nr_php_create_attribute_config(TSRMLS_C);
NRPRG(txn) = nr_txn_begin(NRPRG(app), &opts, attribute_config);
log_forwarding_labels
= nr_php_txn_get_log_forwarding_labels(NRPRG(app)->info.labels);
Copy link
Contributor

@zsistla zsistla Feb 25, 2025

Choose a reason for hiding this comment

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

Why not just have log_forwarding_labels be part of NRPRG(app)->info? Why does it need to be passed separately?

It could just be added as a var here: https://github.com/newrelic/newrelic-php-agent/pull/1027/files#diff-f5f8c5da8db458c336e8505b331bcb42a571175d89cdd0e65fbc39c1121a5960L881

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I considered that but it would be odd to put it in "appinfo" but send it to the daemon in the "transaction" payload. Also I believe the information needed to make the filtered log labels list is not available when "appinfo" is initialized.

@mfulb mfulb force-pushed the feat/apm_logging_labels branch from bc18e12 to df096d7 Compare February 25, 2025 18:06
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