-
Notifications
You must be signed in to change notification settings - Fork 657
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Adding more documentation around examples #277
Conversation
Signed-off-by: Alex Boten <[email protected]>
Signed-off-by: Alex Boten <[email protected]>
Signed-off-by: Alex Boten <[email protected]>
Signed-off-by: Alex Boten <[email protected]>
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. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 <[email protected]>
This ended up giving me problems with black... I just changed the code to multi line import for now |
Signed-off-by: Alex Boten <[email protected]>
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 47 Continue to review full report at Codecov.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's not rendering properly, is an empty line before required?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
examples/http/server.py
Outdated
return "hello" | ||
|
||
|
||
if __name__ == "__main__": |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
examples/basic-tracer/tracer.py
Outdated
) | ||
|
||
if os.getenv("EXPORTER") == "jaeger": | ||
from opentelemetry.ext.jaeger import JaegerSpanExporter |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any reason not to put this in the same conditional as the exporter creation below?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 <[email protected]>
Signed-off-by: Alex Boten <[email protected]>
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.