<?xml version='1.0' encoding='utf-8'?>
<!DOCTYPE rfc [
  <!ENTITY nbsp    "&#160;">
  <!ENTITY zwsp   "&#8203;">
  <!ENTITY nbhy   "&#8209;">
  <!ENTITY wj     "&#8288;">
]>
<?xml-stylesheet type="text/xsl" href="rfc2629.xslt" ?>
<!-- generated by https://github.com/cabo/kramdown-rfc version 1.7.4 (Ruby 3.2.2) -->
<rfc xmlns:xi="http://www.w3.org/2001/XInclude" ipr="trust200902" docName="draft-netconf-restconf-trace-ctx-headers-00" category="std" consensus="true" submissionType="IETF" tocInclude="true" sortRefs="true" symRefs="true" version="3">
  <!-- xml2rfc v2v3 conversion 3.19.0 -->
  <front>
    <title abbrev="rc_trace">RESTCONF Extension to support Trace Context Headers</title>
    <seriesInfo name="Internet-Draft" value="draft-netconf-restconf-trace-ctx-headers-00"/>
    <author fullname="Roque Gagliano">
      <organization>Cisco Systems</organization>
      <address>
        <postal>
          <street>Avenue des Uttins 5</street>
          <city>Rolle</city>
          <code>1180</code>
          <country>Switzerland</country>
        </postal>
        <email>rogaglia@cisco.com</email>
      </address>
    </author>
    <author fullname="Kristian Larsson">
      <organization>Deutsche Telekom AG</organization>
      <address>
        <email>kll@dev.terastrm.net</email>
      </address>
    </author>
    <author fullname="Jan Lindblad">
      <organization>Cisco Systems</organization>
      <address>
        <email>jlindbla@cisco.com</email>
      </address>
    </author>
    <date year="2024" month="January" day="11"/>
    <area>Operations and Management</area>
    <workgroup>NETCONF</workgroup>
    <keyword>telemetry</keyword>
    <keyword>distributed systems</keyword>
    <keyword>opentelemetry</keyword>
    <abstract>
      <?line 64?>

<t>This document extends the RESTCONF protocol in order to support trace context propagation as defined by the W3C.</t>
    </abstract>
    <note removeInRFC="true">
      <name>About This Document</name>
      <t>
        The latest revision of this draft can be found at <eref target="TBD"/>.
        Status information for this document may be found at <eref target="https://datatracker.ietf.org/doc/draft-netconf-restconf-trace-ctx-headers/"/>.
      </t>
      <t>
        Discussion of this document takes place on the
        NETCONF Working Group mailing list (<eref target="mailto:netconf@ietf.org"/>),
        which is archived at <eref target="https://mailarchive.ietf.org/arch/browse/netmod/"/>.
        Subscribe at <eref target="https://www.ietf.org/mailman/listinfo/netconf/"/>.
      </t>
      <t>Source for this draft and an issue tracker can be found at
        <eref target="https://github.com/TBD"/>.</t>
    </note>
  </front>
  <middle>
    <?line 68?>

<section anchor="introduction">
      <name>Introduction</name>
      <t>Network automation and management systems commonly consist of multiple
