Add Atlas Cloud provider support#4077
Conversation
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
📝 WalkthroughHidden review stack artifactWalkthroughAdds Atlas Cloud vendor detection to OpenAI instrumentation, a provider factory and client helpers, a new Atlas Cloud sample app, updated .env example and READMEs, and tests verifying vendor detection and fallback. ChangesAtlas Cloud integration + sample app
Sequence DiagramsequenceDiagram
participant SampleApp
participant ProviderFactory
participant Traceloop
participant OpenAI_SDK
participant AtlasCloud
SampleApp->>Traceloop: init tracing
SampleApp->>ProviderFactory: create_openai_compatible_client("atlascloud")
ProviderFactory-->>SampleApp: (config, client)
SampleApp->>OpenAI_SDK: client.chat.completions.create(...)
OpenAI_SDK->>AtlasCloud: HTTP request to ATLASCLOUD_BASE_URL
AtlasCloud-->>OpenAI_SDK: response
OpenAI_SDK-->>SampleApp: completion response
Traceloop-->>AtlasCloud: spans/metrics reported
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@packages/sample-app/sample_app/provider_factory.py`:
- Around line 14-21: The OpenAICompatibleProviderConfig dataclass exposes the
api_key in its autogenerated __repr__, so change the api_key field declaration
to hide it from repr by using dataclasses.field(repr=False) (i.e., set
repr=False for the api_key field in the OpenAICompatibleProviderConfig
dataclass) to prevent accidental secret leakage when printing or logging the
config.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: c15321dd-1f05-4896-90ce-00285aeb4843
📒 Files selected for processing (6)
packages/opentelemetry-instrumentation-openai/opentelemetry/instrumentation/openai/shared/__init__.pypackages/opentelemetry-instrumentation-openai/tests/test_provider_detection.pypackages/sample-app/.env.examplepackages/sample-app/README.mdpackages/sample-app/sample_app/atlascloud_openai.pypackages/sample-app/sample_app/provider_factory.py
bd59d6c to
1449a9e
Compare
There was a problem hiding this comment.
Actionable comments posted: 1
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
packages/opentelemetry-instrumentation-openai/opentelemetry/instrumentation/openai/shared/__init__.py (1)
337-350:⚠️ Potential issue | 🟡 Minor | ⚡ Quick winNormalize
base_urlcasing before vendor checks.At Line 349, provider detection is case-sensitive. Mixed/upper-case hostnames can be misclassified as
"openai".Proposed fix
def _get_vendor_from_url(base_url): if not base_url: return "openai" + base_url = base_url.lower() if "openai.azure.com" in base_url: return "azure.ai.openai"🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@packages/opentelemetry-instrumentation-openai/opentelemetry/instrumentation/openai/shared/__init__.py` around lines 337 - 350, The vendor detection in _get_vendor_from_url is case-sensitive and will misclassify URLs with mixed/upper-case hostnames; normalize base_url to a consistent case (e.g., lower()) at the start of _get_vendor_from_url (after the falsy check) and run the subsequent substring checks against that normalized string (still return the same vendor strings), ensuring all references in the function use the normalized base_url variable.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@packages/sample-app/sample_app/provider_factory.py`:
- Around line 29-50: Provider construction currently accepts empty or
whitespace-only env vars; update the provider branches for "atlascloud" and
"openai" in provider_factory.py so that API keys are stripped and treated as
missing if empty/whitespace (raise ValueError using
OpenAICompatibleProviderConfig flow), and base_url/default_model env lookups are
normalized (strip and treat "" or whitespace as unset) so they fall back to
ATLASCLOUD_BASE_URL/ATLASCLOUD_DEFAULT_MODEL or
OPENAI_BASE_URL/OPENAI_DEFAULT_MODEL/None as appropriate; modify the logic
around the OpenAICompatibleProviderConfig calls (the blocks that set api_key,
base_url, default_model) to perform .strip() and truthiness checks before using
or falling back to defaults.
---
Outside diff comments:
In
`@packages/opentelemetry-instrumentation-openai/opentelemetry/instrumentation/openai/shared/__init__.py`:
- Around line 337-350: The vendor detection in _get_vendor_from_url is
case-sensitive and will misclassify URLs with mixed/upper-case hostnames;
normalize base_url to a consistent case (e.g., lower()) at the start of
_get_vendor_from_url (after the falsy check) and run the subsequent substring
checks against that normalized string (still return the same vendor strings),
ensuring all references in the function use the normalized base_url variable.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 922e17e3-865c-4488-8fa8-0924a4e723a2
📒 Files selected for processing (6)
packages/opentelemetry-instrumentation-openai/opentelemetry/instrumentation/openai/shared/__init__.pypackages/opentelemetry-instrumentation-openai/tests/test_provider_detection.pypackages/sample-app/.env.examplepackages/sample-app/README.mdpackages/sample-app/sample_app/atlascloud_openai.pypackages/sample-app/sample_app/provider_factory.py
1449a9e to
2255a20
Compare
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
packages/sample-app/sample_app/atlascloud_openai.py (1)
41-42: ⚡ Quick winGuard response rendering against empty choices.
Direct indexing can crash the sample on atypical responses; a small guard keeps the demo stable.
Proposed fix
print("\n=== Response ===") -print(response.choices[0].message.content) +if not getattr(response, "choices", None): + print("No choices returned.") + return +print(response.choices[0].message.content or "")🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@packages/sample-app/sample_app/atlascloud_openai.py` around lines 41 - 42, The sample prints response.choices[0].message.content without checking for missing data; update the rendering to guard against empty/invalid choices by verifying response and response.choices exist and len(response.choices) > 0 and that response.choices[0].message and response.choices[0].message.content are present before accessing them (e.g., print the content only if those checks pass), otherwise print a safe fallback like "No content returned" or log the full response for debugging; touch the code around the response variable and the choices/message/content access to implement these checks.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@packages/sample-app/.env.example`:
- Around line 9-11: Reorder the dotenv keys so they satisfy the linter by
placing TRACELOOP_API_ENDPOINT before TRACELOOP_API_KEY; update the .env example
to declare TRACELOOP_API_ENDPOINT first and then TRACELOOP_API_KEY so the
UnorderedKey warning is resolved (look for the TRACELOOP_API_ENDPOINT and
TRACELOOP_API_KEY entries in the current .env example).
---
Nitpick comments:
In `@packages/sample-app/sample_app/atlascloud_openai.py`:
- Around line 41-42: The sample prints response.choices[0].message.content
without checking for missing data; update the rendering to guard against
empty/invalid choices by verifying response and response.choices exist and
len(response.choices) > 0 and that response.choices[0].message and
response.choices[0].message.content are present before accessing them (e.g.,
print the content only if those checks pass), otherwise print a safe fallback
like "No content returned" or log the full response for debugging; touch the
code around the response variable and the choices/message/content access to
implement these checks.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 554d6741-fb15-43b5-9efa-29598f88e023
📒 Files selected for processing (6)
packages/opentelemetry-instrumentation-openai/opentelemetry/instrumentation/openai/shared/__init__.pypackages/opentelemetry-instrumentation-openai/tests/test_provider_detection.pypackages/sample-app/.env.examplepackages/sample-app/README.mdpackages/sample-app/sample_app/atlascloud_openai.pypackages/sample-app/sample_app/provider_factory.py
🚧 Files skipped from review as they are similar to previous changes (2)
- packages/sample-app/README.md
- packages/sample-app/sample_app/provider_factory.py
2255a20 to
e9e1319
Compare
|
Synced with upstream main — the branch is no longer behind. CLA is signed. Please re-trigger CI when convenient, thanks! |
79098ba to
b1ed430
Compare
|
Rebased onto the latest |
Summary by CodeRabbit
New Features
Documentation
New Samples
Tests
🤝 Partnership & contact
This PR comes from the Atlas Cloud team. Beyond the integration above, we'd love to explore a closer collaboration with openllmetry — for example co-marketing or a featured integration.
If that sounds interesting, reach out anytime:
And of course, happy to revise this PR to match your project's conventions — just leave a comment. 🙌