Can you add an attribute to all LogRecords? #7122
-
|
When setting up OTel in .NET, you can add custom attributes to the Resource via two methods:
Both of these approaches add the custom attributes to the resource for ALL signals that are exported. I am wondering if there is a built-in way to do something similar with attributes on ALL LogRecords for logging signals? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
|
Resources are associated with Logs,Metrics and Traces, so by default they are applied to all 3 of them. But it is entirely possible to construct the providers separately, and have each of them associate with different Resources. But that sounds unnecessary to me as Resource is associated with Logs only in OTel - they are not treated as Attributes in LogRecords - such tasks are done typically at backend only, so most likely the solution is to apply Resource attributes selectively in the backend. |
Beta Was this translation helpful? Give feedback.
if the goal is to add a static attribute to every log record, then best option is to add a LogRecordProcessor to the front of the processor chain, and add the attribute using this processor.