Skip to content
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

Draft
wants to merge 1 commit into
base: tracing-base
Choose a base branch
from
Draft

Enable tracing for development #832

wants to merge 1 commit into from

Conversation

dandavison
Copy link
Contributor

@dandavison dandavison commented Oct 17, 2024

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.

.with_kind(SpanKind::Server)
.with_attributes([KeyValue::new("temporal.worker", true)])
.start(&tracer);
});
Copy link
Contributor Author

@dandavison dandavison Oct 17, 2024

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.

Copy link
Member

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);
Copy link
Contributor Author

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);
Copy link
Contributor Author

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);
Copy link
Contributor Author

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.

Comment on lines +222 to +261
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);
});
Copy link
Member

@Sushisource Sushisource Oct 23, 2024

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)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants