def METHOD_NAME(span):
    # type: (Span) -> Dict[str, Any]
    d = {
        "trace_id": span._trace_id_64bits,
        "parent_id": span.parent_id,
        "span_id": span.span_id,
        "service": span.service,
        "resource": span.resource,
        "name": span.name,
        "error": span.error,
    }
    # a common mistake is to set the error field to a boolean instead of an
    # int. let's special case that here, because it's sure to happen in
    # customer code.
    err = d.get("error")
    if err and type(err) == bool:
        d["error"] = 1
    if span.start_ns:
        d["start"] = span.start_ns
    if span.duration_ns:
        d["duration"] = span.duration_ns
    if span._meta:
        d["meta"] = span._meta
    if span._metrics:
        d["metrics"] = span._metrics
    if span.span_type:
        d["type"] = span.span_type
    return d