Skip to content

add integration tests#6

Merged
nikhilNava merged 3 commits intomainfrom
nikhilc/AddIntegrationTests
Oct 30, 2025
Merged

add integration tests#6
nikhilNava merged 3 commits intomainfrom
nikhilc/AddIntegrationTests

Conversation

@nikhilNava
Copy link
Copy Markdown
Contributor

@nikhilNava nikhilNava commented Oct 30, 2025

Task

  1. Add integration test to test with observability
  2. Remove reference of kairo

Copilot AI review requested due to automatic review settings October 30, 2025 13:24
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds integration tests for the OpenAI trace processor to validate observability functionality with real Azure OpenAI services. The tests verify that telemetry data is correctly captured and processed when using the OpenAI Agents SDK.

Key changes:

  • New integration test suite for OpenAI trace processor with both basic and tool-based scenarios
  • Test infrastructure setup with pytest fixtures for Azure OpenAI and Agent365 configuration
  • CI workflow updates to separate unit and integration tests, with integration tests running conditionally based on available secrets

Reviewed Changes

Copilot reviewed 6 out of 7 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
tests/integration/test_openai_trace_processor.py Adds comprehensive integration tests for OpenAI trace processor with mock span exporter and validation logic
tests/integration/conftest.py Provides pytest fixtures for Azure OpenAI and Agent365 configuration with environment variable support
tests/integration/init.py Initializes the integration tests package with proper copyright header
tests/.env.example Documents the new AZURE_OPENAI_API_KEY environment variable requirement
pyproject.toml Adds development dependencies and pytest configuration for unit and integration test markers
.github/workflows/ci.yml Separates unit and integration test execution with conditional integration test runs

@nikhilNava nikhilNava merged commit e06a40a into main Oct 30, 2025
8 checks passed
@nikhilNava nikhilNava deleted the nikhilc/AddIntegrationTests branch October 30, 2025 22:38
Copilot AI added a commit that referenced this pull request Mar 16, 2026
… asserts, and more

- Fix #1: Downgrade sensitive data logging from INFO to DEBUG in agent365_exporter.py
- Fix #2: Fix unpaired context.attach() in opentelemetry_scope.py add_baggage() by storing
  and detaching baggage tokens on scope end
- Fix #3: Add bounded OrderedDict caps to unbounded dicts in OpenAI trace_processor.py
- Fix #4: Replace 30 assert statements with proper TypeError raises in LangChain utils.py
- Fix #5: Log security warning when HTTP domain override is detected
- Fix #6: Warn when bearer token sent over non-HTTPS connection
- Fix #10: Respect Retry-After header and use exponential backoff in retries
- Fix #13: Rename reset() to _reset() in ObservabilityHostingManager
- Fix #15: Replace print() with logger.warning() in LangChain tracer_instrumentor.py

Co-authored-by: nikhilNava <211831449+nikhilNava@users.noreply.github.com>
nikhilNava added a commit that referenced this pull request Mar 17, 2026
* Initial plan

* Replace assert statements with explicit TypeError raises in langchain utils

Replace all 30 assert statements in utils.py with equivalent
if-not-raise TypeError checks. This ensures type validation is not
silently stripped when Python runs with -O (optimized mode).

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

* security: fix sensitive data logging, context leak, unbounded memory, asserts, and more

- Fix #1: Downgrade sensitive data logging from INFO to DEBUG in agent365_exporter.py
- Fix #2: Fix unpaired context.attach() in opentelemetry_scope.py add_baggage() by storing
  and detaching baggage tokens on scope end
- Fix #3: Add bounded OrderedDict caps to unbounded dicts in OpenAI trace_processor.py
- Fix #4: Replace 30 assert statements with proper TypeError raises in LangChain utils.py
- Fix #5: Log security warning when HTTP domain override is detected
- Fix #6: Warn when bearer token sent over non-HTTPS connection
- Fix #10: Respect Retry-After header and use exponential backoff in retries
- Fix #13: Rename reset() to _reset() in ObservabilityHostingManager
- Fix #15: Replace print() with logger.warning() in LangChain tracer_instrumentor.py

Co-authored-by: nikhilNava <211831449+nikhilNava@users.noreply.github.com>

* Restore agent/tenant IDs and response text in exporter log messages

Agent IDs and tenant IDs are not sensitive data and are useful for
debugging. Restore them in debug/error log messages. Also restore
truncated response text in HTTP error logs to help developers debug
failures.

Log levels remain at DEBUG (from the prior security fix).

Co-authored-by: nikhilNava <211831449+nikhilNava@users.noreply.github.com>

* Remove add_baggage() from OpenTelemetryScope

The method had an unpaired context.attach() that leaked context tokens.
Users should use BaggageBuilder.build() context manager instead, which
properly restores the previous context on exit.

Co-authored-by: nikhilNava <211831449+nikhilNava@users.noreply.github.com>

* Security hardening for observability packages

