-
Notifications
You must be signed in to change notification settings - Fork 77
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
Enable tracing for development #832
base: tracing-base
Are you sure you want to change the base?
Conversation
.with_kind(SpanKind::Server) | ||
.with_attributes([KeyValue::new("temporal.worker", true)]) | ||
.start(&tracer); | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This span is being emitted, but the ones in workflow_machines.rs
, managed_run.rs
, workflow_stream.rs
aren't; not sure why yet.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am guessing this has to do with separate runtimes.
I can't remember exactly how I had this working with a separate one previously. Might need to review those diffs some more
.span_builder("apply_next_wft_from_history") | ||
.with_kind(SpanKind::Server) | ||
.with_attributes([KeyValue::new("temporal.worker", true)]) | ||
.start(&tracer); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This span isn't being emitted; I'm not sure why currently.
.span_builder("successful_completion") | ||
.with_kind(SpanKind::Server) | ||
.with_attributes([KeyValue::new("temporal.worker", true)]) | ||
.start(&tracer); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This span isn't being emitted; I'm not sure why currently.
.span_builder("process_completion") | ||
.with_kind(SpanKind::Server) | ||
.with_attributes([KeyValue::new("temporal.worker", true)]) | ||
.start(&tracer); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This span isn't being emitted; I'm not sure why currently.
let runtime = tokio::runtime::Builder::new_multi_thread() | ||
.thread_name("telemetry") | ||
.worker_threads(2) | ||
.enable_all() | ||
.build() | ||
.unwrap(); | ||
|
||
// create otel export layer | ||
runtime.block_on(async { | ||
let tracer_cfg = opentelemetry_sdk::trace::Config::default() | ||
.with_resource(default_resource_instance().clone()); | ||
let provider = opentelemetry_otlp::new_pipeline() | ||
.tracing() | ||
.with_exporter( | ||
opentelemetry_otlp::new_exporter() | ||
.tonic() | ||
.with_endpoint("grpc://localhost:4317".to_string()), | ||
// .with_metadata(MetadataMap::from_headers(headers.try_into()?)), | ||
) | ||
.with_trace_config(tracer_cfg) | ||
// Using install_simple instead for now because install_batch is not producing spans and is emitting this error message: | ||
// OpenTelemetry trace error occurred. cannot send message to batch processor as the channel is closed | ||
// .install_batch(opentelemetry_sdk::runtime::Tokio) | ||
.install_simple() | ||
.unwrap(); | ||
opentelemetry::global::set_tracer_provider(provider.clone()); | ||
|
||
let tracer = provider.tracer_builder("sdk-core").build(); | ||
let opentelemetry = tracing_opentelemetry::layer().with_tracer(tracer); | ||
// .with_filter(EnvFilter::new(&tracing.filter)) | ||
export_layer = Some(opentelemetry); | ||
|
||
let tracer = provider.tracer("sdk-core"); | ||
|
||
let _span = tracer | ||
.span_builder("telemetry_init") | ||
.with_kind(SpanKind::Server) | ||
.with_attributes([KeyValue::new("temporal.worker", true)]) | ||
.start(&tracer); | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This all definitely needs to be protected behind a flag. (Which I guess you mentioned hehe)
WIP draft PR for discussion. All the spans added here are just temporary examples; the only thing I'll be proposing for merge is the configuration, behind a flag. One span is being emitted but the others aren't; see comments inline.