createSpan method

Future<Span> createSpan(
  1. Span request,
  2. String name, {
  3. String? $fields,
})

Creates a new span.

request - The metadata request object.

Request parameters:

name - Required. The resource name of the span in the following format:

  • projects/[PROJECT_ID]/traces/[TRACE_ID]/spans/[SPAN_ID] [TRACE_ID] is a unique identifier for a trace within a project; it is a 32-character hexadecimal encoding of a 16-byte array. It should not be zero. [SPAN_ID] is a unique identifier for a span within a trace; it is a 16-character hexadecimal encoding of an 8-byte array. It should not be zero. . Value must have pattern ^projects/\[^/\]+/traces/\[^/\]+/spans/\[^/\]+$.

$fields - Selector specifying which fields to include in a partial response.

Completes with a Span.

Completes with a commons.ApiRequestError if the API endpoint returned an error.

If the used http.Client completes with an error when making a REST call, this method will complete with the same error.

Implementation

async.Future<Span> createSpan(
  Span request,
  core.String name, {
  core.String? $fields,
}) async {
  final body_ = convert.json.encode(request);
  final queryParams_ = <core.String, core.List<core.String>>{
    if ($fields != null) 'fields': [$fields],
  };

  final url_ = 'v2/' + core.Uri.encodeFull('$name');

  final response_ = await _requester.request(
    url_,
    'POST',
    body: body_,
    queryParams: queryParams_,
  );
  return Span.fromJson(response_ as core.Map<core.String, core.dynamic>);
}