Shipping Service

Vous consultez la version anglaise de cette page car elle n’a pas encore été entièrement traduite. Vous souhaitez contribuer ? Voir Contribuer.

This service is responsible for providing shipping information including pricing and tracking information, when requested from Checkout Service.

Shipping service is built with Actix Web, Tracing for logs and OpenTelemetry Libraries. All other sub-dependencies are included in Cargo.toml.

Depending on your framework and runtime, you may consider consulting Rust docs to supplement. You’ll find examples of async and sync spans in quote requests and tracking IDs respectively.

Shipping service source

Instrumentation

The OpenTelemetry SDK is configured in the telemetry_conf file.

A function get_resource() is implemented to create a Resource using the default Resource Detectors plus OS and Process detectors:

fn get_resource() -> Resource {
    let detectors: Vec<Box<dyn ResourceDetector>> = vec![
        Box::new(OsResourceDetector),
        Box::new(ProcessResourceDetector),
    ];

    Resource::builder().with_detectors(&detectors).build()
}

With get_resource() in place, the function can be called multiple times across all provider initializations.

Initializing Tracer Provider

fn init_tracer_provider() {
    global::set_text_map_propagator(TraceContextPropagator::new());

    let tracer_provider = opentelemetry_sdk::trace::SdkTracerProvider::builder()
        .with_resource(get_resource())
        .with_batch_exporter(
            opentelemetry_otlp::SpanExporter::builder()
                .with_tonic()
                .