sub-systems and together with the network devices they manage, they effectively form a distributed system.  Distributed tracing is a methodology implemented by tracing tools to follow, analyze and debug operations, such as configuration transactions, across multiple distributed systems.  An operation is uniquely identified by a trace-id and through a trace context, carries some metadata about the operation.  Propagating this "trace context" between systems enables forming a coherent view of the entire operation as carried out by all involved systems.</t>
      <t>The W3C has defined two HTTP headers (traceparent and tracestate) for context propagation that are useful for distributed systems like the ones defined in <xref target="RFC8309"/>. The goal of this document is to adopt this W3C specification for the RESTCONF protocol.</t>
      <t>This document does not define new HTTP extensions but makes those defined in <xref target="W3C-Trace-Context"/> optional headers for the RESTCONF protocol.</t>
      <t>In <xref target="I-D.draft-rogaglia-netconf-trace-ctx-extension-03"/>, the NETCONF protocol extension is defined and we will re-use several of the YANG and XML objects defined in that document for RESTCONF. Please refer to that document for additional context and example applications.</t>
      <section anchor="terminology">
        <name>Terminology</name>
        <t>The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT","SHOULD","SHOULD NOT", "RECOMMENDED", "NOT RECOMMENDED", "MAY", and "OPTIONAL" in this document are to be interpreted as described in BCP 14 <xref target="RFC2119"/> <xref target="RFC8174"/> when, and only when, they appear in all capitals, as shown here.</t>
      </section>
    </section>
    <section anchor="restconf-extensions">
      <name>RESTCONF Extensions</name>
      <t>A RESTCONF server SHOULD support trace context traceparent header as defined in <xref target="W3C-Trace-Context"/>.</t>
      <t>A RESTCONF server SHOULD support trace context tracestate header as defined in <xref target="W3C-Trace-Context"/>.</t>
      <section anchor="errors-handling">
        <name>Errors handling</name>
        <t>The RESTCONF server SHOULD follow the "Processing Model for Working with Trace Context" as specified in <xref target="W3C-Trace-Context"/>.</t>
        <t>If the server rejects the RPC because of the trace context headers values, the server MUST return an rpc-error with the following values:</t>
        <artwork><![CDATA[
  error-tag:      operation-failed
  error-type:     protocol
  error-severity: error
]]></artwork>
        <t>Additionally, the error-info tag SHOULD contain a relevant details about the error.</t>
        <t>Finally, the sx:structure defined in <xref target="I-D.draft-rogaglia-netconf-trace-ctx-extension-03"/> SHOULD be present in any error message from the server.</t>
        <t>Example of a badly formated trace context extension using <xref target="RFC8040"/> example B.2.1:</t>
        <artwork><![CDATA[
  POST /restconf/data/example-jukebox:jukebox/library HTTP/1.1
  Host: example.com
  Content-Type: application/yang-data+json
  traceparent: SomeBadFormatHere
  tracestate: OrSomeBadFormatHere

  {
    "example-jukebox:artist" : [
      {
        "name" : "Foo Fighters"
      }
    ]
  }
]]></artwork>
        <t>And the expected error message:</t>
        <artwork><![CDATA[
 HTTP/1.1 400 Bad Request
 Date: Tue, 20 Jun 2023 20:56:30 GMT
 Server: example-server
 Content-Type: application/yang-data+json

 { "ietf-restconf:errors" : {
     "error" : [
       {
         "error-type" : "protocol",
         "error-tag" : "operation-failed",
         "error-severity" : "error",
         "error-message" :
         "OTLP traceparent attribute incorrectly formatted",
         "error-info": {
           "ietf-netconf-otlp-context:meta-name" : "traceparent",
           "ietf-netconf-otlp-context:meta-value" :
           "SomeBadFormatHere",
           "ietf-netconf-otlp-context:error-type" :
           "ietf-netconf-otlp-context:bad-format"
         }
       }
     ]
   }
 }
]]></artwork>
      </section>
      <section anchor="trace-context-header-versionning">
        <name>Trace Context header versionning</name>
        <t>This extension refers to the <xref target="W3C-Trace-Context"/> trace context capability. The W3C traceparent and trace-state headers include the notion of versions. It would be desirable for a RESTCONF client to be able to discover the one or multiple versions of these headers supported by a server. We would like to achieve this goal avoiding the deffinition of new RESTCONF capabilities for each headers' version.</t>
        <t><xref target="I-D.draft-rogaglia-netconf-trace-ctx-extension-03"/> defines a pair YANG modules that SHOULD be included in the YANG library per <xref target="RFC8525"/> of the RESTCONF server supporting the RESTCONF Trace Context extension that will refer to the headers' supported versions. Future updates of this document could include additional YANG modules for new headers' versions.</t>
      </section>
    </section>
    <section anchor="security-considerations">
      <name>Security Considerations</name>
      <t>TODO Security</t>
    </section>
    <section anchor="iana-considerations">
      <name>IANA Considerations</name>
      <t>This document has no IANA actions.</t>
    </section>
    <section anchor="acknowledgments">
      <name>Acknowledgments</name>
      <t>We would like to acknowledge</t>
    </section>
  </middle>
  <back>
    <references>
      <name>References</name>
      <references anchor="sec-normative-references">
        <name>Normative References</name>
        <reference anchor="RFC2119">
          <front>
            <title>Key words for use in RFCs to Indicate Requirement Levels</title>
            <author fullname="S. Bradner" initials="S." surname="Bradner"/>
            <date month="March" year="1997"/>
            <abstract>
              <t>In many standards track documents several words are used to signify the requirements in the specification. These words are often capitalized. This document defines these words as they should be interpreted in IETF documents. This document specifies an Internet Best Current Practices for the Internet Community, and requests discussion and suggestions for improvements.</t>
            </abstract>
          </front>
          <seriesInfo name="BCP" value="14"/>
          <seriesInfo name="RFC" value="2119"/>
          <seriesInfo name="DOI" value="10.17487/RFC2119"/>
        </reference>
        <reference anchor="RFC8174">
          <front>
            <title>Ambiguity of Uppercase vs Lowercase in RFC 2119 Key Words</title>
            <author fullname="B. Leiba" initials="B." surname="Leiba"/>
            <date month="May" year="2017"/>
            <abstract>
              <t>RFC 2119 specifies common key words that may be used in protocol specifications. This document aims to reduce the ambiguity by clarifying that only UPPERCASE usage of the key words have the defined special meanings.</t>
            </abstract>
          </front>
          <seriesInfo name="BCP" value="14"/>
          <seriesInfo name="RFC" value="8174"/>
          <seriesInfo name="DOI" value="10.17487/RFC8174"/>
        </reference>
        <reference anchor="RFC8525">
          <front>
            <title>YANG Library</title>
            <author fullname="A. Bierman" initials="A." surname="Bierman"/>
            <author fullname="M. Bjorklund" initials="M." surname="Bjorklund"/>
            <author fullname="J. Schoenwaelder" initials="J." surname="Schoenwaelder"/>
            <author fullname="K. Watsen" initials="K." surname="Watsen"/>
            <author fullname="R. Wilton" initials="R." surname="Wilton"/>
            <date month="March" year="2019"/>
            <abstract>
              <t>This document describes a YANG library that provides information about the YANG modules, datastores, and datastore schemas used by a network management server. Simple caching mechanisms are provided to allow clients to minimize retrieval of this information. This version of the YANG library supports the Network Management Datastore Architecture (NMDA) by listing all datastores supported by a network management server and the schema that is used by each of these datastores.</t>
            </abstract>
          </front>
          <seriesInfo name="RFC" value="8525"/>
          <seriesInfo name="DOI" value="10.17487/RFC8525"/>
        </reference>
        <reference anchor="RFC8040">
          <front>
            <title>RESTCONF Protocol</title>
            <author fullname="A. Bierman" initials="A." surname="Bierman"/>
            <author fullname="M. Bjorklund" initials="M." surname="Bjorklund"/>
            <author fullname="K. Watsen" initials="K." surname="Watsen"/>
            <date month="January" year="2017"/>
            <abstract>
              <t>This document describes an HTTP-based protocol that provides a programmatic interface for accessing data defined in YANG, using the datastore concepts defined in the Network Configuration Protocol (NETCONF).</t>
            </abstract>
          </front>
          <seriesInfo name="RFC" value="8040"/>
          <seriesInfo name="DOI" value="10.17487/RFC8040"/>
        </reference>
        <reference anchor="I-D.draft-rogaglia-netconf-trace-ctx-extension-03">
          <front>
            <title>NETCONF Extension to support Trace Context propagation</title>
            <author fullname="Roque Gagliano" initials="R." surname="Gagliano">
              <organization>Cisco Systems</organization>
            </author>
            <author fullname="Kristian Larsson" initials="K." surname="Larsson">
              <organization>Deutsche Telekom AG</organization>
            </author>
            <author fullname="Jan Lindblad" initials="J." surname="Lindblad">
              <organization>Cisco Systems</organization>
            </author>
            <date day="6" month="July" year="2023"/>
            <abstract>
              <t>   This document defines how to propagate trace context information
   across the Network Configuration Protocol (NETCONF), that enables
   distributed tracing scenarios.  It is an adaption of the HTTP-based
   W3C specification.

              </t>
            </abstract>
          </front>
          <seriesInfo name="Internet-Draft" value="draft-rogaglia-netconf-trace-ctx-extension-03"/>
        </reference>
        <reference anchor="W3C-Trace-Context" target="https://www.w3.org/TR/2021/REC-trace-context-1-20211123/">
          <front>
            <title>W3C Recommendation on Trace Context</title>
            <author>
              <organization/>
            </author>
            <date year="2021" month="November" day="23"/>
          </front>
        </reference>
      </references>
      <references anchor="sec-informative-references">
        <name>Informative References</name>
        <reference anchor="RFC8309">
          <front>
            <title>Service Models Explained</title>
            <author fullname="Q. Wu" initials="Q." surname="Wu"/>
            <author fullname="W. Liu" initials="W." surname="Liu"/>
            <author fullname="A. Farrel" initials="A." surname="Farrel"/>
            <date month="January" year="2018"/>
            <abstract>
              <t>The IETF has produced many modules in the YANG modeling language. The majority of these modules are used to construct data models to model devices or monolithic functions.</t>
              <t>A small number of YANG modules have been defined to model services (for example, the Layer 3 Virtual Private Network Service Model (L3SM) produced by the L3SM working group and documented in RFC 8049).</t>
              <t>This document describes service models as used within the IETF and also shows where a service model might fit into a software-defined networking architecture. Note that service models do not make any assumption of how a service is actually engineered and delivered for a customer; details of how network protocols and devices are engineered to deliver a service are captured in other modules that are not exposed through the interface between the customer and the provider.</t>
            </abstract>
          </front>
          <seriesInfo name="RFC" value="8309"/>
          <seriesInfo name="DOI" value="10.17487/RFC8309"/>
        </reference>
      </references>
    </references>
    <?line 166?>

