Search in sources :

Example 1 with OpenTracingClientInterceptor

use of io.temporal.opentracing.OpenTracingClientInterceptor in project samples-java by temporalio.

the class Starter method main.

public static void main(String[] args) {
    String type = "OpenTelemetry";
    if (args.length == 1) {
        type = args[0];
    }
    // Set the OpenTracing client interceptor
    WorkflowClientOptions clientOptions = WorkflowClientOptions.newBuilder().setInterceptors(new OpenTracingClientInterceptor(JaegerUtils.getJaegerOptions(type))).build();
    WorkflowClient client = WorkflowClient.newInstance(service, clientOptions);
    WorkflowOptions workflowOptions = WorkflowOptions.newBuilder().setWorkflowId("tracingWorkflow").setTaskQueue(TASK_QUEUE_NAME).build();
    // Create typed workflow stub
    TracingWorkflow workflow = client.newWorkflowStub(TracingWorkflow.class, workflowOptions);
    // Convert to untyped and start it with signalWithStart
    WorkflowStub untyped = WorkflowStub.fromTyped(workflow);
    untyped.signalWithStart("setLanguage", new Object[] { "Spanish" }, new Object[] { "John" });
    String greeting = untyped.getResult(String.class);
    System.out.println("Greeting: " + greeting);
    System.exit(0);
}
Also used : WorkflowClientOptions(io.temporal.client.WorkflowClientOptions) WorkflowStub(io.temporal.client.WorkflowStub) TracingWorkflow(io.temporal.samples.tracing.workflow.TracingWorkflow) WorkflowClient(io.temporal.client.WorkflowClient) WorkflowOptions(io.temporal.client.WorkflowOptions) OpenTracingClientInterceptor(io.temporal.opentracing.OpenTracingClientInterceptor)

Aggregations

WorkflowClient (io.temporal.client.WorkflowClient)1 WorkflowClientOptions (io.temporal.client.WorkflowClientOptions)1 WorkflowOptions (io.temporal.client.WorkflowOptions)1 WorkflowStub (io.temporal.client.WorkflowStub)1 OpenTracingClientInterceptor (io.temporal.opentracing.OpenTracingClientInterceptor)1 TracingWorkflow (io.temporal.samples.tracing.workflow.TracingWorkflow)1