-
Notifications
You must be signed in to change notification settings - Fork 467
[falcon] Add distributed tracing #437
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
1f15dee
d978302
cb0efb0
3f5b0a3
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,55 @@ | ||
| from ddtrace.propagation.http import HTTPPropagator | ||
| from ddtrace.ext import errors as errx, http as httpx, AppTypes | ||
| from falcon import testing | ||
| from nose.tools import eq_, ok_ | ||
| from tests.test_tracer import get_dummy_tracer | ||
|
|
||
| from .app import get_app | ||
|
|
||
|
|
||
| class DistributedTracingTestCase(testing.TestCase): | ||
| """Executes tests using the manual instrumentation so a middleware | ||
| is explicitly added. | ||
| """ | ||
|
|
||
| def setUp(self): | ||
| super(DistributedTracingTestCase, self).setUp() | ||
| self._service = 'falcon' | ||
| self.tracer = get_dummy_tracer() | ||
| self.api = get_app(tracer=self.tracer, distributed_tracing=True) | ||
|
|
||
| def test_distributred_tracing(self): | ||
| headers = { | ||
| 'x-datadog-trace-id': '100', | ||
| 'x-datadog-parent-id': '42', | ||
| } | ||
| out = self.simulate_get('/200', headers=headers) | ||
| eq_(out.status_code, 200) | ||
| eq_(out.content.decode('utf-8'), 'Success') | ||
|
|
||
| traces = self.tracer.writer.pop_traces() | ||
|
|
||
| eq_(len(traces), 1) | ||
| eq_(len(traces[0]), 1) | ||
|
|
||
| eq_(traces[0][0].parent_id, 42) | ||
| eq_(traces[0][0].trace_id, 100) | ||
|
|
||
| def test_distributred_tracing_disabled(self): | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 👍 |
||
| self.tracer = get_dummy_tracer() | ||
| self.api = get_app(tracer=self.tracer) | ||
| headers = { | ||
| 'x-datadog-trace-id': '100', | ||
| 'x-datadog-parent-id': '42', | ||
| } | ||
| out = self.simulate_get('/200', headers=headers) | ||
| eq_(out.status_code, 200) | ||
| eq_(out.content.decode('utf-8'), 'Success') | ||
|
|
||
| traces = self.tracer.writer.pop_traces() | ||
|
|
||
| eq_(len(traces), 1) | ||
| eq_(len(traces[0]), 1) | ||
|
|
||
| ok_(traces[0][0].parent_id is not 42) | ||
| ok_(traces[0][0].trace_id is not 100) | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -253,7 +253,7 @@ commands = | |
| flaskcache{012,013}: nosetests {posargs} tests/contrib/flask_cache | ||
| flask{010,011,012}: nosetests {posargs} tests/contrib/flask | ||
| flask-autopatch{010,011,012}: ddtrace-run nosetests {posargs} tests/contrib/flask_autopatch | ||
| falcon{10,11,12}: nosetests {posargs} tests/contrib/falcon/test_middleware.py | ||
| falcon{10,11,12}: nosetests {posargs} tests/contrib/falcon/test_middleware.py tests/contrib/falcon/test_distributed_tracing.py | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Also not sure about this. It seemed silly to make a new test directive, but test_distributed doesn't actually depend on the method of patching either. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. can't you simply rewrite this directive in:
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That tries to execute all the tests, including the autopatch tests (which it seems are usually kept separate by convention?) and misinterpreting the test-cases mixin I think if I rename test_suite.py and we're OK with doing the autopatch/middleware tests under the same directive, then it is possible to use There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. sorry forgot that we have an autopatch test also for Falcon. It's fine to keep it separated like we do in other frameworks so all good here. |
||
| falcon-autopatch{10,11,12}: ddtrace-run nosetests {posargs} tests/contrib/falcon/test_autopatch.py | ||
| gevent{11,12}: nosetests {posargs} tests/contrib/gevent | ||
| gevent{10}: nosetests {posargs} tests/contrib/gevent | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Copied this pattern from somewhere else, but is there a smarter thing I should do?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm rewriting this part because we're polluting the system with too many env vars. We can be smart here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems like we could just all use the same env var name eg DATADOG_DISTRIBUTED_TRACING. If a user runs multiple distributed services on a single host they can still just set the env vars per-executable themselves. But is a more structured config process in the pipes?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually yes. For instance you may have your intake application that doesn't have distributed tracing for incoming calls (you don't accept it from clients) but you want to activate it for outgoing calls to other services. So it's still better to provide a way to select exactly what distributed tracing you want to enable.
The configuration system will make it easier, but till now I prefer that all integrations are compliant.