Creates a new span.

        Example:
            >>> from google.cloud import trace_v2
            >>>
            >>> client = trace_v2.TraceServiceClient()
            >>>
            >>> name = client.span_path('[PROJECT]', '[TRACE]', '[SPAN]')
            >>>
            >>> # TODO: Initialize `span_id`:
            >>> span_id = ''
            >>>
            >>> # TODO: Initialize `display_name`:
            >>> display_name = {}
            >>>
            >>> # TODO: Initialize `start_time`:
            >>> start_time = {}
            >>>
            >>> # TODO: Initialize `end_time`:
            >>> end_time = {}
            >>>
            >>> response = client.create_span(name, span_id, display_name, start_time, end_time)

        Args:
            name (str): 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.

                [SPAN\_ID] is a unique identifier for a span within a trace; it is a
                16-character hexadecimal encoding of an 8-byte array.
            span_id (str): The [SPAN\_ID] portion of the span's resource name.
            display_name (Union[dict, ~google.cloud.trace_v2.types.TruncatableString]): A description of the span's operation (up to 128 bytes). Stackdriver
                Trace displays the description in the {% dynamic print
                site\_values.console\_name %}. For example, the display name can be a
                qualified method name or a file name and a line number where the
                operation is called. A best practice is to use the same display name
                within an application and at the same call point. This makes it easier
                to correlate spans in different traces.

                If a dict is provided, it must be of the same form as the protobuf
                message :class:`~google.cloud.trace_v2.types.TruncatableString`
            start_time (Union[dict, ~google.cloud.trace_v2.types.Timestamp]): The start time of the span. On the client side, this is the time kept by
                the local machine where the span execution starts. On the server side, this
                is the time when the server's application handler starts running.

                If a dict is provided, it must be of the same form as the protobuf
                message :class:`~google.cloud.trace_v2.types.Timestamp`
            end_time (Union[dict, ~google.cloud.trace_v2.types.Timestamp]): The end time of the span. On the client side, this is the time kept by
                the local machine where the span execution ends. On the server side, this
                is the time when the server application handler stops running.

                If a dict is provided, it must be of the same form as the protobuf
                message :class:`~google.cloud.trace_v2.types.Timestamp`
            parent_span_id (str): The [SPAN\_ID] of this span's parent span. If this is a root span, then
                this field must be empty.
            attributes (Union[dict, ~google.cloud.trace_v2.types.Attributes]): A set of attributes on the span. You can have up to 32 attributes per
                span.

                If a dict is provided, it must be of the same form as the protobuf
                message :class:`~google.cloud.trace_v2.types.Attributes`
            stack_trace (Union[dict, ~google.cloud.trace_v2.types.StackTrace]): Stack trace captured at the start of the span.

                If a dict is provided, it must be of the same form as the protobuf
                message :class:`~google.cloud.trace_v2.types.StackTrace`
            time_events (Union[dict, ~google.cloud.trace_v2.types.TimeEvents]): A set of time events. You can have up to 32 annotations and 128 message
                events per span.

                If a dict is provided, it must be of the same form as the protobuf
                message :class:`~google.cloud.trace_v2.types.TimeEvents`
            links (Union[dict, ~google.cloud.trace_v2.types.Links]): Links associated with the span. You can have up to 128 links per Span.

                If a dict is provided, it must be of the same form as the protobuf
                message :class:`~google.cloud.trace_v2.types.Links`
            status (Union[dict, ~google.cloud.trace_v2.types.Status]): An optional final status for this span.

                If a dict is provided, it must be of the same form as the protobuf
                message :class:`~google.cloud.trace_v2.types.Status`
            same_process_as_parent_span (Union[dict, ~google.cloud.trace_v2.types.BoolValue]): (Optional) Set this parameter to indicate whether this span is in
                the same process as its parent. If you do not set this parameter,
                Stackdriver Trace is unable to take advantage of this helpful
                information.

                If a dict is provided, it must be of the same form as the protobuf
                message :class:`~google.cloud.trace_v2.types.BoolValue`
            child_span_count (Union[dict, ~google.cloud.trace_v2.types.Int32Value]): An optional number of child spans that were generated while this span
                was active. If set, allows implementation to detect missing child spans.

                If a dict is provided, it must be of the same form as the protobuf
                message :class:`~google.cloud.trace_v2.types.Int32Value`
            retry (Optional[google.api_core.retry.Retry]):  A retry object used
                to retry requests. If ``None`` is specified, requests will not
                be retried.
            timeout (Optional[float]): The amount of time, in seconds, to wait
                for the request to complete. Note that if ``retry`` is
                specified, the timeout applies to each individual attempt.
            metadata (Optional[Sequence[Tuple[str, str]]]): Additional metadata
                that is provided to the method.

        Returns:
            A :class:`~google.cloud.trace_v2.types.Span` instance.

        Raises:
            google.api_core.exceptions.GoogleAPICallError: If the request
                    failed for any reason.
            google.api_core.exceptions.RetryError: If the request failed due
                    to a retryable error and retry attempts failed.
            ValueError: If the parameters are invalid.

def create_span(
        self,
        name,
        span_id,
        display_name,
        start_time,
        end_time,
        parent_span_id=None,
        attributes=None,
        stack_trace=None,
        time_events=None,
        links=None,
        status=None,
        same_process_as_parent_span=None,
        child_span_count=None,
        retry=google.api_core.gapic_v1.method.DEFAULT,
        timeout=google.api_core.gapic_v1.method.DEFAULT,
        metadata=None,
    ):
        """
        Creates a new span.

        Example:
            >>> from google.cloud import trace_v2
            >>>
            >>> client = trace_v2.TraceServiceClient()
            >>>
            >>> name = client.span_path('[PROJECT]', '[TRACE]', '[SPAN]')
            >>>
            >>> # TODO: Initialize `span_id`:
            >>> span_id = ''
            >>>
            >>> # TODO: Initialize `display_name`:
            >>> display_name = {}
            >>>
            >>> # TODO: Initialize `start_time`:
            >>> start_time = {}
            >>>
            >>> # TODO: Initialize `end_time`:
            >>> end_time = {}
            >>>
            >>> response = client.create_span(name, span_id, display_name, start_time, end_time)

        Args:
            name (str): 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.

                [SPAN\_ID] is a unique identifier for a span within a trace; it is a
                16-character hexadecimal encoding of an 8-byte array.
            span_id (str): The [SPAN\_ID] portion of the span's resource name.
            display_name (Union[dict, ~google.cloud.trace_v2.types.TruncatableString]): A description of the span's operation (up to 128 bytes). Stackdriver
                Trace displays the description in the {% dynamic print
                site\_values.console\_name %}. For example, the display name can be a
                qualified method name or a file name and a line number where the
                operation is called. A best practice is to use the same display name
                within an application and at the same call point. This makes it easier
                to correlate spans in different traces.

                If a dict is provided, it must be of the same form as the protobuf
                message :class:`~google.cloud.trace_v2.types.TruncatableString`
            start_time (Union[dict, ~google.cloud.trace_v2.types.Timestamp]): The start time of the span. On the client side, this is the time kept by
                the local machine where the span execution starts. On the server side, this
                is the time when the server's application handler starts running.

                If a dict is provided, it must be of the same form as the protobuf
                message :class:`~google.cloud.trace_v2.types.Timestamp`
            end_time (Union[dict, ~google.cloud.trace_v2.types.Timestamp]): The end time of the span. On the client side, this is the time kept by
                the local machine where the span execution ends. On the server side, this
                is the time when the server application handler stops running.

                If a dict is provided, it must be of the same form as the protobuf
                message :class:`~google.cloud.trace_v2.types.Timestamp`
            parent_span_id (str): The [SPAN\_ID] of this span's parent span. If this is a root span, then
                this field must be empty.
            attributes (Union[dict, ~google.cloud.trace_v2.types.Attributes]): A set of attributes on the span. You can have up to 32 attributes per
                span.

                If a dict is provided, it must be of the same form as the protobuf
                message :class:`~google.cloud.trace_v2.types.Attributes`
            stack_trace (Union[dict, ~google.cloud.trace_v2.types.StackTrace]): Stack trace captured at the start of the span.

                If a dict is provided, it must be of the same form as the protobuf
                message :class:`~google.cloud.trace_v2.types.StackTrace`
            time_events (Union[dict, ~google.cloud.trace_v2.types.TimeEvents]): A set of time events. You can have up to 32 annotations and 128 message
                events per span.

                If a dict is provided, it must be of the same form as the protobuf
                message :class:`~google.cloud.trace_v2.types.TimeEvents`
            links (Union[dict, ~google.cloud.trace_v2.types.Links]): Links associated with the span. You can have up to 128 links per Span.

                If a dict is provided, it must be of the same form as the protobuf
                message :class:`~google.cloud.trace_v2.types.Links`
            status (Union[dict, ~google.cloud.trace_v2.types.Status]): An optional final status for this span.

                If a dict is provided, it must be of the same form as the protobuf
                message :class:`~google.cloud.trace_v2.types.Status`
            same_process_as_parent_span (Union[dict, ~google.cloud.trace_v2.types.BoolValue]): (Optional) Set this parameter to indicate whether this span is in
                the same process as its parent. If you do not set this parameter,
                Stackdriver Trace is unable to take advantage of this helpful
                information.

                If a dict is provided, it must be of the same form as the protobuf
                message :class:`~google.cloud.trace_v2.types.BoolValue`
            child_span_count (Union[dict, ~google.cloud.trace_v2.types.Int32Value]): An optional number of child spans that were generated while this span
                was active. If set, allows implementation to detect missing child spans.

                If a dict is provided, it must be of the same form as the protobuf
                message :class:`~google.cloud.trace_v2.types.Int32Value`
            retry (Optional[google.api_core.retry.Retry]):  A retry object used
                to retry requests. If ``None`` is specified, requests will not
                be retried.
            timeout (Optional[float]): The amount of time, in seconds, to wait
                for the request to complete. Note that if ``retry`` is
                specified, the timeout applies to each individual attempt.
            metadata (Optional[Sequence[Tuple[str, str]]]): Additional metadata
                that is provided to the method.

        Returns:
            A :class:`~google.cloud.trace_v2.types.Span` instance.

        Raises:
            google.api_core.exceptions.GoogleAPICallError: If the request
                    failed for any reason.
            google.api_core.exceptions.RetryError: If the request failed due
                    to a retryable error and retry attempts failed.
            ValueError: If the parameters are invalid.
        """
        # Wrap the transport method to add retry and timeout logic.
        if "create_span" not in self._inner_api_calls:
            self._inner_api_calls[
                "create_span"
            ] = google.api_core.gapic_v1.method.wrap_method(
                self.transport.create_span,
                default_retry=self._method_configs["CreateSpan"].retry,
                default_timeout=self._method_configs["CreateSpan"].timeout,
                client_info=self._client_info,
            )

        request = trace_pb2.Span(
            name=name,
            span_id=span_id,
            display_name=display_name,
            start_time=start_time,
            end_time=end_time,
            parent_span_id=parent_span_id,
            attributes=attributes,
            stack_trace=stack_trace,
            time_events=time_events,
            links=links,
            status=status,
            same_process_as_parent_span=same_process_as_parent_span,
            child_span_count=child_span_count,
        )
        if metadata is None:
            metadata = []
        metadata = list(metadata)
        try:
            routing_header = [("name", name)]
        except AttributeError:
            pass
        else:
            routing_metadata = google.api_core.gapic_v1.routing_header.to_grpc_metadata(
                routing_header
            )
            metadata.append(routing_metadata)

        return self._inner_api_calls["create_span"](
            request, retry=retry, timeout=timeout, metadata=metadata
        )