Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🐛 Bug Report: Watsonx hardcoded values #2163

Open
1 task done
gauthiersiri opened this issue Oct 16, 2024 · 15 comments
Open
1 task done

🐛 Bug Report: Watsonx hardcoded values #2163

gauthiersiri opened this issue Oct 16, 2024 · 15 comments
Labels
bug Something isn't working

Comments

@gauthiersiri
Copy link

Which component is this bug for?

Watsonx Instrumentation

📜 Description

Some variables, showing in traceloop traces, are hardcoded.
For example, even if hitting watsonx in frankfurt, it shows that it's using https://us-south.ml.cloud.ibm.com, which is incorrect.

👟 Reproduction steps

Create a python script using watsonx in frankfurt for example, and see that in the traces it shows https://us-south.ml.cloud.ibm.com, as hardcoded in packages/opentelemetry-instrumentation-watsonx/opentelemetry/instrumentation/watsonx/init.py line 103

👍 Expected behavior

It should show the real parameter istead of harcoded ones.

👎 Actual Behavior with Screenshots

image

🤖 Python Version

3.12

📃 Provide any additional context for the Bug.

No response

👀 Have you spent some time to check if this bug has been raised before?

  • I checked and didn't find similar issue

Are you willing to submit PR?

None

Copy link

dosubot bot commented Oct 16, 2024

Hey @gauthiersiri 👋, I'm here to help you with any bug reports, questions, or contributions. Let me know how I can assist you!

The issue you're experiencing with hardcoded values in Watsonx Instrumentation, specifically the API base URL, can be resolved by modifying the _set_api_attributes function. Currently, the API base URL is hardcoded to "https://us-south.ml.cloud.ibm.com", which causes incorrect URLs to appear in traceloop traces when using different regions like Frankfurt.

To fix this, you can update the _set_api_attributes function to use an environment variable for the API base URL. Here's an example of how you can implement this change:

def _set_api_attributes(span):
    api_base_url = os.getenv("WATSONX_API_BASE_URL", "https://us-south.ml.cloud.ibm.com")
    _set_span_attribute(
        span,
        WatsonxSpanAttributes.WATSONX_API_BASE,
        api_base_url,
    )
    _set_span_attribute(span, WatsonxSpanAttributes.WATSONX_API_TYPE, "watsonx.ai")
    _set_span_attribute(span, WatsonxSpanAttributes.WATSONX_API_VERSION, "1.0")

    return

By using the WATSONX_API_BASE_URL environment variable, you can dynamically set the correct API base URL for different regions, ensuring that the traces reflect the actual configuration [1].

To continue talking to Dosu, mention @dosu.

@dosubot dosubot bot added the bug Something isn't working label Oct 16, 2024
@nirga
Copy link
Member

nirga commented Oct 16, 2024

@gyliu513 fyi

@gyliu513
Copy link
Contributor

Thanks @nirga @gauthiersiri , that is in our backlog, will fix it soon!

@gyliu513
Copy link
Contributor

gyliu513 commented Oct 16, 2024

@gauthiersiri if you work for IBM, please reach out to me via our internal slack as well, happy to be connected and we can discuss more for your use cases and some requirements etc. and then collaborate in openLLMetry and OTEL community to move forward, thanks!

@rajmanna-dev
Copy link

Is this issue up to grab?

@gyliu513
Copy link
Contributor

@rajmanna-dev Yes, as IBM Watsonx AI Platform also support on-prem as well, so with on-prem, the API BASE URL may changed.

@rajmanna-dev
Copy link

Can I take this issue?

@nirga
Copy link
Member

nirga commented Oct 16, 2024

Yes :) @rajmanna-dev

@rajmanna-dev
Copy link

Can you please assign me? @nirga

@gyliu513
Copy link
Contributor

@rajmanna-dev just a fix proposal here, as the URL was mainly used as a span attribute, so we can probably let customer set a env var before they run their apps, and then we can update the code to use os.getenv to get the base URL, similar as here, this should works, good luck, look forward to your PR.

@nirga
Copy link
Member

nirga commented Oct 16, 2024

@gyliu513 you can't just get it from the client sdk?

@gyliu513
Copy link
Contributor

@nirga No, from https://github.com/traceloop/openllmetry/blob/main/packages/sample-app/sample_app/watsonx-langchain.py#L31 , you can see this is configured by customer when they are trying to build the model for watsonx platform.

@nirga
Copy link
Member

nirga commented Oct 16, 2024

Ah great so we can get it from there!

@rajmanna-dev
Copy link

packages/sample-app/sample_app/watsonx_generate.py and packages/sample-app/sample_app/watsonx_flow.py also have the hardcoded api url values.

@nirga
Copy link
Member

nirga commented Oct 17, 2024

@rajmanna-dev that's ok - these are samples

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
4 participants