Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Warning for SERVICE_NAME even after explicitly given value in config #1908

Open
noddy09 opened this issue Sep 28, 2023 · 3 comments
Open

Warning for SERVICE_NAME even after explicitly given value in config #1908

noddy09 opened this issue Sep 28, 2023 · 3 comments
Labels
agent-python community Issues opened by the community triage Issues awaiting triage

Comments

@noddy09
Copy link

noddy09 commented Sep 28, 2023

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
@github-actions github-actions bot added agent-python community Issues opened by the community triage Issues awaiting triage labels Sep 28, 2023
@basepi
Copy link
Contributor

basepi commented Sep 29, 2023

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.

@noddy09
Copy link
Author

noddy09 commented Jan 4, 2024

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

@basepi
Copy link
Contributor

basepi commented Jan 4, 2024

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
agent-python community Issues opened by the community triage Issues awaiting triage
Projects
None yet
Development

No branches or pull requests

2 participants