Пример #1
0
async def test_analytics_integration_default(app_tracer, aiohttp_client):
    """Check trace has analytics sample rate set"""
    app, tracer = app_tracer
    client = await aiohttp_client(app)
    request = await client.request("GET", "/template/")
    await request.text()

    # Assert root span does not have the appropriate metric
    root = get_root_span(tracer.writer.spans)
    assert root.get_metric(ANALYTICS_SAMPLE_RATE_KEY) is None
Пример #2
0
async def test_analytics_integration_disabled(app_tracer, aiohttp_client):
    """Check trace has analytics sample rate set"""
    app, tracer = app_tracer
    client = await aiohttp_client(app)
    app["datadog_trace"]["analytics_enabled"] = False
    request = await client.request("GET", "/template/")
    await request.text()

    # Assert root span does not have the appropriate metric
    root = get_root_span(tracer.pop())
    assert root.get_metric(ANALYTICS_SAMPLE_RATE_KEY) is None
Пример #3
0
async def test_analytics_integration_enabled(app_tracer, aiohttp_client):
    """Check trace has analytics sample rate set"""
    app, tracer = app_tracer
    client = await aiohttp_client(app)
    app["datadog_trace"]["analytics_enabled"] = True
    app["datadog_trace"]["analytics_sample_rate"] = 0.5
    request = await client.request("GET", "/template/")
    await request.text()

    # Assert root span sets the appropriate metric
    root = get_root_span(tracer.writer.spans)
    root.assert_structure(
        dict(name="aiohttp.request", metrics={ANALYTICS_SAMPLE_RATE_KEY: 0.5}))