Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ import { SEMANTIC_ATTRIBUTE_SENTRY_OP, SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN } from '
import { expect, it } from 'vitest';
import {
GEN_AI_AGENT_NAME_ATTRIBUTE,
GEN_AI_INPUT_MESSAGES_ATTRIBUTE,
GEN_AI_OPERATION_NAME_ATTRIBUTE,
GEN_AI_PIPELINE_NAME_ATTRIBUTE,
GEN_AI_REQUEST_AVAILABLE_TOOLS_ATTRIBUTE,
GEN_AI_REQUEST_MESSAGES_ATTRIBUTE,
GEN_AI_RESPONSE_MODEL_ATTRIBUTE,
GEN_AI_USAGE_INPUT_TOKENS_ATTRIBUTE,
GEN_AI_USAGE_OUTPUT_TOKENS_ATTRIBUTE,
Expand Down Expand Up @@ -49,7 +49,7 @@ it('traces langgraph compile and invoke operations', async ({ signal }) => {
[SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: 'auto.ai.langgraph',
[GEN_AI_AGENT_NAME_ATTRIBUTE]: 'weather_assistant',
[GEN_AI_PIPELINE_NAME_ATTRIBUTE]: 'weather_assistant',
[GEN_AI_REQUEST_MESSAGES_ATTRIBUTE]: '[{"role":"user","content":"What is the weather in SF?"}]',
[GEN_AI_INPUT_MESSAGES_ATTRIBUTE]: '[{"role":"user","content":"What is the weather in SF?"}]',
[GEN_AI_RESPONSE_MODEL_ATTRIBUTE]: 'mock-model',
[GEN_AI_USAGE_INPUT_TOKENS_ATTRIBUTE]: 20,
[GEN_AI_USAGE_OUTPUT_TOKENS_ATTRIBUTE]: 10,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ import { SEMANTIC_ATTRIBUTE_SENTRY_OP, SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN } from '
import { afterAll, describe, expect } from 'vitest';
import {
ANTHROPIC_AI_RESPONSE_TIMESTAMP_ATTRIBUTE,
GEN_AI_INPUT_MESSAGES_ATTRIBUTE,
GEN_AI_OPERATION_NAME_ATTRIBUTE,
GEN_AI_REQUEST_AVAILABLE_TOOLS_ATTRIBUTE,
GEN_AI_REQUEST_MAX_TOKENS_ATTRIBUTE,
GEN_AI_REQUEST_MESSAGES_ATTRIBUTE,
GEN_AI_REQUEST_MODEL_ATTRIBUTE,
GEN_AI_REQUEST_STREAM_ATTRIBUTE,
GEN_AI_REQUEST_TEMPERATURE_ATTRIBUTE,
Expand Down Expand Up @@ -107,7 +107,7 @@ describe('Anthropic integration', () => {
data: expect.objectContaining({
[GEN_AI_OPERATION_NAME_ATTRIBUTE]: 'chat',
[GEN_AI_REQUEST_MAX_TOKENS_ATTRIBUTE]: 100,
[GEN_AI_REQUEST_MESSAGES_ATTRIBUTE]: '[{"role":"user","content":"What is the capital of France?"}]',
[GEN_AI_INPUT_MESSAGES_ATTRIBUTE]: '[{"role":"user","content":"What is the capital of France?"}]',
[GEN_AI_REQUEST_MODEL_ATTRIBUTE]: 'claude-3-haiku-20240307',
[GEN_AI_REQUEST_TEMPERATURE_ATTRIBUTE]: 0.7,
[GEN_AI_RESPONSE_ID_ATTRIBUTE]: 'msg_mock123',
Expand Down Expand Up @@ -147,7 +147,7 @@ describe('Anthropic integration', () => {
expect.objectContaining({
data: expect.objectContaining({
[GEN_AI_OPERATION_NAME_ATTRIBUTE]: 'chat',
[GEN_AI_REQUEST_MESSAGES_ATTRIBUTE]: '[{"role":"user","content":"This will fail"}]',
[GEN_AI_INPUT_MESSAGES_ATTRIBUTE]: '[{"role":"user","content":"This will fail"}]',
[GEN_AI_REQUEST_MODEL_ATTRIBUTE]: 'error-model',
[GEN_AI_SYSTEM_ATTRIBUTE]: 'anthropic',
[SEMANTIC_ATTRIBUTE_SENTRY_OP]: 'gen_ai.chat',
Expand Down Expand Up @@ -180,7 +180,7 @@ describe('Anthropic integration', () => {
expect.objectContaining({
data: expect.objectContaining({
[GEN_AI_OPERATION_NAME_ATTRIBUTE]: 'chat',
[GEN_AI_REQUEST_MESSAGES_ATTRIBUTE]: '[{"role":"user","content":"What is the capital of France?"}]',
[GEN_AI_INPUT_MESSAGES_ATTRIBUTE]: '[{"role":"user","content":"What is the capital of France?"}]',
[GEN_AI_REQUEST_MODEL_ATTRIBUTE]: 'claude-3-haiku-20240307',
[GEN_AI_RESPONSE_TEXT_ATTRIBUTE]: '15',
[GEN_AI_SYSTEM_ATTRIBUTE]: 'anthropic',
Expand Down Expand Up @@ -250,7 +250,7 @@ describe('Anthropic integration', () => {
expect.objectContaining({
data: expect.objectContaining({
[GEN_AI_OPERATION_NAME_ATTRIBUTE]: 'chat',
[GEN_AI_REQUEST_MESSAGES_ATTRIBUTE]: '[{"role":"user","content":"What is the capital of France?"}]',
[GEN_AI_INPUT_MESSAGES_ATTRIBUTE]: '[{"role":"user","content":"What is the capital of France?"}]',
[GEN_AI_REQUEST_MODEL_ATTRIBUTE]: 'claude-3-haiku-20240307',
[GEN_AI_REQUEST_STREAM_ATTRIBUTE]: true,
[GEN_AI_RESPONSE_ID_ATTRIBUTE]: 'msg_stream123',
Expand Down Expand Up @@ -308,15 +308,15 @@ describe('Anthropic integration', () => {
// Check that custom options are respected
expect.objectContaining({
data: expect.objectContaining({
[GEN_AI_REQUEST_MESSAGES_ATTRIBUTE]: expect.any(String), // Should include messages when recordInputs: true
[GEN_AI_INPUT_MESSAGES_ATTRIBUTE]: expect.any(String), // Should include messages when recordInputs: true
[GEN_AI_RESPONSE_TEXT_ATTRIBUTE]: expect.any(String), // Should include response text when recordOutputs: true
}),
}),
// Check token counting with options
expect.objectContaining({
data: expect.objectContaining({
[GEN_AI_OPERATION_NAME_ATTRIBUTE]: 'chat',
[GEN_AI_REQUEST_MESSAGES_ATTRIBUTE]: expect.any(String), // Should include messages when recordInputs: true
[GEN_AI_INPUT_MESSAGES_ATTRIBUTE]: expect.any(String), // Should include messages when recordInputs: true
[GEN_AI_RESPONSE_TEXT_ATTRIBUTE]: '15', // Present because recordOutputs=true is set in options
}),
op: 'gen_ai.chat',
Expand Down Expand Up @@ -667,9 +667,7 @@ describe('Anthropic integration', () => {
[GEN_AI_SYSTEM_ATTRIBUTE]: 'anthropic',
[GEN_AI_REQUEST_MODEL_ATTRIBUTE]: 'claude-3-haiku-20240307',
// Messages should be present (truncation happened) and should be a JSON array
[GEN_AI_REQUEST_MESSAGES_ATTRIBUTE]: expect.stringMatching(
/^\[\{"role":"user","content":"C+"\}\]$/,
),
[GEN_AI_INPUT_MESSAGES_ATTRIBUTE]: expect.stringMatching(/^\[\{"role":"user","content":"C+"\}\]$/),
}),
description: 'chat claude-3-haiku-20240307',
op: 'gen_ai.chat',
Expand All @@ -685,7 +683,7 @@ describe('Anthropic integration', () => {
[GEN_AI_SYSTEM_ATTRIBUTE]: 'anthropic',
[GEN_AI_REQUEST_MODEL_ATTRIBUTE]: 'claude-3-haiku-20240307',
// Small message should be kept intact
[GEN_AI_REQUEST_MESSAGES_ATTRIBUTE]: JSON.stringify([
[GEN_AI_INPUT_MESSAGES_ATTRIBUTE]: JSON.stringify([
{ role: 'user', content: 'This is a small message that fits within the limit' },
]),
}),
Expand Down Expand Up @@ -719,7 +717,7 @@ describe('Anthropic integration', () => {
[GEN_AI_SYSTEM_ATTRIBUTE]: 'anthropic',
[GEN_AI_REQUEST_MODEL_ATTRIBUTE]: 'claude-3-haiku-20240307',
// Only the last message (with filtered media) should be kept
[GEN_AI_REQUEST_MESSAGES_ATTRIBUTE]: JSON.stringify([
[GEN_AI_INPUT_MESSAGES_ATTRIBUTE]: JSON.stringify([
{
role: 'user',
content: [
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { SEMANTIC_ATTRIBUTE_SENTRY_OP, SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN } from '@sentry/core';
import { afterAll, describe, expect } from 'vitest';
import {
GEN_AI_INPUT_MESSAGES_ATTRIBUTE,
GEN_AI_OPERATION_NAME_ATTRIBUTE,
GEN_AI_REQUEST_AVAILABLE_TOOLS_ATTRIBUTE,
GEN_AI_REQUEST_MAX_TOKENS_ATTRIBUTE,
GEN_AI_REQUEST_MESSAGES_ATTRIBUTE,
GEN_AI_REQUEST_MODEL_ATTRIBUTE,
GEN_AI_REQUEST_TEMPERATURE_ATTRIBUTE,
GEN_AI_REQUEST_TOP_P_ATTRIBUTE,
Expand Down Expand Up @@ -114,7 +114,7 @@ describe('Google GenAI integration', () => {
[GEN_AI_REQUEST_TEMPERATURE_ATTRIBUTE]: 0.8,
[GEN_AI_REQUEST_TOP_P_ATTRIBUTE]: 0.9,
[GEN_AI_REQUEST_MAX_TOKENS_ATTRIBUTE]: 150,
[GEN_AI_REQUEST_MESSAGES_ATTRIBUTE]: '[{"role":"user","parts":[{"text":"Hello, how are you?"}]}]',
[GEN_AI_INPUT_MESSAGES_ATTRIBUTE]: '[{"role":"user","parts":[{"text":"Hello, how are you?"}]}]',
}),
description: 'chat gemini-1.5-pro create',
op: 'gen_ai.chat',
Expand All @@ -129,7 +129,7 @@ describe('Google GenAI integration', () => {
[SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: 'auto.ai.google_genai',
[GEN_AI_SYSTEM_ATTRIBUTE]: 'google_genai',
[GEN_AI_REQUEST_MODEL_ATTRIBUTE]: 'gemini-1.5-pro',
[GEN_AI_REQUEST_MESSAGES_ATTRIBUTE]: expect.any(String), // Should include message when recordInputs: true
[GEN_AI_INPUT_MESSAGES_ATTRIBUTE]: expect.any(String), // Should include message when recordInputs: true
[GEN_AI_RESPONSE_TEXT_ATTRIBUTE]: expect.any(String), // Should include response when recordOutputs: true
[GEN_AI_USAGE_INPUT_TOKENS_ATTRIBUTE]: 8,
[GEN_AI_USAGE_OUTPUT_TOKENS_ATTRIBUTE]: 12,
Expand All @@ -151,7 +151,7 @@ describe('Google GenAI integration', () => {
[GEN_AI_REQUEST_TEMPERATURE_ATTRIBUTE]: 0.7,
[GEN_AI_REQUEST_TOP_P_ATTRIBUTE]: 0.9,
[GEN_AI_REQUEST_MAX_TOKENS_ATTRIBUTE]: 100,
[GEN_AI_REQUEST_MESSAGES_ATTRIBUTE]: expect.any(String), // Should include contents when recordInputs: true
[GEN_AI_INPUT_MESSAGES_ATTRIBUTE]: expect.any(String), // Should include contents when recordInputs: true
[GEN_AI_RESPONSE_TEXT_ATTRIBUTE]: expect.any(String), // Should include response when recordOutputs: true
[GEN_AI_USAGE_INPUT_TOKENS_ATTRIBUTE]: 8,
[GEN_AI_USAGE_OUTPUT_TOKENS_ATTRIBUTE]: 12,
Expand All @@ -170,7 +170,7 @@ describe('Google GenAI integration', () => {
[SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: 'auto.ai.google_genai',
[GEN_AI_SYSTEM_ATTRIBUTE]: 'google_genai',
[GEN_AI_REQUEST_MODEL_ATTRIBUTE]: 'error-model',
[GEN_AI_REQUEST_MESSAGES_ATTRIBUTE]: expect.any(String), // Should include contents when recordInputs: true
[GEN_AI_INPUT_MESSAGES_ATTRIBUTE]: expect.any(String), // Should include contents when recordInputs: true
}),
description: 'generate_content error-model',
op: 'gen_ai.generate_content',
Expand All @@ -186,7 +186,7 @@ describe('Google GenAI integration', () => {
// Check that custom options are respected
expect.objectContaining({
data: expect.objectContaining({
[GEN_AI_REQUEST_MESSAGES_ATTRIBUTE]: expect.any(String), // Should include messages when recordInputs: true
[GEN_AI_INPUT_MESSAGES_ATTRIBUTE]: expect.any(String), // Should include messages when recordInputs: true
[GEN_AI_RESPONSE_TEXT_ATTRIBUTE]: expect.any(String), // Should include response text when recordOutputs: true
}),
description: expect.not.stringContaining('stream-response'), // Non-streaming span
Expand Down Expand Up @@ -239,7 +239,7 @@ describe('Google GenAI integration', () => {
[GEN_AI_SYSTEM_ATTRIBUTE]: 'google_genai',
[GEN_AI_REQUEST_MODEL_ATTRIBUTE]: 'gemini-2.0-flash-001',
[GEN_AI_REQUEST_AVAILABLE_TOOLS_ATTRIBUTE]: EXPECTED_AVAILABLE_TOOLS_JSON,
[GEN_AI_REQUEST_MESSAGES_ATTRIBUTE]: expect.any(String), // Should include contents
[GEN_AI_INPUT_MESSAGES_ATTRIBUTE]: expect.any(String), // Should include contents
[GEN_AI_RESPONSE_TEXT_ATTRIBUTE]: expect.any(String), // Should include response text
[GEN_AI_RESPONSE_TOOL_CALLS_ATTRIBUTE]: expect.any(String), // Should include tool calls
[GEN_AI_USAGE_INPUT_TOKENS_ATTRIBUTE]: 15,
Expand All @@ -260,7 +260,7 @@ describe('Google GenAI integration', () => {
[GEN_AI_SYSTEM_ATTRIBUTE]: 'google_genai',
[GEN_AI_REQUEST_MODEL_ATTRIBUTE]: 'gemini-2.0-flash-001',
[GEN_AI_REQUEST_AVAILABLE_TOOLS_ATTRIBUTE]: EXPECTED_AVAILABLE_TOOLS_JSON,
[GEN_AI_REQUEST_MESSAGES_ATTRIBUTE]: expect.any(String), // Should include contents
[GEN_AI_INPUT_MESSAGES_ATTRIBUTE]: expect.any(String), // Should include contents
[GEN_AI_RESPONSE_STREAMING_ATTRIBUTE]: true,
[GEN_AI_RESPONSE_TEXT_ATTRIBUTE]: expect.any(String), // Should include response text
[GEN_AI_RESPONSE_TOOL_CALLS_ATTRIBUTE]: expect.any(String), // Should include tool calls
Expand All @@ -283,7 +283,7 @@ describe('Google GenAI integration', () => {
[SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: 'auto.ai.google_genai',
[GEN_AI_SYSTEM_ATTRIBUTE]: 'google_genai',
[GEN_AI_REQUEST_MODEL_ATTRIBUTE]: 'gemini-2.0-flash-001',
[GEN_AI_REQUEST_MESSAGES_ATTRIBUTE]: expect.any(String), // Should include contents
[GEN_AI_INPUT_MESSAGES_ATTRIBUTE]: expect.any(String), // Should include contents
[GEN_AI_RESPONSE_TEXT_ATTRIBUTE]: expect.any(String), // Should include response text
[GEN_AI_USAGE_INPUT_TOKENS_ATTRIBUTE]: 8,
[GEN_AI_USAGE_OUTPUT_TOKENS_ATTRIBUTE]: 12,
Expand Down Expand Up @@ -405,7 +405,7 @@ describe('Google GenAI integration', () => {
[GEN_AI_REQUEST_TEMPERATURE_ATTRIBUTE]: 0.7,
[GEN_AI_REQUEST_TOP_P_ATTRIBUTE]: 0.9,
[GEN_AI_REQUEST_MAX_TOKENS_ATTRIBUTE]: 100,
[GEN_AI_REQUEST_MESSAGES_ATTRIBUTE]: expect.any(String), // Should include contents when recordInputs: true
[GEN_AI_INPUT_MESSAGES_ATTRIBUTE]: expect.any(String), // Should include contents when recordInputs: true
[GEN_AI_RESPONSE_STREAMING_ATTRIBUTE]: true,
[GEN_AI_RESPONSE_ID_ATTRIBUTE]: 'mock-response-streaming-id',
[GEN_AI_RESPONSE_MODEL_ATTRIBUTE]: 'gemini-1.5-pro',
Expand Down Expand Up @@ -444,7 +444,7 @@ describe('Google GenAI integration', () => {
[SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: 'auto.ai.google_genai',
[GEN_AI_SYSTEM_ATTRIBUTE]: 'google_genai',
[GEN_AI_REQUEST_MODEL_ATTRIBUTE]: 'gemini-1.5-pro',
[GEN_AI_REQUEST_MESSAGES_ATTRIBUTE]: expect.any(String), // Should include message when recordInputs: true
[GEN_AI_INPUT_MESSAGES_ATTRIBUTE]: expect.any(String), // Should include message when recordInputs: true
[GEN_AI_RESPONSE_STREAMING_ATTRIBUTE]: true,
[GEN_AI_RESPONSE_ID_ATTRIBUTE]: 'mock-response-streaming-id',
[GEN_AI_RESPONSE_MODEL_ATTRIBUTE]: 'gemini-1.5-pro',
Expand All @@ -467,7 +467,7 @@ describe('Google GenAI integration', () => {
[GEN_AI_SYSTEM_ATTRIBUTE]: 'google_genai',
[GEN_AI_REQUEST_MODEL_ATTRIBUTE]: 'blocked-model',
[GEN_AI_REQUEST_TEMPERATURE_ATTRIBUTE]: 0.7,
[GEN_AI_REQUEST_MESSAGES_ATTRIBUTE]: expect.any(String), // Should include contents when recordInputs: true
[GEN_AI_INPUT_MESSAGES_ATTRIBUTE]: expect.any(String), // Should include contents when recordInputs: true
[GEN_AI_RESPONSE_STREAMING_ATTRIBUTE]: true,
}),
description: 'generate_content blocked-model stream-response',
Expand All @@ -484,7 +484,7 @@ describe('Google GenAI integration', () => {
[GEN_AI_SYSTEM_ATTRIBUTE]: 'google_genai',
[GEN_AI_REQUEST_MODEL_ATTRIBUTE]: 'error-model',
[GEN_AI_REQUEST_TEMPERATURE_ATTRIBUTE]: 0.7,
[GEN_AI_REQUEST_MESSAGES_ATTRIBUTE]: expect.any(String), // Should include contents when recordInputs: true
[GEN_AI_INPUT_MESSAGES_ATTRIBUTE]: expect.any(String), // Should include contents when recordInputs: true
}),
description: 'generate_content error-model stream-response',
op: 'gen_ai.generate_content',
Expand Down Expand Up @@ -531,7 +531,7 @@ describe('Google GenAI integration', () => {
[GEN_AI_SYSTEM_ATTRIBUTE]: 'google_genai',
[GEN_AI_REQUEST_MODEL_ATTRIBUTE]: 'gemini-1.5-flash',
// Messages should be present (truncation happened) and should be a JSON array with parts
[GEN_AI_REQUEST_MESSAGES_ATTRIBUTE]: expect.stringMatching(
[GEN_AI_INPUT_MESSAGES_ATTRIBUTE]: expect.stringMatching(
/^\[\{"role":"user","parts":\[\{"text":"C+"\}\]\}\]$/,
),
}),
Expand All @@ -549,7 +549,7 @@ describe('Google GenAI integration', () => {
[GEN_AI_SYSTEM_ATTRIBUTE]: 'google_genai',
[GEN_AI_REQUEST_MODEL_ATTRIBUTE]: 'gemini-1.5-flash',
// Small message should be kept intact
[GEN_AI_REQUEST_MESSAGES_ATTRIBUTE]: JSON.stringify([
[GEN_AI_INPUT_MESSAGES_ATTRIBUTE]: JSON.stringify([
{
role: 'user',
parts: [{ text: 'This is a small message that fits within the limit' }],
Expand Down
Loading
Loading