Skip to content
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

Closed
wants to merge 15 commits into from

Conversation

kaylareopelle
Copy link
Owner

@kaylareopelle kaylareopelle commented Aug 16, 2023

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.

@kaylareopelle kaylareopelle changed the title Logger provider sdk Logs SDK - Logger Provider Aug 16, 2023
@kaylareopelle kaylareopelle changed the title Logs SDK - Logger Provider feat: Create Logs SDK LoggerProvider Aug 21, 2023
Comment on lines +78 to +81
if @stopped
OpenTelemetry.logger.warn('LoggerProvider#shutdown called multiple times.')
return OpenTelemetry::SDK::Logs::Export::FAILURE
end
Copy link
Owner Author

@kaylareopelle kaylareopelle Aug 22, 2023

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.

Copy link
Owner Author

@kaylareopelle kaylareopelle Aug 22, 2023

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.

Comment on lines +122 to +125
rescue StandardError => e
OpenTelemetry.handle_error(exception: e, message: FORCE_FLUSH_ERROR)
Export::FAILURE
end
Copy link
Owner Author

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 in TracerProvider#force_flush that I'm missing?
  • Similar documentation exists for the LoggerProvider/TracerProvider#shutdown methods. If we choose to add a rescue here, should the #shutdown methods also have a similar rescue?

# 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)
Copy link
Owner Author

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?

@kaylareopelle
Copy link
Owner Author

Closed in favor of otel-ruby 1517

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant