Skip to content

Commit

Permalink
address zipkin address issue
Browse files Browse the repository at this point in the history
  • Loading branch information
jettify committed Jul 11, 2018
1 parent c85f1cc commit 0b5f23e
Show file tree
Hide file tree
Showing 16 changed files with 23 additions and 22 deletions.
2 changes: 1 addition & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ Simple example
async def run():
# setup zipkin client
zipkin_address = "http://127.0.0.1:9411"
zipkin_address = 'http://127.0.0.1:9411/api/v2/spans'
endpoint = az.create_endpoint(
"simple_service", ipv4="127.0.0.1", port=8080)
tracer = await az.create(zipkin_address, endpoint, sample_rate=1.0)
Expand Down
4 changes: 2 additions & 2 deletions aiozipkin/tracer.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,9 +94,9 @@ def create(zipkin_address: str,
send_interval: float=5,
loop: OptLoop=None) -> Awaitable[Tracer]:

async def f() -> Tracer:
async def build_tracer() -> Tracer:
sampler = Sampler(sample_rate=sample_rate)
transport = Transport(zipkin_address, send_interval=send_interval, loop=loop)
return Tracer(transport, sampler, local_endpoint)
result = _ContextManager(f()) # type: Awaitable[Tracer]
result = _ContextManager(build_tracer()) # type: Awaitable[Tracer]
return result
2 changes: 1 addition & 1 deletion aiozipkin/transport.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class Transport:

def __init__(self, address: str, send_interval: float=5,
loop: OptLoop=None) -> None:
self._address = URL(address) / 'api/v2/spans'
self._address = URL(address)
self._queue = [] # type: List[Dict[str, Any]]
self._closing = False
self._send_interval = send_interval
Expand Down
2 changes: 1 addition & 1 deletion demos/microservices/service_a.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
service_e_api = 'http://127.0.0.1:9005/api/v1/data'
host = '127.0.0.1'
port = 9001
zipkin_address = 'http://127.0.0.1:9411'
zipkin_address = 'http://127.0.0.1:9411/api/v2/spans'


async def handler(request):
Expand Down
2 changes: 1 addition & 1 deletion demos/microservices/service_b.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ async def make_app():
app = web.Application()
app.router.add_get('/api/v1/data', handler)

zipkin_address = 'http://127.0.0.1:9411'
zipkin_address = 'http://127.0.0.1:9411/api/v2/spans'
endpoint = az.create_endpoint('service_b', ipv4=host, port=port)
tracer = await az.create(zipkin_address, endpoint, sample_rate=1.0)
az.setup(app, tracer)
Expand Down
2 changes: 1 addition & 1 deletion demos/microservices/service_c.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ async def make_app():
app = web.Application()
app.router.add_get('/api/v1/data', handler)

zipkin_address = 'http://127.0.0.1:9411'
zipkin_address = 'http://127.0.0.1:9411/api/v2/spans'
endpoint = az.create_endpoint('service_c', ipv4=host, port=port)
tracer = await az.create(zipkin_address, endpoint, sample_rate=1.0)
az.setup(app, tracer)
Expand Down
2 changes: 1 addition & 1 deletion demos/microservices/service_d.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ async def make_app():
app = web.Application()
app.router.add_get('/api/v1/data', handler)

zipkin_address = 'http://127.0.0.1:9411'
zipkin_address = 'http://127.0.0.1:9411/api/v2/spans'
endpoint = az.create_endpoint('service_d', ipv4=host, port=port)
tracer = await az.create(zipkin_address, endpoint, sample_rate=1.0)
az.setup(app, tracer)
Expand Down
2 changes: 1 addition & 1 deletion demos/microservices/service_e.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ async def make_app():
app = web.Application()
app.router.add_get('/api/v1/data', handler)

zipkin_address = 'http://127.0.0.1:9411'
zipkin_address = 'http://127.0.0.1:9411/api/v2/spans'
endpoint = az.create_endpoint('service_e', ipv4=host, port=port)
tracer = await az.create(zipkin_address, endpoint, sample_rate=1.0)
az.setup(app, tracer)
Expand Down
2 changes: 1 addition & 1 deletion demos/queue/backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ async def make_app(host, port):
app.router.add_post('/consume', handler)
aiojobs.aiohttp.setup(app)

zipkin_address = 'http://127.0.0.1:9411'
zipkin_address = 'http://127.0.0.1:9411/api/v2/spans'
endpoint = az.create_endpoint(
'backend_broker', ipv4=host, port=port)
tracer = await az.create(zipkin_address, endpoint, sample_rate=1.0)
Expand Down
2 changes: 1 addition & 1 deletion demos/queue/frontend.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ async def make_app(host, port):
session = aiohttp.ClientSession()
app['session'] = session

zipkin_address = 'http://127.0.0.1:9411'
zipkin_address = 'http://127.0.0.1:9411/api/v2/spans'
endpoint = az.create_endpoint('frontend', ipv4=host, port=port)
tracer = await az.create(zipkin_address, endpoint, sample_rate=1.0)
az.setup(app, tracer)
Expand Down
2 changes: 1 addition & 1 deletion examples/aiohttp_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ async def make_app(host, port):
endpoint = az.create_endpoint(
'aiohttp_server', ipv4=host, port=port)

zipkin_address = 'http://127.0.0.1:9411'
zipkin_address = 'http://127.0.0.1:9411/api/v2/spans'
tracer = await az.create(zipkin_address, endpoint, sample_rate=1.0)
az.setup(app, tracer, skip_routes=[skip_route])
return app
Expand Down
2 changes: 1 addition & 1 deletion examples/minimal.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

async def run():
# setup zipkin client
zipkin_address = 'http://127.0.0.1:9411'
zipkin_address = 'http://127.0.0.1:9411/api/v2/spans'
# address and name of current machine for better trace information
endpoint = az.create_endpoint('minimal_example', ipv4='127.0.0.1')

Expand Down
2 changes: 1 addition & 1 deletion examples/simple.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

async def run():
# setup zipkin client
zipkin_address = 'http://127.0.0.1:9411'
zipkin_address = 'http://127.0.0.1:9411/api/v2/spans'
endpoint = az.create_endpoint(
'simple_service', ipv4='127.0.0.1', port=8080)

Expand Down
6 changes: 4 additions & 2 deletions tests/docker_fixtures.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,8 @@ async def zipkin_server(docker, docker_pull):

@pytest.fixture
def zipkin_url(zipkin_server):
return 'http://{host}:{port}'.format(**zipkin_server)
url = 'http://{host}:{port}/api/v2/spans'.format(**zipkin_server)
return url


@pytest.fixture(scope='session')
Expand Down Expand Up @@ -134,7 +135,8 @@ async def jaeger_server(docker, docker_pull):

@pytest.fixture
def jaeger_url(jaeger_server):
return 'http://{host}:{zipkin_port}'.format(**jaeger_server)
url = 'http://{host}:{zipkin_port}/api/v2/spans'.format(**jaeger_server)
return url


@pytest.fixture
Expand Down
9 changes: 4 additions & 5 deletions tests/test_aiohttp_ingegration.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,8 @@ async def test_client_signals(tracer, fake_transport):
# do not propagate headers
ctx = {'span_context': span.context, 'propagate_headers': False}
resp = await session.get(url, trace_request_ctx=ctx)
await resp.text()
assert resp.status == 200
data = await resp.read()
assert len(data) > 0
assert az.make_context(resp.request_info.headers) is None

# by default headers added
Expand Down Expand Up @@ -114,8 +114,7 @@ async def test_client_signals_no_span(tracer, fake_transport):

url = 'https://httpbin.org/get'
resp = await session.get(url)
await resp.text()
assert resp.status == 200

data = await resp.read()
assert len(data) > 0
await session.close()
assert len(fake_transport.records) == 0
2 changes: 1 addition & 1 deletion tests/test_zipkin.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ def func(span):
async def test_zipkin_error(client, loop, caplog):
endpoint = az.create_endpoint('error_service', ipv4='127.0.0.1', port=80)
interval = 50
zipkin_url = 'https://httpbin.org/status/400'
zipkin_url = 'https://httpbin.org/status/404'
async with az.create(zipkin_url, endpoint, sample_rate=1.0,
send_interval=interval, loop=loop) as tracer:
with tracer.new_trace(sampled=True) as span:
Expand Down

0 comments on commit 0b5f23e

Please sign in to comment.