Skip to content

Add dynamic custom attributes to Log #1275

Open
@mbyrne00

Description

@mbyrne00

Is your feature request related to a problem? Please describe.

I cannot add request-contextual data to my log entries.

Feature Description

I want to include per-request information to each log entry so that I do not have to rely explicitly on Transaction. As per the Same feature in the ruby agent something simple like newrelic.agent. add_custom_log_attributes() and newrelic.agent. add_custom_log_attribute() equivalents to the existing add_custom_attribute() and add_custom_attributes() functions for Transactions. Alternatively a setting to allow transaction custom attributes to propagate to logs.

I would like to set this in my FastAPI @app.middleware("http") function much like I have been doing for add_custom_attributes() and hoping they would appear in log entries.

The direct contextual information is available in Splunk on legacy apps and we would like to rely less on that.

Alternatives

Maybe the Ruby feature isn't supporting dynamic attributes after reading this back a bit. If the logging does not manage a lifecycle like transactions do then it would be great if there was a guide for how to dynamically add attributes to certain logs with python logging and the newrelic-admin run-program agent running in our Dockerfile. is there a way to omit json logging via our app and have the outer agent understand this? Is there any other hooks? Do we have to revert to forwarding all logs manually if that's not the case and is there a guide on how to do this beginning to end with custom attributes? Or is this why Transactions exist?

I figured there must be a way if there are various contextual logging context vars optionally flushed through.

Priority

Really want

I've searched, cloned this repo and reversed-engineered, but I'm pretty sure this feature does not exist. Very happy to be corrected if it does exist.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions