You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: articles/azure-monitor/app/opencensus-python.md
+18-15Lines changed: 18 additions & 15 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -73,10 +73,12 @@ First you have to create an Application Insights resource which will generate an
73
73
74
74
## OpenCensus Python package
75
75
76
-
1. Install the Open Census package for Python with pip or pipenv from the command line:
76
+
1. Install the Open Census package for Python and exporter with pip or pipenv from the command line:
77
77
78
-
```python
78
+
```console
79
79
python -m pip install opencensus
80
+
python -m pip install opencensus-ext-ocagent
81
+
80
82
# pip env install opencensus
81
83
```
82
84
@@ -87,20 +89,20 @@ First you have to create an Application Insights resource which will generate an
87
89
88
90
```python
89
91
from opencensus.trace.tracer import Tracer
90
-
92
+
91
93
def main():
92
94
while True:
93
95
valuePrompt()
94
-
96
+
95
97
def valuePrompt():
96
98
tracer = Tracer()
97
99
with tracer.span(name="test") as span:
98
100
line = input("Enter a value: ")
99
101
print(line)
100
-
102
+
101
103
if __name__ == "__main__":
102
104
main()
103
-
105
+
104
106
```
105
107
106
108
3. Running the code will repeatedly prompt you to enter a value. With each entry, the value will be printed to the shell, and a corresponding piece of **SpanData** will be generated by the OpenCensus Python Module. The OpenCensus project defines a [_trace as a tree of spans_](https://opencensus.io/core-concepts/tracing/).
@@ -122,32 +124,33 @@ First you have to create an Application Insights resource which will generate an
122
124
```python
123
125
from opencensus.trace.tracer import Tracer
124
126
from opencensus.trace import config_integration
125
-
from opencensus.trace.exporters.ocagent import trace_exporter
127
+
from opencensus.ext.ocagent.trace_exporter import TraceExporter
126
128
from opencensus.trace import tracer as tracer_module
5. If you save and try running the above module, you may receive a `ModuleNotFoundError` for `grpc`. If this occurs run the following to install the [grpcio package](https://pypi.org/project/grpcio/) with:
0 commit comments