Skip to content

Commit

Permalink
Add setup exporter logic as creating executor (#2480)
Browse files Browse the repository at this point in the history
# Description
Setting up exporter as creating executor.
Then we could skip setting up it in many places.
Will use e2e test to cover this scenario.
# All Promptflow Contribution checklist:
- [X] **The pull request does not introduce [breaking changes].**
- [ ] **CHANGELOG is updated for new features, bug fixes or other
significant changes.**
- [X] **I have read the [contribution guidelines](../CONTRIBUTING.md).**
- [ ] **Create an issue and link to the pull request to get dedicated
review from promptflow team. Learn more: [suggested
workflow](../CONTRIBUTING.md#suggested-workflow).**

## General Guidelines and Best Practices
- [X] Title of the pull request is clear and informative.
- [X] 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](https://github.com/Azure/azure-powershell/blob/master/documentation/development-docs/cleaning-up-commits.md).

### Testing Guidelines
- [ ] Pull request includes test coverage for the included changes.

Co-authored-by: robbenwang <[email protected]>
  • Loading branch information
huaiyan and robbenwang authored Mar 28, 2024
1 parent eb0eb27 commit 5b1be09
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -696,11 +696,6 @@ def _process_wrapper(
bulk_logger.info("Current thread is not main thread, skip signal handler registration in batch process pool.")
OperationContext.get_instance().update(operation_contexts_dict) # Update the operation context for the new process.

# set up OpenTelemetry exporter in process who executes the line
from promptflow.tracing._start_trace import setup_exporter_from_environ

setup_exporter_from_environ()

_exec_line_for_queue(
executor_creation_func,
output_dir,
Expand Down
2 changes: 2 additions & 0 deletions src/promptflow-core/promptflow/executor/flow_executor.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@
from promptflow.storage._run_storage import DefaultRunStorage
from promptflow.tracing._integrations._openai_injector import inject_openai_api
from promptflow.tracing._operation_context import OperationContext
from promptflow.tracing._start_trace import setup_exporter_from_environ
from promptflow.tracing._trace import (
enrich_span_with_context,
enrich_span_with_input,
Expand Down Expand Up @@ -199,6 +200,7 @@ def create(
:return: A new instance of FlowExecutor.
:rtype: ~promptflow.executor.flow_executor.FlowExecutor
"""
setup_exporter_from_environ()
if is_flex_flow(file_path=flow_file, working_dir=working_dir):
from ._script_executor import ScriptExecutor

Expand Down

0 comments on commit 5b1be09

Please sign in to comment.