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: Update Logger#on_emit to create LogRecords #1611
base: main
Are you sure you want to change the base?
feat: Update Logger#on_emit to create LogRecords #1611
Conversation
Co-authored-by: James Bunch <fallwith@gmail.com>
👋 This pull request has been marked as stale because it has been open with no activity. You can: comment on the issue or remove the stale label to hold stale off for a while, add the |
Previously, trace_id, span_id, and trace_flags were assigned based on the OpenTelemetry::Trace.current_span's SpanContext. The specification requires a context be accepted as an argument on emit. If no context is provided, OpenTelemetry::Context.current will be used. If there isn't a current span on OpenTelemetry::Context.current trace_id, span_id, and trace_flags will be nil unless they are passed as arguments. Also, remaining #emit methods are renamed to #on_emit.
# | ||
# @api public | ||
def emit( | ||
def on_emit( |
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.
When we renamed the method in #1517, I forgot to go back and change the references in the API.
This code was leftover and should have been removed. Now, the specfic `trace_id`, `span_id`, and `trace_flags` attributes are used instead.
…lemetry-ruby into logs-sdk-log-record
@span_id = span_id | ||
@trace_flags = trace_flags | ||
@resource = logger&.resource | ||
@instrumentation_scope = logger&.instrumentation_scope |
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.
Is it possible for a log record to get created from an api logger? Otherwise I would expect instrumentation scope to always be present (do we need the safe operator here?).
@trace_id = trace_id | ||
@span_id = span_id | ||
@trace_flags = trace_flags | ||
@resource = logger&.resource |
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.
I know there's a method added to the sdk logger here to support this but it still reads like logger.logger_provider.resource
to me.
I wonder if there's any merit in following the same pattern we did with the tracer https://github.com/open-telemetry/opentelemetry-ruby/blob/main/sdk/lib/opentelemetry/sdk/trace/tracer.rb#L35
:resource, # optional OpenTelemetry::SDK::Resources::Resource | ||
:instrumentation_scope, # OpenTelemetry::SDK::InstrumentationScope | ||
:total_recorded_attributes) do # Integer | ||
def unix_nano_timestamp |
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.
nit: is that possible to do alias_method :unix_nano_observed_timestamp, :unix_nano_timestamp
?
This PR creates a
LogRecord
class that is read/writeable to start with, and becomes read-only when it transitions toLogRecordData
.Additionally, it provides the SDK implementation of the Logs Bridge API
Logger#on_emit
method to emitLogRecord
s to the processing pipeline.Relates to the following specs:
Resolves: #1484