Skip to content

Stabilize Logs #3361

Open
Open

Description

@jeremydvoss

After confirming all of the following have been taken care of, I think we can stabilized logs. Got these from open-telemetry/opentelemetry-specification#2911

Is your feature request related to a problem?
Leaving Logs unstable enabled breaking changes like #2943

Describe the solution you'd like
With the logging spec stable, we should confirm we have everything we need and stabilize logs as soon as possible.

Activity

  1. jeremydvoss commented on Jun 28, 2023

    @jeremydvoss
    ContributorAuthor

    Confirmed emit does not seem to default timestamp. This also means that trying to export that LogRecord to console fails because it cannot format timestamp. LogRecord.to_json() does not expect None. EX:

    from opentelemetry.sdk.logs.export import ConsoleLogExporter, BatchLogRecordProcessor
    
    lr = LogRecord()
    print("timestamp: %s" % lr.timestamp)
    
    # logger = Logger()
    lp = LoggerProvider()
    lp.add_log_record_processor(BatchLogRecordProcessor(ConsoleLogExporter()))
    logger = lp.get_logger(__name__)
    
    logger.emit(lr)
    
  2. jeremydvoss commented on Jun 28, 2023

    @jeremydvoss
    ContributorAuthor

    Looking into include_trace_context, it does not seem python has this to begin with. LoggingHandler.emit calls LoggingHandler._translate which uses get_current_span().get_span_context(). This may be an optional feature for if we want people to be able to EXPLICATELY set the context of a logger.

    Related question: should a log's trace context fields be populated if include_trace_context=false and context is explicitly passed? I think yes. However, for languages that rely on explicit context because no implicit context is available, there's no point to having the include_trace_context parameter since it doesn't change any behavior
    https://github.com/open-telemetry/opentelemetry-specification/pull/3387/files

  3. jeremydvoss commented on Jun 28, 2023

    @jeremydvoss
    ContributorAuthor

    Here is the observed_timestamp field

  4. jeremydvoss commented on Jun 28, 2023

    @jeremydvoss
    ContributorAuthor

    Seems we are NOT defaulting observed_timestamp to current time. We could change this in the sdk...

    class LogRecord(APILogRecord):
        def __init__(
            ...
        ):
            if not observed_timestamp:
                observed_timestamp = int(time.time() * 1e9)
            super().__init__(
                ...
    

    ... or in the api:

    class LogRecord(ABC):
    
        def __init__(
            ...
        ):
            self.timestamp = timestamp
            if observed_timestamp:
                self.observed_timestamp = observed_timestamp
            else:
                self.observed_timestamp = int(time.time() * 1e9)
            self.trace_id = trace_id
            ...
    

    I am getting int(time.time() * 1e9) from how to translate native logs

  5. jeremydvoss commented on Jun 29, 2023

    @jeremydvoss
    ContributorAuthor

    Use time.time_ns()

  6. jenshnielsen commented on Jul 6, 2023

    @jenshnielsen
    Contributor

    Perhaps it would be worth including a fix for #3353 before stabilizing. This might not technically be a breaking change but it does significantly change the messages received

  7. lzchen commented on Jul 6, 2023

    @lzchen
    Contributor

    @jenshnielsen

    I don't believe the issue exists within the SDK itself so it wouldn't be a blocker.

  8. lzchen commented on Sep 25, 2023

    @lzchen
    Contributor

    Might be another issue: #3193

  9. jeremydvoss commented on Feb 1, 2024

    @jeremydvoss
    ContributorAuthor

    Take a look at #3608

  10. jeremydvoss commented on Apr 11, 2024

    @jeremydvoss
    ContributorAuthor

    Take a look at #3810

  11. moved this from Done to Todo in Python Logging API/SDK RCon Oct 31, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions