Exception: Instrumentation key was required but not provided
See original GitHub issueSystem information
- OS Platform and Distribution (e.g., Linux Ubuntu 16.04): macOS 10.14.2
- Python version: 3.7
Describe the problem
Can’t run the docker image: an exception occurs that is related to Azure. It might be due to https://github.com/chakki-works/doccano/pull/72
Source code / logs
To reproduce docker run -p 8080:80 doccano:1
Traceback (most recent call last):
File "/usr/local/lib/python3.6/site-packages/gunicorn/arbiter.py", line 583, in spawn_worker
worker.init_process()
File "/usr/local/lib/python3.6/site-packages/gunicorn/workers/base.py", line 129, in init_process
self.load_wsgi()
File "/usr/local/lib/python3.6/site-packages/gunicorn/workers/base.py", line 138, in load_wsgi
self.wsgi = self.app.wsgi()
File "/usr/local/lib/python3.6/site-packages/gunicorn/app/base.py", line 67, in wsgi
self.callable = self.load()
File "/usr/local/lib/python3.6/site-packages/gunicorn/app/wsgiapp.py", line 52, in load
return self.load_wsgiapp()
File "/usr/local/lib/python3.6/site-packages/gunicorn/app/wsgiapp.py", line 41, in load_wsgiapp
return util.import_app(self.app_uri)
File "/usr/local/lib/python3.6/site-packages/gunicorn/util.py", line 350, in import_app
__import__(module)
File "/doccano/app/app/wsgi.py", line 16, in <module>
application = get_wsgi_application()
File "/usr/local/lib/python3.6/site-packages/django/core/wsgi.py", line 13, in get_wsgi_application
return WSGIHandler()
File "/usr/local/lib/python3.6/site-packages/django/core/handlers/wsgi.py", line 136, in __init__
self.load_middleware()
File "/usr/local/lib/python3.6/site-packages/django/core/handlers/base.py", line 36, in load_middleware
mw_instance = middleware(handler)
File "/usr/local/lib/python3.6/site-packages/applicationinsights/django/middleware.py", line 109, in __init__
self._client = common.create_client(self._settings)
File "/usr/local/lib/python3.6/site-packages/applicationinsights/django/common.py", line 74, in create_client
client = applicationinsights.TelemetryClient(aisettings.ikey, channel)
File "/usr/local/lib/python3.6/site-packages/applicationinsights/TelemetryClient.py", line 28, in __init__
raise Exception('Instrumentation key was required but not provided')
Exception: Instrumentation key was required but not provided
Issue Analytics
- State:
- Created 5 years ago
- Comments:7 (4 by maintainers)
Top Results From Across the Web
Exception: Instrumentation key was required but not provided
Solution · Solution1: Update settings.py · Solution2: Delete AZURE_APPINSIGHT_IKEY from Dockerfile and pass it when executing docker run command.
Read more >Application Insights 'invalid instrumentation key' when using ...
It works fine if i give it an instrumentation key from the regular azure cloud, but if i give it one from the...
Read more >Connection strings in Application Insights - Azure Monitor
This article shows how to use connection strings.
Read more >What happens if I do not provide instrumentation key in azure ...
If a question is poorly phrased then either ask for clarification, ignore it, or edit the question and fix the problem. Insults are...
Read more >Writing Your Code - Application Insights Succinctly Ebook
This uses the instrumentation key present in the ApplicationInsights.config file. However, since InstrumentationKey is a property of this class, ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Problem
I found the cause. In line 71 of
applicationinsights/django/common.py
, there is the following logic:where
ikey
is assigned according toAZURE_APPINSIGHT_IKEY
.If there is no
AZURE_APPINSIGHT_IKEY
in environment variables,ikey
isNone
. It doesn’t cause any problems. But if there isAZURE_APPINSIGHT_IKEY
with empty string,ikey
is notNone
. As a result, the exception is raised in line 74.Solution
I came up with two solutions.
Solution1: Update settings.py
The problem is caused due to an empty string. So if
AZURE_APPINSIGHTS_IKEY
is empty, it will be converted toNone
in settings.py:Solution2: Delete
AZURE_APPINSIGHT_IKEY
from Dockerfile and pass it when executing docker run commandFirst, delete
AZURE_APPINSIGHTS_IKEY
from Dockerfile:Then pass it to a docker container when executing docker run command:
I managed to circumvent the issue by commenting out
ENV AZURE_APPINSIGHTS_IKEY=""
in the Dockerfile. Hope this helps as a temporary workaround and in finding the underlying issue. My guess would be that this is related to #76