Comments (6)
Could you provide how you do the otel initialization that set the custom logger (e.g. OpenTelemetry::SDK.configure )?
Have you tried following config to set the custom logger?
OpenTelemetry::SDK.configure do |c|
c.logger = ::Logger.new($stdout, level: <the_level_you_want>) # or any custom logger with ::Logger.new
c.use_all()
end
from opentelemetry-ruby.
Opentelemetry::SDK.configure do |conf|
conf.logger = Rails.logger
end
But I beleive that doesn't really matter since I can see that we always pass a nil
as a message to a logger, and the message itself is passed in progname
attribute.
So, yes, ActiveSupport::Logger
manages it, and, I guess, some others do it too, and I can definitely patch my logger to be capable to manage it, but the logic in code itself seems a little odd to me.
from opentelemetry-ruby.
Looking at the Ruby logger source, it also passes a nil message from the info
method to the add
method, with source pretty much identical to the source in ForwardingLogger. However, the Ruby logger's add
method treats a nil
message as an excuse to call the block to construct the message, or reuses the progname parameter as a message if no block is passed.
So the bug is the ForwardingLogger add
method not passing through the block to the logger it's forwarding to. Without that, the normal block fallback behavior doesn't work.
from opentelemetry-ruby.
@BrianHawley thanks for the finding. I did little test and I believe you are correct on "ForwardingLogger add method not passing through the block to the logger it's forwarding to".
Would you mind to contribute a PR to amend this?
from opentelemetry-ruby.
@ngoral I fixed ForwardingLogger's add
method to forward the block parameter. You should fix your custom logger's add
method to use the same parameter handling tricks as Ruby's Logger class:
if progname.nil?
progname = @progname
end
if message.nil?
if block_given?
message = yield
else
message = progname
progname = @progname
end
end
You might prefer to just derive your custom logger from Ruby's Logger class, then change where you're logging to or the formatter. Up to you.
from opentelemetry-ruby.
This seems to also be busted when using Ougai
as the logger.
Current workaround is OpenTelemetry.logger = Rails.logger
from opentelemetry-ruby.
Related Issues (20)
- Attribute limits should discard from the end
- `OTEL_RESOURCE_ATTRIBUTES` parsing has whitespace in keys HOT 3
- Enhancement Request: Lazy Evaluation of Attributes for OpenTelemetry Spans HOT 3
- Support YARD's experimental type parser by removing "optional" from type descriptions HOT 1
- Add :cumulative aggregation_temporality to metrics aggregators HOT 1
- Fix TruffleRuby install failures on tests HOT 1
- Add CSV as a dependency of Zipkin exporter HOT 3
- Push `opentelemetry-exporter-otlp-grpc` gem to ruby gems HOT 3
- OpenTelemetry OTLP GRPC Exporter HOT 1
- Adding backtraces to error logs HOT 2
- Release PR #1593 failed with errors HOT 1
- Not able to capture traces for ruby on rails service with rails version 4.2.8. HOT 1
- Runtime exceptions from auto-instrumentation code HOT 2
- How to set the traces data limit? HOT 2
- Release PR #1618 failed with errors HOT 1
- `ArgumentError` thrown from auto-instrumentation code when running Datadog in parallel HOT 3
- Create configuration-specific doc HOT 1
- Enhance the thread management in periodic metric reader HOT 1
- Zipkin exporter receiving 400 from Open Telemetry Collector HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from opentelemetry-ruby.