Monitoring Standalone application

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.

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"] = {
    "LOG_FILE": "/Users/ahmed/Desktop/SPL/Elastic/Logs/flaskapm.log",
    "LOG_LEVEL": "trace",
    "SERVER_TIMEOUT": "20s",
    "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)
def hello_name(name):
   return 'Hello %s!' % name

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
        return n*fact(n-1)
if __name__ == '__main__':
    handler = LoggingHandler(client=apm.client)

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

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

Your help is greatly appreciated.

Any input on this please?


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