@hatchet-dev/typescript-sdk 1.17.2 → 1.19.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (35) hide show
  1. package/clients/event/event-client.d.ts +8 -0
  2. package/clients/event/event-client.js +8 -0
  3. package/clients/hatchet-client/client-config.d.ts +45 -0
  4. package/clients/hatchet-client/client-config.js +14 -1
  5. package/opentelemetry/hatchet-exporter.d.ts +36 -0
  6. package/opentelemetry/hatchet-exporter.js +145 -0
  7. package/opentelemetry/hatchet-span-context.d.ts +22 -0
  8. package/opentelemetry/hatchet-span-context.js +27 -0
  9. package/opentelemetry/index.d.ts +3 -0
  10. package/opentelemetry/index.js +7 -0
  11. package/opentelemetry/instrumentor.d.ts +78 -0
  12. package/opentelemetry/instrumentor.js +592 -0
  13. package/opentelemetry/types.d.ts +6 -0
  14. package/opentelemetry/types.js +8 -0
  15. package/package.json +6 -1
  16. package/util/config-loader/config-loader.d.ts +1 -0
  17. package/util/config-loader/config-loader.js +18 -4
  18. package/util/opentelemetry.d.ts +34 -0
  19. package/util/opentelemetry.js +38 -0
  20. package/v1/client/admin.d.ts +6 -0
  21. package/v1/client/admin.js +6 -0
  22. package/v1/client/features/schedules.d.ts +3 -0
  23. package/v1/client/features/schedules.js +3 -0
  24. package/v1/client/worker/worker-internal.d.ts +10 -2
  25. package/v1/client/worker/worker-internal.js +13 -2
  26. package/v1/examples/opentelemetry_instrumentation/run.d.ts +1 -0
  27. package/v1/examples/opentelemetry_instrumentation/run.js +57 -0
  28. package/v1/examples/opentelemetry_instrumentation/setup.d.ts +9 -0
  29. package/v1/examples/opentelemetry_instrumentation/setup.js +26 -0
  30. package/v1/examples/opentelemetry_instrumentation/worker.d.ts +7 -0
  31. package/v1/examples/opentelemetry_instrumentation/worker.js +123 -0
  32. package/v1/examples/webhooks/workflow.d.ts +61 -0
  33. package/v1/examples/webhooks/workflow.js +58 -1
  34. package/version.d.ts +1 -1
  35. package/version.js +1 -1
