Skip to content

Commit

Permalink
renamed "traces" to "spans", "app" to "service"
Browse files Browse the repository at this point in the history
This change only affects the resulting documents. The code itself
has not yet been changed as to keep the potential for conflict as low
as possible while active development still foremost happens on the
1.x/master branch
  • Loading branch information
beniwohli committed Dec 11, 2017
1 parent c8a0099 commit b9b9fd1
Show file tree
Hide file tree
Showing 17 changed files with 48 additions and 48 deletions.
2 changes: 1 addition & 1 deletion elasticapm/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ def build_msg_for_logging(self, event_type, data=None, date=None,

def build_msg(self, data=None, **kwargs):
data = data or {}
data['app'] = self.get_app_info()
data['service'] = self.get_app_info()
data['system'] = self.get_system_info()
data.update(**kwargs)
return data
Expand Down
8 changes: 4 additions & 4 deletions elasticapm/processors.py
Original file line number Diff line number Diff line change
Expand Up @@ -204,10 +204,10 @@ def _is_in_app(frame):
if 'module' not in frame:
return
mod = frame['module']
frame['in_app'] = mod and bool(
frame['library_frame'] = not (mod and bool(
any(mod.startswith(path + '.') or mod == path for path in include) and
not any(mod.startswith(path + '.') or mod == path for path in exclude)
)
))

_process_stack_frames(event, _is_in_app)
return event
Expand Down Expand Up @@ -252,9 +252,9 @@ def _sanitize_string(unsanitized, itemsep, kvsep):


def _process_stack_frames(event, func):
if 'traces' in event:
if 'spans' in event:
# every trace can have a stack trace
for trace in event['traces']:
for trace in event['spans']:
if 'stacktrace' in trace:
for frame in trace['stacktrace']:
func(frame)
Expand Down
2 changes: 1 addition & 1 deletion elasticapm/traces.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ def to_dict(self):
'result': str(self.result),
'timestamp': self.timestamp.strftime(constants.TIMESTAMP_FORMAT),
'context': self._context,
'traces': [
'spans': [
trace_obj.to_dict() for trace_obj in self.traces
]
}
Expand Down
8 changes: 4 additions & 4 deletions tests/contrib/django/django_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -903,7 +903,7 @@ def test_stacktraces_have_templates(client, django_elasticapm_client):
assert len(transactions) == 1
transaction = transactions[0]
assert transaction['result'] == 'HTTP 2xx'
traces = transaction['traces']
traces = transaction['spans']
assert len(traces) == 2, [t['name'] for t in traces]

expected_names = {'list_users.html', 'something_expensive'}
Expand Down Expand Up @@ -936,7 +936,7 @@ def test_stacktrace_filtered_for_elasticapm(client, django_elasticapm_client):

transactions = django_elasticapm_client.instrumentation_store.get_all()
assert transactions[0]['result'] == 'HTTP 2xx'
traces = transactions[0]['traces']
traces = transactions[0]['spans']

expected_signatures = ['transaction', 'list_users.html',
'something_expensive']
Expand Down Expand Up @@ -966,7 +966,7 @@ def test_perf_template_render(benchmark, client, django_elasticapm_client):
# this will have two items.
assert len(transactions) == len(responses)
for transaction in transactions:
assert len(transaction['traces']) == 2
assert len(transaction['spans']) == 2
assert transaction['result'] == 'HTTP 2xx'


Expand Down Expand Up @@ -1007,7 +1007,7 @@ def test_perf_database_render(benchmark, client, django_elasticapm_client):

assert len(transactions) == len(responses)
for transaction in transactions:
assert len(transaction['traces']) in (102, 103)
assert len(transaction['spans']) in (102, 103)


@pytest.mark.django_db
Expand Down
4 changes: 2 additions & 2 deletions tests/contrib/flask/flask_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ def test_instrumentation(flask_apm_client):
'Content-Length': '78',
'Content-Type': 'text/html; charset=utf-8',
}
traces = transactions[0]['traces']
traces = transactions[0]['spans']
assert len(traces) == 1, [t['name'] for t in traces]

expected_signatures = {'users.html'}
Expand All @@ -142,7 +142,7 @@ def test_instrumentation_404(flask_apm_client):
transactions = flask_apm_client.client.instrumentation_store.get_all()

assert len(transactions) == 1
traces = transactions[0]['traces']
traces = transactions[0]['spans']
assert transactions[0]['result'] == 'HTTP 4xx'
assert transactions[0]['context']['response']['status_code'] == 404
assert len(traces) == 0, [t["signature"] for t in traces]
Expand Down
2 changes: 1 addition & 1 deletion tests/instrumentation/botocore_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,5 @@ def test_botocore_instrumentation(mock_make_request, elasticapm_client):
elasticapm_client.end_transaction("MyView")