<section anchor="example-restconf-calls">
      <name>Example RESTCONF calls</name>
      <t>TBD</t>
    </section>
    <section anchor="changes-to-be-deleted-by-rfc-editor">
      <name>Changes (to be deleted by RFC Editor)</name>
      <section anchor="from-version-00-to-draft-netconf-restconf-trace-ctx-headers-00">
        <name>From version 00 to draft-netconf-restconf-trace-ctx-headers-00</name>
        <ul spacing="normal">
          <li>
            <t>Adopted by NETCONF WG</t>
          </li>
          <li>
            <t>Moved repository to NETCONF WG</t>
          </li>
          <li>
            <t>Changed build system to use martinthomson's excellent framework</t>
          </li>
          <li>
            <t>Ran make fix-lint to remove white space at EOL etc.</t>
          </li>
          <li>
            <t>Added this change note. No other content changes.</t>
          </li>
        </ul>
      </section>
    </section>
    <section anchor="to-do-list-to-be-deleted-by-rfc-editor">
      <name>TO DO List (to be deleted by RFC Editor)</name>
      <ul spacing="normal">
        <li>
          <t>Security Considerations</t>
        </li>
        <li>
          <t>Example RESTCONF Calls</t>
        </li>
        <li>
          <t>The W3C is working on a draft document to introduce the concept of "baggage" that we expect part of a future draft for NETCONF and RESTCONF</t>
        </li>
      </ul>
    </section>
  </back>
  <!-- ##markdown-source:
