Skip to content

Commit 97e4979

Browse files
authored
Console support (#160)
* Enable a ipython console that is disabled by default. * Touchups and more help links
1 parent a445364 commit 97e4979

File tree

1 file changed

+46
-2
lines changed

1 file changed

+46
-2
lines changed

instana/__main__.py

Lines changed: 46 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,12 @@
1+
"""
2+
This module provides "python -m instana" functionality. This is used for basic module
3+
information display and a IPython console to diagnose environments.
4+
5+
The console is disabled by default unless the ipython package is installed.
6+
"""
7+
import os
8+
import sys
9+
110
print("""\
211
============================================================================
312
8888888 888b 888 .d8888b. 88888888888 d8888 888b 888 d8888
@@ -9,11 +18,46 @@
918
888 888 Y8888 Y88b d88P 888 d8888888888 888 Y8888 d8888888888
1019
8888888 888 Y888 "Y8888P" 888 d88P 888 888 Y888 d88P 888
1120
============================================================================
21+
""")
22+
23+
if "console" in sys.argv:
24+
try:
25+
import IPython
26+
except ImportError:
27+
print("This console is not enabled by default.")
28+
print("IPython not installed. To use this debug console do: 'pip install ipython'\n")
29+
else:
30+
print("Welcome to the Instana console.\n")
31+
print("This is a simple IPython console with the Instana Python Sensor pre-loaded.\n")
32+
33+
if "INSTANA_DEBUG" not in os.environ:
34+
print("If you want debug output of this sensors' activity run instead:\n")
35+
print(" INSTANA_DEBUG=true python -m instana console")
36+
37+
print("""
38+
Helpful Links
39+
============================================================================
1240
41+
Monitoring Python Documentation:
42+
https://docs.instana.io/ecosystem/python
43+
44+
Help & Support:
45+
https://support.instana.com/
46+
""")
47+
48+
IPython.start_ipython(argv=[])
49+
else:
50+
print("""\
1351
This is an informational screen for Instana.
1452
53+
Supported commands:
54+
- console:
55+
* Requires ipython package: pip install ipython
56+
* Example:
57+
- python -m instana console
58+
1559
See the Instana Python documentation for details on using this package with
16-
your Python applications, workers, queues and more.
60+
your Python applications, workers, queues, neural networks and more.
1761
1862
1963
Related Blog Posts:
@@ -33,7 +77,7 @@
3377
https://docs.instana.io/ecosystem/python
3478
3579
Help & Support:
36-
https://support.instana.com/hc/en-us
80+
https://support.instana.com/
3781
3882
Python Instrumentation on Github:
3983
https://github.com/instana/python-sensor/

0 commit comments

Comments
 (0)