<?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.8 (Ruby 2.7.0) -->
<rfc xmlns:xi="http://www.w3.org/2001/XInclude" ipr="trust200902" docName="draft-ietf-netconf-restconf-trace-ctx-headers-00" category="std" consensus="true" submissionType="IETF" tocInclude="true" sortRefs="true" symRefs="true" version="3">
  <!-- xml2rfc v2v3 conversion 3.20.1 -->
  <front>
    <title abbrev="rc_trace">RESTCONF Extension to support Trace Context Headers</title>
    <seriesInfo name="Internet-Draft" value="draft-ietf-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="April" day="10"/>
    <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-ietf-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-ietf-netconf-restconf-trace-ctx-headers-00">
        <name>From version 00 to draft-ietf-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:
H4sIAAAAAAAAA51ZWXMbNxJ+n1/RRT9kU6vhIdmbhC9rWYetrCRqZbq8qa1U
CpwBSVjDwQTAiGJc+u/7NQ4eEp2srVJZM5gG+v66G87zPCt1UYuFHFJpxNTl
SrppXktX6HqaG2nDgzOikHnhHvK5FKU0Nu/3M6dchX10e/Z+fDK6PqezBydr
q3RNTpNtm0YbR2PeSie6dvLB0buwPROTiZH3QzLFb/7srBBOzrRZDcm6Mivx
NqTD/uHLvH+UD37IMtWYITnTWnfY7//UP8xsO1koy9zcqgHxxdn4PIOwFiK0
1tPKDBz6mTBSDGnUSCMcyC2JuqQrUYuZXMjaZUtt7mZGt82Qrs+8JtmdXGG1
HGaUk5MV6JxZ8UuprDNq0jpZkl1ZJxeWl3WDg9Z097JuJfbSk1OJgqgfwVDV
M3rLn7G6EKoaUjT6a/ZAV5sZPghTzIc0d66xw16PyXhF3ctuIurxQm9i9NLK
Hk5Y6LLHjJWbt5Mhjd+c4q2CNa0Lb5l1UP83UekakqykzexCGPfb760GEaTQ
WaOG9F+niwOycKCRU4un1YIffs0y0bq5NmwZnEw0basqxM+t/r2V9FbMKiVw
Cn+EgKJWf3izD+lE2ULT+2Q1/MCWUkKwY28xKqWlD84puOiV/17oEgcPBj/2
w6tyK+ZTVTJ+bmvHIfN+qdwf0lTQzH+QwaJGz7w0rwvm3C30Insu9r8MXAqJ
6VIYa3W9R/BT2TpbzCWN4eI7vaDjt9ts7qrqdSnvuw4BBo0WXfhhD6OfmYeq
y0klyv/LOvH4T1XYtK1Frc0C++59lN2enxwOBj/Fxx8HP7xMj68OX6XH/sv+
EELRRX7aDZm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