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

feat(js/plugins): added experimental_debugTraces option to googleai and vertexai plugins #2023

Merged
merged 2 commits into from
Feb 19, 2025

Conversation

pavelgj
Copy link
Collaborator

@pavelgj pavelgj commented Feb 18, 2025

const ai = genkit({
  plugins: [googleAI({experimental_debugTraces: true})],
});
image

Checklist (if applicable):

@pavelgj pavelgj requested a review from MichaelDoyle February 18, 2025 18:36
@github-actions github-actions bot added the js label Feb 18, 2025
@chrisraygill
Copy link
Contributor

chrisraygill commented Feb 18, 2025

Questions: Does this need to be plugin-specific? Or is there something we can do at the framework level to enable this for all plugins?

@pavelgj
Copy link
Collaborator Author

pavelgj commented Feb 18, 2025

Questions: Does this need to be plugin-specific? Or is there something we can do at the framework level to enable this for all plugins?

I think there's an opportunity to do something at the framework level, but tracing logic must be implemented per-plugin anyway...

I think it's fine like this. We can revisit this later. For now the dev can always do something like:

const ai = genkit({
  plugins: [googleAI({debugTraces: process.env.DEBUG_TRACES === 'true'})],
});

@pavelgj pavelgj requested a review from apascal07 February 18, 2025 23:46
@MichaelDoyle
Copy link
Member

MichaelDoyle commented Feb 19, 2025

This is super interesting, thanks! It's potentially relevant to some things we are looking at in AIM.

I have a few questions.

  1. What was the motivation for this?
  2. Is output also relevant?
  3. Depending on the motivation, is this something that ideally the Vertex/Gemini SDKs should be tracing? If yes, I wonder if we can/should try and contribute it there (and eventually migrate over to that). Or if we should engage with that team to prioritize it (we might know some folks involved in trying to get OTel adopted there for other reasons).

Should we consider (in addition to input/output, which is Genkit specific) layering in the semantic conventions? If we write this trace according to the semantic conventions, in production, Cloud Trace will show it really nicely in a gen AI specific view. and eventually AIM will too.

Currently, we are planning to do that on the model action span: #1601

See also: https://opentelemetry.io/docs/specs/semconv/gen-ai/gen-ai-spans/

@MichaelDoyle
Copy link
Member

cc @bryanatkinson

@MichaelDoyle
Copy link
Member

Couple more questions. Is this mostly geared towards our team (i.e. people developing Genkit)? Or do we expect app developers to use it? Troubleshooting with us? In prod?

I am wondering if "debug" is descriptive enough for what the use case is (all tracing is debug related in a way 😄) versus say "internal" traces. Inspiration: https://opentelemetry.io/docs/collector/internal-telemetry/

Copy link
Member

@MichaelDoyle MichaelDoyle left a comment

Choose a reason for hiding this comment

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

This looks cool. I want to use it already! It also made me think of a bunch of questions.

@pavelgj
Copy link
Collaborator Author

pavelgj commented Feb 19, 2025

This is super interesting, thanks! It's potentially relevant to some things we are looking at in AIM.

I have a few questions.

  1. What was the motivation for this?
  2. Is output also relevant?
  3. Depending on the motivation, is this something that ideally the Vertex/Gemini SDKs should be tracing? If yes, I wonder if we can/should try and contribute it there (and eventually migrate over to that). Or if we should engage with that team to prioritize it (we might know some folks involved in trying to get OTel adopted there for other reasons).

Should we consider (in addition to input/output, which is Genkit specific) layering in the semantic conventions? If we write this trace according to the semantic conventions, in production, Cloud Trace will show it really nicely in a gen AI specific view. and eventually AIM will too.

Currently, we are planning to do that on the model action span: #1601

See also: https://opentelemetry.io/docs/specs/semconv/gen-ai/gen-ai-spans/

  1. The motivation is that Genkit plugin does extremely non-trivial translation of Genkit data model into model SDK specific model. A more specific motivation came from one user who was troubleshooting tool calling ([JS] Tool calling doesn't respect input schema #2022) and the suspicion was a bug in the plugin logic... which led to fix(js/plugins): fixed gemini tool schema converter to correctly handle descriptions, enums and nullable fields #2027 (a bug). This feature was instrumental in helping me debug the issue.

Beyond that, I believe it will be super helpful for developers who are already familiar with provider SDK to understand what Genkit actually does to generate the request.

  1. we already include raw response in the GenerateResponse... so technically it's not super useful... but we can add more stuff in there if we want.

  2. that's interesting... we should explore this.

@pavelgj
Copy link
Collaborator Author

pavelgj commented Feb 19, 2025

Couple more questions. Is this mostly geared towards our team (i.e. people developing Genkit)? Or do we expect app developers to use it? Troubleshooting with us? In prod?

I am wondering if "debug" is descriptive enough for what the use case is (all tracing is debug related in a way 😄) versus say "internal" traces. Inspiration: https://opentelemetry.io/docs/collector/internal-telemetry/

I think devs might be interested in looking at those traces... those traces should look familiar to devs who used the SDK directly in the past... but internal-telemetry approach looks interesting as well.

@pavelgj pavelgj changed the title feat(js/plugins): added debugTraces option to googleai and vertexai plugins feat(js/plugins): added experimental_debugTraces option to googleai and vertexai plugins Feb 19, 2025
@pavelgj
Copy link
Collaborator Author

pavelgj commented Feb 19, 2025

decided to prefix the flag with experimental_ -- we will probably want to tweak this.

@pavelgj pavelgj merged commit 4a10ee8 into main Feb 19, 2025
7 checks passed
@pavelgj pavelgj deleted the pj/debugTracesGemini branch February 19, 2025 14:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

3 participants