@temporalio/core-bridge 0.22.0 → 0.23.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.
- package/Cargo.lock +2 -0
- package/Cargo.toml +2 -1
- package/index.d.ts +90 -15
- package/package.json +3 -3
- package/releases/aarch64-apple-darwin/index.node +0 -0
- package/releases/x86_64-apple-darwin/index.node +0 -0
- package/releases/x86_64-pc-windows-msvc/index.node +0 -0
- package/releases/x86_64-unknown-linux-gnu/index.node +0 -0
- package/sdk-core/bridge-ffi/src/lib.rs +1 -1
- package/sdk-core/bridge-ffi/src/wrappers.rs +60 -34
- package/sdk-core/client/Cargo.toml +1 -0
- package/sdk-core/client/src/lib.rs +24 -7
- package/sdk-core/client/src/raw.rs +1 -1
- package/sdk-core/core/benches/workflow_replay.rs +1 -7
- package/sdk-core/core/src/lib.rs +2 -1
- package/sdk-core/core/src/protosext/mod.rs +1 -3
- package/sdk-core/core/src/retry_logic.rs +73 -16
- package/sdk-core/core/src/telemetry/mod.rs +167 -109
- package/sdk-core/core/src/worker/activities/local_activities.rs +6 -12
- package/sdk-core/protos/local/temporal/sdk/core/bridge/bridge.proto +27 -5
- package/sdk-core/sdk/src/lib.rs +1 -1
- package/sdk-core/sdk-core-protos/src/lib.rs +13 -0
- package/sdk-core/test-utils/src/histfetch.rs +1 -1
- package/sdk-core/test-utils/src/lib.rs +10 -7
- package/sdk-core/tests/integ_tests/client_tests.rs +2 -2
- package/sdk-core/tests/main.rs +5 -2
- package/src/conversions.rs +104 -33
- package/src/lib.rs +70 -6
|
@@ -18,13 +18,15 @@ use opentelemetry::{
|
|
|
18
18
|
};
|
|
19
19
|
use opentelemetry_otlp::WithExportConfig;
|
|
20
20
|
use parking_lot::{const_mutex, Mutex};
|
|
21
|
+
use std::collections::HashMap;
|
|
22
|
+
use std::convert::TryInto;
|
|
21
23
|
use std::{collections::VecDeque, net::SocketAddr, time::Duration};
|
|
22
24
|
use temporal_sdk_core_api::CoreTelemetry;
|
|
23
|
-
use
|
|
25
|
+
use tonic::metadata::MetadataMap;
|
|
26
|
+
use tracing_subscriber::{filter::ParseError, layer::SubscriberExt, EnvFilter};
|
|
24
27
|
use url::Url;
|
|
25
28
|
|
|
26
29
|
const TELEM_SERVICE_NAME: &str = "temporal-core-sdk";
|
|
27
|
-
const LOG_FILTER_ENV_VAR: &str = "TEMPORAL_TRACING_FILTER";
|
|
28
30
|
static DEFAULT_FILTER: &str = "temporal_sdk_core=INFO";
|
|
29
31
|
static GLOBAL_TELEM_DAT: OnceCell<GlobalTelemDat> = OnceCell::new();
|
|
30
32
|
static TELETM_MUTEX: Mutex<()> = const_mutex(());
|
|
@@ -37,39 +39,71 @@ fn default_resource() -> Resource {
|
|
|
37
39
|
Resource::new(default_resource_kvs().iter().cloned())
|
|
38
40
|
}
|
|
39
41
|
|
|
42
|
+
/// Options for exporting to an OpenTelemetry Collector
|
|
43
|
+
#[derive(Debug, Clone)]
|
|
44
|
+
pub struct OtelCollectorOptions {
|
|
45
|
+
/// The url of the OTel collector to export telemetry and metrics to. Lang SDK should also
|
|
46
|
+
/// export to this same collector.
|
|
47
|
+
pub url: Url,
|
|
48
|
+
/// Optional set of HTTP headers to send to the Collector, e.g for authentication.
|
|
49
|
+
pub headers: HashMap<String, String>,
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/// Control where traces are exported
|
|
53
|
+
#[derive(Debug, Clone)]
|
|
54
|
+
pub enum TraceExporter {
|
|
55
|
+
/// Export traces to an OpenTelemetry Collector <https://opentelemetry.io/docs/collector/>.
|
|
56
|
+
Otel(OtelCollectorOptions),
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/// Control where metrics are exported
|
|
60
|
+
#[derive(Debug, Clone)]
|
|
61
|
+
pub enum MetricsExporter {
|
|
62
|
+
/// Export metrics to an OpenTelemetry Collector <https://opentelemetry.io/docs/collector/>.
|
|
63
|
+
Otel(OtelCollectorOptions),
|
|
64
|
+
/// Expose metrics directly via an embedded http server bound to the provided address.
|
|
65
|
+
Prometheus(SocketAddr),
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/// Control where logs go
|
|
69
|
+
#[derive(Debug, Clone)]
|
|
70
|
+
pub enum Logger {
|
|
71
|
+
/// Log directly to console.
|
|
72
|
+
Console,
|
|
73
|
+
/// Forward logs to Lang - collectable with `fetch_global_buffered_logs`.
|
|
74
|
+
Forward(LevelFilter),
|
|
75
|
+
}
|
|
76
|
+
|
|
40
77
|
/// Telemetry configuration options. Construct with [TelemetryOptionsBuilder]
|
|
41
78
|
#[derive(Debug, Clone, derive_builder::Builder)]
|
|
42
79
|
#[non_exhaustive]
|
|
43
80
|
pub struct TelemetryOptions {
|
|
44
|
-
/// The url of the OTel collector to export telemetry and metrics to. Lang SDK should also
|
|
45
|
-
/// export to this same collector. If unset, telemetry is not exported and tracing data goes
|
|
46
|
-
/// to the console instead.
|
|
47
|
-
#[builder(setter(into, strip_option), default)]
|
|
48
|
-
pub otel_collector_url: Option<Url>,
|
|
49
81
|
/// A string in the [EnvFilter] format which specifies what tracing data is included in
|
|
50
82
|
/// telemetry, log forwarded to lang, or console output. May be overridden by the
|
|
51
83
|
/// `TEMPORAL_TRACING_FILTER` env variable.
|
|
52
84
|
#[builder(default = "DEFAULT_FILTER.to_string()")]
|
|
53
85
|
pub tracing_filter: String,
|
|
54
|
-
|
|
55
|
-
///
|
|
56
|
-
/// running only one workflow at a time. This sets the level at which they are filtered.
|
|
57
|
-
/// TRACE level will export span start/stop info as well.
|
|
58
|
-
///
|
|
59
|
-
/// Default is INFO. If set to `Off`, the mechanism is disabled entirely (saves on perf).
|
|
60
|
-
/// If set to anything besides `Off`, any console output directly from core is disabled.
|
|
61
|
-
#[builder(setter(into), default = "LevelFilter::Info")]
|
|
62
|
-
pub log_forwarding_level: LevelFilter,
|
|
63
|
-
/// If set, prometheus metrics will be exposed directly via an embedded http server bound to
|
|
64
|
-
/// the provided address. Useful if users would like to collect metrics with prometheus but
|
|
65
|
-
/// do not want to run an OTel collector. **Note**: If this is set metrics will *not* be sent
|
|
66
|
-
/// to the OTel collector if it is also set, only traces will be.
|
|
86
|
+
|
|
87
|
+
/// Optional trace exporter - set as None to disable.
|
|
67
88
|
#[builder(setter(into, strip_option), default)]
|
|
68
|
-
pub
|
|
69
|
-
///
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
89
|
+
pub tracing: Option<TraceExporter>,
|
|
90
|
+
/// Optional logger - set as None to disable.
|
|
91
|
+
#[builder(setter(into, strip_option), default)]
|
|
92
|
+
pub logging: Option<Logger>,
|
|
93
|
+
/// Optional metrics exporter - set as None to disable.
|
|
94
|
+
#[builder(setter(into, strip_option), default)]
|
|
95
|
+
pub metrics: Option<MetricsExporter>,
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
impl TelemetryOptions {
|
|
99
|
+
/// Construct an [EnvFilter] from given `tracing_filter`.
|
|
100
|
+
pub fn try_get_env_filter(&self) -> Result<EnvFilter, ParseError> {
|
|
101
|
+
EnvFilter::try_new(if self.tracing_filter.is_empty() {
|
|
102
|
+
DEFAULT_FILTER
|
|
103
|
+
} else {
|
|
104
|
+
&self.tracing_filter
|
|
105
|
+
})
|
|
106
|
+
}
|
|
73
107
|
}
|
|
74
108
|
|
|
75
109
|
impl Default for TelemetryOptions {
|
|
@@ -140,93 +174,116 @@ pub fn telemetry_init(opts: &TelemetryOptions) -> Result<&'static GlobalTelemDat
|
|
|
140
174
|
// Ensure closure captures the mutex guard
|
|
141
175
|
let _ = &*guard;
|
|
142
176
|
|
|
143
|
-
if opts.totally_disable {
|
|
144
|
-
return Ok(GlobalTelemDat {
|
|
145
|
-
metric_push_controller: None,
|
|
146
|
-
core_export_logger: None,
|
|
147
|
-
runtime: None,
|
|
148
|
-
prom_srv: None,
|
|
149
|
-
});
|
|
150
|
-
}
|
|
151
|
-
|
|
152
177
|
let runtime = tokio::runtime::Builder::new_multi_thread()
|
|
153
178
|
.thread_name("telemetry")
|
|
154
179
|
.worker_threads(2)
|
|
155
180
|
.enable_all()
|
|
156
181
|
.build()?;
|
|
157
182
|
let mut globaldat = GlobalTelemDat::default();
|
|
158
|
-
let am_forwarding_logs = opts.log_forwarding_level != LevelFilter::Off;
|
|
159
|
-
|
|
160
|
-
if am_forwarding_logs {
|
|
161
|
-
log::set_max_level(opts.log_forwarding_level);
|
|
162
|
-
globaldat.core_export_logger =
|
|
163
|
-
Some(CoreExportLogger::new(opts.log_forwarding_level));
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
let filter_layer = EnvFilter::try_from_env(LOG_FILTER_ENV_VAR).or_else(|_| {
|
|
167
|
-
let filter = if opts.tracing_filter.is_empty() {
|
|
168
|
-
DEFAULT_FILTER
|
|
169
|
-
} else {
|
|
170
|
-
&opts.tracing_filter
|
|
171
|
-
};
|
|
172
|
-
EnvFilter::try_new(filter)
|
|
173
|
-
})?;
|
|
174
183
|
|
|
175
|
-
if let Some(
|
|
176
|
-
|
|
177
|
-
|
|
184
|
+
if let Some(ref logger) = opts.logging {
|
|
185
|
+
match logger {
|
|
186
|
+
Logger::Console => {
|
|
187
|
+
// TODO: this is duplicated below and is quite ugly, remove the duplication
|
|
188
|
+
if opts.tracing.is_none() {
|
|
189
|
+
let pretty_fmt = tracing_subscriber::fmt::format()
|
|
190
|
+
.pretty()
|
|
191
|
+
.with_source_location(false);
|
|
192
|
+
let reg = tracing_subscriber::registry()
|
|
193
|
+
.with((&opts).try_get_env_filter()?)
|
|
194
|
+
.with(
|
|
195
|
+
tracing_subscriber::fmt::layer()
|
|
196
|
+
.with_target(false)
|
|
197
|
+
.event_format(pretty_fmt),
|
|
198
|
+
);
|
|
199
|
+
tracing::subscriber::set_global_default(reg)?;
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
Logger::Forward(filter) => {
|
|
203
|
+
log::set_max_level(*filter);
|
|
204
|
+
globaldat.core_export_logger = Some(CoreExportLogger::new(*filter));
|
|
205
|
+
}
|
|
206
|
+
};
|
|
178
207
|
};
|
|
179
208
|
|
|
180
|
-
if let Some(
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
.
|
|
185
|
-
.with_exporter(
|
|
186
|
-
opentelemetry_otlp::new_exporter()
|
|
187
|
-
.tonic()
|
|
188
|
-
.with_endpoint(otel_url.to_string()),
|
|
189
|
-
)
|
|
190
|
-
.with_trace_config(tracer_cfg)
|
|
191
|
-
.install_batch(opentelemetry::runtime::Tokio)?;
|
|
192
|
-
|
|
193
|
-
let opentelemetry = tracing_opentelemetry::layer().with_tracer(tracer);
|
|
194
|
-
|
|
195
|
-
if globaldat.prom_srv.is_none() {
|
|
196
|
-
let metrics = opentelemetry_otlp::new_pipeline()
|
|
197
|
-
.metrics(|f| runtime.spawn(f), tokio_interval_stream)
|
|
198
|
-
.with_aggregator_selector(SDKAggSelector)
|
|
199
|
-
.with_period(Duration::from_secs(1))
|
|
200
|
-
.with_resource(default_resource_kvs().iter().cloned())
|
|
201
|
-
.with_exporter(
|
|
202
|
-
// No joke exporter builder literally not cloneable for some insane
|
|
203
|
-
// reason
|
|
204
|
-
opentelemetry_otlp::new_exporter()
|
|
205
|
-
.tonic()
|
|
206
|
-
.with_endpoint(otel_url.to_string()),
|
|
207
|
-
)
|
|
208
|
-
.build()?;
|
|
209
|
-
global::set_meter_provider(metrics.provider());
|
|
210
|
-
globaldat.metric_push_controller = Some(metrics);
|
|
209
|
+
if let Some(ref metrics) = opts.metrics {
|
|
210
|
+
match metrics {
|
|
211
|
+
MetricsExporter::Prometheus(addr) => {
|
|
212
|
+
let srv = PromServer::new(*addr)?;
|
|
213
|
+
globaldat.prom_srv = Some(srv);
|
|
211
214
|
}
|
|
215
|
+
MetricsExporter::Otel(OtelCollectorOptions { url, headers }) => {
|
|
216
|
+
runtime.block_on(async {
|
|
217
|
+
let metrics = opentelemetry_otlp::new_pipeline()
|
|
218
|
+
.metrics(|f| runtime.spawn(f), tokio_interval_stream)
|
|
219
|
+
.with_aggregator_selector(SDKAggSelector)
|
|
220
|
+
.with_period(Duration::from_secs(1))
|
|
221
|
+
.with_resource(default_resource_kvs().iter().cloned())
|
|
222
|
+
.with_exporter(
|
|
223
|
+
// No joke exporter builder literally not cloneable for some insane
|
|
224
|
+
// reason
|
|
225
|
+
opentelemetry_otlp::new_exporter()
|
|
226
|
+
.tonic()
|
|
227
|
+
.with_endpoint(url.to_string())
|
|
228
|
+
.with_metadata(MetadataMap::from_headers(
|
|
229
|
+
headers.try_into()?,
|
|
230
|
+
)),
|
|
231
|
+
)
|
|
232
|
+
.build()?;
|
|
233
|
+
global::set_meter_provider(metrics.provider());
|
|
234
|
+
globaldat.metric_push_controller = Some(metrics);
|
|
235
|
+
Result::<(), anyhow::Error>::Ok(())
|
|
236
|
+
})?;
|
|
237
|
+
}
|
|
238
|
+
};
|
|
239
|
+
};
|
|
240
|
+
|
|
241
|
+
if let Some(ref tracing) = opts.tracing {
|
|
242
|
+
match tracing {
|
|
243
|
+
TraceExporter::Otel(OtelCollectorOptions { url, headers }) => {
|
|
244
|
+
runtime.block_on(async {
|
|
245
|
+
let tracer_cfg = Config::default().with_resource(default_resource());
|
|
246
|
+
let tracer = opentelemetry_otlp::new_pipeline()
|
|
247
|
+
.tracing()
|
|
248
|
+
.with_exporter(
|
|
249
|
+
opentelemetry_otlp::new_exporter()
|
|
250
|
+
.tonic()
|
|
251
|
+
.with_endpoint(url.to_string())
|
|
252
|
+
.with_metadata(MetadataMap::from_headers(
|
|
253
|
+
headers.try_into()?,
|
|
254
|
+
)),
|
|
255
|
+
)
|
|
256
|
+
.with_trace_config(tracer_cfg)
|
|
257
|
+
.install_batch(opentelemetry::runtime::Tokio)?;
|
|
212
258
|
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
259
|
+
let opentelemetry = tracing_opentelemetry::layer().with_tracer(tracer);
|
|
260
|
+
|
|
261
|
+
// TODO: remove all of this duplicate code
|
|
262
|
+
if let Some(Logger::Console) = opts.logging {
|
|
263
|
+
let pretty_fmt = tracing_subscriber::fmt::format()
|
|
264
|
+
.pretty()
|
|
265
|
+
.with_source_location(false);
|
|
266
|
+
let reg = tracing_subscriber::registry()
|
|
267
|
+
.with(opentelemetry)
|
|
268
|
+
.with(opts.try_get_env_filter()?)
|
|
269
|
+
.with(
|
|
270
|
+
tracing_subscriber::fmt::layer()
|
|
271
|
+
.with_target(false)
|
|
272
|
+
.event_format(pretty_fmt),
|
|
273
|
+
);
|
|
274
|
+
// Can't use try_init here as it will blow away our custom logger if we do
|
|
275
|
+
tracing::subscriber::set_global_default(reg)?;
|
|
276
|
+
} else {
|
|
277
|
+
let reg = tracing_subscriber::registry()
|
|
278
|
+
.with(opentelemetry)
|
|
279
|
+
.with(opts.try_get_env_filter()?);
|
|
280
|
+
// Can't use try_init here as it will blow away our custom logger if we do
|
|
281
|
+
tracing::subscriber::set_global_default(reg)?;
|
|
282
|
+
}
|
|
283
|
+
Result::<(), anyhow::Error>::Ok(())
|
|
284
|
+
})?;
|
|
285
|
+
}
|
|
286
|
+
};
|
|
230
287
|
};
|
|
231
288
|
|
|
232
289
|
globaldat.runtime = Some(runtime);
|
|
@@ -257,11 +314,10 @@ pub fn fetch_global_buffered_logs() -> Vec<CoreLog> {
|
|
|
257
314
|
#[cfg(test)]
|
|
258
315
|
pub(crate) fn test_telem_console() {
|
|
259
316
|
telemetry_init(&TelemetryOptions {
|
|
260
|
-
otel_collector_url: None,
|
|
261
317
|
tracing_filter: "temporal_sdk_core=DEBUG,temporal_sdk=DEBUG".to_string(),
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
318
|
+
logging: Some(Logger::Console),
|
|
319
|
+
tracing: None,
|
|
320
|
+
metrics: None,
|
|
265
321
|
})
|
|
266
322
|
.unwrap();
|
|
267
323
|
}
|
|
@@ -270,11 +326,13 @@ pub(crate) fn test_telem_console() {
|
|
|
270
326
|
#[cfg(test)]
|
|
271
327
|
pub(crate) fn test_telem_collector() {
|
|
272
328
|
telemetry_init(&TelemetryOptions {
|
|
273
|
-
otel_collector_url: Some("grpc://localhost:4317".parse().unwrap()),
|
|
274
329
|
tracing_filter: "temporal_sdk_core=DEBUG,temporal_sdk=DEBUG".to_string(),
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
330
|
+
logging: Some(Logger::Console),
|
|
331
|
+
tracing: Some(TraceExporter::Otel(OtelCollectorOptions {
|
|
332
|
+
url: "grpc://localhost:4317".parse().unwrap(),
|
|
333
|
+
headers: Default::default(),
|
|
334
|
+
})),
|
|
335
|
+
metrics: None,
|
|
278
336
|
})
|
|
279
337
|
.unwrap();
|
|
280
338
|
}
|
|
@@ -14,10 +14,7 @@ use temporal_sdk_core_protos::{
|
|
|
14
14
|
activity_task::{activity_task, ActivityCancelReason, ActivityTask, Cancel, Start},
|
|
15
15
|
common::WorkflowExecution,
|
|
16
16
|
},
|
|
17
|
-
temporal::api::
|
|
18
|
-
enums::v1::TimeoutType,
|
|
19
|
-
failure::v1::{failure::FailureInfo, ApplicationFailureInfo},
|
|
20
|
-
},
|
|
17
|
+
temporal::api::enums::v1::TimeoutType,
|
|
21
18
|
};
|
|
22
19
|
use tokio::{
|
|
23
20
|
sync::{
|
|
@@ -423,13 +420,9 @@ impl LocalActivityManager {
|
|
|
423
420
|
LocalActivityExecutionResult::Failed(f) => {
|
|
424
421
|
if let Some(backoff_dur) = info.la_info.schedule_cmd.retry_policy.should_retry(
|
|
425
422
|
info.attempt as usize,
|
|
426
|
-
f.failure
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
..
|
|
430
|
-
})) => r#type.as_str(),
|
|
431
|
-
_ => "",
|
|
432
|
-
}),
|
|
423
|
+
f.failure
|
|
424
|
+
.as_ref()
|
|
425
|
+
.and_then(|f| f.maybe_application_failure()),
|
|
433
426
|
) {
|
|
434
427
|
let will_use_timer =
|
|
435
428
|
backoff_dur > info.la_info.schedule_cmd.local_retry_threshold;
|
|
@@ -644,7 +637,8 @@ mod tests {
|
|
|
644
637
|
use super::*;
|
|
645
638
|
use crate::protosext::LACloseTimeouts;
|
|
646
639
|
use temporal_sdk_core_protos::{
|
|
647
|
-
coresdk::common::RetryPolicy,
|
|
640
|
+
coresdk::common::RetryPolicy,
|
|
641
|
+
temporal::api::failure::v1::{failure::FailureInfo, ApplicationFailureInfo, Failure},
|
|
648
642
|
};
|
|
649
643
|
use tokio::{sync::mpsc::error::TryRecvError, task::yield_now};
|
|
650
644
|
|
|
@@ -21,10 +21,33 @@ enum LogLevel {
|
|
|
21
21
|
}
|
|
22
22
|
|
|
23
23
|
message InitTelemetryRequest {
|
|
24
|
-
string
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
24
|
+
string tracing_filter = 1;
|
|
25
|
+
oneof logging {
|
|
26
|
+
ConsoleLoggerOptions console = 2;
|
|
27
|
+
ForwardLoggerOptions forward = 3;
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
oneof tracing {
|
|
31
|
+
OtelCollectorOptions otel_tracing = 4;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
oneof metrics {
|
|
35
|
+
OtelCollectorOptions otel_metrics = 5;
|
|
36
|
+
PrometheusOptions prometheus = 6;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
message ConsoleLoggerOptions {}
|
|
40
|
+
message ForwardLoggerOptions {
|
|
41
|
+
LogLevel level = 1;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
message OtelCollectorOptions {
|
|
45
|
+
string url = 1;
|
|
46
|
+
map<string, string> headers = 2;
|
|
47
|
+
}
|
|
48
|
+
message PrometheusOptions {
|
|
49
|
+
string export_bind_address = 1;
|
|
50
|
+
}
|
|
28
51
|
}
|
|
29
52
|
|
|
30
53
|
message CreateClientRequest {
|
|
@@ -32,7 +55,6 @@ message CreateClientRequest {
|
|
|
32
55
|
string namespace = 2;
|
|
33
56
|
string client_name = 3;
|
|
34
57
|
string client_version = 4;
|
|
35
|
-
map<string, string> static_headers = 5;
|
|
36
58
|
string identity = 6;
|
|
37
59
|
string worker_binary_id = 7;
|
|
38
60
|
TlsConfig tls_config = 8;
|
package/sdk-core/sdk/src/lib.rs
CHANGED
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
//! #[tokio::main]
|
|
17
17
|
//! async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
|
18
18
|
//! let server_options = sdk_client_options(Url::from_str("http://localhost:7233")?).build()?;
|
|
19
|
-
//! let client = server_options.connect("my_namespace", None).await?;
|
|
19
|
+
//! let client = server_options.connect("my_namespace", None, None).await?;
|
|
20
20
|
//! let worker_config = WorkerConfigBuilder::default().build()?;
|
|
21
21
|
//! let core_worker = init_worker(worker_config, client);
|
|
22
22
|
//!
|
|
@@ -1172,6 +1172,19 @@ pub mod coresdk {
|
|
|
1172
1172
|
..Default::default()
|
|
1173
1173
|
}
|
|
1174
1174
|
}
|
|
1175
|
+
|
|
1176
|
+
/// Extracts an ApplicationFailureInfo from a Failure instance if it exists
|
|
1177
|
+
pub fn maybe_application_failure(&self) -> Option<&ApplicationFailureInfo> {
|
|
1178
|
+
if let Failure {
|
|
1179
|
+
failure_info: Some(FailureInfo::ApplicationFailureInfo(f)),
|
|
1180
|
+
..
|
|
1181
|
+
} = self
|
|
1182
|
+
{
|
|
1183
|
+
Some(f)
|
|
1184
|
+
} else {
|
|
1185
|
+
None
|
|
1186
|
+
}
|
|
1187
|
+
}
|
|
1175
1188
|
}
|
|
1176
1189
|
|
|
1177
1190
|
impl Display for Failure {
|
|
@@ -11,7 +11,7 @@ use temporal_sdk_core_test_utils::get_integ_server_options;
|
|
|
11
11
|
#[tokio::main]
|
|
12
12
|
async fn main() -> Result<(), anyhow::Error> {
|
|
13
13
|
let gw_opts = get_integ_server_options();
|
|
14
|
-
let client = gw_opts.connect("default", None).await?;
|
|
14
|
+
let client = gw_opts.connect("default", None, None).await?;
|
|
15
15
|
let wf_id = std::env::args()
|
|
16
16
|
.nth(1)
|
|
17
17
|
.expect("must provide workflow id as only argument");
|
|
@@ -8,7 +8,6 @@ pub mod canned_histories;
|
|
|
8
8
|
|
|
9
9
|
use crate::stream::TryStreamExt;
|
|
10
10
|
use futures::{stream, stream::FuturesUnordered, StreamExt};
|
|
11
|
-
use log::LevelFilter;
|
|
12
11
|
use parking_lot::Mutex;
|
|
13
12
|
use prost::Message;
|
|
14
13
|
use rand::{distributions::Standard, Rng};
|
|
@@ -29,8 +28,9 @@ use temporal_client::{
|
|
|
29
28
|
};
|
|
30
29
|
use temporal_sdk::{interceptors::WorkerInterceptor, IntoActivityFunc, Worker, WorkflowFunction};
|
|
31
30
|
use temporal_sdk_core::{
|
|
32
|
-
init_replay_worker, init_worker, telemetry_init, ClientOptions, ClientOptionsBuilder,
|
|
33
|
-
|
|
31
|
+
init_replay_worker, init_worker, telemetry_init, ClientOptions, ClientOptionsBuilder, Logger,
|
|
32
|
+
MetricsExporter, OtelCollectorOptions, TelemetryOptions, TelemetryOptionsBuilder,
|
|
33
|
+
TraceExporter, WorkerConfig, WorkerConfigBuilder,
|
|
34
34
|
};
|
|
35
35
|
use temporal_sdk_core_api::Worker as CoreWorker;
|
|
36
36
|
use temporal_sdk_core_protos::{
|
|
@@ -240,7 +240,7 @@ impl CoreWfStarter {
|
|
|
240
240
|
telemetry_init(&self.telemetry_options).expect("Telemetry inits cleanly");
|
|
241
241
|
let client = Arc::new(
|
|
242
242
|
get_integ_server_options()
|
|
243
|
-
.connect(self.worker_config.namespace.clone(), None)
|
|
243
|
+
.connect(self.worker_config.namespace.clone(), None, None)
|
|
244
244
|
.await
|
|
245
245
|
.expect("Must connect"),
|
|
246
246
|
);
|
|
@@ -439,16 +439,19 @@ pub fn get_integ_telem_options() -> TelemetryOptions {
|
|
|
439
439
|
.ok()
|
|
440
440
|
.map(|x| x.parse::<Url>().unwrap())
|
|
441
441
|
{
|
|
442
|
-
ob.
|
|
442
|
+
ob.tracing(TraceExporter::Otel(OtelCollectorOptions {
|
|
443
|
+
url,
|
|
444
|
+
headers: Default::default(),
|
|
445
|
+
}));
|
|
443
446
|
}
|
|
444
447
|
if let Some(addr) = env::var(PROM_ENABLE_ENV_VAR)
|
|
445
448
|
.ok()
|
|
446
449
|
.map(|x| SocketAddr::new([127, 0, 0, 1].into(), x.parse().unwrap()))
|
|
447
450
|
{
|
|
448
|
-
ob.
|
|
451
|
+
ob.metrics(MetricsExporter::Prometheus(addr));
|
|
449
452
|
}
|
|
450
453
|
ob.tracing_filter(env::var("RUST_LOG").unwrap_or_else(|_| "temporal_sdk_core=INFO".to_string()))
|
|
451
|
-
.
|
|
454
|
+
.logging(Logger::Console)
|
|
452
455
|
.build()
|
|
453
456
|
.unwrap()
|
|
454
457
|
}
|
|
@@ -17,7 +17,7 @@ async fn can_use_retry_client() {
|
|
|
17
17
|
#[tokio::test]
|
|
18
18
|
async fn can_use_retry_raw_client() {
|
|
19
19
|
let opts = get_integ_server_options();
|
|
20
|
-
let raw_client = opts.connect_no_namespace(None).await.unwrap();
|
|
20
|
+
let raw_client = opts.connect_no_namespace(None, None).await.unwrap();
|
|
21
21
|
let mut retry_client = RetryClient::new(raw_client, opts.retry_config);
|
|
22
22
|
retry_client
|
|
23
23
|
.describe_namespace(DescribeNamespaceRequest {
|
|
@@ -31,6 +31,6 @@ async fn can_use_retry_raw_client() {
|
|
|
31
31
|
#[tokio::test]
|
|
32
32
|
async fn calls_get_system_info() {
|
|
33
33
|
let opts = get_integ_server_options();
|
|
34
|
-
let raw_client = opts.connect_no_namespace(None).await.unwrap();
|
|
34
|
+
let raw_client = opts.connect_no_namespace(None, None).await.unwrap();
|
|
35
35
|
assert!(raw_client.get_client().capabilities().is_some());
|
|
36
36
|
}
|
package/sdk-core/tests/main.rs
CHANGED
|
@@ -28,7 +28,7 @@ mod integ_tests {
|
|
|
28
28
|
let opts = get_integ_server_options();
|
|
29
29
|
let telem_d = telemetry_init(&get_integ_telem_options()).unwrap();
|
|
30
30
|
let mut retrying_client = opts
|
|
31
|
-
.connect_no_namespace(telem_d.get_metric_meter())
|
|
31
|
+
.connect_no_namespace(telem_d.get_metric_meter(), None)
|
|
32
32
|
.await
|
|
33
33
|
.unwrap();
|
|
34
34
|
|
|
@@ -84,7 +84,10 @@ mod integ_tests {
|
|
|
84
84
|
})
|
|
85
85
|
.build()
|
|
86
86
|
.unwrap();
|
|
87
|
-
let con = sgo
|
|
87
|
+
let con = sgo
|
|
88
|
+
.connect(NAMESPACE.to_string(), None, None)
|
|
89
|
+
.await
|
|
90
|
+
.unwrap();
|
|
88
91
|
con.list_namespaces().await.unwrap();
|
|
89
92
|
}
|
|
90
93
|
}
|