-
Notifications
You must be signed in to change notification settings - Fork 37
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
Telemetry collection p2 #222
Conversation
…y of DBOS context and add it to every span
2fb9444
to
2e63bfd
Compare
"@opentelemetry/exporter-logs-otlp-proto": "0.46.0", | ||
"@opentelemetry/exporter-trace-otlp-proto": "0.46.0", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use the latest version and lock it. These are experimental packages and breaking changes happen often.
@@ -276,7 +283,7 @@ export class DBOSExecutor { | |||
} catch (err) { | |||
(err as Error).message = `failed to initialize workflow executor: ${(err as Error).message}` | |||
this.logger.error(err); | |||
throw new DBOSInitializationError(`failed to initialize workflow executor: ${(err as Error).message}`); | |||
throw new DBOSInitializationError(`${(err as Error).message}`); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove duplicate text in this error message.
export const OperationType = { | ||
HANDLER: "handler", | ||
WORKFLOW: "workflow", | ||
TRANSACTION: "transaction", | ||
COMMUNICATOR: "communicator", | ||
} as const; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Useful as span metadata
if (koaContext.request.headers && koaContext.request.headers[DBOSExecutorIDHeader]) { | ||
this.executorID = koaContext.request.headers[DBOSExecutorIDHeader] as string; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Now get executor ID as soon as we create the handler context
traceId: string; | ||
spanId: string; | ||
includeContextMetadata: boolean; // Should the console transport formatter include the context metadata? | ||
span: Span; // All context metadata should be attributes of the context's span |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We use the span attributes as bearer for all contextual metadata
const logRecordProcessor = { | ||
forceFlush: async () => { | ||
// no-op | ||
}, | ||
onEmit(logRecord: LogRecord) { | ||
telemetryCollector.push(logRecord); | ||
}, | ||
shutdown: async () => { | ||
// no-op | ||
}, | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a custom log processor we can given to the OTel logger. It's only job is to push log records in our collector queue.
We might want to tweak its parameters in the future.
@@ -146,7 +146,7 @@ describe("recovery-tests", () => { | |||
ExecutorRecovery.resolve2 = resolve; | |||
}); | |||
|
|||
const execHandle = await testRuntime.invoke(ExecutorRecovery, undefined, { authenticatedUser: "cloud_user", request: { headers: { "dbos-executor-id": "fcvm123" } } }).executorWorkflow(5); | |||
const execHandle = await testRuntime.invoke(ExecutorRecovery, undefined, { authenticatedUser: "cloud_user", request: { headers: { "dbos-executor-id": "fcvm123", executorID: "fcvm123" } } }).executorWorkflow(5); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
works around the fact that the testing runtime does not use the handlers
@@ -27,7 +27,17 @@ export class WorkflowContextDebug extends DBOSContextImpl implements WorkflowCon | |||
readonly isTempWorkflow: boolean; | |||
|
|||
constructor(dbosExec: DBOSExecutor, parentCtx: DBOSContextImpl | undefined, workflowUUID: string, readonly workflowConfig: WorkflowConfig, workflowName: string) { | |||
const span = dbosExec.tracer.startSpan(workflowName, { workflowUUID: workflowUUID }, parentCtx?.span); | |||
const span = dbosExec.tracer.startSpan( | |||
workflowName, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why are we doing any sort of tracing in debug workflows? @qianl15 what do you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah right now the usage is unclear. Maybe we could need it for retro action, in the future. Happy to remove it if @qianl15 doesn't find it useful.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good. To make sure I'm understanding it right, the main goals are to add better information to the trace attributes and to temporarily improve our handling of executor IDs (which really should be handled through MMDS...)?
Correct |
executorID
1) a property of the context 2) parsed from headers at the handler (earlier than where it was before, when creating a workflow context). ExecutorID is "local" by default and will take on the header's if provided. Note we have to keep the logic ininternalWorkflow
to accommodate the testing runtime. Eventually we should just expose the executor ID to the environment.