Skip to content

chore(closes OPEN-10363): clean up trace configuration#642

Open
gustavocidornelas wants to merge 1 commit into
mainfrom
gustavo/open-10363-clean-up-trace-configuration
Open

chore(closes OPEN-10363): clean up trace configuration#642
gustavocidornelas wants to merge 1 commit into
mainfrom
gustavo/open-10363-clean-up-trace-configuration

Conversation

@gustavocidornelas
Copy link
Copy Markdown
Contributor

Pull Request

Summary

Unifies tracer configuration around a new init() function with merge semantics and a single resolver. Today there are three overlapping ways to configure the tracer (env vars, configure(), per-decorator override) and they don't all agree — most notably, configure() silently resets unspecified options on each call, and the LangChain callback bypasses configure()'s state entirely.

This PR makes the three paths consistent and lays the foundation for a future init(auto_instrument=True) feature.

Changes

  • Add init() as the new canonical entry point in openlayer.lib. Idempotent and merges with prior state — partial calls (e.g. init(api_key="X")) no longer reset unspecified options.
  • Replace eleven _configured_* module globals with one _tracer_config dict + _UNSET sentinel.
  • Add public resolvers resolve_api_key(), resolve_pipeline_id(), resolve_base_url() — single source of truth
    (_tracer_config > env var > default). Used by _get_client(), the @trace() decorator, and integrations.
  • Fix LangChain callback bypass at langchain_callback.py:252 and :1310 — was reading OPENLAYER_INFERENCE_PIPELINE_ID directly via utils.get_env_variable, ignoring configure(inference_pipeline_id=...). Now routes through resolve_pipeline_id().
  • Deprecate configure() — kept as a thin alias that emits DeprecationWarning (with stacklevel=2) plus a one-time INFO log, then delegates to init(). Slated for removal in v1.0.
  • Add get_tracer_config() debug helper — returns the resolved config with API key redacted.
  • Add one-time INFO log on first client build showing the resolved pipeline_id and base_url.
  • Route attachment_uploader.py and the LangChain callback's background_publish_enabled check through _resolve() so no integration bypasses the resolver.
  • Remove stale OPENLAYER_PROJECT_NAME reference in the @trace() docstring (it was never actually read anywhere).
  • Rewrite tests/test_tracer_configuration.py with new merge-semantics, resolver, deprecation, and LangChain-bypass-fix tests.
    Update teardowns in test_tracing_core.py and test_offline_buffering.py to use tracer._tracer_config.clear().
  • Rewrite examples/tracing/programmatic_configuration.py to recommend init() and demonstrate merge semantics; keep one labeled-deprecated configure() example.

Context

OPEN-10363: Clean up trace configuration

Testing

  • Unit tests
  • Manual testing

Monitoring

  • No expected impact

Notes

  • Behavior change for configure() callers: previously, configure(api_key="X") silently reset every other configured value. Under the new merge semantics, unspecified args are preserved. Pass an explicit None to clear a configured value. We are not aware of any callers relying on the old replace-on-omit behavior, but worth a callout in the changelog.
  • All custom code stays under openlayer.lib/ per the Stainless constraint. The generated openlayer/__init__.py is untouched.
  • Internal/edge-case env vars unchanged: OPENLAYER_DISABLE_PUBLISH and OPENLAYER_VERIFY_SSL remain read at import time and are intentionally not exposed via init().

@gustavocidornelas gustavocidornelas force-pushed the gustavo/open-10363-clean-up-trace-configuration branch from d01da6e to 64517d1 Compare May 12, 2026 17:49
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.

1 participant