Skip to content

Commit

Permalink
Deploying to gh-pages from @ f725dbe 🚀
Browse files Browse the repository at this point in the history
  • Loading branch information
rohanpm committed Jan 21, 2025
1 parent 8d631b7 commit bef8a1c
Show file tree
Hide file tree
Showing 11 changed files with 131 additions and 131 deletions.
2 changes: 1 addition & 1 deletion _modules/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Overview: module code &#8212; pubtools documentation</title>
<link rel="stylesheet" type="text/css" href="../_static/pygments.css?v=d1102ebc" />
<link rel="stylesheet" type="text/css" href="../_static/pygments.css?v=5ecbeea2" />
<link rel="stylesheet" type="text/css" href="../_static/basic.css?v=686e5160" />
<link rel="stylesheet" type="text/css" href="../_static/alabaster.css?v=19a2ea7e" />
<script src="../_static/documentation_options.js?v=5929fcd5"></script>
Expand Down
24 changes: 12 additions & 12 deletions _modules/pubtools/_impl/pluggy.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>pubtools._impl.pluggy &#8212; pubtools documentation</title>
<link rel="stylesheet" type="text/css" href="../../../_static/pygments.css?v=d1102ebc" />
<link rel="stylesheet" type="text/css" href="../../../_static/pygments.css?v=5ecbeea2" />
<link rel="stylesheet" type="text/css" href="../../../_static/basic.css?v=686e5160" />
<link rel="stylesheet" type="text/css" href="../../../_static/alabaster.css?v=19a2ea7e" />
<script src="../../../_static/documentation_options.js?v=5929fcd5"></script>
Expand All @@ -31,12 +31,12 @@
<div class="body" role="main">

<h1>Source code for pubtools._impl.pluggy</h1><div class="highlight"><pre>
<span></span><span class="kn">import</span> <span class="nn">logging</span>
<span class="kn">import</span> <span class="nn">sys</span>
<span class="kn">from</span> <span class="nn">contextlib</span> <span class="kn">import</span> <span class="n">contextmanager</span>
<span></span><span class="kn">import</span><span class="w"> </span><span class="nn">logging</span>
<span class="kn">import</span><span class="w"> </span><span class="nn">sys</span>
<span class="kn">from</span><span class="w"> </span><span class="nn">contextlib</span><span class="w"> </span><span class="kn">import</span> <span class="n">contextmanager</span>

<span class="kn">import</span> <span class="nn">pkg_resources</span>
<span class="kn">import</span> <span class="nn">pluggy</span>
<span class="kn">import</span><span class="w"> </span><span class="nn">pkg_resources</span>
<span class="kn">import</span><span class="w"> </span><span class="nn">pluggy</span>

<span class="n">LOG</span> <span class="o">=</span> <span class="n">logging</span><span class="o">.</span><span class="n">getLogger</span><span class="p">(</span><span class="s2">&quot;pubtools&quot;</span><span class="p">)</span>

Expand All @@ -45,7 +45,7 @@ <h1>Source code for pubtools._impl.pluggy</h1><div class="highlight"><pre>
<span class="n">hookimpl</span> <span class="o">=</span> <span class="n">pluggy</span><span class="o">.</span><span class="n">HookimplMarker</span><span class="p">(</span><span class="s2">&quot;pubtools&quot;</span><span class="p">)</span>


<span class="k">def</span> <span class="nf">resolve_hooks</span><span class="p">():</span>
<span class="k">def</span><span class="w"> </span><span class="nf">resolve_hooks</span><span class="p">():</span>
<span class="c1"># A private helper to ensure all code defining hookspecs/hookimpls has been imported</span>
<span class="c1"># before continuing.</span>

Expand All @@ -70,7 +70,7 @@ <h1>Source code for pubtools._impl.pluggy</h1><div class="highlight"><pre>


<span class="nd">@hookspec</span>
<span class="k">def</span> <span class="nf">task_start</span><span class="p">():</span>
<span class="k">def</span><span class="w"> </span><span class="nf">task_start</span><span class="p">():</span>
<span class="w"> </span><span class="sd">&quot;&quot;&quot;Called when a task starts.</span>

<span class="sd"> This hook can be used to register additional hook implementations with</span>
Expand All @@ -79,7 +79,7 @@ <h1>Source code for pubtools._impl.pluggy</h1><div class="highlight"><pre>


<span class="nd">@hookspec</span>
<span class="k">def</span> <span class="nf">task_stop</span><span class="p">(</span><span class="n">failed</span><span class="p">):</span>
<span class="k">def</span><span class="w"> </span><span class="nf">task_stop</span><span class="p">(</span><span class="n">failed</span><span class="p">):</span>
<span class="w"> </span><span class="sd">&quot;&quot;&quot;Called when a task ends.</span>

