-
Notifications
You must be signed in to change notification settings - Fork 3.7k
Expand file tree
/
Copy pathtrigger.config.ts
More file actions
85 lines (81 loc) · 2.96 KB
/
Copy pathtrigger.config.ts
File metadata and controls
85 lines (81 loc) · 2.96 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
import { OTLPLogExporter } from '@opentelemetry/exporter-logs-otlp-http'
import { OTLPMetricExporter } from '@opentelemetry/exporter-metrics-otlp-http'
import { OTLPTraceExporter } from '@opentelemetry/exporter-trace-otlp-http'
import { resourceFromAttributes } from '@opentelemetry/resources'
import {
additionalFiles,
additionalPackages,
syncEnvVars,
} from '@trigger.dev/build/extensions/core'
import { defineConfig } from '@trigger.dev/sdk'
import { env } from './lib/core/config/env'
import { parseOtlpHeaders } from './lib/monitoring/otlp'
const grafanaEndpoint = env.GRAFANA_OTLP_ENDPOINT
const grafanaHeaders = env.GRAFANA_OTLP_HEADERS
const grafanaDeploymentEnvironment = env.GRAFANA_DEPLOYMENT_ENVIRONMENT
const grafanaConfigured = Boolean(grafanaEndpoint || grafanaHeaders || grafanaDeploymentEnvironment)
const grafanaFullyConfigured = Boolean(
grafanaEndpoint && grafanaHeaders && grafanaDeploymentEnvironment
)
if (grafanaConfigured && !grafanaFullyConfigured) {
throw new Error(
'Grafana OTLP telemetry is partially configured. Set GRAFANA_OTLP_ENDPOINT, GRAFANA_OTLP_HEADERS, and GRAFANA_DEPLOYMENT_ENVIRONMENT together, or leave all three unset.'
)
}
const grafanaTelemetry = grafanaFullyConfigured
? (() => {
const baseUrl = grafanaEndpoint!.replace(/\/+$/, '')
const headers = parseOtlpHeaders(grafanaHeaders!)
if (Object.keys(headers).length === 0) {
throw new Error(
'GRAFANA_OTLP_HEADERS is set but yielded no valid key=value pairs. Expected format: "key1=value1,key2=value2".'
)
}
const resource = resourceFromAttributes({
'deployment.environment.name': grafanaDeploymentEnvironment!,
})
return {
exporters: [new OTLPTraceExporter({ url: `${baseUrl}/v1/traces`, headers })],
logExporters: [new OTLPLogExporter({ url: `${baseUrl}/v1/logs`, headers })],
metricExporters: [new OTLPMetricExporter({ url: `${baseUrl}/v1/metrics`, headers })],
resource,
}
})()
: undefined
export default defineConfig({
project: env.TRIGGER_PROJECT_ID!,
runtime: 'node-22',
logLevel: 'log',
maxDuration: 5400,
retries: {
enabledInDev: false,
default: {
maxAttempts: 1,
},
},
dirs: ['./background'],
...(grafanaTelemetry ? { telemetry: grafanaTelemetry } : {}),
build: {
external: ['isolated-vm', '@earendil-works/pi-coding-agent', 'cpu-features'],
extensions: [
syncEnvVars(() => [{ name: 'DB_APP_NAME', value: 'sim-trigger' }]),
additionalFiles({
files: [
'./lib/execution/isolated-vm-worker.cjs',
'./lib/execution/sandbox/bundles/pptxgenjs.cjs',
'./lib/execution/sandbox/bundles/docx.cjs',
'./lib/execution/sandbox/bundles/pdf-lib.cjs',
],
}),
additionalPackages({
packages: [
'unpdf',
'isolated-vm',
'react-dom',
'@react-email/render',
'@earendil-works/pi-coding-agent',
],
}),
],
},
})