Ejemplo n.º 1
0
def test_structlog_processor_span(elasticapm_client):
    transaction = elasticapm_client.begin_transaction("test")
    with capture_span("test") as span:
        event_dict = {}
        new_dict = structlog_processor(None, None, event_dict)
        assert new_dict["transaction.id"] == transaction.id
        assert new_dict[
            "service.name"] == transaction.tracer.config.service_name
        assert new_dict["trace.id"] == transaction.trace_parent.trace_id
        assert new_dict["span.id"] == span.id

    # Capture too many spans so we start dropping
    for i in range(10):
        with capture_span("drop"):
            pass

    # Test logging with DroppedSpan
    with capture_span("drop") as span:
        event_dict = {}
        new_dict = structlog_processor(None, None, event_dict)
        assert new_dict["transaction.id"] == transaction.id
        assert new_dict[
            "service.name"] == transaction.tracer.config.service_name
        assert new_dict["trace.id"] == transaction.trace_parent.trace_id
        assert "span.id" not in new_dict
Ejemplo n.º 2
0
def test_structlog_processor_no_span(elasticapm_client):
    transaction = elasticapm_client.begin_transaction("test")
    event_dict = {}
    new_dict = structlog_processor(None, None, event_dict)
    assert new_dict["transaction.id"] == transaction.id
    assert new_dict["trace.id"] == transaction.trace_parent.trace_id
    assert "span.id" not in new_dict