Skip to content
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

Merged
merged 22 commits into from
Dec 15, 2023
Merged

Telemetry collection p2 #222

merged 22 commits into from
Dec 15, 2023

Conversation

maxdml
Copy link
Contributor

@maxdml maxdml commented Dec 13, 2023

  • Use protobuf to export OTLP signals
  • Make 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 in internalWorkflow to accommodate the testing runtime. Eventually we should just expose the executor ID to the environment.
  • Systematically add operation (workflow, transaction, etc) information to trace attributes

@maxdml maxdml force-pushed the telemetry-collection-p2 branch from 2fb9444 to 2e63bfd Compare December 14, 2023 03:43
Comment on lines +50 to +51
"@opentelemetry/exporter-logs-otlp-proto": "0.46.0",
"@opentelemetry/exporter-trace-otlp-proto": "0.46.0",
Copy link
Contributor Author

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}`);
Copy link
Contributor Author

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.

Comment on lines +80 to +85
export const OperationType = {
HANDLER: "handler",
WORKFLOW: "workflow",
TRANSACTION: "transaction",
COMMUNICATOR: "communicator",
} as const;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Useful as span metadata

Comment on lines +71 to +73
if (koaContext.request.headers && koaContext.request.headers[DBOSExecutorIDHeader]) {
this.executorID = koaContext.request.headers[DBOSExecutorIDHeader] as string;
}
Copy link
Contributor Author

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
Copy link
Contributor Author

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

Comment on lines +190 to +200
const logRecordProcessor = {
forceFlush: async () => {
// no-op
},
onEmit(logRecord: LogRecord) {
telemetryCollector.push(logRecord);
},
shutdown: async () => {
// no-op
},
};
Copy link
Contributor Author

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);
Copy link
Contributor Author

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

@maxdml maxdml marked this pull request as ready for review December 15, 2023 01:34
@@ -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,
Copy link
Member

@kraftp kraftp Dec 15, 2023

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?

Copy link
Contributor Author

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.

Copy link
Member

@kraftp kraftp left a 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...)?

@maxdml
Copy link
Contributor Author

maxdml commented Dec 15, 2023

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

@maxdml maxdml merged commit 6dcbe08 into main Dec 15, 2023
2 checks passed
@maxdml maxdml deleted the telemetry-collection-p2 branch December 15, 2023 23:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants