-
Notifications
You must be signed in to change notification settings - Fork 326
set service name & version in ecs-logging #3064
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
Conversation
|
/test |
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.
Clean and nicely understandable solution!
...s/apm-ecs-logging-plugin/src/main/java/co/elastic/apm/agent/ecs_logging/EcsLoggingUtils.java
Outdated
Show resolved
Hide resolved
...in/src/main/java/co/elastic/apm/agent/ecs_logging/log4j1/Log4jEcsServiceInstrumentation.java
Outdated
Show resolved
Hide resolved
Sounds very reasonable to me. As you said, it is very unlikely that two logging frameworks are used within the same JVM (except JUL + other maybe) and it's even more unlikely that users would want to disable a feature for one framework but no the other. I would suggest you go with the groups you proposed and mention it as "Potentially breaking change" in the changelog. |
fd7db68 to
49717f6
Compare
Fixes #1626
What does this PR do?
When ECS logging library is used, the agent should provide fallback values if not explicitly set for the following fields
service.nameservice.versionFor now
service.environmentis not covered and will be handled as a follow-up PR with #3051 .This behavior is described in more detail in agent specification for log correlation.
The code is a bit verbose and repetitive due to covering the following
service.versionis only supported in1.4.0and later, thus it requires dedicated instrumentation and testsI decided to simplify the instrumentation groups to a singlelogging-ecs(in addition to the existinglogginggroup), as there is usually at most one logging library involved in a given application and there is very little risk to break anything here (so disabling is even less likely to be used). This could be added to the changelog as a "potentially breaking change" in the case where some existing users relied on the value that was used previously (log4j2-ecs).Update: added as a discussion item to agree on.
Instrumentation group names (to be discussed during review)
This could definitely be handled in a separate PR/issue if needed.
For log-related instrumentations we have the following instrumentation groups:
loggingadded to all log-related instrumentations<framework>-correlationto enable log-correlation, examples includejul-correlation,log4j1-correlation,log4j2-correlation, ...<framework>-ecsfor ecs-reformatting, examples includelog4j1-ecs,log4j2-ecs, ...<framework>-ecsto set service correlation fields (name, version and soon environment)<framework>-errorfor error capture, examples includeslf4j-errorThis currently produces the current list of instrumentation groups:
jboss-logging-correlationjul-ecsjul-errorlog4j1-correlationlog4j1-ecslog4j1-errorlog4j2-correlationlog4j2-ecslog4j2-errorlogback-correlationlogback-ecslogginglogging-ecsslf4j-errortomcat-ecsThis list is quite long and naming is a bit confusing to link to features, also there is very rarely multiple distinct log frameworks used in the same application, so the need to fine-tune instrumentation of
log4j1orlog4j2should definitely be quite rare.I would suggest to simplify by using the following instrumentation groups by removing the framework and focus on features:
loggingfor all log-related instrumentations (as it currently is)log-correlation: log-correlationlog-ecs: log-reformatting to ECS (or rename it tolog-reformattingto remove he ECS implementation detail).log-error: error captureAlso, making the agent provide a value for service name and version (and soon environment) should be part of
log-correlationas it allows to correlate logs.Checklist
Added an API method or config option? Document in which version this will be introduced