Comments (3)
This is a great question that we don't touch on in the docs (but should).
Short answer:
Nameko does't dictate any particular tool. At onefinestay we log exceptions to sentry, timing stats to graphite and entrypoint invocation (service and method name, arguments, call stack, success/error status, result bytes, response time etc.) to elasticsearch/logstash. This is a really powerful setup for debugging across multiple services.
Each of these loggers are service dependencies, and we intend to open source each of them as community extensions.
Longer answer:
One of the nice things about nameko's dependency injection pattern is the integration with the worker lifecycle. DependencyProvider extensions are notified when workers are setup, torn down, and generate a result. A trivial logging dependency might look like:
class LoggingDependency(DependencyProvider):
def __init__(self):
self.timestamps = WeakKeyDictionary()
def worker_setup(self, worker_ctx):
self.timestamps[worker_ctx] = datetime.datetime.now()
service_name = worker_ctx.service_name
method_name = worker_ctx.entrypoint.method_name
log.info("Worker %s.%s starting", service_name, method_name)
def worker_result(self, worker_ctx, result=None, exc_info=None):
service_name = worker_ctx.service_name
method_name = worker_ctx.entrypoint.method_name
if exc_info is None:
status = "completed"
else:
status = "errored"
now = datetime.datetime.now()
worker_started = self.timestamps.pop(worker_ctx)
elapsed = (now - worker_started).seconds
log.info("Worker %s.%s %s after %ss",
service_name, method_name, status, elapsed)
Then you can add it to your service in a nicely decoupled way:
class Service(object):
name = "myservice"
logger = LoggingDependency() # << just add this line
@rpc
def method(self, arg):
...
from nameko.
Really nice answer, thank you very much!
from nameko.
This issue was moved to https://discourse.nameko.io/t/how-do-you-do-monitoring/319
from nameko.
Related Issues (20)
- AttributeError: 'SubRequest' object has no attribute 'funcargnames' HOT 3
- nameko.exceptions.UnknownService: Unknown service `service_x`
- nameko.exceptions.UnknownService: Unknown service `service_x` HOT 2
- Incompatible versions in the resolved dependencies between Nameko and Celery in Kombu HOT 4
- Use another augmented assignment statement HOT 1
- Check for existing key HOT 1
- Should ipython and bpython be listed in some configuration files? HOT 1
- Why using dnspython 1.x instead of 2.x ? HOT 8
- need upgrade to support python 3.10 HOT 2
- Publisher crashing when exchange is provided and RabbitMQ is down
- Nameko crashes when consuming illegal messages HOT 6
- [ DOUBT ] Events Pub / Sub - How can I make a consumer only run one event at a time
- from nameko.rpc import rpc class GreetingService: name = "greeting_service" def hello(self, name): return "Hello, {}!".format(name)
- Timer work on master process or every process? HOT 2
- dnspython dependency version overly restrictive HOT 3
- "verify_amqp_uri" in the module "nameko.amqp.utils" had been removed? HOT 2
- Should HttpRequestHandler print out the exception to the browser? HOT 2
- nameko multiprocess problem HOT 1
- Do you die? we need you to improve Nameko Library HOT 5
- DB Migrations not working with Flask-Migrate HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from nameko.