def test_get_counts_reallocations():
    items = []
    objtrace.enable()
    for i in range(1000):
        items.append(i)
    counts = objtrace.get_counts()
    assert counts[2] > 0
Exemple #2
0
def test_get_counts_allocations():
    lists = []
    objtrace.enable()
    lists.extend([1] for _ in range(100))
    objtrace.disable()
    counts = objtrace.get_counts()
    assert counts[0] > 0
def install(config=None):
    global shutdown_registered
    if config is not None:
        scout_config.set(**config)
    scout_config.log()

    if os.name == "nt":
        logger.info("APM Not Launching on PID: %s - Windows is not supported",
                    os.getpid())
        return False

    if not scout_config.value("monitor"):
        logger.info(
            "APM Not Launching on PID: %s - Configuration 'monitor' is not true",
            os.getpid(),
        )
        return False

    instruments.ensure_all_installed()
    objtrace.enable()

    logger.debug("APM Launching on PID: %s", os.getpid())
    launched = CoreAgentManager().launch()

    report_app_metadata()
    if launched:
        # Stop the thread to avoid running threads pre-fork
        CoreAgentSocketThread.ensure_stopped()

    if scout_config.value(
            "shutdown_timeout_seconds") > 0.0 and not shutdown_registered:
        atexit.register(shutdown)
        shutdown_registered = True

    return True
Exemple #4
0
def install(*args, **kwargs):
    if "config" in kwargs:
        ScoutConfig().set(**kwargs["config"])
    context = AgentContext.build(config=ScoutConfig())

    if not context.config.value("monitor"):
        logger.info(
            "APM Not Launching on PID: %s - Configuration 'monitor' is not true",
            getpid(),
        )
        return False

    InstrumentManager().install_all()

    if objtrace is not None:
        objtrace.enable()

    logger.debug("APM Launching on PID: %s", getpid())
    launched = CoreAgentManager().launch()

    AppMetadata.report()
    if launched:
        AgentContext.socket().stop()

    return True
Exemple #5
0
def test_allocation_counts(reset_objtrace_counts):
    lists = []
    objtrace.enable()
    for _ in range(100):
        lists.append([1])
    objtrace.disable()
    c = objtrace.get_counts()
    assert c[0] > 0
 def test_allocation_counts(self):
     l = []
     objtrace.enable()
     for _ in range(100):
         l.append([1])
     objtrace.disable()
     c = objtrace.get_counts()
     assert (c[0] > 0)
Exemple #7
0
def test_get_counts_reallocations():
    text = "some text"
    leg = " scout"
    objtrace.enable()
    for _ in range(3):
        text += leg
    counts = objtrace.get_counts()
    assert counts[2] > 0
Exemple #8
0
def install(*args, **kwargs):
    if 'config' in kwargs:
        ScoutConfig().set(**kwargs['config'])
    context = AgentContext.build(config=ScoutConfig())

    if not context.config.value('monitor'):
        logger.info(
            "APM Not Launching on PID: %s - Configuration 'monitor' is not true",
            getpid())
        return False

    InstrumentManager().install_all()

    if HAS_OBJTRACE:
        objtrace.enable()

    logger.debug('APM Launching on PID: %s', getpid())
    CoreAgentManager().launch()

    AppMetadata.report()
    AgentContext.socket().stop()
    return True
Exemple #9
0
def test_enables_and_disabled(reset_objtrace_counts):
    objtrace.enable()
    objtrace.get_counts()
    objtrace.disable()
Exemple #10
0
def test_enable_twice():
    objtrace.enable()
    objtrace.enable()
 def test_frees_counts(self):
     objtrace.enable()
     for x in (1, 2, 3):
         y = x
     c = objtrace.get_counts()
     assert (c[3] > 0)
 def test_enables_and_disabled(self):
     objtrace.enable()
     objtrace.get_counts()
     objtrace.disable()
def test_tags_allocations_for_spans_no_objtrace_extension(tracked_request):
    objtrace.enable()
    span = tracked_request.start_span(operation="myoperation")
    tracked_request.stop_span()
    assert "allocations" not in span.tags
Exemple #14
0
def test_get_counts():
    objtrace.enable()
    counts = objtrace.get_counts()
    assert isinstance(counts, tuple)
    assert len(counts) == 4
    assert all(isinstance(x, int) for x in counts)
Exemple #15
0
def test_frees_counts(reset_objtrace_counts):
    objtrace.enable()
    for x in (1, 2, 3):
        y = x  # noqa: F841
    c = objtrace.get_counts()
    assert c[3] > 0
Exemple #16
0
def test_get_counts_frees():
    objtrace.enable()
    for x in (1, 2, 3):
        y = x  # noqa: F841
    counts = objtrace.get_counts()
    assert counts[3] > 0
Exemple #17
0
def test_get_counts_multiple_allocations():
    objtrace.enable()
    bytes(123)
    counts = objtrace.get_counts()
    assert counts[1] > 0
Exemple #18
0
def test_tags_allocations_for_spans(tr):
    objtrace.enable()
    span = tr.start_span()
    tr.stop_span()
    assert span.tags["allocations"] > 0
def test_tags_allocations_for_spans(tracked_request):
    objtrace.enable()
    span = tracked_request.start_span(operation="myoperation")
    tracked_request.stop_span()
    assert span.tags["allocations"] > 0