transactions = elasticapm_client.instrumentation_store.get_all()
traces = transactions[0]['traces']
traces = transactions[0]['spans']
assert 'ec2:DescribeInstances' in map(lambda x: x['name'], traces)
4 changes: 2 additions & 2 deletions tests/instrumentation/django_tests/template_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ def test_template_rendering(should_collect, django_elasticapm_client, client):
transactions = django_elasticapm_client.instrumentation_store.get_all()

assert len(transactions) == 3
traces = transactions[0]['traces']
traces = transactions[0]['spans']
assert len(traces) == 2, [t['name'] for t in traces]

kinds = ['code', 'template.django']
Expand Down Expand Up @@ -81,7 +81,7 @@ def test_template_rendering_django18_jinja2(should_collect, django_elasticapm_cl
transactions = django_elasticapm_client.instrumentation_store.get_all()

assert len(transactions) == 3
traces = transactions[0]['traces']
traces = transactions[0]['spans']
assert len(traces) == 1, [t['name'] for t in traces]

kinds = ['template.jinja2']
Expand Down
4 changes: 2 additions & 2 deletions tests/instrumentation/jinja2_tests/jinja2_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def test_from_file(should_collect, jinja_env, elasticapm_client):
elasticapm_client.end_transaction("MyView")

transactions = elasticapm_client.instrumentation_store.get_all()
traces = transactions[0]['traces']
traces = transactions[0]['spans']

expected_signatures = {'mytemplate.html'}

Expand All @@ -39,7 +39,7 @@ def test_from_string(elasticapm_client):
elasticapm_client.end_transaction("test")

transactions = elasticapm_client.instrumentation_store.get_all()
traces = transactions[0]['traces']
traces = transactions[0]['spans']

expected_signatures = {'<template>'}

Expand Down
2 changes: 1 addition & 1 deletion tests/instrumentation/psycopg2_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ def test_psycopg2_select_LIKE(postgres_connection, elasticapm_client):
finally:
# make sure we've cleared out the traces for the other tests.
transactions = elasticapm_client.instrumentation_store.get_all()
traces = transactions[0]['traces']
traces = transactions[0]['spans']
trace = traces[0]
assert trace['name'] == 'SELECT FROM test'
assert 'db' in trace['context']
Expand Down
28 changes: 14 additions & 14 deletions tests/instrumentation/pymongo_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def test_collection_bulk_write(elasticapm_client, mongo_database):
assert result.upserted_count == 1
elasticapm_client.end_transaction('transaction.test')
transactions = elasticapm_client.instrumentation_store.get_all()
trace = _get_pymongo_trace(transactions[0]['traces'])
trace = _get_pymongo_trace(transactions[0]['spans'])
assert trace['type'] == 'db.mongodb.query'
assert trace['name'] == 'elasticapm_test.blogposts.bulk_write'

Expand All @@ -47,7 +47,7 @@ def test_collection_count(elasticapm_client, mongo_database):
assert count == 1
elasticapm_client.end_transaction('transaction.test')
transactions = elasticapm_client.instrumentation_store.get_all()
trace = _get_pymongo_trace(transactions[0]['traces'])
trace = _get_pymongo_trace(transactions[0]['spans'])
assert trace['type'] == 'db.mongodb.query'
assert trace['name'] == 'elasticapm_test.blogposts.count'

Expand All @@ -63,7 +63,7 @@ def test_collection_delete_one(elasticapm_client, mongo_database):
assert r.deleted_count == 1
elasticapm_client.end_transaction('transaction.test')
transactions = elasticapm_client.instrumentation_store.get_all()
trace = _get_pymongo_trace(transactions[0]['traces'])
trace = _get_pymongo_trace(transactions[0]['spans'])
assert trace['type'] == 'db.mongodb.query'
assert trace['name'] == 'elasticapm_test.blogposts.delete_one'

Expand All @@ -79,7 +79,7 @@ def test_collection_delete_many(elasticapm_client, mongo_database):
assert r.deleted_count == 1
elasticapm_client.end_transaction('transaction.test')
transactions = elasticapm_client.instrumentation_store.get_all()
trace = _get_pymongo_trace(transactions[0]['traces'])
trace = _get_pymongo_trace(transactions[0]['spans'])
assert trace['type'] == 'db.mongodb.query'
assert trace['name'] == 'elasticapm_test.blogposts.delete_many'

Expand All @@ -93,7 +93,7 @@ def test_collection_insert(elasticapm_client, mongo_database):
assert r is not None
elasticapm_client.end_transaction('transaction.test')
transactions = elasticapm_client.instrumentation_store.get_all()
trace = _get_pymongo_trace(transactions[0]['traces'])
trace = _get_pymongo_trace(transactions[0]['spans'])
assert trace['type'] == 'db.mongodb.query'
assert trace['name'] == 'elasticapm_test.blogposts.insert'

Expand All @@ -108,7 +108,7 @@ def test_collection_insert_one(elasticapm_client, mongo_database):
assert r.inserted_id is not None
elasticapm_client.end_transaction('transaction.test')
transactions = elasticapm_client.instrumentation_store.get_all()
trace = _get_pymongo_trace(transactions[0]['traces'])
trace = _get_pymongo_trace(transactions[0]['spans'])
assert trace['type'] == 'db.mongodb.query'
assert trace['name'] == 'elasticapm_test.blogposts.insert_one'

Expand All @@ -124,7 +124,7 @@ def test_collection_insert_many(elasticapm_client, mongo_database):
elasticapm_client.end_transaction('transaction.test')
transactions = elasticapm_client.instrumentation_store.get_all()

trace = _get_pymongo_trace(transactions[0]['traces'])
trace = _get_pymongo_trace(transactions[0]['spans'])
assert trace['type'] == 'db.mongodb.query'
assert trace['name'] == 'elasticapm_test.blogposts.insert_many'

Expand All @@ -144,7 +144,7 @@ def test_collection_find(elasticapm_client, mongo_database):

elasticapm_client.end_transaction('transaction.test')
transactions = elasticapm_client.instrumentation_store.get_all()
trace = _get_pymongo_trace(transactions[0]['traces'])
trace = _get_pymongo_trace(transactions[0]['spans'])
assert trace['type'] == 'db.mongodb.query'
assert trace['name'] == 'elasticapm_test.blogposts.cursor.refresh'

Expand All @@ -160,7 +160,7 @@ def test_collection_find_one(elasticapm_client, mongo_database):
assert r['author'] == 'Tom'
elasticapm_client.end_transaction('transaction.test')
transactions = elasticapm_client.instrumentation_store.get_all()
trace = _get_pymongo_trace(transactions[0]['traces'])
trace = _get_pymongo_trace(transactions[0]['spans'])
assert trace['type'] == 'db.mongodb.query'
assert trace['name'] == 'elasticapm_test.blogposts.find_one'

Expand All @@ -175,7 +175,7 @@ def test_collection_remove(elasticapm_client, mongo_database):
assert r['n'] == 1
elasticapm_client.end_transaction('transaction.test')
transactions = elasticapm_client.instrumentation_store.get_all()
trace = _get_pymongo_trace(transactions[0]['traces'])
trace = _get_pymongo_trace(transactions[0]['spans'])
assert trace['type'] == 'db.mongodb.query'
assert trace['name'] == 'elasticapm_test.blogposts.remove'

Expand All @@ -191,7 +191,7 @@ def test_collection_update(elasticapm_client, mongo_database):
assert r['n'] == 1
elasticapm_client.end_transaction('transaction.test')
transactions = elasticapm_client.instrumentation_store.get_all()
trace = _get_pymongo_trace(transactions[0]['traces'])
trace = _get_pymongo_trace(transactions[0]['spans'])
assert trace['type'] == 'db.mongodb.query'
assert trace['name'] == 'elasticapm_test.blogposts.update'

Expand All @@ -208,7 +208,7 @@ def test_collection_update_one(elasticapm_client, mongo_database):
assert r.modified_count == 1
elasticapm_client.end_transaction('transaction.test')
transactions = elasticapm_client.instrumentation_store.get_all()
trace = _get_pymongo_trace(transactions[0]['traces'])
trace = _get_pymongo_trace(transactions[0]['spans'])
assert trace['type'] == 'db.mongodb.query'
assert trace['name'] == 'elasticapm_test.blogposts.update_one'

Expand All @@ -225,7 +225,7 @@ def test_collection_update_many(elasticapm_client, mongo_database):
assert r.modified_count == 1
elasticapm_client.end_transaction('transaction.test')
transactions = elasticapm_client.instrumentation_store.get_all()
trace = _get_pymongo_trace(transactions[0]['traces'])
trace = _get_pymongo_trace(transactions[0]['spans'])
assert trace['type'] == 'db.mongodb.query'
assert trace['name'] == 'elasticapm_test.blogposts.update_many'

Expand All @@ -241,7 +241,7 @@ def test_bulk_execute(elasticapm_client, mongo_database):
bulk.execute()
elasticapm_client.end_transaction('transaction.test')
transactions = elasticapm_client.instrumentation_store.get_all()
trace = _get_pymongo_trace(transactions[0]['traces'])
trace = _get_pymongo_trace(transactions[0]['spans'])
assert trace['type'] == 'db.mongodb.query'
assert trace['name'] == 'elasticapm_test.test_bulk.bulk.execute'

Expand Down
2 changes: 1 addition & 1 deletion tests/instrumentation/python_memcached_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def test_memcached(elasticapm_client):
elasticapm_client.end_transaction("BillingView")

transactions = elasticapm_client.instrumentation_store.get_all()
traces = transactions[0]['traces']
traces = transactions[0]['spans']

expected_signatures = {'test_memcached',
'Client.set', 'Client.get',
Expand Down
6 changes: 3 additions & 3 deletions tests/instrumentation/redis_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def test_pipeline(elasticapm_client, redis_conn):
elasticapm_client.end_transaction("MyView")

transactions = elasticapm_client.instrumentation_store.get_all()
traces = transactions[0]['traces']
traces = transactions[0]['spans']

expected_signatures = {'test_pipeline', 'StrictPipeline.execute'}

Expand Down Expand Up @@ -61,7 +61,7 @@ def test_rq_patches_redis(elasticapm_client, redis_conn):
elasticapm_client.end_transaction("MyView")

transactions = elasticapm_client.instrumentation_store.get_all()
traces = transactions[0]['traces']
traces = transactions[0]['spans']

expected_signatures = {'test_pipeline', 'StrictPipeline.execute'}

Expand All @@ -85,7 +85,7 @@ def test_redis_client(elasticapm_client, redis_conn):
elasticapm_client.end_transaction("MyView")

transactions = elasticapm_client.instrumentation_store.get_all()
traces = transactions[0]['traces']
traces = transactions[0]['spans']

expected_signatures = {'test_redis_client', 'RPUSH', 'EXPIRE'}

Expand Down
6 changes: 3 additions & 3 deletions tests/instrumentation/requests_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def test_requests_instrumentation(elasticapm_client):
elasticapm_client.end_transaction("MyView")

transactions = elasticapm_client.instrumentation_store.get_all()
traces = transactions[0]['traces']
traces = transactions[0]['spans']
assert 'GET example.com' == traces[0]['name']
assert 'http://example.com/' == traces[0]['context']['url']

Expand All @@ -38,7 +38,7 @@ def test_requests_instrumentation_via_session(elasticapm_client):
elasticapm_client.end_transaction("MyView")

transactions = elasticapm_client.instrumentation_store.get_all()
traces = transactions[0]['traces']
traces = transactions[0]['spans']
assert 'GET example.com' == traces[0]['name']
assert 'http://example.com/' == traces[0]['context']['url']

Expand All @@ -53,7 +53,7 @@ def test_requests_instrumentation_via_prepared_request(elasticapm_client):
elasticapm_client.end_transaction("MyView")

transactions = elasticapm_client.instrumentation_store.get_all()
traces = transactions[0]['traces']
traces = transactions[0]['spans']
assert 'GET example.com' == traces[0]['name']
assert 'http://example.com/' == traces[0]['context']['url']

Expand Down
2 changes: 1 addition & 1 deletion tests/instrumentation/sqlite_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ def test_connect(elasticapm_client):
elasticapm_client.end_transaction("MyView")

transactions = elasticapm_client.instrumentation_store.get_all()
traces = transactions[0]['traces']
traces = transactions[0]['spans']

expected_signatures = {'sqlite3.connect :memory:',
'CREATE TABLE', 'INSERT INTO testdb',
Expand Down
2 changes: 1 addition & 1 deletion tests/instrumentation/transactions_store_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ def test_leaf_tracing(transaction_store):
transaction_store.end_transaction(None, "transaction")

transactions = transaction_store.get_all()
traces = transactions[0]['traces']
traces = transactions[0]['spans']

assert len(traces) == 2

Expand Down
2 changes: 1 addition & 1 deletion tests/instrumentation/urllib3_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def test_urllib3(should_collect, elasticapm_client, httpserver):
elasticapm_client.end_transaction("MyView")

transactions = elasticapm_client.instrumentation_store.get_all()
traces = transactions[0]['traces']
traces = transactions[0]['spans']

expected_signatures = {'test_pipeline', expected_sig}

Expand Down
12 changes: 6 additions & 6 deletions tests/processors/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -217,12 +217,12 @@ def test_mark_in_app_frames():
data = processors.mark_in_app_frames(client, data)
frames = data['exception']['stacktrace']

assert frames[0]['in_app']
assert frames[1]['in_app']
assert not frames[2]['in_app']
assert not frames[3]['in_app']
assert frames[4]['in_app']
assert not frames[5]['in_app']
assert not frames[0]['library_frame']
assert not frames[1]['library_frame']
assert frames[2]['library_frame']
assert frames[3]['library_frame']
assert not frames[4]['library_frame']
assert frames[5]['library_frame']


def dummy_processor(client, data):
Expand Down

0 comments on commit b9b9fd1

Please sign in to comment.