-
Notifications
You must be signed in to change notification settings - Fork 0
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
feat: Create Logs SDK LoggerProvider #2
Conversation
if @stopped | ||
OpenTelemetry.logger.warn('LoggerProvider#shutdown called multiple times.') | ||
return OpenTelemetry::SDK::Logs::Export::FAILURE | ||
end |
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.
The code for LoggerProvider#shutdown
and LoggerProvider#force_flush
are drawn mainly from TracerProvider
methods of the same names.
Why does #shutdown
return a failure status code if called when @stopped
is true, but #force_flush
returns a success status code?
JS, for example, does similar things for both #force_flush
and #shutdown
.
The specs on #force_flush
(very similar for Logs and Traces), don't describe the desired behavior in cases where the method is called, but the provider has stopped/shutdown.
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.
Also, the spec states:
After the call to Shutdown, subsequent attempts to get a Logger are not allowed. SDKs SHOULD return a valid no-op Logger for these calls, if possible.
Source
This is also true for TracerProvider#shutdown
(source). Should I update this code in the Logs SDK to return OpenTelemetry::Logs::LoggerProvider::NOOP_LOGGER
? If so, should action be taken on the Trace SDK?
I think we should keep the Logs SDK and the Trace SDK as similar as possible. Some things like this might be better handled as issues to tackle in both libraries after the initial implementation. I'm open to keeping things in sync for now and making dual changes later on.
rescue StandardError => e | ||
OpenTelemetry.handle_error(exception: e, message: FORCE_FLUSH_ERROR) | ||
Export::FAILURE | ||
end |
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.
There is not a rescue
in the TracerProvider#force_flush method, but the method documentation states "Export::FAILURE
should be returned if a non-specific failure occurred." I'm assuming a non-specific failure would be any StandardError
instance.
- Is there a condition to return
Export::FAILURE
on non-specific errors inTracerProvider#force_flush
that I'm missing? - Similar documentation exists for the
LoggerProvider
/TracerProvider#shutdown
methods. If we choose to add arescue
here, should the#shutdown
methods also have a similarrescue
?
# LogRecordProcessor to add. | ||
def add_log_record_processor(log_record_processor) | ||
@mutex.synchronize do | ||
@log_record_processors = @log_record_processors.dup.push(log_record_processor) |
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.
This is copied from TracerProvider#add_span_processor
. @fallwith and I were chatting about this LOC. He was asking about the use of .dup.push
here.
Does dup.push
provide atomicity in a way that the push
method alone couldn't deliver? Or is there a different reason dup.push
was used?
Closed in favor of otel-ruby 1517 |
Fulfills the Logs SDK specs for Logger Provider
The Logger Provider has a lot of similarities with the already implemented Tracer Provider, as they have very similar specs.