Skip to content

Commit 3fdfa6d

Browse files
owaislzchen
andauthored
Updated website docs (#2082)
* Updated website docs * Update docs/getting-started.rst Co-authored-by: Leighton Chen <[email protected]> Co-authored-by: Leighton Chen <[email protected]>
1 parent b76683e commit 3fdfa6d

File tree

2 files changed

+11
-13
lines changed

2 files changed

+11
-13
lines changed

docs/getting-started.rst

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
Getting Started with OpenTelemetry Python
2-
=========================================
1+
Getting Started
2+
===============
33

44
This guide walks you through instrumenting a Python application with ``opentelemetry-python``.
55

website_docs/getting-started.md

+9-11
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
---
2-
date: '2021-05-07T21:49:47.106Z'
2+
date: '2021-08-30T16:49:17.700Z'
33
docname: getting-started
44
images: {}
55
path: /getting-started
6-
title: "Getting Started"
7-
weight: 22
6+
title: Getting Started
87
---
98

9+
# Getting Started
10+
1011
This guide walks you through instrumenting a Python application with `opentelemetry-python`.
1112

1213
For more elaborate examples, see [examples](https://github.com/open-telemetry/opentelemetry-python/tree/main/docs/examples/).
@@ -38,8 +39,8 @@ The following example script emits a trace containing three named spans: “foo
3839
from opentelemetry import trace
3940
from opentelemetry.sdk.trace import TracerProvider
4041
from opentelemetry.sdk.trace.export import (
41-
ConsoleSpanExporter,
4242
BatchSpanProcessor,
43+
ConsoleSpanExporter,
4344
)
4445
4546
provider = TracerProvider()
@@ -54,9 +55,6 @@ with tracer.start_as_current_span("foo"):
5455
with tracer.start_as_current_span("bar"):
5556
with tracer.start_as_current_span("baz"):
5657
print("Hello world from OpenTelemetry Python!")
57-
58-
# Flush all ended spans that are yet to be written to stdout before process exit.
59-
provider.force_flush()
6058
```
6159

6260
When you run the script you can see the traces printed to your console:
@@ -225,8 +223,8 @@ from opentelemetry.instrumentation.flask import FlaskInstrumentor
225223
from opentelemetry.instrumentation.requests import RequestsInstrumentor
226224
from opentelemetry.sdk.trace import TracerProvider
227225
from opentelemetry.sdk.trace.export import (
228-
ConsoleSpanExporter,
229226
BatchSpanProcessor,
227+
ConsoleSpanExporter,
230228
)
231229
232230
trace.set_tracer_provider(TracerProvider())
@@ -238,16 +236,17 @@ app = flask.Flask(__name__)
238236
FlaskInstrumentor().instrument_app(app)
239237
RequestsInstrumentor().instrument()
240238
239+
tracer = trace.get_tracer(__name__)
240+
241241
242242
@app.route("/")
243243
def hello():
244-
tracer = trace.get_tracer(__name__)
245244
with tracer.start_as_current_span("example-request"):
246245
requests.get("http://www.example.com")
247246
return "hello"
248247
249248
250-
app.run(port=5000)
249+
app.run(debug=True, port=5000)
251250
```
252251

253252
Now run the script, hit the root URL ([http://localhost:5000/](http://localhost:5000/)) a few times, and watch your spans be emitted!
@@ -336,7 +335,6 @@ Finally, execute the following script:
336335

337336
```
338337
# otcollector.py
339-
import time
340338
341339
from opentelemetry import trace
342340
from opentelemetry.exporter.otlp.proto.grpc.trace_exporter import (

0 commit comments

Comments
 (0)