public final void batchWriteSpans(ProjectName name, List<Span> spans) {
    BatchWriteSpansRequest request =
        BatchWriteSpansRequest.newBuilder()
            .setName(name == null ? null : name.toString())
            .addAllSpans(spans)
            .build();
    batchWriteSpans(request);
  }
Batch writes new spans to new or existing traces. You cannot update existing spans.

<p>Sample code:

<pre>{@code
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try (TraceServiceClient traceServiceClient = TraceServiceClient.create()) {
  ProjectName name = ProjectName.of("[PROJECT]");
  List<Span> spans = new ArrayList<>();
  traceServiceClient.batchWriteSpans(name, spans);
}
}</pre>

@param name Required. The name of the project where the spans belong. The format is
    `projects/[PROJECT_ID]`.
@param spans Required. A list of new spans. The span names must not match existing spans,
    otherwise the results are undefined.
@throws com.google.api.gax.rpc.ApiException if the remote call fails
java-trace/google-cloud-trace/src/main/java/com/google/cloud/trace/v2/TraceServiceClient.java