# Monitoring Standalone application

**URL:** <https://discuss.elastic.co/t/monitoring-standalone-application/301345>\
**Category:** APM\
**Tags:** python\
**Created:** [April 1, 2022, 3:13pm UTC](https://discuss.elastic.co/t/monitoring-standalone-application/301345 "2022-04-01T15:13:31Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![ahmedts](https://avatars.discourse-cdn.com/v4/letter/a/ecb155/32.png) [@ahmedts](https://discuss.elastic.co/u/ahmedts)\
**Post date:** [April 1, 2022, 3:13pm UTC](https://discuss.elastic.co/t/monitoring-standalone-application/301345/1 "2022-04-01T15:13:31Z")

</div>

Hello all,

I'm a beginner with Elastic APM, currently trying to use Elastic APM to monitor a simple standalone python application using APM Server v8.1 to get an understanding for it. The application uses Flask framework and has one request that receives a number and computes its factorial.

```auto
import logging
from flask import Flask
from elasticapm.contrib.flask import ElasticAPM
from elasticapm.handlers.logging import LoggingHandler
import elasticapm

app = Flask( __name__ )

server_url = 'http://localhost:8200'
service_name = 'DemoFlask'
environment = 'dev'
DEBUG = False
app.config["ELASTIC_APM"] = {
    "DEBUG": DEBUG,
    "LOG_FILE": "/Users/ahmed/Desktop/SPL/Elastic/Logs/flaskapm.log",
    "LOG_LEVEL": "trace",
    "SERVER_TIMEOUT": "20s",
    "COLLECT_LOCAL_VARIABLES": "all",
    "SOURCE_LINES_SPAN_APP_FRAMES": "5",
    "SOURCE_LINES_SPAN_LIBRARY_FRAMES": "5",
    "CAPTURE_BODY": "all",
    "span_stack_trace_min_duration": "0ms",
    "exit_span_min_duration": "0ms"

}

environment=environment, logging=logging.INFO)
apm = ElasticAPM(app, service_name=service_name)
elasticapm.label(platform='DemoPlatform')
  
  
@app.route('/hello/<name>')
def hello_name(name):
   return 'Hello %s!' % name

@app.route('/fact/<num>')
def fact_helper(num):
    num = int(num)
    return 'The factorial of %d is %d!' % (num, fact(num))

def fact(n):
    if n == 1 or n == 0:
        return 1
    else:
        return n*fact(n-1)
  
if __name__ == ' __main__':
    handler = LoggingHandler(client=apm.client)
    handler.setLevel(logging.INFO)
    app.logger.addHandler(handler)
    app.run()

```

When observing the logs of APM Service, I can see that requests to '/fact/num' are being captured, however no spans are captured.

```auto
{"log.level":"debug","@timestamp":"2022-04-01T19:02:26.536+0400","log.logger":"spanmetrics","log.origin":{"file.name":"spanmetrics/aggregator.go","file.line":163},"message":"no span metrics to publish","service.name":"apm-server","ecs.version":"1.6.0"}
{"log.level":"debug","@timestamp":"2022-04-01T19:02:26.536+0400","log.logger":"txmetrics","log.origin":{"file.name":"txmetrics/aggregator.go","file.line":230},"message":"publishing 1 metricsets","service.name":"apm-server","ecs.version":"1.6.0"}

```

Am I configuring anything incorrectly or is this due to the fact that spans with no service destinations are dropped as mentioned [here](https://github.com/elastic/apm/blob/main/specs/agents/tracing-spans-destination.md).

Your help is greatly appreciated.

---

<div class="post-metadata">

**Author:** ![ahmedts](https://avatars.discourse-cdn.com/v4/letter/a/ecb155/32.png) [@ahmedts](https://discuss.elastic.co/u/ahmedts)\
**Post date:** [April 5, 2022, 6:30am UTC](https://discuss.elastic.co/t/monitoring-standalone-application/301345/2 "2022-04-05T06:30:23Z")

</div>

Any input on this please?

---

<div class="post-metadata">

**Author:** ![DopplerSzz](https://avatars.discourse-cdn.com/v4/letter/d/f04885/32.png) [@DopplerSzz](https://discuss.elastic.co/u/DopplerSzz)\
**Post date:** [April 5, 2022, 7:20pm UTC](https://discuss.elastic.co/t/monitoring-standalone-application/301345/3 "2022-04-05T19:20:48Z")

</div>

following

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [April 26, 2022, 3:21pm UTC](https://discuss.elastic.co/t/monitoring-standalone-application/301345/4 "2022-04-26T15:21:21Z")

</div>

This topic was automatically closed 20 days after the last reply. New replies are no longer allowed.
