Skip to content

Commit 7269484

Browse files
msonnbclaude
andauthored
feat(cloudflare)!: Use function span op for cron, email and workflow steps (#22703)
Use `function` instead of `faas.cron`, `faas.email`, and `function.step.do`. Trigger and workflow phase belong in attributes rather than a new op per trigger. `faas.trigger` (`timer`/`email`) and the `faas.cron` attribute holding the cron expression are unchanged. Workflow steps additionally set `code.function.name` and `workflow.step.name`, since the step name was previously only the span name. Part of #22446 --------- Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
1 parent f030305 commit 7269484

15 files changed

Lines changed: 45 additions & 33 deletions

File tree

dev-packages/cloudflare-integration-tests/suites/tracing/propagation/no-propagation-worker-do/test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ it('does not propagate trace from scheduled handler to durable object when enabl
183183
expect.objectContaining({
184184
contexts: expect.objectContaining({
185185
trace: expect.objectContaining({
186-
op: 'faas.cron',
186+
op: 'function',
187187
data: expect.objectContaining({
188188
'sentry.origin': 'auto.faas.cloudflare.scheduled',
189189
}),

dev-packages/cloudflare-integration-tests/suites/tracing/propagation/worker-do/test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ it('propagates trace from scheduled handler to durable object', async ({ signal
179179
expect.objectContaining({
180180
contexts: expect.objectContaining({
181181
trace: expect.objectContaining({
182-
op: 'faas.cron',
182+
op: 'function',
183183
data: expect.objectContaining({
184184
'sentry.origin': 'auto.faas.cloudflare.scheduled',
185185
}),

dev-packages/cloudflare-integration-tests/suites/tracing/propagation/workflow-do/test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@ it('traces a workflow that calls a durable object with the same trace id', async
1515
expect.objectContaining({
1616
contexts: expect.objectContaining({
1717
trace: expect.objectContaining({
18-
op: 'function.step.do',
18+
op: 'function',
1919
data: expect.objectContaining({
20-
'sentry.op': 'function.step.do',
20+
'sentry.op': 'function',
2121
'sentry.origin': 'auto.faas.cloudflare.workflow',
2222
}),
2323
origin: 'auto.faas.cloudflare.workflow',

dev-packages/cloudflare-integration-tests/suites/tracing/scheduled/test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,11 @@ it('Scheduled handler creates transaction with correct attributes', async ({ sig
2222
trace: {
2323
span_id: expect.any(String),
2424
trace_id: expect.any(String),
25-
op: 'faas.cron',
25+
op: 'function',
2626
origin: 'auto.faas.cloudflare.scheduled',
2727
status: 'ok',
2828
data: {
29-
[SEMANTIC_ATTRIBUTE_SENTRY_OP]: 'faas.cron',
29+
[SEMANTIC_ATTRIBUTE_SENTRY_OP]: 'function',
3030
[SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: 'auto.faas.cloudflare.scheduled',
3131
[SEMANTIC_ATTRIBUTE_SENTRY_SOURCE]: 'task',
3232
[SEMANTIC_ATTRIBUTE_SENTRY_SAMPLE_RATE]: 1,

dev-packages/cloudflare-integration-tests/suites/tracing/workflow/test.ts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,16 @@ it('Workflow steps create transactions with correct attributes', async ({ signal
2121
trace: {
2222
span_id: expect.any(String),
2323
trace_id: expect.any(String),
24-
op: 'function.step.do',
24+
op: 'function',
2525
origin: 'auto.faas.cloudflare.workflow',
2626
status: 'ok',
2727
data: {
28-
[SEMANTIC_ATTRIBUTE_SENTRY_OP]: 'function.step.do',
28+
[SEMANTIC_ATTRIBUTE_SENTRY_OP]: 'function',
2929
[SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: 'auto.faas.cloudflare.workflow',
3030
[SEMANTIC_ATTRIBUTE_SENTRY_SOURCE]: 'task',
3131
[SEMANTIC_ATTRIBUTE_SENTRY_SAMPLE_RATE]: 1,
32+
'code.function.name': 'step-one',
33+
'workflow.step.name': 'step-one',
3234
'cloudflare.workflow.attempt': 1,
3335
},
3436
},
@@ -48,14 +50,16 @@ it('Workflow steps create transactions with correct attributes', async ({ signal
4850
trace: {
4951
span_id: expect.any(String),
5052
trace_id: expect.any(String),
51-
op: 'function.step.do',
53+
op: 'function',
5254
origin: 'auto.faas.cloudflare.workflow',
5355
status: 'ok',
5456
data: {
55-
[SEMANTIC_ATTRIBUTE_SENTRY_OP]: 'function.step.do',
57+
[SEMANTIC_ATTRIBUTE_SENTRY_OP]: 'function',
5658
[SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: 'auto.faas.cloudflare.workflow',
5759
[SEMANTIC_ATTRIBUTE_SENTRY_SOURCE]: 'task',
5860
[SEMANTIC_ATTRIBUTE_SENTRY_SAMPLE_RATE]: 1,
61+
'code.function.name': 'step-two',
62+
'workflow.step.name': 'step-two',
5963
'cloudflare.workflow.attempt': 1,
6064
},
6165
},

dev-packages/cloudflare-integration-tests/suites/vite-autoinstrument/durableobject-workflow-manual-mixed/test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,12 @@ function expectDurableObjectTransaction(transactionEvent: TransactionEvent): voi
2828
]);
2929
}
3030

31-
// A workflow step runs in its own invocation and reports a `function.step.do` /
31+
// A workflow step runs in its own invocation and reports a `function` /
3232
// `auto.faas.cloudflare.workflow` transaction named after the step — present
3333
// only because the transform auto-wrapped the Workflow class.
3434
function expectWorkflowStepTransaction(transactionEvent: TransactionEvent): void {
3535
expect(transactionEvent.transaction).toBe('step-one');
36-
expect(transactionEvent.contexts?.trace?.op).toBe('function.step.do');
36+
expect(transactionEvent.contexts?.trace?.op).toBe('function');
3737
expect(transactionEvent.contexts?.trace?.origin).toBe('auto.faas.cloudflare.workflow');
3838
}
3939

dev-packages/cloudflare-integration-tests/suites/vite-autoinstrument/durableobject-workflow-specifier/test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,12 @@ function expectDurableObjectTransaction(transactionEvent: TransactionEvent): voi
2828
]);
2929
}
3030

31-
// A workflow step runs in its own invocation and reports a `function.step.do` /
31+
// A workflow step runs in its own invocation and reports a `function` /
3232
// `auto.faas.cloudflare.workflow` transaction named after the step — present
3333
// only when the Workflow class was wrapped with `instrumentWorkflowWithSentry`.
3434
function expectWorkflowStepTransaction(transactionEvent: TransactionEvent): void {
3535
expect(transactionEvent.transaction).toBe('step-one');
36-
expect(transactionEvent.contexts?.trace?.op).toBe('function.step.do');
36+
expect(transactionEvent.contexts?.trace?.op).toBe('function');
3737
expect(transactionEvent.contexts?.trace?.origin).toBe('auto.faas.cloudflare.workflow');
3838
}
3939

dev-packages/cloudflare-integration-tests/suites/vite-autoinstrument/durableobject-workflow/test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,12 @@ function expectDurableObjectTransaction(transactionEvent: TransactionEvent): voi
2828
]);
2929
}
3030

31-
// A workflow step runs in its own invocation and reports a `function.step.do` /
31+
// A workflow step runs in its own invocation and reports a `function` /
3232
// `auto.faas.cloudflare.workflow` transaction named after the step — present
3333
// only when the Workflow class was wrapped with `instrumentWorkflowWithSentry`.
3434
function expectWorkflowStepTransaction(transactionEvent: TransactionEvent): void {
3535
expect(transactionEvent.transaction).toBe('step-one');
36-
expect(transactionEvent.contexts?.trace?.op).toBe('function.step.do');
36+
expect(transactionEvent.contexts?.trace?.op).toBe('function');
3737
expect(transactionEvent.contexts?.trace?.origin).toBe('auto.faas.cloudflare.workflow');
3838
}
3939

dev-packages/cloudflare-integration-tests/suites/vite-autoinstrument/workflow/test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ it('auto-instruments a Workflow class', async ({ signal }) => {
1111
.expect(envelope => {
1212
const transactionEvent = envelope[1]?.[0]?.[1] as TransactionEvent;
1313
expect(transactionEvent.transaction).toBe('step-one');
14-
expect(transactionEvent.contexts?.trace?.op).toBe('function.step.do');
14+
expect(transactionEvent.contexts?.trace?.op).toBe('function');
1515
expect(transactionEvent.contexts?.trace?.origin).toBe('auto.faas.cloudflare.workflow');
1616
})
1717
.start(signal);

packages/cloudflare/src/instrumentations/worker/instrumentEmail.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
import type { EmailMessage, ExportedHandler } from '@cloudflare/workers-types';
22
import type { env as cloudflareEnv } from 'cloudflare:workers';
3+
import { SENTRY_OP } from '@sentry/conventions/attributes';
4+
import { GENERAL_FUNCTION_SPAN_OP } from '@sentry/conventions/op';
35
import {
46
captureException,
57
SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN,
@@ -35,9 +37,9 @@ function wrapEmailHandler(
3537

3638
return startSpan(
3739
{
38-
op: 'faas.email',
3940
name: `Handle Email ${emailMessage.to}`,
4041
attributes: {
42+
[SENTRY_OP]: GENERAL_FUNCTION_SPAN_OP,
4143
'faas.trigger': 'email',
4244
[SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: 'auto.faas.cloudflare.email',
4345
[SEMANTIC_ATTRIBUTE_SENTRY_SOURCE]: 'task',

0 commit comments

Comments
 (0)