Skip to content

Commit 272bc0e

Browse files
authored
docs: adding faq (open-telemetry#1068)
Adding an FAQ section, which can also serve as a quick reference. Not having such a section makes common scenarios harder to discover.
1 parent 4726bbf commit 272bc0e

File tree

2 files changed

+28
-0
lines changed

2 files changed

+28
-0
lines changed

docs/faq-and-cookbook.rst

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
Frequently Asked Questions and Cookbook
2+
=======================================
3+
4+
This page answers frequently asked questions, and serves as a cookbook
5+
for common scenarios.
6+
7+
Create a new span
8+
-----------------
9+
10+
.. code-block:: python
11+
12+
from opentelemetry import trace
13+
14+
tracer = trace.get_tracer(__name__)
15+
with tracer.start_as_current_span("print") as span:
16+
print("foo")
17+
span.set_attribute("printed_string", "foo")
18+
19+
Getting and modifying a span
20+
----------------------------
21+
22+
.. code-block:: python
23+
24+
from opentelemetry import trace
25+
26+
current_span = trace.get_current_span()
27+
current_span.set_attribute("hometown", "seattle")

docs/index.rst

+1
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ install <https://pip.pypa.io/en/stable/reference/pip_install/#editable-installs>
6262
:name: getting-started
6363

6464
getting-started
65+
faq-and-cookbook
6566

6667
.. toctree::
6768
:maxdepth: 1

0 commit comments

Comments
 (0)