发布

  • [Executor][Internal] Adjust legacy tracer logic to avoid warnings when directly uses trace (#1967)

    frostbyte_neo 发布于 2024-02-05 07:47:22 +00:00

    Description

    Currently there are following warnings when directly call some function
    with @trace

    WARNING:root:Try to push trace but no active tracer in current context.
    WARNING:opentelemetry.attributes:Invalid type NoneType for attribute 'node_name' value. Expected one of ['bool', 'str', 'bytes', 'int', 'float'] or a sequen
    WARNING:root:Try to push trace but no active tracer in current context.
    WARNING:opentelemetry.attributes:Invalid type NoneType for attribute 'node_name' value. Expected one of ['bool', 'str', 'bytes', 'int', 'float'] or a sequence of those types
    

    This pull request for src/promptflow/promptflow/_core/tracer.py
    includes changes that simplify the code and improve error handling. The
    most significant changes include removing unnecessary logging warnings
    and exception raising in the end_tracing method, removing a logging
    warning in the push method, and improving the handling of the
    node_name attribute in the enrich_span_with_trace method.

    Code simplification and improved error handling:

    src/promptflow/promptflow/_core/tracer.py:
    Removed unnecessary logging warnings and exception raising in the
    end_tracing method, simplifying the code and making it easier to
    understand.
    *
    src/promptflow/promptflow/_core/tracer.py:
    Removed a logging warning in the push method, making the code cleaner
    and more straightforward.

    Improved attribute handling:

    src/promptflow/promptflow/_core/tracer.py:
    Modified the enrich_span_with_trace method to only set the node_name
    attribute if it exists, improving the handling of this attribute and
    preventing potential issues.

    All Promptflow Contribution checklist:

    • The pull request does not introduce [breaking changes].
    • CHANGELOG is updated for new features, bug fixes or other
      significant changes.
    • I have read the contribution guidelines.
    • Create an issue and link to the pull request to get dedicated
      review from promptflow team. Learn more: suggested
      workflow
      .

    General Guidelines and Best Practices

    • Title of the pull request is clear and informative.
    • There are a small number of commits, each of which have an
      informative message. This means that previously merged commits do not
      appear in the history of the PR. For more information on cleaning up the
      commits in your PR, see this
      page
      .

    Testing Guidelines

    • Pull request includes test coverage for the included changes.

    Co-authored-by: Heyi heta@microsoft.com

    下载附件