Mirror of https://github.com/roostorg/osprey github.com/roostorg/osprey
2
fork

Configure Feed

Select the types of activity you want to include in your feed.

Add timing metrics to MultiOutputSink (#85)

authored by

Leon Shi and committed by
GitHub
3f952176 2ea38adc

+9 -8
+9 -8
osprey_worker/src/osprey/worker/sinks/sink/output_sink.py
··· 54 54 55 55 for sink in self._sinks: 56 56 if sink.will_do_work(result): 57 + sink_name = sink.__class__.__name__ 57 58 try: 58 - with trace(f'{sink.__class__.__name__}.push'), gevent.Timeout(GEVENT_TIMEOUT): 59 + with ( 60 + trace(f'{sink_name}.push'), 61 + metrics.timed('handled_message_output', tags=[f'sink:{sink_name}'], use_ms=True), 62 + gevent.Timeout(GEVENT_TIMEOUT), 63 + ): 59 64 sink.push(result) 60 65 except gevent.Timeout as timeout_exc: 61 - logger.exception( 62 - f'Timeout exception raised when pushing event to sink: {str(sink.__class__.__name__)}' 63 - ) 66 + logger.exception(f'Timeout exception raised when pushing event to sink: {sink_name}') 64 67 errors[sink] = timeout_exc 65 - metrics.increment('output_sink.timeout', tags=[f'sink:{sink.__class__.__name__}']) 68 + metrics.increment('output_sink.timeout', tags=[f'sink:{sink_name}']) 66 69 # Capture the Timeout exception 67 70 sentry_sdk.capture_exception() 68 71 except Exception as exc: 69 72 errors[sink] = exc 70 - metrics.increment( 71 - 'output_sink.error', tags=[f'sink:{sink.__class__.__name__}', f'error:{exc.__class__.__name__}'] 72 - ) 73 + metrics.increment('output_sink.error', tags=[f'sink:{sink_name}', f'error:{exc.__class__.__name__}']) 73 74 # Capture the current exception for now until we fix PartialSinkFailure 74 75 sentry_sdk.capture_exception() 75 76