Skip to content

BackgroundThreadTransport with StackdriverExporter not working #395

Open
@marctc

Description

I'm trying the Django integration of OpenCensus tracing to export traces to Stackdriver. Since sending traces synchronously is slow operation I've tried to add the BackgroundThreadTransport. But it doesn't send any trace to Stackdriver.

The app is deployed on Kubernetes (GKE) with uWSGI as wsgi server:

versions:

  • python = 3.6/3.7
  • django = 2.1.1
  • opencensus = master branch

opencensus config in settings.py:

OPENCENSUS_TRACE = {
    'EXPORTER': 'opencensus.trace.exporters.stackdriver_exporter.StackdriverExporter',
}
OPENCENSUS_TRACE_PARAMS = {
    'BLACKLIST_PATHS': ['health', 'metrics', 'favicon.ico'],
    'GCP_EXPORTER_PROJECT': opts.get('GOOGLE_CLOUD_PROJECT', 'my-project'),
    'TRANSPORT': 'opencensus.trace.exporters.transports.background_thread.BackgroundThreadTransport',
}
OPENCENSUS_INTEGRATIONS = ['threading', 'postgresql']
config_integration.trace_integrations(OPENCENSUS_INTEGRATIONS)

uwsgi log:

→ Running in clear (non auth) mode
[uWSGI] getting INI configuration from /etc/uwsgi/uwsgi.ini
[uwsgi-static] added mapping for /static => /data/static
...
uWSGI http bound on :8080 fd 7
uwsgi socket 0 bound to TCP address 127.0.0.1:39479 (port auto-assigned) fd 6
Python version: 3.6.7 (default, Oct 24 2018, 22:47:56)  [GCC 6.3.0 20170516]
Python main interpreter initialized at 0x559aa1557d80
python threads support enabled
*** Operational MODE: threaded ***
[2018-11-13 15:26:21,935] DEBUG google.auth.transport._http_client-101 Making request: GET http://xxx.xxx.xxx.xxx
[2018-11-13 15:26:21,940] DEBUG google.auth.transport._http_client-101 Making request: GET http://metadata.google.internal/computeMetadata/v1/project/project-id
[2018-11-13 15:26:21,997] DEBUG google.auth.transport._http_client-101 Making request: GET http://xxx.xxx.xxx.xxx
[2018-11-13 15:26:21,999] DEBUG google.auth.transport._http_client-101 Making request: GET http://metadata.google.internal/computeMetadata/v1/project/project-id
[2018-11-13 15:26:22,013] DEBUG opencensus.trace.exporters.transports.background_thread-90 Background thread started.
[2018-11-13 15:26:22,023] DEBUG google.auth.transport._http_client-101 Making request: GET http://xxx.xxx.xxx.xxx
[2018-11-13 15:26:22,027] DEBUG google.auth.transport._http_client-101 Making request: GET http://metadata.google.internal/computeMetadata/v1/project/project-id
[2018-11-13 15:26:22,040] DEBUG google.auth.transport._http_client-101 Making request: GET http://xxx.xxx.xxx.xxx
[2018-11-13 15:26:22,044] DEBUG google.auth.transport._http_client-101 Making request: GET http://metadata.google.internal/computeMetadata/v1/project/project-id
WSGI app 0 (mountpoint='') ready in 13 seconds on interpreter 0x559aa1557d80 pid: 1 (default app)
*** uWSGI is running in multiple interpreter mode ***
spawned uWSGI master process (pid: 1)
spawned uWSGI worker 1 (pid: 37, cores: 32)
*** Stats server enabled on :1717 fd: 15 ***
spawned 1 offload threads for uWSGI worker 1
[2018-11-13 15:26:22,059] DEBUG opencensus.trace.exporters.transports.background_thread-90 Background thread started.
spawned uWSGI http 1 (pid: 70)

Activity

c24t

c24t commented on May 2, 2019

@c24t
Member

@marctc thanks for raising the issue, and sorry for the long delayed response here. Can you still reproduce this with recent versions of opencensus and opencensus-ext-django?

jgaz

jgaz commented on Oct 7, 2019

@jgaz

@c24t Hi, I am having the same issue in a similar environment, the code works fine in Django devel server, but it does not run under uWSGI server, I am using the default transport, which I think is async.

ebrake

ebrake commented on Sep 21, 2020

@ebrake

Since OPENCENSUS_TRACE_PARAMS was removed, does OPENCENSUS_TRACE => TRANSPORT work any longer using django settings? It doesn't seem to do anything!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      BackgroundThreadTransport with StackdriverExporter not working · Issue #395 · census-instrumentation/opencensus-python