chore(closes OPEN-10363): clean up trace configuration#642
Open
gustavocidornelas wants to merge 1 commit into
Open
chore(closes OPEN-10363): clean up trace configuration#642gustavocidornelas wants to merge 1 commit into
gustavocidornelas wants to merge 1 commit into
Conversation
d01da6e to
64517d1
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 bypassesconfigure()'s state entirely.This PR makes the three paths consistent and lays the foundation for a future
init(auto_instrument=True)feature.Changes
init()as the new canonical entry point inopenlayer.lib. Idempotent and merges with prior state — partial calls (e.g.init(api_key="X")) no longer reset unspecified options._configured_*module globals with one_tracer_configdict +_UNSETsentinel.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.langchain_callback.py:252and:1310— was readingOPENLAYER_INFERENCE_PIPELINE_IDdirectly viautils.get_env_variable, ignoringconfigure(inference_pipeline_id=...). Now routes throughresolve_pipeline_id().configure()— kept as a thin alias that emitsDeprecationWarning(withstacklevel=2) plus a one-timeINFOlog, then delegates toinit(). Slated for removal in v1.0.get_tracer_config()debug helper — returns the resolved config with API key redacted.INFOlog on first client build showing the resolvedpipeline_idandbase_url.attachment_uploader.pyand the LangChain callback'sbackground_publish_enabledcheck through_resolve()so no integration bypasses the resolver.OPENLAYER_PROJECT_NAMEreference in the@trace()docstring (it was never actually read anywhere).tests/test_tracer_configuration.pywith new merge-semantics, resolver, deprecation, and LangChain-bypass-fix tests.Update teardowns in
test_tracing_core.pyandtest_offline_buffering.pyto usetracer._tracer_config.clear().examples/tracing/programmatic_configuration.pyto recommendinit()and demonstrate merge semantics; keep one labeled-deprecatedconfigure()example.Context
OPEN-10363: Clean up trace configuration
Testing
Monitoring
Notes
configure()callers: previously,configure(api_key="X")silently reset every other configured value. Under the new merge semantics, unspecified args are preserved. Pass an explicitNoneto 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.openlayer.lib/per the Stainless constraint. The generatedopenlayer/__init__.pyis untouched.OPENLAYER_DISABLE_PUBLISHandOPENLAYER_VERIFY_SSLremain read at import time and are intentionally not exposed viainit().