Skip to content
Merged
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 @@ -181,8 +181,7 @@ test('creates an rpc span named after the @callable() method', async ({ page, ba
description: 'greet',
origin: 'auto.faas.cloudflare.agents',
data: expect.objectContaining({
'cloudflare.agent.class': 'MyBaseAgent',
'cloudflare.agent.name': 'user-123',
'gen_ai.agent.name': 'MyBaseAgent',
}),
}),
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,6 @@ test('creates an rpc span for a @callable() invocation on an AIChatAgent', async
op: 'rpc',
description: 'greet',
origin: 'auto.faas.cloudflare.agents',
data: expect.objectContaining({
'cloudflare.agent.name': AGENT_INSTANCE,
}),
}),
);
});
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,7 @@ for (const { title, binding, agentClass } of [
// confirms the wrapper landed on the user's real class. Matched loosely
// because the transform renames the class it wraps to
// `__SENTRY_ORIGINAL_<name>__` and the bundler infers that name.
'cloudflare.agent.class': expect.stringContaining(agentClass),
'cloudflare.agent.name': instance,
'gen_ai.agent.name': expect.stringContaining(agentClass),
}),
}),
);
Expand Down
10 changes: 2 additions & 8 deletions packages/cloudflare/src/instrumentations/agents/types.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import { GEN_AI_AGENT_NAME } from '@sentry/conventions/attributes';
import { getCurrentScope } from '@sentry/core';

export const AGENT_SPAN_ORIGIN = 'auto.faas.cloudflare.agents';
export const AGENT_CLASS_ATTRIBUTE = 'cloudflare.agent.class';
export const AGENT_NAME_ATTRIBUTE = 'cloudflare.agent.name';

/**
* The subset of the `agents` `Agent` instance internals that we instrument. These are runtime
Expand Down Expand Up @@ -40,12 +39,7 @@ export function getAgentAttributes(instance: AgentInternals): Record<string, str

const agentClass = instance._ParentClass?.name;
if (typeof agentClass === 'string' && agentClass) {
attributes[AGENT_CLASS_ATTRIBUTE] = agentClass;
}

const agentName = instance.name;
if (typeof agentName === 'string' && agentName) {
attributes[AGENT_NAME_ATTRIBUTE] = agentName;
attributes[GEN_AI_AGENT_NAME] = agentClass;
}

return attributes;
Comment thread
JPeer264 marked this conversation as resolved.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,7 @@ describe('instrumentCloudflareAgent', () => {
op: 'rpc',
origin: 'auto.faas.cloudflare.agents',
data: expect.objectContaining({
'cloudflare.agent.class': 'MyAgent',
'cloudflare.agent.name': 'instance-1',
'gen_ai.agent.name': 'MyAgent',
}),
}),
);
Expand Down
Loading