Skip to content

Comments

feat(core): Enable simple instrumentation for Otel#183

Open
franz101 wants to merge 13 commits intomainfrom
otel_instrument
Open

feat(core): Enable simple instrumentation for Otel#183
franz101 wants to merge 13 commits intomainfrom
otel_instrument

Conversation

@franz101
Copy link
Contributor

Simply import from galileo.otel import enable_tracing

@franz101 franz101 requested a review from a team as a code owner June 17, 2025 19:56
@codecov
Copy link

codecov bot commented Jun 17, 2025

Codecov Report

Attention: Patch coverage is 98.43750% with 1 line in your changes missing coverage. Please review.

Project coverage is 80.11%. Comparing base (c3fc62b) to head (883382f).

Files with missing lines Patch % Lines
src/galileo/api_client.py 50.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #183      +/-   ##
==========================================
+ Coverage   79.68%   80.11%   +0.43%     
==========================================
  Files          42       43       +1     
  Lines        2815     2876      +61     
==========================================
+ Hits         2243     2304      +61     
  Misses        572      572              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

franz101 and others added 6 commits June 24, 2025 11:43
@franz101
Copy link
Contributor Author

franz101 commented Jul 3, 2025

@ajaynayak @setu4993 @andriisoldatenko are you free to review, I have the docs also added for it

log_stream: str | None = None,
session_id: str | UUID | None = None,
console_url: str = "",
auto_instrument: bool = True,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How much overhead does auto instrumentation of the libraries below add to a user's app? Should this be True by default?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Whoops my comment was not posted:
Here is an Example
from openinference.instrumentation.langchain import LangChainInstrumentor
LangChainInstrumentor().instrument(tracer_provider=tracer_provider)
https://github.com/Focadecombate/docling-test/blob/main/src/otel.py

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

quite complex if you don't know what a trace provider is

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@franz101 I'm referring to the code block below, since auto_instrument is set to True by default, these will always be instantiated and I'm not sure if this is necessary. Feels like the default should be False.

# (Optional) auto‑instrument popular Gen‑AI libs
    if auto_instrument:
        _safe_instrument("openinference.instrumentation.openai", "OpenAIInstrumentor")
        _safe_instrument("openinference.instrumentation.litellm", "LiteLLMInstrumentor")
        _safe_instrument("openinference.instrumentation.langchain", "LangchainInstrumentor")
        _safe_instrument("openinference.instrumentation.crewai", "CrewAIInstrumentor")
        _safe_instrument("openinference.instrumentation.google_genai", "GoogleGenAIInstrumentor")
        _safe_instrument("openinference.instrumentation.vertexai", "VertexAIInstrumentor")
        _safe_instrument("openinference.instrumentation.llama_index", "LlamaIndexInstrumentor")

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Putting the user first, I would disagree :

  • Import will only haben if the instrumentation is installed
  • If you just want to log, you don't want to know what an instrumentor is
  • Making the barrier to entry as low as possible here

Comment on lines +157 to +164
otel = [
"opentelemetry-api>=1.34.1,<2.0.0",
"opentelemetry-sdk>=1.30.0,<2.0.0",
"opentelemetry-exporter-otlp>=1.30.0,<2.0.0",
"openinference-instrumentation-openai>=0.1.30,<0.2.0",
"openinference-instrumentation-litellm>=0.1.22,<0.2.0",
"openinference-instrumentation-langchain>=0.1.43,<0.2.0",
]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We shouldn't need all of these at all times? Anyone using OpenAI doesn't need litellm / langchain...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

reason was, these three are the most common one

we could split them up even?
galileo[otel-langchain]

log_stream: str | None = None,
session_id: str | UUID | None = None,
console_url: str = "",
auto_instrument: bool = True,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1.

@franz101
Copy link
Contributor Author

@ajaynayak @setu4993 I added my reasoning for making auto instrument true by default:

Putting the user first, I would disagree :

  • Import will only haben if the instrumentation is installed
  • If you just want to log, you don't want to know what an instrumentor is
  • Making the barrier to entry as low as possible here

Let's make a decision here so we can merge it, if users complain we can still change it.
But this allows us a very straightforward way of enabling logging for the user

@franz101 franz101 requested a review from ajaynayak July 17, 2025 14:24
Copy link
Contributor

@Focadecombate Focadecombate left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For me it's fine, auto-instrumentation is something that is pushed by otel so I don't think it should be an issue. So it's a good way of making the barrier of entry into Galileo lower.

@franz101 franz101 requested a review from a team as a code owner September 2, 2025 18:26
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.

5 participants