<span class="sd"> If :func:`task_start` was used to register additional hook implementations,</span>
Expand All @@ -94,7 +94,7 @@ <h1>Source code for pubtools._impl.pluggy</h1><div class="highlight"><pre>
<div class="viewcode-block" id="task_context">
<a class="viewcode-back" href="../../../hooks.html#pubtools.pluggy.task_context">[docs]</a>
<span class="nd">@contextmanager</span>
<span class="k">def</span> <span class="nf">task_context</span><span class="p">():</span>
<span class="k">def</span><span class="w"> </span><span class="nf">task_context</span><span class="p">():</span>
<span class="w"> </span><span class="sd">&quot;&quot;&quot;Run a block of code within a task context, ensuring task lifecycle hooks are invoked</span>
<span class="sd"> when appropriate.</span>

Expand Down Expand Up @@ -130,7 +130,7 @@ <h1>Source code for pubtools._impl.pluggy</h1><div class="highlight"><pre>


<span class="nd">@hookspec</span><span class="p">(</span><span class="n">firstresult</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span>
<span class="k">def</span> <span class="nf">get_cert_key_paths</span><span class="p">(</span><span class="n">server_url</span><span class="p">):</span>
<span class="k">def</span><span class="w"> </span><span class="nf">get_cert_key_paths</span><span class="p">(</span><span class="n">server_url</span><span class="p">):</span>
<span class="w"> </span><span class="sd">&quot;&quot;&quot;Get location of SSL certificates used to authenticate with a given service.</span>

<span class="sd"> If there are multiple hook implementations and multiple values are returned, the first</span>
Expand All @@ -149,7 +149,7 @@ <h1>Source code for pubtools._impl.pluggy</h1><div class="highlight"><pre>


<span class="nd">@hookspec</span><span class="p">(</span><span class="n">firstresult</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span>
<span class="k">def</span> <span class="nf">otel_exporter</span><span class="p">():</span>
<span class="k">def</span><span class="w"> </span><span class="nf">otel_exporter</span><span class="p">():</span>
<span class="w"> </span><span class="sd">&quot;&quot;&quot;Return an OTEL exporter, used by OTEL instrumentation.</span>

<span class="sd"> If OTEL tracing is enabled and this hook is not implemented, a default</span>
Expand Down
46 changes: 23 additions & 23 deletions _modules/pubtools/_impl/tracing.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>pubtools._impl.tracing &#8212; pubtools documentation</title>
<link rel="stylesheet" type="text/css" href="../../../_static/pygments.css?v=d1102ebc" />
<link rel="stylesheet" type="text/css" href="../../../_static/pygments.css?v=5ecbeea2" />
<link rel="stylesheet" type="text/css" href="../../../_static/basic.css?v=686e5160" />
<link rel="stylesheet" type="text/css" href="../../../_static/alabaster.css?v=19a2ea7e" />
<script src="../../../_static/documentation_options.js?v=5929fcd5"></script>
Expand Down Expand Up @@ -40,20 +40,20 @@ <h1>Source code for pubtools._impl.tracing</h1><div class="highlight"><pre>

<span class="sd">&quot;&quot;&quot;</span>

<span class="kn">import</span> <span class="nn">functools</span>
<span class="kn">import</span> <span class="nn">logging</span>
<span class="kn">import</span> <span class="nn">os</span>
<span class="kn">import</span> <span class="nn">threading</span>
<span class="kn">import</span><span class="w"> </span><span class="nn">functools</span>
<span class="kn">import</span><span class="w"> </span><span class="nn">logging</span>
<span class="kn">import</span><span class="w"> </span><span class="nn">os</span>
<span class="kn">import</span><span class="w"> </span><span class="nn">threading</span>

<span class="k">try</span><span class="p">:</span>
<span class="kn">from</span> <span class="nn">opentelemetry</span> <span class="kn">import</span> <span class="n">baggage</span><span class="p">,</span> <span class="n">context</span><span class="p">,</span> <span class="n">trace</span>
<span class="kn">from</span> <span class="nn">opentelemetry.baggage.propagation</span> <span class="kn">import</span> <span class="n">W3CBaggagePropagator</span>
<span class="kn">from</span> <span class="nn">opentelemetry.propagate</span> <span class="kn">import</span> <span class="n">set_global_textmap</span>
<span class="kn">from</span> <span class="nn">opentelemetry.sdk.resources</span> <span class="kn">import</span> <span class="n">SERVICE_NAME</span><span class="p">,</span> <span class="n">Resource</span>
<span class="kn">from</span> <span class="nn">opentelemetry.sdk.trace</span> <span class="kn">import</span> <span class="n">TracerProvider</span>
<span class="kn">from</span> <span class="nn">opentelemetry.sdk.trace.export</span> <span class="kn">import</span> <span class="n">BatchSpanProcessor</span><span class="p">,</span> <span class="n">ConsoleSpanExporter</span>
<span class="kn">from</span> <span class="nn">opentelemetry.trace</span> <span class="kn">import</span> <span class="n">Status</span><span class="p">,</span> <span class="n">StatusCode</span>
<span class="kn">from</span> <span class="nn">opentelemetry.trace.propagation.tracecontext</span> <span class="kn">import</span> <span class="p">(</span>
<span class="kn">from</span><span class="w"> </span><span class="nn">opentelemetry</span><span class="w"> </span><span class="kn">import</span> <span class="n">baggage</span><span class="p">,</span> <span class="n">context</span><span class="p">,</span> <span class="n">trace</span>
<span class="kn">from</span><span class="w"> </span><span class="nn">opentelemetry.baggage.propagation</span><span class="w"> </span><span class="kn">import</span> <span class="n">W3CBaggagePropagator</span>
<span class="kn">from</span><span class="w"> </span><span class="nn">opentelemetry.propagate</span><span class="w"> </span><span class="kn">import</span> <span class="n">set_global_textmap</span>
<span class="kn">from</span><span class="w"> </span><span class="nn">opentelemetry.sdk.resources</span><span class="w"> </span><span class="kn">import</span> <span class="n">SERVICE_NAME</span><span class="p">,</span> <span class="n">Resource</span>
<span class="kn">from</span><span class="w"> </span><span class="nn">opentelemetry.sdk.trace</span><span class="w"> </span><span class="kn">import</span> <span class="n">TracerProvider</span>
<span class="kn">from</span><span class="w"> </span><span class="nn">opentelemetry.sdk.trace.export</span><span class="w"> </span><span class="kn">import</span> <span class="n">BatchSpanProcessor</span><span class="p">,</span> <span class="n">ConsoleSpanExporter</span>
<span class="kn">from</span><span class="w"> </span><span class="nn">opentelemetry.trace</span><span class="w"> </span><span class="kn">import</span> <span class="n">Status</span><span class="p">,</span> <span class="n">StatusCode</span>
<span class="kn">from</span><span class="w"> </span><span class="nn">opentelemetry.trace.propagation.tracecontext</span><span class="w"> </span><span class="kn">import</span> <span class="p">(</span>
<span class="n">TraceContextTextMapPropagator</span><span class="p">,</span>
<span class="p">)</span>

Expand All @@ -63,7 +63,7 @@ <h1>Source code for pubtools._impl.tracing</h1><div class="highlight"><pre>
<span class="c1"># TracingWrapper to provide pass through functions.</span>
<span class="n">OPENTELEMETRY_AVAILABLE</span> <span class="o">=</span> <span class="kc">False</span>

<span class="kn">from</span> <span class="nn">pubtools.pluggy</span> <span class="kn">import</span> <span class="n">pm</span>
<span class="kn">from</span><span class="w"> </span><span class="nn">pubtools.pluggy</span><span class="w"> </span><span class="kn">import</span> <span class="n">pm</span>

<span class="n">propagator</span> <span class="o">=</span> <span class="n">TraceContextTextMapPropagator</span><span class="p">()</span>
<span class="n">baggage_propagator</span> <span class="o">=</span> <span class="n">W3CBaggagePropagator</span><span class="p">()</span>
Expand All @@ -73,7 +73,7 @@ <h1>Source code for pubtools._impl.tracing</h1><div class="highlight"><pre>

<div class="viewcode-block" id="get_trace_wrapper">
<a class="viewcode-back" href="../../../tracing.html#pubtools.tracing.get_trace_wrapper">[docs]</a>
<span class="k">def</span> <span class="nf">get_trace_wrapper</span><span class="p">():</span>
<span class="k">def</span><span class="w"> </span><span class="nf">get_trace_wrapper</span><span class="p">():</span>
<span class="w"> </span><span class="sd">&quot;&quot;&quot;return a global trace wrapper instance&quot;&quot;&quot;</span>
<span class="k">global</span> <span class="n">TRACE_WRAPPER</span>
<span class="k">if</span> <span class="n">TRACE_WRAPPER</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">:</span>
Expand All @@ -82,17 +82,17 @@ <h1>Source code for pubtools._impl.tracing</h1><div class="highlight"><pre>



<span class="k">class</span> <span class="nc">TracingWrapper</span><span class="p">:</span>
<span class="k">class</span><span class="w"> </span><span class="nc">TracingWrapper</span><span class="p">:</span>
<span class="w"> </span><span class="sd">&quot;&quot;&quot;Wrapper class to initialize opentelemetry instrumentation and provide a helper function</span>
<span class="sd"> for instrumenting a function&quot;&quot;&quot;</span>

<span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
<span class="k">def</span><span class="w"> </span><span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
<span class="bp">self</span><span class="o">.</span><span class="n">_processor</span> <span class="o">=</span> <span class="kc">None</span>
<span class="bp">self</span><span class="o">.</span><span class="n">_provider</span> <span class="o">=</span> <span class="kc">None</span>
<span class="bp">self</span><span class="o">.</span><span class="n">_enabled_trace</span> <span class="o">=</span> <span class="kc">None</span>
<span class="bp">self</span><span class="o">.</span><span class="n">_reset</span><span class="p">()</span>

<span class="k">def</span> <span class="nf">_reset</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
<span class="k">def</span><span class="w"> </span><span class="nf">_reset</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
<span class="c1"># Construct the needed resources, if and only if OTEL_TRACING is enabled</span>
<span class="c1"># and the resources were not already constructed.</span>
<span class="c1">#</span>
Expand Down Expand Up @@ -126,7 +126,7 @@ <h1>Source code for pubtools._impl.tracing</h1><div class="highlight"><pre>
<span class="n">trace</span><span class="o">.</span><span class="n">set_tracer_provider</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_provider</span><span class="p">)</span>
<span class="n">set_global_textmap</span><span class="p">(</span><span class="n">propagator</span><span class="p">)</span>

<span class="k">def</span> <span class="nf">instrument_func</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">span_name</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> <span class="n">carrier</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> <span class="n">args_to_attr</span><span class="o">=</span><span class="kc">False</span><span class="p">):</span>
<span class="k">def</span><span class="w"> </span><span class="nf">instrument_func</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">span_name</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> <span class="n">carrier</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> <span class="n">args_to_attr</span><span class="o">=</span><span class="kc">False</span><span class="p">):</span>
<span class="w"> </span><span class="sd">&quot;&quot;&quot;Instrument tracing for a function.</span>

<span class="sd"> Args:</span>
Expand All @@ -142,9 +142,9 @@ <h1>Source code for pubtools._impl.tracing</h1><div class="highlight"><pre>
<span class="sd"> The decorated function</span>
<span class="sd"> &quot;&quot;&quot;</span>

<span class="k">def</span> <span class="nf">_instrument_func</span><span class="p">(</span><span class="n">func</span><span class="p">):</span>
<span class="k">def</span><span class="w"> </span><span class="nf">_instrument_func</span><span class="p">(</span><span class="n">func</span><span class="p">):</span>
<span class="nd">@functools</span><span class="o">.</span><span class="n">wraps</span><span class="p">(</span><span class="n">func</span><span class="p">)</span>
<span class="k">def</span> <span class="nf">wrap</span><span class="p">(</span><span class="o">*</span><span class="n">args</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">):</span>
<span class="k">def</span><span class="w"> </span><span class="nf">wrap</span><span class="p">(</span><span class="o">*</span><span class="n">args</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">):</span>
<span class="n">attributes</span> <span class="o">=</span> <span class="p">{</span>
<span class="s2">&quot;function_name&quot;</span><span class="p">:</span> <span class="n">func</span><span class="o">.</span><span class="vm">__qualname__</span><span class="p">,</span>
<span class="p">}</span>
Expand Down Expand Up @@ -203,14 +203,14 @@ <h1>Source code for pubtools._impl.tracing</h1><div class="highlight"><pre>

<span class="k">return</span> <span class="n">_instrument_func</span>

<span class="k">def</span> <span class="nf">force_flush</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
<span class="k">def</span><span class="w"> </span><span class="nf">force_flush</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
<span class="w"> </span><span class="sd">&quot;&quot;&quot;Flush trace data into OTEL collectors&quot;&quot;&quot;</span>
<span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_processor</span><span class="p">:</span>
<span class="bp">self</span><span class="o">.</span><span class="n">_processor</span><span class="o">.</span><span class="n">force_flush</span><span class="p">()</span>
<span class="n">log</span><span class="o">.</span><span class="n">info</span><span class="p">(</span><span class="s2">&quot;Flush trace data into OTEL collectors&quot;</span><span class="p">)</span>

<span class="nd">@property</span>
<span class="k">def</span> <span class="nf">provider</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
<span class="k">def</span><span class="w"> </span><span class="nf">provider</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
<span class="w"> </span><span class="sd">&quot;&quot;&quot;Trace provider&quot;&quot;&quot;</span>
<span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_provider</span>
</pre></div>
Expand Down
Loading

0 comments on commit bef8a1c

Please sign in to comment.