@@ -29,7 +29,15 @@ export declare class EventClient {
29
29
  tenantId: string;
30
30
  logger: Logger;
31
31
  constructor(config: ClientConfig, channel: Channel, factory: ClientFactory, api: HatchetClient['api']);
32
+ /**
33
+ * @important This method is instrumented by HatchetInstrumentor._patchPushEvent.
34
+ * Keep the signature in sync with the instrumentor wrapper.
35
+ */
32
36
  push<T>(type: string, input: T, options?: PushEventOptions): Promise<import("../../protoc/events/events").Event>;
37
+ /**
38
+ * @important This method is instrumented by HatchetInstrumentor._patchBulkPushEvent.
39
+ * Keep the signature in sync with the instrumentor wrapper.
40
+ */
33
41
  bulkPush<T>(type: string, inputs: EventWithMetadata<T>[], options?: PushEventOptions): Promise<import("../../protoc/events/events").Events>;
34
42
  putLog(taskRunExternalId: string, log: string, level?: LogLevel, taskRetryCount?: number, metadata?: Record<string, unknown>): Promise<void>;
35
43
  putStream(taskRunExternalId: string, data: string | Uint8Array, index: number | undefined): Promise<void>;
@@ -30,6 +30,10 @@ class EventClient {
30
30
  this.api = api;
31
31
  this.tenantId = config.tenant_id;
32
32
  }
33
+ /**
34
+ * @important This method is instrumented by HatchetInstrumentor._patchPushEvent.
35
+ * Keep the signature in sync with the instrumentor wrapper.
36
+ */
33
37
  push(type, input, options = {}) {
34
38
  const namespacedType = (0, apply_namespace_1.applyNamespace)(type, this.config.namespace);
35
39
  const req = {
@@ -51,6 +55,10 @@ class EventClient {
51
55
  throw (0, hatchet_error_1.toHatchetError)(e);
52
56
  }
53
57
  }
58
+ /**
59
+ * @important This method is instrumented by HatchetInstrumentor._patchBulkPushEvent.
60
+ * Keep the signature in sync with the instrumentor wrapper.
61
+ */
54
62
  bulkPush(type, inputs, options = {}) {
55
63
  const namespacedType = (0, apply_namespace_1.applyNamespace)(type, this.config.namespace);
56
64
  const events = inputs.map((input) => {
@@ -21,6 +21,25 @@ declare const ClientTLSConfigSchema: z.ZodObject<{
21
21
  key_file?: string | undefined;
22
22
  server_name?: string | undefined;
23
23
  }>;
24
+ export declare const OpenTelemetryConfigSchema: z.ZodObject<{
25
+ /**
26
+ * List of attribute keys to exclude from spans.
27
+ * Useful for filtering sensitive or verbose data like payloads.
28
+ */
29
+ excludedAttributes: z.ZodDefault<z.ZodOptional<z.ZodArray<z.ZodString, "many">>>;
30
+ /**
31
+ * If true, includes the task name in the span name for task run spans.
32
+ * e.g., "hatchet.start_step_run.my_task" instead of "hatchet.start_step_run"
33
+ */
34
+ includeTaskNameInSpanName: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
35
+ }, "strip", z.ZodTypeAny, {
36
+ excludedAttributes: string[];
37
+ includeTaskNameInSpanName: boolean;
38
+ }, {
39
+ excludedAttributes?: string[] | undefined;
40
+ includeTaskNameInSpanName?: boolean | undefined;
41
+ }>;
42
+ export type OpenTelemetryConfig = z.infer<typeof OpenTelemetryConfigSchema>;
24
43
  export declare const ClientConfigSchema: z.ZodObject<{
25
44
  token: z.ZodString;
26
45
  tls_config: z.ZodObject<{
@@ -57,6 +76,24 @@ export declare const ClientConfigSchema: z.ZodObject<{
57
76
  log_level: z.ZodOptional<z.ZodEnum<["OFF", "DEBUG", "INFO", "WARN", "ERROR"]>>;
58
77
  tenant_id: z.ZodString;
59
78
  namespace: z.ZodOptional<z.ZodString>;
79
+ otel: z.ZodOptional<z.ZodObject<{
80
+ /**
81
+ * List of attribute keys to exclude from spans.
82
+ * Useful for filtering sensitive or verbose data like payloads.
83
+ */
84
+ excludedAttributes: z.ZodDefault<z.ZodOptional<z.ZodArray<z.ZodString, "many">>>;
85
+ /**
86
+ * If true, includes the task name in the span name for task run spans.
87
+ * e.g., "hatchet.start_step_run.my_task" instead of "hatchet.start_step_run"
88
+ */
89
+ includeTaskNameInSpanName: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
90
+ }, "strip", z.ZodTypeAny, {
91
+ excludedAttributes: string[];
92
+ includeTaskNameInSpanName: boolean;
93
+ }, {
94
+ excludedAttributes?: string[] | undefined;
95
+ includeTaskNameInSpanName?: boolean | undefined;
96
+ }>>;
60
97
  middleware: z.ZodOptional<z.ZodObject<{
61
98
  before: z.ZodOptional<z.ZodAny>;
62
99
  after: z.ZodOptional<z.ZodAny>;
@@ -89,6 +126,10 @@ export declare const ClientConfigSchema: z.ZodObject<{
89
126
  } | undefined;
90
127
  log_level?: "OFF" | "DEBUG" | "INFO" | "WARN" | "ERROR" | undefined;
91
128
  namespace?: string | undefined;
129
+ otel?: {
130
+ excludedAttributes: string[];
131
+ includeTaskNameInSpanName: boolean;
132
+ } | undefined;
92
133
  middleware?: {
93
134
  before?: any;
94
135
  after?: any;
@@ -111,6 +152,10 @@ export declare const ClientConfigSchema: z.ZodObject<{
111
152
  } | undefined;
112
153
  log_level?: "OFF" | "DEBUG" | "INFO" | "WARN" | "ERROR" | undefined;
113
154
  namespace?: string | undefined;
155
+ otel?: {
156
+ excludedAttributes?: string[] | undefined;
157
+ includeTaskNameInSpanName?: boolean | undefined;
158
+ } | undefined;
114
159
  middleware?: {
115
160
  before?: any;
116
161
  after?: any;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ClientConfigSchema = void 0;
3
+ exports.ClientConfigSchema = exports.OpenTelemetryConfigSchema = void 0;
4
4
  const zod_1 = require("zod");
5
5
  const ClientTLSConfigSchema = zod_1.z.object({
6
6
  tls_strategy: zod_1.z.enum(['tls', 'mtls', 'none']).optional(),
@@ -13,6 +13,18 @@ const HealthcheckConfigSchema = zod_1.z.object({
13
13
  enabled: zod_1.z.boolean().optional().default(false),
14
14
  port: zod_1.z.number().optional().default(8001),
15
15
  });
16
+ exports.OpenTelemetryConfigSchema = zod_1.z.object({
17
+ /**
18
+ * List of attribute keys to exclude from spans.
19
+ * Useful for filtering sensitive or verbose data like payloads.
20
+ */
21
+ excludedAttributes: zod_1.z.array(zod_1.z.string()).optional().default([]),
22
+ /**
23
+ * If true, includes the task name in the span name for task run spans.
24
+ * e.g., "hatchet.start_step_run.my_task" instead of "hatchet.start_step_run"
25
+ */
26
+ includeTaskNameInSpanName: zod_1.z.boolean().optional().default(false),
27
+ });
16
28
  const TaskMiddlewareSchema = zod_1.z
17
29
  .object({
18
30
  before: zod_1.z.any().optional(),
@@ -29,6 +41,7 @@ exports.ClientConfigSchema = zod_1.z.object({
29
41
  log_level: zod_1.z.enum(['OFF', 'DEBUG', 'INFO', 'WARN', 'ERROR']).optional(),
30
42
  tenant_id: zod_1.z.string(),
31
43
  namespace: zod_1.z.string().optional(),
44
+ otel: exports.OpenTelemetryConfigSchema.optional(),
32
45
  middleware: TaskMiddlewareSchema,
33
46
  cancellation_grace_period: DurationMsSchema.optional().default(1000),
34
47
  cancellation_warning_threshold: DurationMsSchema.optional().default(300),
@@ -0,0 +1,36 @@
1
+ /**
2
+ * Hatchet OTLP Exporter
3
+ *
4
+ * Creates an OTLP gRPC trace exporter that sends spans to the Hatchet engine's
5
+ * collector endpoint, and a SpanProcessor that injects hatchet.* attributes
6
+ * into all child spans so they are queryable by the same attributes as the parent.
7
+ *
8
+ * This mirrors the Go SDK's EnableHatchetCollector() and the Python SDK's
9
+ * enable_hatchet_otel_collector option.
10
+ */
11
+ import type { ClientConfig } from '../clients/hatchet-client/client-config';
12
+ declare const BatchSpanProcessor: typeof import("@opentelemetry/sdk-trace-base").BatchSpanProcessor;
13
+ type ReadableSpan = import('@opentelemetry/sdk-trace-base').ReadableSpan;
14
+ type SdkSpan = import('@opentelemetry/sdk-trace-base').Span;
15
+ /**
16
+ * HatchetAttributeSpanProcessor wraps a BatchSpanProcessor and injects
17
+ * hatchet.* attributes into every span created within a step run context.
18
+ * This ensures child spans are queryable by the same attributes (e.g.
19
+ * hatchet.step_run_id) as the parent span.
20
+ */
21
+ declare class HatchetAttributeSpanProcessor extends BatchSpanProcessor {
22
+ onStart(span: SdkSpan): void;
23
+ onEnd(span: ReadableSpan): void;
24
+ }
25
+ export interface HatchetBspConfig {
26
+ scheduledDelayMillis?: number;
27
+ maxExportBatchSize?: number;
28
+ maxQueueSize?: number;
29
+ }
30
+ /**
31
+ * Creates a SpanProcessor that sends spans to the Hatchet engine's
32
+ * collector endpoint using the same connection settings as the Hatchet client.
33
+ * Pass the returned processor to BasicTracerProvider's `spanProcessors` option.
34
+ */
35
+ export declare function createHatchetSpanProcessor(config: ClientConfig, bspConfig?: HatchetBspConfig): InstanceType<typeof HatchetAttributeSpanProcessor>;
36
+ export {};
@@ -0,0 +1,145 @@
1
+ "use strict";
2
+ /**
3
+ * Hatchet OTLP Exporter
4
+ *
5
+ * Creates an OTLP gRPC trace exporter that sends spans to the Hatchet engine's
6
+ * collector endpoint, and a SpanProcessor that injects hatchet.* attributes
7
+ * into all child spans so they are queryable by the same attributes as the parent.
8
+ *
9
+ * This mirrors the Go SDK's EnableHatchetCollector() and the Python SDK's
10
+ * enable_hatchet_otel_collector option.
11
+ */
12
+ Object.defineProperty(exports, "__esModule", { value: true });
13
+ exports.createHatchetSpanProcessor = createHatchetSpanProcessor;
14
+ const hatchet_span_context_1 = require("./hatchet-span-context");
15
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
16
+ let otelDiag;
17
+ try {
18
+ // eslint-disable-next-line @typescript-eslint/no-require-imports
19
+ otelDiag = require('@opentelemetry/api').diag;
20
+ }
21
+ catch (_a) {
22
+ // best-effort
23
+ }
24
+ try {
25
+ require.resolve('@opentelemetry/exporter-trace-otlp-grpc');
26
+ require.resolve('@opentelemetry/sdk-trace-base');
27
+ require.resolve('@opentelemetry/core');
28
+ }
29
+ catch (_b) {
30
+ throw new Error('To use HatchetInstrumentor with enableHatchetCollector, you must install: ' +
31
+ 'npm install @opentelemetry/exporter-trace-otlp-grpc @opentelemetry/sdk-trace-base @opentelemetry/core');
32
+ }
33
+ /* eslint-disable @typescript-eslint/no-require-imports */
34
+ // prettier-ignore
35
+ const { OTLPTraceExporter } = require('@opentelemetry/exporter-trace-otlp-grpc');
36
+ // prettier-ignore
37
+ const sdkTraceBase = require('@opentelemetry/sdk-trace-base');
38
+ // prettier-ignore
39
+ const { ExportResultCode } = require('@opentelemetry/core');
40
+ /* eslint-enable @typescript-eslint/no-require-imports */
41
+ const { BatchSpanProcessor } = sdkTraceBase;
42
+ const GRPC_STATUS_UNIMPLEMENTED = 12;
43
+ const RETRY_AFTER_MS = 5 * 60 * 1000;
44
+ class HatchetExporterWrapper {
45
+ constructor(inner) {
46
+ this.retryAt = 0;
47
+ this.inner = inner;
48
+ }
49
+ export(spans, resultCallback) {
50
+ var _a;
51
+ if (this.retryAt > 0 && Date.now() < this.retryAt) {
52
+ resultCallback({ code: ExportResultCode.SUCCESS });
53
+ return;
54
+ }
55
+ try {
56
+ this.inner.export(spans, (result) => {
57
+ var _a;
58
+ if (result.code !== ExportResultCode.SUCCESS && result.error) {
59
+ const err = result.error;
60
+ if (err.code === GRPC_STATUS_UNIMPLEMENTED ||
61
+ ((_a = err.message) === null || _a === void 0 ? void 0 : _a.toString().includes('UNIMPLEMENTED'))) {
62
+ this.retryAt = Date.now() + RETRY_AFTER_MS;
63
+ resultCallback({ code: ExportResultCode.SUCCESS });
64
+ return;
65
+ }
66
+ }
67
+ this.retryAt = 0;
68
+ resultCallback(result);
69
+ });
70
+ }
71
+ catch (e) {
72
+ if (e instanceof TypeError && ((_a = e.message) === null || _a === void 0 ? void 0 : _a.includes("reading 'name'"))) {
73
+ otelDiag === null || otelDiag === void 0 ? void 0 : otelDiag.error('hatchet instrumentation: OpenTelemetry package version mismatch. ' +
74
+ '@opentelemetry/exporter-trace-otlp-grpc and @opentelemetry/sdk-trace-base must be ' +
75
+ 'from the same release set (1.x + 0.5x.x, or 2.x + 0.20x.x). ' +
76
+ 'See https://github.com/open-telemetry/opentelemetry-js#version-compatibility');
77
+ resultCallback({ code: ExportResultCode.SUCCESS });
78
+ return;
79
+ }
80
+ throw e;
81
+ }
82
+ }
83
+ shutdown() {
84
+ return this.inner.shutdown();
85
+ }
86
+ forceFlush() {
87
+ var _a, _b, _c;
88
+ return (_c = (_b = (_a = this.inner).forceFlush) === null || _b === void 0 ? void 0 : _b.call(_a)) !== null && _c !== void 0 ? _c : Promise.resolve();
89
+ }
90
+ }
91
+ /**
92
+ * HatchetAttributeSpanProcessor wraps a BatchSpanProcessor and injects
93
+ * hatchet.* attributes into every span created within a step run context.
94
+ * This ensures child spans are queryable by the same attributes (e.g.
95
+ * hatchet.step_run_id) as the parent span.
96
+ */
97
+ class HatchetAttributeSpanProcessor extends BatchSpanProcessor {
98
+ onStart(span) {
99
+ const attrs = hatchet_span_context_1.hatchetSpanAttributes.getStore();
100
+ if (attrs) {
101
+ span.setAttributes(attrs);
102
+ }
103
+ super.onStart(span, undefined);
104
+ }
105
+ onEnd(span) {
106
+ super.onEnd(span);
107
+ }
108
+ }
109
+ function createHatchetExporter(config) {
110
+ const insecure = config.tls_config.tls_strategy === 'none';
111
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
112
+ const opts = {
113
+ url: `${insecure ? 'http' : 'https'}://${config.host_port}`,
114
+ metadata: { authorization: `Bearer ${config.token}` },
115
+ };
116
+ if (!insecure && config.tls_config.ca_file) {
117
+ try {
118
+ /* eslint-disable @typescript-eslint/no-require-imports */
119
+ const fs = require('fs');
120
+ const { ChannelCredentials } = require('nice-grpc');
121
+ /* eslint-enable @typescript-eslint/no-require-imports */
122
+ const rootCerts = fs.readFileSync(config.tls_config.ca_file);
123
+ opts.credentials = ChannelCredentials.createSsl(rootCerts);
124
+ }
125
+ catch (_a) {
126
+ // Fall through to default TLS handling
127
+ }
128
+ }
129
+ return new OTLPTraceExporter(opts);
130
+ }
131
+ /**
132
+ * Creates a SpanProcessor that sends spans to the Hatchet engine's
133
+ * collector endpoint using the same connection settings as the Hatchet client.
134
+ * Pass the returned processor to BasicTracerProvider's `spanProcessors` option.
135
+ */
136
+ function createHatchetSpanProcessor(config, bspConfig) {
137
+ const inner = createHatchetExporter(config);
138
+ const exporter = new HatchetExporterWrapper(inner);
139
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
140
+ return new HatchetAttributeSpanProcessor(exporter, {
141
+ scheduledDelayMillis: bspConfig === null || bspConfig === void 0 ? void 0 : bspConfig.scheduledDelayMillis,
142
+ maxExportBatchSize: bspConfig === null || bspConfig === void 0 ? void 0 : bspConfig.maxExportBatchSize,
143
+ maxQueueSize: bspConfig === null || bspConfig === void 0 ? void 0 : bspConfig.maxQueueSize,
144
+ });
145
+ }
@@ -0,0 +1,22 @@
1
+ /**
2
+ * Shared async context for propagating hatchet.* attributes to child spans.
3
+ *
4
+ * Uses AsyncLocalStorage to store hatchet attributes from the active task run
5
+ * span so that HatchetAttributeSpanProcessor can inject them into all child
6
+ * spans created within the same async context.
7
+ *
8
+ * This mirrors the Go SDK's context.WithValue approach and the Python SDK's
9
+ * ContextVar approach.
10
+ */
11
+ import { AsyncLocalStorage } from 'async_hooks';
12
+ import type { Attributes } from '@opentelemetry/api';
13
+ /**
14
+ * AsyncLocalStorage that holds hatchet.* attributes from the active
15
+ * hatchet task run span so they can be injected into child spans.
16
+ */
17
+ export declare const hatchetSpanAttributes: AsyncLocalStorage<Attributes>;
18
+ /**
19
+ * Store hatchet attributes in async context so the SpanProcessor
20
+ * can inject them into child spans.
21
+ */
22
+ export declare function setHatchetSpanAttributes(attrs: Attributes): void;
@@ -0,0 +1,27 @@
1
+ "use strict";
2
+ /**
3
+ * Shared async context for propagating hatchet.* attributes to child spans.
4
+ *
5
+ * Uses AsyncLocalStorage to store hatchet attributes from the active task run
6
+ * span so that HatchetAttributeSpanProcessor can inject them into all child
7
+ * spans created within the same async context.
8
+ *
9
+ * This mirrors the Go SDK's context.WithValue approach and the Python SDK's
10
+ * ContextVar approach.
11
+ */
12
+ Object.defineProperty(exports, "__esModule", { value: true });
13
+ exports.hatchetSpanAttributes = void 0;
14
+ exports.setHatchetSpanAttributes = setHatchetSpanAttributes;
15
+ const async_hooks_1 = require("async_hooks");
16
+ /**
17
+ * AsyncLocalStorage that holds hatchet.* attributes from the active
18
+ * hatchet task run span so they can be injected into child spans.
19
+ */
20
+ exports.hatchetSpanAttributes = new async_hooks_1.AsyncLocalStorage();
21
+ /**
22
+ * Store hatchet attributes in async context so the SpanProcessor
23
+ * can inject them into child spans.
24
+ */
25
+ function setHatchetSpanAttributes(attrs) {
26
+ exports.hatchetSpanAttributes.enterWith(attrs);
27
+ }
@@ -0,0 +1,3 @@
1
+ export { HatchetInstrumentor } from './instrumentor';
2
+ export type { OpenTelemetryConfig } from './types';
3
+ export { OTelAttribute, OTelAttributeType } from '../util/opentelemetry';
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.OTelAttribute = exports.HatchetInstrumentor = void 0;
4
+ var instrumentor_1 = require("./instrumentor");
5
+ Object.defineProperty(exports, "HatchetInstrumentor", { enumerable: true, get: function () { return instrumentor_1.HatchetInstrumentor; } });
6
+ var opentelemetry_1 = require("../util/opentelemetry");
7
+ Object.defineProperty(exports, "OTelAttribute", { enumerable: true, get: function () { return opentelemetry_1.OTelAttribute; } });
@@ -0,0 +1,78 @@
1
+ /**
2
+ * Hatchet OpenTelemetry Instrumentor
3
+ *
4
+ * This module provides automatic instrumentation for Hatchet SDK operations
5
+ * including workflow runs, event pushes, and step executions.
6
+ *
7
+ * The instrumentor follows the OpenTelemetry instrumentation pattern,
8
+ * patching module prototypes to automatically instrument all instances.
9
+ */
10
+ import type { InstrumentationConfig } from '@opentelemetry/instrumentation';
11
+ import type { ClientConfig } from '../clients/hatchet-client/client-config';
12
+ import { OpenTelemetryConfig } from './types';
13
+ import type { HatchetBspConfig } from './hatchet-exporter';
14
+ declare const InstrumentationBase: typeof import("@opentelemetry/instrumentation").InstrumentationBase, InstrumentationNodeModuleDefinition: typeof import("@opentelemetry/instrumentation").InstrumentationNodeModuleDefinition;
15
+ type HatchetInstrumentationConfig = OpenTelemetryConfig & InstrumentationConfig & {
16
+ /**
17
+ * Enable sending traces to the Hatchet engine's OTLP collector (default: true).
18
+ * Requires @opentelemetry/exporter-trace-otlp-grpc and @opentelemetry/sdk-trace-base.
19
+ * Connection settings (endpoint, token, TLS) are read from the provided clientConfig
20
+ * or from the same environment variables used by the Hatchet client.
21
+ * Set to false to disable.
22
+ */
23
+ enableHatchetCollector?: boolean;
24
+ /**
25
+ * The Hatchet ClientConfig to use for the collector connection.
26
+ * If not provided and enableHatchetCollector is true, config will be loaded
27
+ * from environment variables / .hatchet.yaml.
28
+ */
29
+ clientConfig?: ClientConfig;
30
+ /**
31
+ * Configuration for the BatchSpanProcessor that sends spans to the Hatchet collector.
32
+ */
33
+ bspConfig?: HatchetBspConfig;
34
+ };
35
+ /**
36
+ * HatchetInstrumentor provides OpenTelemetry instrumentation for Hatchet SDK v1.
37
+ *
38
+ * It automatically instruments:
39
+ * - Workflow runs (runWorkflow, runWorkflows)
40
+ * - Scheduled workflow runs (schedules.create)
41
+ * - Event pushes (push, bulkPush)
42
+ * - Step executions (handleStartStepRun, handleCancelStepRun)
43
+ *
44
+ * Traceparent context is automatically propagated through metadata.
45
+ *
46
+ * The instrumentor uses the global tracer/meter providers by default.
47
+ * Use `setTracerProvider()` and `setMeterProvider()` to configure custom providers.
48
+ */
49
+ export declare class HatchetInstrumentor extends InstrumentationBase<HatchetInstrumentationConfig> {
50
+ constructor(config?: Partial<HatchetInstrumentationConfig>);
51
+ /**
52
+ * Sets up the Hatchet OTLP exporter on the current TracerProvider.
53
+ * Loads client config from environment if not provided.
54
+ */
55
+ private _setupHatchetCollector;
56
+ setConfig(config?: Partial<HatchetInstrumentationConfig>): void;
57
+ private readonly _getConfig;
58
+ protected init(): InstanceType<typeof InstrumentationNodeModuleDefinition>[];
59
+ private patchEventClient;
60
+ private unpatchEventClient;
61
+ private _patchPushEvent;
62
+ private _patchBulkPushEvent;
63
+ private patchAdminClient;
64
+ private unpatchAdminClient;
65
+ private _patchRunWorkflow;
66
+ private _patchRunWorkflows;
67
+ private patchWorker;
68
+ private unpatchWorker;
69
+ private _patchHandleStartStepRun;
70
+ private _patchHandleCancelStepRun;
71
+ private patchScheduleClient;
72
+ private unpatchScheduleClient;
73
+ private _patchScheduleCreate;
74
+ private patchDurableContext;
75
+ private unpatchDurableContext;
76
+ private _patchWaitFor;
77
+ }
78
+ export default HatchetInstrumentor;