open-telemetry / opentelemetry-java-instrumentation

OpenTelemetry auto-instrumentation and instrumentation libraries for Java
https://opentelemetry.io
Apache License 2.0
1.88k stars 823 forks source link

logback %L can map to OTLP model attributes #6263

Closed tuyula closed 1 year ago

tuyula commented 2 years ago

Is your feature request related to a problem? Please describe. we want view logs by this %d{yyyy-MM-dd HH:mm:ss.SSS} %-5level [%thread] [%logger:%L] %msg%n but i dont know how to get %L which mean code num in otlp model

Describe the solution you'd like map %L to otlp attributes so that i can view in es

mateuszrzeszutek commented 2 years ago

Hey @tuyula , Can you explain more about your use case? What kind of attributes do you want included in the log statements? %L means line number in log4j AFAIR, I don't understand how it's related to OpenTelemetry.

tuyula commented 2 years ago

we use java-agent export logging=otlp to collector

our company logs pattern like: 10:29:44 [http-nio-8080-exec-3] INFO com.observable.trace.otel.controller.SpanController:27 [traceId=54ce397c1b94affeae68e063e62608a7 spanId=afa2ea8e73f5c135] hello world

however, otlp logs like collector_1 | InstrumentationScope com.observable.trace.otel.controller.SpanController collector_1 | LogRecord #0 collector_1 | ObservedTimestamp: 1970-01-01 00:00:00 +0000 UTC collector_1 | Timestamp: 2022-07-06 02:29:44.492 +0000 UTC collector_1 | Severity: INFO collector_1 | Body: enter index / collector_1 | Trace ID: 54ce397c1b94affeae68e063e62608a7 collector_1 | Span ID: afa2ea8e73f5c135 collector_1 | Flags: 1

but, we also want collector %L by java-agent, then we cant view line number in our logs system

tuyula commented 2 years ago
image

just like zap "caller", i want log4j have the same propery

trask commented 1 year ago

hi @tuyula! this is now possible using -Dotel.instrumentation.logback-appender.experimental.capture-code-attributes=true, check out:

https://github.com/open-telemetry/opentelemetry-java-instrumentation/tree/main/instrumentation/logback/logback-appender-1.0/javaagent#settings-for-the-logback-appender-instrumentation

github-actions[bot] commented 1 year ago

This has been automatically marked as stale because it has been marked as needing author feedback and has not had any activity for 7 days. It will be closed automatically if there is no response from the author within 7 additional days from this comment.