-
[Executor][Internal] Adjust legacy tracer logic to avoid warnings when directly uses trace (#1967)
发布于
2024-02-05 07:47:22 +00:00 Description
Currently there are following warnings when directly call some function
with @traceWARNING: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 typesThis 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 theend_tracingmethod, removing a logging
warning in thepushmethod, and improving the handling of the
node_nameattribute in theenrich_span_with_tracemethod.Code simplification and improved error handling:
src/promptflow/promptflow/_core/tracer.py:
Removed unnecessary logging warnings and exception raising in the
end_tracingmethod, simplifying the code and making it easier to
understand.
*
src/promptflow/promptflow/_core/tracer.py:
Removed a logging warning in thepushmethod, making the code cleaner
and more straightforward.Improved attribute handling:
src/promptflow/promptflow/_core/tracer.py:
Modified theenrich_span_with_tracemethod to only set thenode_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
下载附件