Skip to content

Commit 6d8681a

Browse files
authored
Add CI tags to tracked spans (#105)
* ci: enable tracing * Apply suggestions from code review
1 parent 0600c34 commit 6d8681a

File tree

4 files changed

+9
-44
lines changed

4 files changed

+9
-44
lines changed

.azure-pipelines/all.yml

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ schedules:
1919
resources:
2020
containers:
2121
- container: datadog-agent
22-
image: datadog/agent:7
22+
image: datadog/agent:latest
2323
options: --health-cmd="exit 0" --health-interval=1s
2424
ports:
2525
- 8125:8125
@@ -46,7 +46,11 @@ jobs:
4646
services:
4747
datadog-agent: datadog-agent
4848
steps:
49-
- script: python -m pip install -e .[apm,tests]
49+
- script: |
50+
python -m pip install --upgrade pip setuptools
51+
python -m pip install cython
52+
python -m pip install -e .[apm,tests]
53+
python -m pip install -U --pre --find-links=https://s3.amazonaws.com/pypi.datadoghq.com/trace-dev/index.html ddtrace
5054
displayName: Install package
5155
- script: ./run-tests.sh
5256
displayName: Run integration tests
@@ -55,11 +59,13 @@ jobs:
5559
DD_AGENT_HOST: datadog-agent
5660
DD_ENV: prod
5761
DD_SERVICE: datadog-api-client-python
58-
DD_TAGS: "team:integration-tools-and-libraries,build.requested_by:$(Build.RequestedForId),build.attempt:$(System.StageAttempt),pull_request.number:$(System.PullRequest.PullRequestNumber)"
62+
DD_TAGS: "team:integration-tools-and-libraries"
5963
DD_TEST_CLIENT_API_KEY: $(datadogAPIKey)
6064
DD_TEST_CLIENT_APP_KEY: $(datadogAPPKey)
6165
DD_TRACE_ANALYTICS_ENABLED: "true"
6266
RECORD: "none"
67+
PYTEST_ADDOPTS: "--ddtrace"
68+
DD_PYTEST_OPERATION_NAME: "test"
6369
- script: |
6470
bash <(curl -s https://codecov.io/bash) -F integration -v
6571

tests/conftest.py

Lines changed: 0 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -35,45 +35,6 @@
3535
logging.basicConfig()
3636

3737

38-
@pytest.hookimpl(tryfirst=True, hookwrapper=True)
39-
def pytest_runtest_makereport(item, call):
40-
"""Store outcome for tracing."""
41-
outcome = yield
42-
rep = outcome.get_result()
43-
setattr(item, "dd_outcome", rep)
44-
45-
46-
def pytest_sessionfinish(session, exitstatus):
47-
"""Flush open tracer."""
48-
if tracer is None:
49-
return
50-
51-
tracer.shutdown()
52-
53-
54-
@pytest.fixture(scope="function")
55-
def ddspan(request):
56-
if tracer is None:
57-
yield None
58-
return
59-
60-
tags = [marker.kwargs for marker in request.node.iter_markers(name="dd_tag")]
61-
62-
with tracer.trace("test", resource=request.node.name, span_type="test") as span:
63-
from ddtrace.constants import ANALYTICS_SAMPLE_RATE_KEY
64-
span.set_tag(ANALYTICS_SAMPLE_RATE_KEY, True)
65-
66-
for tag in tags:
67-
for key, value in tag.items():
68-
span.set_tag(key, value)
69-
70-
yield span
71-
72-
outcome = request.node.dd_outcome
73-
if outcome.failed:
74-
span.set_exc_info(sys.last_type, sys.last_value, sys.last_traceback)
75-
76-
7738
def pytest_bdd_before_step(request, feature, scenario, step, step_func):
7839
if tracer is None:
7940
return

tests/v1/test_scenarios.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77

88
pytestmark = [
99
pytest.mark.vcr,
10-
pytest.mark.usefixtures("ddspan"),
1110
]
1211

1312
scenarios("features")

tests/v2/test_scenarios.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66

77
pytestmark = [
88
pytest.mark.vcr,
9-
pytest.mark.usefixtures("ddspan"),
109
]
1110

1211

0 commit comments

Comments
 (0)