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 @@ -183,7 +183,7 @@ it('does not propagate trace from scheduled handler to durable object when enabl
expect.objectContaining({
contexts: expect.objectContaining({
trace: expect.objectContaining({
op: 'faas.cron',
op: 'function',
data: expect.objectContaining({
'sentry.origin': 'auto.faas.cloudflare.scheduled',
}),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ it('propagates trace from scheduled handler to durable object', async ({ signal
expect.objectContaining({
contexts: expect.objectContaining({
trace: expect.objectContaining({
op: 'faas.cron',
op: 'function',
data: expect.objectContaining({
'sentry.origin': 'auto.faas.cloudflare.scheduled',
}),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ it('traces a workflow that calls a durable object with the same trace id', async
expect.objectContaining({
contexts: expect.objectContaining({
trace: expect.objectContaining({
op: 'function.step.do',
op: 'function',
data: expect.objectContaining({
'sentry.op': 'function.step.do',
'sentry.op': 'function',
'sentry.origin': 'auto.faas.cloudflare.workflow',
}),
origin: 'auto.faas.cloudflare.workflow',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@ it('Scheduled handler creates transaction with correct attributes', async ({ sig
trace: {
span_id: expect.any(String),
trace_id: expect.any(String),
op: 'faas.cron',
op: 'function',
origin: 'auto.faas.cloudflare.scheduled',
status: 'ok',
data: {
[SEMANTIC_ATTRIBUTE_SENTRY_OP]: 'faas.cron',
[SEMANTIC_ATTRIBUTE_SENTRY_OP]: 'function',
[SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: 'auto.faas.cloudflare.scheduled',
[SEMANTIC_ATTRIBUTE_SENTRY_SOURCE]: 'task',
[SEMANTIC_ATTRIBUTE_SENTRY_SAMPLE_RATE]: 1,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,16 @@ it('Workflow steps create transactions with correct attributes', async ({ signal
trace: {
span_id: expect.any(String),
trace_id: expect.any(String),
op: 'function.step.do',
op: 'function',
origin: 'auto.faas.cloudflare.workflow',
status: 'ok',
data: {
[SEMANTIC_ATTRIBUTE_SENTRY_OP]: 'function.step.do',
[SEMANTIC_ATTRIBUTE_SENTRY_OP]: 'function',
[SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: 'auto.faas.cloudflare.workflow',
[SEMANTIC_ATTRIBUTE_SENTRY_SOURCE]: 'task',
[SEMANTIC_ATTRIBUTE_SENTRY_SAMPLE_RATE]: 1,
'code.function.name': 'step-one',
'workflow.step.name': 'step-one',
'cloudflare.workflow.attempt': 1,
},
},
Expand All @@ -48,14 +50,16 @@ it('Workflow steps create transactions with correct attributes', async ({ signal
trace: {
span_id: expect.any(String),
trace_id: expect.any(String),
op: 'function.step.do',
op: 'function',
origin: 'auto.faas.cloudflare.workflow',
status: 'ok',
data: {
[SEMANTIC_ATTRIBUTE_SENTRY_OP]: 'function.step.do',
[SEMANTIC_ATTRIBUTE_SENTRY_OP]: 'function',
[SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: 'auto.faas.cloudflare.workflow',
[SEMANTIC_ATTRIBUTE_SENTRY_SOURCE]: 'task',
[SEMANTIC_ATTRIBUTE_SENTRY_SAMPLE_RATE]: 1,
'code.function.name': 'step-two',
'workflow.step.name': 'step-two',
'cloudflare.workflow.attempt': 1,
},
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,12 @@ function expectDurableObjectTransaction(transactionEvent: TransactionEvent): voi
]);
}

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,12 @@ function expectDurableObjectTransaction(transactionEvent: TransactionEvent): voi
]);
}

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,12 @@ function expectDurableObjectTransaction(transactionEvent: TransactionEvent): voi
]);
}

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ it('auto-instruments a Workflow class', async ({ signal }) => {
.expect(envelope => {
const transactionEvent = envelope[1]?.[0]?.[1] as TransactionEvent;
expect(transactionEvent.transaction).toBe('step-one');
expect(transactionEvent.contexts?.trace?.op).toBe('function.step.do');
expect(transactionEvent.contexts?.trace?.op).toBe('function');
expect(transactionEvent.contexts?.trace?.origin).toBe('auto.faas.cloudflare.workflow');
})
.start(signal);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import type { EmailMessage, ExportedHandler } from '@cloudflare/workers-types';
import type { env as cloudflareEnv } from 'cloudflare:workers';
import { SENTRY_OP } from '@sentry/conventions/attributes';
import { GENERAL_FUNCTION_SPAN_OP } from '@sentry/conventions/op';
import {
captureException,
SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN,
Expand Down Expand Up @@ -35,9 +37,9 @@ function wrapEmailHandler(

return startSpan(
{
op: 'faas.email',
name: `Handle Email ${emailMessage.to}`,
attributes: {
[SENTRY_OP]: GENERAL_FUNCTION_SPAN_OP,
'faas.trigger': 'email',
[SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: 'auto.faas.cloudflare.email',
[SEMANTIC_ATTRIBUTE_SENTRY_SOURCE]: 'task',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import type { ExportedHandler, ScheduledController } from '@cloudflare/workers-types';
import type { env as cloudflareEnv, WorkerEntrypoint } from 'cloudflare:workers';
import { SENTRY_OP } from '@sentry/conventions/attributes';
import { GENERAL_FUNCTION_SPAN_OP } from '@sentry/conventions/op';
import {
captureException,
SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN,
Expand Down Expand Up @@ -32,9 +34,9 @@ function wrapScheduledHandler(

return startSpan(
{
op: 'faas.cron',
name: `Scheduled Cron ${controller.cron}`,
attributes: {
[SENTRY_OP]: GENERAL_FUNCTION_SPAN_OP,
'faas.cron': controller.cron,
'faas.time': new Date(controller.scheduledTime).toISOString(),
'faas.trigger': 'timer',
Expand Down
6 changes: 5 additions & 1 deletion packages/cloudflare/src/workflows.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { CODE_FUNCTION_NAME, SENTRY_OP } from '@sentry/conventions/attributes';
import { GENERAL_FUNCTION_SPAN_OP } from '@sentry/conventions/op';
import type { PropagationContext } from '@sentry/core';
import {
captureException,
Expand Down Expand Up @@ -117,10 +119,12 @@ class WrappedWorkflowStep implements WorkflowStep {

return startSpan(
{
op: 'function.step.do',
name,
scope: scopeForStep,
attributes: {
[SENTRY_OP]: GENERAL_FUNCTION_SPAN_OP,
[CODE_FUNCTION_NAME]: name,
'workflow.step.name': name,
'cloudflare.workflow.timeout': config?.timeout,
'cloudflare.workflow.retries.backoff': config?.retries?.backoff,
// In workers-types v5, `delay` may be a `WorkflowDelayFunction`, which isn't a valid span attribute value.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -262,12 +262,12 @@ describe('instrumentEmail', () => {
expect(sentryEvent.contexts?.trace).toEqual({
data: {
'sentry.origin': 'auto.faas.cloudflare.email',
'sentry.op': 'faas.email',
'sentry.op': 'function',
'faas.trigger': 'email',
'sentry.sample_rate': 1,
'sentry.source': 'task',
},
op: 'faas.email',
op: 'function',
origin: 'auto.faas.cloudflare.email',
status: 'ok',
span_id: expect.stringMatching(/[a-f0-9]{16}/),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -256,14 +256,14 @@ describe('instrumentScheduled', () => {
expect(sentryEvent.contexts?.trace).toEqual({
data: {
'sentry.origin': 'auto.faas.cloudflare.scheduled',
'sentry.op': 'faas.cron',
'sentry.op': 'function',
'faas.cron': '0 0 0 * * *',
'faas.time': expect.any(String),
'faas.trigger': 'timer',
'sentry.sample_rate': 1,
'sentry.source': 'task',
},
op: 'faas.cron',
op: 'function',
origin: 'auto.faas.cloudflare.scheduled',
status: 'ok',
span_id: expect.stringMatching(/[a-f0-9]{16}/),
Expand Down
18 changes: 9 additions & 9 deletions packages/cloudflare/test/workflow.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -159,11 +159,11 @@ describe.skipIf(NODE_MAJOR_VERSION < 20)('workflows', () => {
trace_id: TRACE_ID,
data: expect.objectContaining({
'sentry.origin': 'auto.faas.cloudflare.workflow',
'sentry.op': 'function.step.do',
'sentry.op': 'function',
'sentry.source': 'task',
'sentry.sample_rate': 1,
}),
op: 'function.step.do',
op: 'function',
status: 'ok',
origin: 'auto.faas.cloudflare.workflow',
}),
Expand Down Expand Up @@ -276,11 +276,11 @@ describe.skipIf(NODE_MAJOR_VERSION < 20)('workflows', () => {
trace_id: '0d2b6d1743ce6d53af4f5ee416ad5d1b',
data: expect.objectContaining({
'sentry.origin': 'auto.faas.cloudflare.workflow',
'sentry.op': 'function.step.do',
'sentry.op': 'function',
'sentry.source': 'task',
'sentry.sample_rate': 1,
}),
op: 'function.step.do',
op: 'function',
status: 'ok',
origin: 'auto.faas.cloudflare.workflow',
}),
Expand Down Expand Up @@ -353,11 +353,11 @@ describe.skipIf(NODE_MAJOR_VERSION < 20)('workflows', () => {
trace_id: TRACE_ID,
data: expect.objectContaining({
'sentry.origin': 'auto.faas.cloudflare.workflow',
'sentry.op': 'function.step.do',
'sentry.op': 'function',
'sentry.source': 'task',
'sentry.sample_rate': 1,
}),
op: 'function.step.do',
op: 'function',
status: 'internal_error',
origin: 'auto.faas.cloudflare.workflow',
}),
Expand Down Expand Up @@ -396,11 +396,11 @@ describe.skipIf(NODE_MAJOR_VERSION < 20)('workflows', () => {
trace_id: TRACE_ID,
data: expect.objectContaining({
'sentry.origin': 'auto.faas.cloudflare.workflow',
'sentry.op': 'function.step.do',
'sentry.op': 'function',
'sentry.source': 'task',
'sentry.sample_rate': 1,
}),
op: 'function.step.do',
op: 'function',
status: 'ok',
origin: 'auto.faas.cloudflare.workflow',
}),
Expand Down Expand Up @@ -609,7 +609,7 @@ describe.skipIf(NODE_MAJOR_VERSION < 20)('workflows', () => {
const rootSpanId = rootSpan.contexts.trace.span_id;

// Child span for the step.do with the custom span as parent
const stepSpan = rootSpan.spans.find((s: any) => s.description === 'first step' && s.op === 'function.step.do');
const stepSpan = rootSpan.spans.find((s: any) => s.description === 'first step' && s.op === 'function');
expect(stepSpan).toBeDefined();
expect(stepSpan.parent_span_id).toBe(rootSpanId);
});
Expand Down
Loading