diff --git a/instana/eum.js b/instana/eum.js deleted file mode 100644 index c5390faf5..000000000 --- a/instana/eum.js +++ /dev/null @@ -1,10 +0,0 @@ - diff --git a/instana/eum_test.js b/instana/eum_test.js deleted file mode 100644 index e1fff8bc4..000000000 --- a/instana/eum_test.js +++ /dev/null @@ -1,12 +0,0 @@ - diff --git a/instana/helpers.py b/instana/helpers.py index 8c4a852e2..16eba1a9b 100644 --- a/instana/helpers.py +++ b/instana/helpers.py @@ -14,9 +14,7 @@ def eum_snippet(trace_id=None, eum_api_key=None, meta=None): """ - Return an EUM snippet for use in views, templates and layouts that reports - client side metrics to Instana that will automagically be linked to the - current trace. + This method has been deprecated and will be removed in a future version. @param trace_id [optional] the trace ID to insert into the EUM string @param eum_api_key [optional] the EUM API key from your Instana dashboard @@ -25,44 +23,12 @@ def eum_snippet(trace_id=None, eum_api_key=None, meta=None): @return string """ - try: - eum_file = open(os.path.dirname(__file__) + '/eum.js') - eum_src = Template(eum_file.read()) - - # Prepare the standard required IDs - ids = dict() - ids['meta_kvs'] = '' - - parent_span = tracer.active_span - - if trace_id or parent_span: - ids['trace_id'] = trace_id or parent_span.trace_id - else: - # No trace_id passed in and tracer doesn't show an active span so - # return nothing, nada & zip. - return '' - - if eum_api_key: - ids['eum_api_key'] = eum_api_key - else: - ids['eum_api_key'] = global_eum_api_key - - # Process passed in EUM 'meta' key/values - if meta is not None: - for key, value in meta.items(): - ids['meta_kvs'] += ("'ineum('meta', '%s', '%s');'" % (key, value)) - - return eum_src.substitute(ids) - except Exception: - logger.debug("eum_snippet: ", exc_info=True) - return '' + return '' def eum_test_snippet(trace_id=None, eum_api_key=None, meta=None): """ - Return an EUM snippet for use in views, templates and layouts that reports - client side metrics to Instana that will automagically be linked to the - current trace. + This method has been deprecated and will be removed in a future version. @param trace_id [optional] the trace ID to insert into the EUM string @param eum_api_key [optional] the EUM API key from your Instana dashboard @@ -71,34 +37,4 @@ def eum_test_snippet(trace_id=None, eum_api_key=None, meta=None): @return string """ - - try: - eum_file = open(os.path.dirname(__file__) + '/eum_test.js') - eum_src = Template(eum_file.read()) - - # Prepare the standard required IDs - ids = {} - ids['meta_kvs'] = '' - - parent_span = tracer.active_span - if trace_id or parent_span: - ids['trace_id'] = trace_id or parent_span.trace_id - else: - # No trace_id passed in and tracer doesn't show an active span so - # return nothing, nada & zip. - return '' - - if eum_api_key: - ids['eum_api_key'] = eum_api_key - else: - ids['eum_api_key'] = global_eum_api_key - - # Process passed in EUM 'meta' key/values - if meta is not None: - for key, value in meta.items(): - ids['meta_kvs'] += ("'ineum('meta', '%s', '%s');'" % (key, value)) - - return eum_src.substitute(ids) - except Exception: - logger.debug("eum_snippet: ", exc_info=True) - return '' + return '' diff --git a/tests/test_helpers.py b/tests/test_helpers.py deleted file mode 100644 index 41eeae818..000000000 --- a/tests/test_helpers.py +++ /dev/null @@ -1,87 +0,0 @@ -from nose.tools import assert_equals - -from instana.helpers import eum_snippet, eum_test_snippet - -# fake trace_id to test against -trace_id = "aMLx9G2GnnQ6QyMCLJLuCM8nw" -# fake api key to test against -eum_api_key = "FJB66VjwGgGQX6jiCpekoR4vf" - -# fake meta key/values -meta1 = "Z7RmMKQAiyCLEAmseNy7e6Vm4" -meta2 = "Dp2bowfm6kJVD9CccmyBt4ePD" -meta3 = "N4poUwbNz98YcvWRAizy2phCo" - - -def test_vanilla_eum_snippet(): - eum_string = eum_snippet(trace_id=trace_id, eum_api_key=eum_api_key) - assert type(eum_string) is str - - assert eum_string.find(trace_id) != -1 - assert eum_string.find(eum_api_key) != -1 - - -def test_eum_snippet_with_meta(): - meta_kvs = {} - meta_kvs['meta1'] = meta1 - meta_kvs['meta2'] = meta2 - meta_kvs['meta3'] = meta3 - - eum_string = eum_snippet(trace_id=trace_id, eum_api_key=eum_api_key, meta=meta_kvs) - assert type(eum_string) is str - - assert eum_string.find(trace_id) != -1 - assert eum_string.find(eum_api_key) != -1 - assert eum_string.find(meta1) != -1 - assert eum_string.find(meta2) != -1 - assert eum_string.find(meta3) != -1 - - -def test_eum_snippet_error(): - meta_kvs = {} - meta_kvs['meta1'] = meta1 - meta_kvs['meta2'] = meta2 - meta_kvs['meta3'] = meta3 - - # No active span on tracer & no trace_id passed in. - eum_string = eum_snippet(eum_api_key=eum_api_key, meta=meta_kvs) - assert_equals('', eum_string) - - -def test_vanilla_eum_test_snippet(): - eum_string = eum_test_snippet(trace_id=trace_id, eum_api_key=eum_api_key) - assert type(eum_string) is str - - assert eum_string.find(trace_id) != -1 - assert eum_string.find(eum_api_key) != -1 - assert eum_string.find('reportingUrl') != -1 - assert eum_string.find('//eum-test-fullstack-0-us-west-2.instana.io') != -1 - - -def test_eum_test_snippet_with_meta(): - meta_kvs = {} - meta_kvs['meta1'] = meta1 - meta_kvs['meta2'] = meta2 - meta_kvs['meta3'] = meta3 - - eum_string = eum_test_snippet(trace_id=trace_id, eum_api_key=eum_api_key, meta=meta_kvs) - assert type(eum_string) is str - assert eum_string.find('reportingUrl') != -1 - assert eum_string.find('//eum-test-fullstack-0-us-west-2.instana.io') != -1 - - assert eum_string.find(trace_id) != -1 - assert eum_string.find(eum_api_key) != -1 - assert eum_string.find(meta1) != -1 - assert eum_string.find(meta2) != -1 - assert eum_string.find(meta3) != -1 - - -def test_eum_test_snippet_error(): - meta_kvs = {} - meta_kvs['meta1'] = meta1 - meta_kvs['meta2'] = meta2 - meta_kvs['meta3'] = meta3 - - # No active span on tracer & no trace_id passed in. - eum_string = eum_test_snippet(eum_api_key=eum_api_key, meta=meta_kvs) - assert_equals('', eum_string)