Exemple #1
0
def test_logging_filter_span(elasticapm_client):
    transaction = elasticapm_client.begin_transaction("test")
    with capture_span("test") as span:
        f = LoggingFilter()
        record = logging.LogRecord(__name__, logging.DEBUG, __file__, 252, "dummy_msg", [], None)
        f.filter(record)
        assert record.elasticapm_transaction_id == transaction.id
        assert record.elasticapm_service_name == transaction.tracer.config.service_name
        assert record.elasticapm_trace_id == transaction.trace_parent.trace_id
        assert record.elasticapm_span_id == span.id
        assert record.elasticapm_labels

    # 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:
        record = logging.LogRecord(__name__, logging.DEBUG, __file__, 252, "dummy_msg2", [], None)
        f.filter(record)
        assert record.elasticapm_transaction_id == transaction.id
        assert record.elasticapm_service_name == transaction.tracer.config.service_name
        assert record.elasticapm_trace_id == transaction.trace_parent.trace_id
        assert record.elasticapm_span_id is None
        assert record.elasticapm_labels
Exemple #2
0
def test_logging_filter_no_span(elasticapm_client):
    transaction = elasticapm_client.begin_transaction("test")
    f = LoggingFilter()
    record = logging.LogRecord(__name__, logging.DEBUG, __file__, 252, "dummy_msg", [], None)
    f.filter(record)
    assert record.elasticapm_transaction_id == transaction.id
    assert record.elasticapm_trace_id == transaction.trace_parent.trace_id
    assert record.elasticapm_span_id is None
    assert record.elasticapm_labels