Skip to content

Conversation

viniciusdsmello
Copy link
Contributor

@viniciusdsmello viniciusdsmello commented Sep 24, 2025

Pull Request

Summary

Added support for custom Openlayer client settings in the tracer configuration, allowing users to programmatically set timeout and max_retries parameters through the configure() function instead of relying solely on environment variables.

Changes

  • Added timeout parameter to tracer.configure() function accepting int or float values (defaults to 60 seconds)
  • Added max_retries parameter to tracer.configure() function accepting int values (defaults to 2 retries)
  • Added module-level configuration variables _configured_timeout and _configured_max_retries
  • Updated _get_client() to pass configured timeout and max_retries to Openlayer client initialization
  • Enhanced function docstring with parameter descriptions and usage examples
  • Maintained backward compatibility with existing environment variable configuration

Context

Users needed more granular control over Openlayer client behavior, particularly for timeout and retry settings in different deployment environments. Previously, these settings could only be controlled when users instantiated the Openlayer client manually. However, when using the @trace decorator, this was not possible.

This enhancement allows users to:

  • Set custom timeouts for API calls based on their specific requirements
  • Configure retry behavior for improved reliability in unstable network conditions
  • Programmatically adjust client settings without modifying environment variables
  • Maintain different configurations for different parts of their application

Testing

  • Unit tests - Added comprehensive tests for timeout and max_retries functionality
  • Manual testing - Verified configuration works with real Openlayer API calls
  • Integration testing - Confirmed backward compatibility
  • Edge case testing - Validated parameter validation and fallback behavior

The implementation follows the existing pattern used for api_key, inference_pipeline_id, and base_url configuration, ensuring consistency and maintainability.

@viniciusdsmello viniciusdsmello changed the title feat: add timeout configuration for Openlayer tracer feat: add Openlayer's client custom settings for Openlayer tracer Sep 24, 2025
@viniciusdsmello viniciusdsmello changed the title feat: add Openlayer's client custom settings for Openlayer tracer feat: add Openlayer's client custom settings for tracer Sep 24, 2025
@viniciusdsmello viniciusdsmello self-assigned this Sep 24, 2025
@viniciusdsmello viniciusdsmello merged commit aca3dab into main Sep 24, 2025
5 checks passed
@viniciusdsmello viniciusdsmello deleted the vini/open-7449-tracer-adds-custom-timeout-to-tracerconfigure branch September 24, 2025 20:02
@stainless-app stainless-app bot mentioned this pull request Sep 24, 2025
@viniciusdsmello viniciusdsmello added the enhancement New feature or request label Sep 24, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants