fix: Queue retry behavior (#3359)

* fix: Queue retry behavior

* Add default options for task queue
This commit is contained in:
Tom Moor
2022-04-10 17:50:42 -07:00
committed by GitHub
parent cfa71762c2
commit 963475d2b0
5 changed files with 124 additions and 34 deletions

View File

@@ -3,6 +3,7 @@ import winston from "winston";
import env from "@server/env";
import Metrics from "@server/logging/metrics";
import Sentry from "@server/logging/sentry";
import * as Tracing from "./tracing";
const isProduction = env.NODE_ENV === "production";
type LogCategory =
@@ -10,8 +11,9 @@ type LogCategory =
| "hocuspocus"
| "http"
| "commands"
| "processor"
| "worker"
| "task"
| "processor"
| "email"
| "queue"
| "database"
@@ -98,6 +100,7 @@ class Logger {
*/
error(message: string, error: Error, extra?: Extra) {
Metrics.increment("logger.error");
Tracing.setError(error);
if (process.env.SENTRY_DSN) {
Sentry.withScope(function (scope) {

View File

@@ -1,4 +1,4 @@
import { init, tracer } from "@theo.gravity/datadog-apm";
import { init, tracer, addTags, markAsError } from "@theo.gravity/datadog-apm";
export * as APM from "@theo.gravity/datadog-apm";
@@ -18,4 +18,30 @@ if (process.env.DD_API_KEY) {
);
}
/**
* Change the resource of the active APM span. This method wraps addTags to allow
* safe use in environments where APM is disabled.
*
* @param name The name of the resource
*/
export function setResource(name: string) {
if (tracer) {
addTags({
"resource.name": `${name}`,
});
}
}
/**
* Mark the current active span as an error. This method wraps addTags to allow
* safe use in environments where APM is disabled.
*
* @param error The error to add
*/
export function setError(error: Error) {
if (tracer) {
markAsError(error);
}
}
export default tracer;