H4sIAAAAAAAAA51YWXMbNxJ+n1/RRT9kU9HwkOzdhC9rWYetrCRqZbq8qa1U
CpwBSVjDwQTAiGJc+u/7NQ4eEp2srXKZM5gG+v66G3meZ6UuarGQQyqNmLq8
lq7Q9TQ30oYHZ0Qh88I95HMpSmls3u9nTrkKW+j27P34ZHR9TmcPTtZW6Zqc
Jts2jTaOxryVTnTt5IOjd2F7JiYTI++HZIrf/NlZIZycabMaknVlVuJtSIf9
w5d5f5APBlmmGjMkZ1rrDvv9n/qHmW0nC2WZm1s1IL44G59nENZChNZ6WpmB
Qz8TRoohjRpphAO5JVGXdCVqMZMLWbtsqc3dzOi2GdL1mdcku5MrrJbDjHJy
sgKdMyt+KZV1Rk1aJ0uyK+vkwvKybnDQmu5e1q3EXnpyKlEQ9SMYqnpGb/kz
VhdCVUOKRn+tpJt2tZnhgzDFfEhz5xo77PWYjFfUvewmoh4v9CZGL63s4YSF
LnvMWLl5OxnS+M0p3ipY07rwllkH9X8Tla4hyUrazC6Ecb/93moQQQqdNWpI
/3W6OCALBxo5tXhaLfjh1ywTrZtrw5bByUTTtqpC6Nzq31tJb8WsUgKn8EcI
KGr1hzf7kE6ULTS9T1bDH2wpJQQ79hajUlr64JyCi17574UucfBg8GM/vCq3
Yj5VJePntnYcMu+Xyv0hTQXN/AcZLGr0zEvzumDO3UIvsudi/8vApZCYLoWx
Vtd7BD+VrbPFXNIYLr7TCzp+u83mrqpel/K+6xBg0GjRhR/2MPqZeai6nFSi
/L+sE4//VIVN21rU2iyw795H2e35yeFg8FN8/HHwj5fp8dXhq/TYf9kfQii6
yE+7IcmTddbZvklymRI57x/5XR+PTnKfyHlM5KG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