Co-authored-by: nikhilNava <211831449+nikhilNava@users.noreply.github.com>

* Fix formatting in test_agent365_exporter.py and replace remaining raise TypeError with isinstance guards in langchain utils.py

Co-authored-by: nikhilNava <211831449+nikhilNava@users.noreply.github.com>

* Move _parse_retry_after to exporters/utils.py as standalone parse_retry_after function

Co-authored-by: nikhilNava <211831449+nikhilNava@users.noreply.github.com>

* Replace type(e).__name__ with str(e) in exporter error logging per PR review

Co-authored-by: nikhilNava <211831449+nikhilNava@users.noreply.github.com>

* feat: add bounded collections for LangChain tracer and OutputScope

- Convert LangChain _spans_by_run from unbounded DictWithLock to
  bounded OrderedDict with _MAX_TRACKED_RUNS=10000 cap
- Add _cap_ordered_dict helper for FIFO eviction (matching OpenAI pattern)
- Add thread-safe lock usage for _spans_by_run in error handlers
- Add _MAX_OUTPUT_MESSAGES=5000 cap for OutputScope._output_messages
- Add unit tests for both bounded collections

Co-authored-by: nikhilNava <211831449+nikhilNava@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: nikhilNava <211831449+nikhilNava@users.noreply.github.com>
Co-authored-by: Nikhil Navakiran <nikhil.navakiran@gmail.com>
biswapm pushed a commit to biswapm/Agent365-python that referenced this pull request Mar 20, 2026
* Initial plan

* Replace assert statements with explicit TypeError raises in langchain utils

Replace all 30 assert statements in utils.py with equivalent
if-not-raise TypeError checks. This ensures type validation is not
silently stripped when Python runs with -O (optimized mode).

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

* security: fix sensitive data logging, context leak, unbounded memory, asserts, and more

- Fix microsoft#1: Downgrade sensitive data logging from INFO to DEBUG in agent365_exporter.py
- Fix microsoft#2: Fix unpaired context.attach() in opentelemetry_scope.py add_baggage() by storing
  and detaching baggage tokens on scope end
- Fix microsoft#3: Add bounded OrderedDict caps to unbounded dicts in OpenAI trace_processor.py
- Fix microsoft#4: Replace 30 assert statements with proper TypeError raises in LangChain utils.py
- Fix microsoft#5: Log security warning when HTTP domain override is detected
- Fix microsoft#6: Warn when bearer token sent over non-HTTPS connection
- Fix microsoft#10: Respect Retry-After header and use exponential backoff in retries
- Fix microsoft#13: Rename reset() to _reset() in ObservabilityHostingManager
- Fix microsoft#15: Replace print() with logger.warning() in LangChain tracer_instrumentor.py

Co-authored-by: nikhilNava <211831449+nikhilNava@users.noreply.github.com>

* Restore agent/tenant IDs and response text in exporter log messages

Agent IDs and tenant IDs are not sensitive data and are useful for
debugging. Restore them in debug/error log messages. Also restore
truncated response text in HTTP error logs to help developers debug
failures.

Log levels remain at DEBUG (from the prior security fix).

Co-authored-by: nikhilNava <211831449+nikhilNava@users.noreply.github.com>

* Remove add_baggage() from OpenTelemetryScope

The method had an unpaired context.attach() that leaked context tokens.
Users should use BaggageBuilder.build() context manager instead, which
properly restores the previous context on exit.

Co-authored-by: nikhilNava <211831449+nikhilNava@users.noreply.github.com>

* Security hardening for observability packages

Co-authored-by: nikhilNava <211831449+nikhilNava@users.noreply.github.com>

* Fix formatting in test_agent365_exporter.py and replace remaining raise TypeError with isinstance guards in langchain utils.py

Co-authored-by: nikhilNava <211831449+nikhilNava@users.noreply.github.com>

* Move _parse_retry_after to exporters/utils.py as standalone parse_retry_after function

Co-authored-by: nikhilNava <211831449+nikhilNava@users.noreply.github.com>

* Replace type(e).__name__ with str(e) in exporter error logging per PR review

Co-authored-by: nikhilNava <211831449+nikhilNava@users.noreply.github.com>

* feat: add bounded collections for LangChain tracer and OutputScope

- Convert LangChain _spans_by_run from unbounded DictWithLock to
  bounded OrderedDict with _MAX_TRACKED_RUNS=10000 cap
- Add _cap_ordered_dict helper for FIFO eviction (matching OpenAI pattern)
- Add thread-safe lock usage for _spans_by_run in error handlers
- Add _MAX_OUTPUT_MESSAGES=5000 cap for OutputScope._output_messages
- Add unit tests for both bounded collections

Co-authored-by: nikhilNava <211831449+nikhilNava@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: nikhilNava <211831449+nikhilNava@users.noreply.github.com>
Co-authored-by: Nikhil Navakiran <nikhil.navakiran@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants