Skip to content

Commit 9889bd6

Browse files
committed
Use opentracing.Tracer for our examples.
1 parent 8c0d6fd commit 9889bd6

7 files changed

Lines changed: 19 additions & 32 deletions

File tree

examples/README.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
## Examples
22

3-
This directory contains examples of tracing applications using the sqlalchemy package. To run the examples, make sure you've installed the packages `opentracing` and `lightstep`. If you have a lightstep token and would like to view the created spans, then uncomment to proper lines under the given examples. If you would like to use a different OpenTracing implementation, you may also replace the lightstep tracer with the tracer of your choice.
3+
This directory contains examples of tracing applications using the sqlalchemy package. To run the examples, make sure you've installed the package `opentracing`. If you have access to a tracing platform and would like to view the created spans, replace the `tracer` in the example files with the tracer of your choice.
44

55
Then simply:
66

77
```
88
> python example-file.py
99
```
10-

examples/core-childspans.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,13 @@
33
from sqlalchemy import select
44
from sqlalchemy.schema import CreateTable
55

6-
import lightstep
6+
import opentracing
77
import sqlalchemy_opentracing
88

99
DB_LOCATION = '/tmp/simple.db'
1010

11-
tracer = lightstep.Tracer(
12-
component_name='sqlalchemy-childspans',
13-
access_token='{your_lightstep_token}'
14-
)
11+
# Your OpenTracing-compatible tracer here.
12+
tracer = opentracing.Tracer()
1513

1614

1715
if __name__ == '__main__':

examples/core-connection.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,11 @@
11
from sqlalchemy import MetaData, Table, Integer, String, Column, create_engine
22
from sqlalchemy.schema import CreateTable
33

4-
import lightstep
4+
import opentracing
55
import sqlalchemy_opentracing
66

7-
tracer = lightstep.Tracer(
8-
component_name='sqlalchemy-conn',
9-
access_token='{your_lightstep_token}'
10-
)
7+
# Your OpenTracing-compatible tracer here.
8+
tracer = opentracing.Tracer()
119

1210
if __name__ == '__main__':
1311
engine = create_engine('sqlite:///:memory:')

examples/core-simple.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,11 @@
11
from sqlalchemy import MetaData, Table, Integer, String, Column, create_engine
22
from sqlalchemy.schema import CreateTable
33

4-
import lightstep
4+
import opentracing
55
import sqlalchemy_opentracing
66

7-
tracer = lightstep.Tracer(
8-
component_name='sqlalchemy-simple',
9-
access_token='{your_lightstep_token}'
10-
)
7+
# Your OpenTracing-compatible tracer here.
8+
tracer = opentracing.Tracer()
119

1210
if __name__ == '__main__':
1311
engine = create_engine('sqlite:///:memory:')

examples/orm-bulk.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,13 @@
33
from sqlalchemy.ext.declarative import declarative_base
44
from sqlalchemy.orm import sessionmaker
55

6-
import lightstep
6+
import opentracing
77
import sqlalchemy_opentracing
88

99
DB_LOCATION = '/tmp/simple.db'
1010

11-
tracer = lightstep.Tracer(
12-
component_name='sqlalchemy-orm-bulk',
13-
access_token='{your_lightstep_token}'
14-
)
11+
# Your OpenTracing-compatible tracer here.
12+
tracer = opentracing.Tracer()
1513

1614
Base = declarative_base()
1715

examples/orm-childspan.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,13 @@
33
from sqlalchemy.ext.declarative import declarative_base
44
from sqlalchemy.orm import sessionmaker
55

6-
import lightstep
6+
import opentracing
77
import sqlalchemy_opentracing
88

99
DB_LOCATION = '/tmp/simple.db'
1010

11-
tracer = lightstep.Tracer(
12-
component_name='sqlalchemy-orm-childspan',
13-
access_token='{your_lightstep_token}'
14-
)
11+
# Your OpenTracing-compatible tracer here.
12+
tracer = opentracing.Tracer()
1513

1614
Base = declarative_base()
1715

examples/orm-simple.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,13 @@
33
from sqlalchemy.ext.declarative import declarative_base
44
from sqlalchemy.orm import sessionmaker
55

6-
import lightstep
6+
import opentracing
77
import sqlalchemy_opentracing
88

99
DB_LOCATION = '/tmp/simple.db'
1010

11-
tracer = lightstep.Tracer(
12-
component_name='sqlalchemy-orm-simple',
13-
access_token='{your_lightstep_token}'
14-
)
11+
# Your OpenTracing-compatible tracer here.
12+
tracer = opentracing.Tracer()
1513

1614
Base = declarative_base()
1715

0 commit comments

Comments
 (0)