-
Notifications
You must be signed in to change notification settings - Fork 63
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
Add app logging custom attributes settings #1291
Add app logging custom attributes settings #1291
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Found a few typos to fix.
Co-authored-by: Alex Hemsath <[email protected]>
Co-authored-by: Alex Hemsath <[email protected]>
Co-authored-by: Alex Hemsath <[email protected]>
Co-authored-by: Alex Hemsath <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Approved. 👍
… instrumentation (#1317) * Add app logging custom attributes settings (#1291) * Add logging custom attributes settings. * Deserialize new logging settings. * Add unit tests * Report new configs. * fix failing test. * Update src/Agent/NewRelic/Agent/Core/Config/Configuration.xsd Co-authored-by: Alex Hemsath <[email protected]> * Update src/Agent/NewRelic/Agent/Core/Config/Configuration.xsd Co-authored-by: Alex Hemsath <[email protected]> * Fix another failing test. * Update src/Agent/NewRelic/Agent/Core/Config/Configuration.xsd Co-authored-by: Alex Hemsath <[email protected]> * Update src/Agent/NewRelic/Agent/Core/Config/Configuration.xsd Co-authored-by: Alex Hemsath <[email protected]> Co-authored-by: Alex Hemsath <[email protected]> * Add context data dictionary to LogEventWireModel * Serialize ContextData from LogEventWireModel (#1299) * Serialize ContextData. * Remove redundant tests. * Update RecordLogMessage() API to take getter function for context data (#1297) * Initial implementation that builds * Working unit tests, include filtration tests * PR feedback * Logging custom attributes: attribute include/exclude filtering per the spec (#1300) * Initial implementation that builds * Working unit tests, include filtration tests * PR feedback * Implementation of filtering with wildcards and specificity order * Refactor 1. Cache rule lists 2. Better test case descriptions * Move log context data filtering to separate class * Performance improvements * More PR feedback * Test config updates, cleanup * Use trygetvalue * Add warning log message and unit test for max clusion cache size exceeded * Add custom attribute support for Serilog logging (#1302) Add custom attribute support for Serilog logging * Adds context data to forwarded log events with log4net (#1305) * capture logevent properties. * POV: Log4net custom attributes capture and integration tests. * Refactored and expand log4net ContextData tests * Updates log4net wrapper to capture context properties with tests * Fix problem with the info level test * Fixed bug in LoggingTester and in Log4netWrapper Co-authored-by: Vu Tran <[email protected]> * NLog/MEL instrumentation adds context data to log event data (#1306) * Working for string keys * Handle non-primitive value objects * Add NLog integration tests * Simplify key to string logic in wrapper * Try to ToString() before falling back to the type name * MEL context data (+3 squashed commit) Squashed commit: [2b0eb96c] WIP [8b82a6cf] WIP - crashing [f9666e6d] WIP * exclude SpanId, TraceId, and ParentId by default from context data * Run context data tests in CI * Cleanup (+1 squashed commits) Squashed commits: [ccaa306a] Cleanup (+1 squashed commits) Squashed commits: [d2ab548b] Add MEL tests * Update unit tests for new default exclude configuration * revert change as it breaks our local decoration tests (this failure is actually related to serilog's behavior, but let's not change it now) Co-authored-by: Josh Coleman <[email protected]> * Serilog context data integration tests (#1307) * Working for string keys * Handle non-primitive value objects * Add NLog integration tests * Simplify key to string logic in wrapper * Add Serilog context data integration tests * Add context data support to SerilogWeb case and test it * Add some null checks to fix failures * Update CHANGELOG.md (#1316) Co-authored-by: Vu Tran <[email protected]> Co-authored-by: Chris Hynes <[email protected]> Co-authored-by: Jacob Affinito <[email protected]> Co-authored-by: Josh Coleman <[email protected]>
If you can please show an example (with full or just small conceptual piece of code) on how to add custom attributes to logs? I can't deduct anything from changes on this PR. In Ruby it's really nice: NewRelic::Agent.add_custom_log_attributes Is there something like this? |
The .NET agent doesn't have an API for adding custom attributes to log events directly. Instead, if you add attributes/properties to the log event in your logging framework, the agent can be configured to capture those automatically. You can find details on enabling this feature on this page, about a quarter of the way down (just after the first yellow important box), It also has some information on how to include or exclude specific properties if you don't want all of them sent up. |
Thanks for the answer I am not an expert with .NET, the platform and it's setup ways, still can't understand much from the original doc. As far as I've got only "static" attributes (that are encoded in XML) can be added with this agent. I believe an example added to this conversation or the agent repo itself would be highly appreciated by anyone who wants to add custom log attributes to the .NET add hussle-free. |
Since each logging framework we support (log4net, NLog, Serilog, Microsoft.Extensions.Logging) often has many different ways to add properties it makes it difficult to add examples that are up to date and extensive enough. We recommend looking at the individual logging library's documentation for how to add properties to the messages. |
Description
Add app logging custom attributes settings.