-
Notifications
You must be signed in to change notification settings - Fork 325
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
set service name & version in ecs-logging #3064
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.name
service.version
For now
service.environment
is 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.version
is only supported in1.4.0
and later, thus it requires dedicated instrumentation and testsI decided to simplify the instrumentation groups to a singlelogging-ecs
(in addition to the existinglogging
group), 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:
logging
added to all log-related instrumentations<framework>-correlation
to enable log-correlation, examples includejul-correlation
,log4j1-correlation
,log4j2-correlation
, ...<framework>-ecs
for ecs-reformatting, examples includelog4j1-ecs
,log4j2-ecs
, ...<framework>-ecs
to set service correlation fields (name, version and soon environment)<framework>-error
for error capture, examples includeslf4j-error
This currently produces the current list of instrumentation groups:
jboss-logging-correlation
jul-ecs
jul-error
log4j1-correlation
log4j1-ecs
log4j1-error
log4j2-correlation
log4j2-ecs
log4j2-error
logback-correlation
logback-ecs
logging
logging-ecs
slf4j-error
tomcat-ecs
This 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
log4j1
orlog4j2
should definitely be quite rare.I would suggest to simplify by using the following instrumentation groups by removing the framework and focus on features:
logging
for all log-related instrumentations (as it currently is)log-correlation
: log-correlationlog-ecs
: log-reformatting to ECS (or rename it tolog-reformatting
to 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-correlation
as it allows to correlate logs.Checklist
Added an API method or config option? Document in which version this will be introduced