Skip to main content

Client code for python Mona instrumentation

Project description

Python Client

Using Mona's wrapper for the "requests" package

instead of importing "requests", import the requests object from mona_requests: from mona_requests import requests

After that, use requests as usual. The only difference in behavior is that any request or session will always have a header "mona_id" added to it, with the current context's complete id.

Concurrency

Mona saves the ARC's id on a special variable, which is local to the thread and to greenlets. This means that if you start a new thread/greenlet, by default the new thread will have an empty context.

This is usually the preffered behavior, as a new thread usually means a new received request (on servers) or a completely new run of an algorithm.

If by any chance you'd like to continue with the same context on a new thread, just use the child class MonaThread under mona_thread.py. This class takes care of transferring the full context id to the newly started thread.

Using Mona's GCP pubusb support

We provide support for transferring Mona context data via pubsub using our class MonaPublisherClient (child of PublisherClient). This class extends the functionaliy of the publish() method, by adding the current context id via the message attributes.

On the other side, if you subscribe to a pubsub topic and wish to have your mona context change according to the publisher's context, just send any message to our init_mona_from_pubsub_message(msg) method. That's it.

Testing the client code

The client's tests are written using the pytest framework, so in order to run the tests (assuming you have pytest installed on your environment), you just need to type "pytest" to your shell.

The only caveat is in pubsub_test.py, which you need to use a pubsub emulator to activate. Please refer to that file for explanations.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

mona_client-0.0.1.tar.gz (5.1 kB view details)

Uploaded Source

Built Distribution

mona_client-0.0.1-py3-none-any.whl (7.4 kB view details)

Uploaded Python 3

File details

Details for the file mona_client-0.0.1.tar.gz.

File metadata

  • Download URL: mona_client-0.0.1.tar.gz
  • Upload date:
  • Size: 5.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.20.1 setuptools/40.6.2 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.6.6

File hashes

Hashes for mona_client-0.0.1.tar.gz
Algorithm Hash digest
SHA256 3842457cdcb0045c403835ace214ef3730f7e420544a5defb7248b336b7ef315
MD5 6c8e3307c5e138027b9ed82431f639b9
BLAKE2b-256 4b5c77b707ff94ec8c696fb365b17f0d9ca05615d6cf1b87634ff189687acc84

See more details on using hashes here.

Provenance

File details

Details for the file mona_client-0.0.1-py3-none-any.whl.

File metadata

  • Download URL: mona_client-0.0.1-py3-none-any.whl
  • Upload date:
  • Size: 7.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.20.1 setuptools/40.6.2 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.6.6

File hashes

Hashes for mona_client-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 ba406b483aebec6e72a11d4fbd8c65a41726d4060b0879392d7bb639a4631ed8
MD5 04cc0943057e8db714e6503350586139
BLAKE2b-256 169002c869aef48b602efd906e3b96fd048d5747d032ef456bffb1c5cf972a06

See more details on using hashes here.

Provenance

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page