apm-agent-python icon indicating copy to clipboard operation
apm-agent-python copied to clipboard

Warning for `SERVICE_NAME` even after explicitly given value in config

Open noddy09 opened this issue 2 years ago • 3 comments

I have integrated elastic-apm with flask application, following simple document provided in flask-support documentation. Im getting warning:

[2023-09-28 15:07:07,840 base.py->__init__():123]WARNING: No custom SERVICE_NAME was set -- using non-descript default 'unknown-python-service'

Here is exact code:

apm = None
try:
    app.config['ELASTIC_APM'] = {
        'SERVICE_NAME': 'myservice-api',
        'SECRET_TOKEN': '<my-token>',
        'SERVER_URL': '<my-url>',
        'ENVIRONMENT': '<my-env>',
    }
    apm = ElasticAPM(app)
except Exception as e:
    logging.critical(f"APM error for middleware: {e}")
    del apm

I tried another way to initialize apm object: apm = ElasticAPM(app, service_name='myservice-api')

But doesn't make any difference.

  • OS: WSL2 (Windows 11 with Ubuntu 22.04)
  • Python version: 3.10.12
  • Framework and version: Flask 2.0.1
  • elastic-apm==6.17.0

noddy09 avatar Sep 28 '23 09:09 noddy09

Can you check that you don't have any ELASTIC_APM_* environment variables set? Environment variables will override inline config, so that's a possibility. Otherwise I can't see any obvious problems with your code... 🤔 I'll have to think on it.

basepi avatar Sep 29 '23 17:09 basepi

On same host, I'm running multiple simultaneous flask app with different APM conf values, will one app affect another app's APM config?

noddy09 avatar Jan 04 '24 14:01 noddy09

will one app affect another app's APM config?

Only if you're configuring your apps via environment variables, and don't have sufficient separation between the apps. If you're using inline config for all your apps (app.config['ELASTIC_APM']) then they will not affect each other.

Another thing to check -- are you using our experimental wrapper script?

Do all your apps have this problem, or just this one?

I'm just trying to figure out why the config is not being loaded, as your code looks right to me. Perhaps you could redact and show me more of your code?

basepi avatar Jan 04 '24 23:01 basepi