How to customise the open telemetry for logs Provider? #3275
-
I am referring to this page https://github.com/open-telemetry/opentelemetry-dotnet/tree/main/docs/logs/customizing-the-sdk that has TODO around the customisation of the log providers. I have several of my own LogProviders made already that ALWAYS inject specific things about the application so that we can group, query and analyse by our business needs. The implementation is always specific to the product we integrating.
I can achieve the same using custom or extending the LogProvider but I am still stuck with the LogRecord that I can't really add too much to add. But its unclear how to customise the OpenTelemetryLoggerProvider So I have been looking at adding a custom log processor but its unclear how I can use DI with this. Ideally I would like to add extra attributes to LogRecord but there is northing to allow me to do this? The OpenTelemetry data model for stand alone logs suggest that there should an Attributes property I am pretty sure this is where the current States KV are being copied over to.. but how does a 1st class application add their own attributes?
Ideally I would like to add extra attributes to LogRecord but I can not see any options to do so from the above methods. So the only other place I can see how to add attributes is to dynamically set it Resource builder? This is ideal for me because I can add my attribute to everything being exported - I just need the value to be dynamic per request.
|
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 4 replies
-
Is your goal to add more attributes to logs, but without modifying the ilogger.log().. call itself? |
Beta Was this translation helpful? Give feedback.
Is your goal to add more attributes to logs, but without modifying the ilogger.log().. call itself?
Have you tried using Scopes?