Repository: open-telemetry/opentelemetry-python

Issue:
Author a full getting started guide
As part of the final beta announce on March 30th, we should have a full getting started guide, similar to this one for js:

https://github.com/open-telemetry/opentelemetry-js/blob/master/getting-started/README.md




Discussion:
for this work, we should leverage or contribute back to the existing examples as much as possilble. This helps minimize the number of examples we have to keep up to date.

Resolving patch:
diff --git a/docs/examples/opentelemetry-example-app/src/opentelemetry_example_app/flask_example.py b/docs/examples/opentelemetry-example-app/src/opentelemetry_example_app/flask_example.py
--- a/docs/examples/opentelemetry-example-app/src/opentelemetry_example_app/flask_example.py
+++ b/docs/examples/opentelemetry-example-app/src/opentelemetry_example_app/flask_example.py
@@ -17,50 +17,31 @@
 the requests library to perform downstream requests
 """
 import flask
-import pkg_resources
 import requests
 
 import opentelemetry.ext.http_requests
 from opentelemetry import trace
 from opentelemetry.ext.flask import instrument_app
 from opentelemetry.sdk.trace import TracerProvider
+from opentelemetry.sdk.trace.export import ConsoleSpanExporter
+from opentelemetry.sdk.trace.export import SimpleExportSpanProcessor
 
-
-def configure_opentelemetry(flask_app: flask.Flask):
-    """Configure a flask application to use OpenTelemetry.
-
-    This activates the specific components:
-
-    * sets tracer to the SDK's Tracer
-    * enables requests integration on the Tracer
-    * uses a WSGI middleware to enable configuration
-    """
-    # Start by configuring all objects required to ensure a complete end to end
-    # workflow.
-    trace.set_tracer_provider(TracerProvider())
-
-    # Next, we need to configure how the values that are used by traces and
-    # metrics are propagated (such as what specific headers carry this value).
-    # Integrations are the glue that binds the OpenTelemetry API and the
-    # frameworks and libraries that are used together, automatically creating
-    # Spans and propagating context as appropriate.
-    opentelemetry.ext.http_requests.enable(trace.get_tracer_provider())
-    instrument_app(flask_app)
-
+trace.set_tracer_provider(TracerProvider())
+trace.get_tracer_provider().add_span_processor(
+    SimpleExportSpanProcessor(ConsoleSpanExporter())
+)
 
 app = flask.Flask(__name__)
+opentelemetry.ext.http_requests.enable(trace.get_tracer_provider())
+instrument_app(app)
 
 
 @app.route("/")
 def hello():
-    # Emit a trace that measures how long the sleep takes
-    version = pkg_resources.get_distribution(
-        "opentelemetry-example-app"
-    ).version
-    tracer = trace.get_tracer(__name__, version)
+    tracer = trace.get_tracer(__name__)
     with tracer.start_as_current_span("example-request"):
         requests.get("http://www.example.com")
     return "hello"
 
 
-configure_opentelemetry(app)
+app.run(debug=True)
diff --git a/docs/trace_example.py b/docs/trace_example.py
--- a/docs/trace_example.py
+++ b/docs/trace_example.py
@@ -5,8 +5,8 @@
     SimpleExportSpanProcessor,
 )
 
-trace.set_preferred_tracer_provider_implementation(lambda T: TracerProvider())
-trace.tracer_provider().add_span_processor(
+trace.set_tracer_provider(TracerProvider())
+trace.get_tracer_provider().add_span_processor(
     SimpleExportSpanProcessor(ConsoleSpanExporter())
 )
 


Test patch: