Adding more documentation around examples#277
Conversation
Signed-off-by: Alex Boten <aboten@lightstep.com>
Signed-off-by: Alex Boten <aboten@lightstep.com>
Signed-off-by: Alex Boten <aboten@lightstep.com>
Signed-off-by: Alex Boten <aboten@lightstep.com>
|
Heads up that isort complains about some of these files. E.g., it would change: diff --git a/examples/http/server.py b/examples/http/server.py
index fd3d5fd..50f0168 100644
--- a/examples/http/server.py
+++ b/examples/http/server.py
@@ -1,14 +1,16 @@
-import flask
import os
-import requests
+import flask
+import requests
from opentelemetry import trace
from opentelemetry.ext import http_requests
from opentelemetry.ext.jaeger import JaegerSpanExporter
from opentelemetry.ext.wsgi import OpenTelemetryMiddleware
from opentelemetry.sdk.trace import Tracer
-from opentelemetry.sdk.trace.export import ConsoleSpanExporter
-from opentelemetry.sdk.trace.export import BatchExportSpanProcessor
+from opentelemetry.sdk.trace.export import (
+ BatchExportSpanProcessor,
+ ConsoleSpanExporter,
+)We had to use this isort configuration to use black, but I think this actually makes imports less readable, and think we might actually prefer the single-line-import style for examples. We may want to disable isort for examples altogether. |
c24t
left a comment
There was a problem hiding this comment.
LGTM, I think it's a great idea to have top-level examples with nice README files like this.
We may want to move these off jaeger in the future, or include links to other exporter examples, but this looks great for now.
Signed-off-by: Alex Boten <aboten@lightstep.com>
This ended up giving me problems with black... I just changed the code to multi line import for now |
Signed-off-by: Alex Boten <aboten@lightstep.com>
Codecov Report
@@ Coverage Diff @@
## master #277 +/- ##
=======================================
Coverage 85.74% 85.74%
=======================================
Files 33 33
Lines 1620 1620
Branches 183 183
=======================================
Hits 1389 1389
Misses 184 184
Partials 47 47Continue to review full report at Codecov.
|
mauriciovasquezbernal
left a comment
There was a problem hiding this comment.
LGTM overall.
My only blocking point is that the http example you introduced overlaps with https://github.com/open-telemetry/opentelemetry-python/tree/master/examples/trace, those should be combined together.
examples/basic-tracer/tracer.py
Outdated
|
|
||
| from opentelemetry import trace | ||
| from opentelemetry.context import Context | ||
| from opentelemetry.ext.jaeger import JaegerSpanExporter |
There was a problem hiding this comment.
I think this import has to be moved under the conditional because somebody trying only the console exporter will not have installed the Jaeger one.
Applies for other examples as well.
There was a problem hiding this comment.
good point, updated the examples
| Click on the trace to view its details. | ||
|
|
||
| <p align="center"><img src="./images/jaeger-ui-detail.png?raw=true"/></p> | ||
| ## Useful links |
There was a problem hiding this comment.
It's not rendering properly, is an empty line before required?
| return "hello" | ||
|
|
||
|
|
||
| if __name__ == "__main__": |
There was a problem hiding this comment.
I am wondering if this conditional is really required.
|
I forgot to say that a link in the main readme could be nice. We have a link but only for the example-app, (just before the contributing section https://github.com/open-telemetry/opentelemetry-python/blob/master/README.md#contributing), maybe this should point to all the examples instead. |
- combining http & trace examples into single example - adding README in examples - adding link to examples in the main README - updating example code to conditional import the JaegerSpanExporter Signed-off-by: Alex Boten <aboten@lightstep.com>
codeboten
left a comment
There was a problem hiding this comment.
I updated the main README with a link to the examples folder, which now contains a README with some information about the examples https://github.com/open-telemetry/opentelemetry-python/tree/85dc4a63592d5bcdede2d508efcc3de67b8740e3/examples
| ) | ||
|
|
||
| if os.getenv("EXPORTER") == "jaeger": | ||
| from opentelemetry.ext.jaeger import JaegerSpanExporter |
There was a problem hiding this comment.
Any reason not to put this in the same conditional as the exporter creation below?
There was a problem hiding this comment.
I was thinking about doing that as well. The only reason I didn't was to keep the imports separate from the rest of the code, but i don't feel strongly one way or another. I'll update it, it makes the code simpler
Signed-off-by: Alex Boten <aboten@lightstep.com>
toumorokoshi
left a comment
There was a problem hiding this comment.
I think the code looks great! But I do agree with @mauriciovasquezbernal that we need to keep the examples concise and not duplicate.
There's already examples nearly identical to this in opentelemetry-example-app and in trace. Please reconcile this one with at least one of those so we don't have a third example of the same thing.
Also unit tests would be great, so we could catch the examples breaking.
|
@toumorokoshi I combined the |
Signed-off-by: Alex Boten <aboten@lightstep.com>
Signed-off-by: Alex Boten <aboten@lightstep.com>
|
LGTM! thanks for adding tests, and thanks for considering standardization by normalizing our names with the js project! |
Adding examples with README files. Basing this off the opentelemetry-js/examples content for consistency.