當前位置: 首頁>>代碼示例>>Python>>正文


Python tags.ERROR屬性代碼示例

本文整理匯總了Python中opentracing.ext.tags.ERROR屬性的典型用法代碼示例。如果您正苦於以下問題:Python tags.ERROR屬性的具體用法?Python tags.ERROR怎麽用?Python tags.ERROR使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在opentracing.ext.tags的用法示例。


在下文中一共展示了tags.ERROR屬性的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: _after_request_fn

# 需要導入模塊: from opentracing.ext import tags [as 別名]
# 或者: from opentracing.ext.tags import ERROR [as 別名]
def _after_request_fn(self, response=None, error=None):
        request = stack.top.request

        # the pop call can fail if the request is interrupted by a
        # `before_request` method so we need a default
        scope = self._current_scopes.pop(request, None)
        if scope is None:
            return

        if response is not None:
            scope.span.set_tag(tags.HTTP_STATUS_CODE, response.status_code)
        if error is not None:
            scope.span.set_tag(tags.ERROR, True)
            scope.span.log_kv({
                'event': tags.ERROR,
                'error.object': error,
            })

        scope.close() 
開發者ID:opentracing-contrib,項目名稱:python-flask,代碼行數:21,代碼來源:tracing.py

示例2: log_kv

# 需要導入模塊: from opentracing.ext import tags [as 別名]
# 或者: from opentracing.ext.tags import ERROR [as 別名]
def log_kv(self, key_values, timestamp=None):
        exc_type, exc_val, exc_tb = None, None, None
        if "python.exception.type" in key_values:
            exc_type = key_values["python.exception.type"]
            exc_val = key_values.get("python.exception.val")
            exc_tb = key_values.get("python.exception.tb")
        elif ot_logs and key_values.get(ot_logs.EVENT) == tags.ERROR:
            exc_type = key_values[ot_logs.ERROR_KIND]
            exc_val = key_values.get(ot_logs.ERROR_OBJECT)
            exc_tb = key_values.get(ot_logs.STACK)
        else:
            logger.debug("Can't handle non-exception type opentracing logs")
        if exc_type:
            agent = self.tracer._agent
            agent.capture_exception(exc_info=(exc_type, exc_val, exc_tb))
        return self 
開發者ID:elastic,項目名稱:apm-agent-python,代碼行數:18,代碼來源:span.py

示例3: traced_fetch_impl

# 需要導入模塊: from opentracing.ext import tags [as 別名]
# 或者: from opentracing.ext.tags import ERROR [as 別名]
def traced_fetch_impl(real_fetch_impl):

    @functools.wraps(real_fetch_impl)
    def new_fetch_impl(self, request, callback):
        request_wrapper = TornadoRequestWrapper(request=request)
        span = before_http_request(request=request_wrapper,
                                   current_span_extractor=get_current_span)

        def new_callback(response):
            if hasattr(response, 'code') and response.code:
                span.set_tag(tags.HTTP_STATUS_CODE, '%s' % response.code)
            if hasattr(response, 'error') and response.error:
                span.set_tag(tags.ERROR, True)
                span.log(event=tags.ERROR, payload='%s' % response.error)
            span.finish()
            return callback(response)

        real_fetch_impl(self, request, new_callback)

    return new_fetch_impl 
開發者ID:uber-common,項目名稱:opentracing-python-instrumentation,代碼行數:22,代碼來源:tornado_http.py

示例4: __exit__

# 需要導入模塊: from opentracing.ext import tags [as 別名]
# 或者: from opentracing.ext.tags import ERROR [as 別名]
def __exit__(self, exc_type, exc_val, exc_tb):
        """Ends context manager and calls finish() on the :class:`Span`.

        If exception has occurred during execution, it is automatically logged
        and added as a tag. :attr:`~operation.ext.tags.ERROR` will also be set
        to `True`.
        """
        Span._on_error(self, exc_type, exc_val, exc_tb)
        self.finish() 
開發者ID:opentracing,項目名稱:opentracing-python,代碼行數:11,代碼來源:span.py

示例5: _on_error

# 需要導入模塊: from opentracing.ext import tags [as 別名]
# 或者: from opentracing.ext.tags import ERROR [as 別名]
def _on_error(span, exc_type, exc_val, exc_tb):
        if not span or not exc_val:
            return

        span.set_tag(tags.ERROR, True)
        span.log_kv({
            logs.EVENT: tags.ERROR,
            logs.MESSAGE: str(exc_val),
            logs.ERROR_OBJECT: exc_val,
            logs.ERROR_KIND: exc_type,
            logs.STACK: exc_tb,
        }) 
開發者ID:opentracing,項目名稱:opentracing-python,代碼行數:14,代碼來源:span.py

示例6: _verify_error

# 需要導入模塊: from opentracing.ext import tags [as 別名]
# 或者: from opentracing.ext.tags import ERROR [as 別名]
def _verify_error(self, span):
        assert span.tags.get(tags.ERROR) is True

        assert len(span.logs) == 1
        assert span.logs[0].key_values.get('event', None) is tags.ERROR
        assert isinstance(
                span.logs[0].key_values.get('error.object', None),
                RuntimeError
        ) 
開發者ID:opentracing-contrib,項目名稱:python-flask,代碼行數:11,代碼來源:test_flask_tracing.py

示例7: test_error

# 需要導入模塊: from opentracing.ext import tags [as 別名]
# 或者: from opentracing.ext.tags import ERROR [as 別名]
def test_error(self):
        def start_span_cb(span, request):
            raise RuntimeError('Should not happen')

        tracing = FlaskTracing(MockTracer(), True, app,
                               start_span_cb=start_span_cb)
        rv = test_app.get('/test')
        assert '200' in str(rv.status_code)

        spans = tracing.tracer.finished_spans()
        assert len(spans) == 1
        assert spans[0].tags.get(tags.ERROR, None) is None 
開發者ID:opentracing-contrib,項目名稱:python-flask,代碼行數:14,代碼來源:test_flask_tracing.py

示例8: _finish_tracing

# 需要導入模塊: from opentracing.ext import tags [as 別名]
# 或者: from opentracing.ext.tags import ERROR [as 別名]
def _finish_tracing(self, request, response=None, error=None):
        scope = self._current_scopes.pop(request, None)
        if scope is None:
            return

        if error is not None:
            scope.span.set_tag(tags.ERROR, True)
            scope.span.log_kv({
                'event': tags.ERROR,
                'error.object': error,
            })
        if response is not None:
            scope.span.set_tag(tags.HTTP_STATUS_CODE, response.status_code)

        scope.close() 
開發者ID:opentracing-contrib,項目名稱:python-django,代碼行數:17,代碼來源:tracing.py

示例9: verify_traced_with_error

# 需要導入模塊: from opentracing.ext import tags [as 別名]
# 或者: from opentracing.ext.tags import ERROR [as 別名]
def verify_traced_with_error(self):
        client = Client()
        with self.assertRaises(ValueError):
            client.get('/traced_with_error/')

        spans = settings.OPENTRACING_TRACING._tracer.finished_spans()
        assert len(spans) == 1
        assert spans[0].tags.get(tags.ERROR, False) is True

        assert len(spans[0].logs) == 1
        assert spans[0].logs[0].key_values.get('event', None) is 'error'
        assert isinstance(
                spans[0].logs[0].key_values.get('error.object', None),
                ValueError
        ) 
開發者ID:opentracing-contrib,項目名稱:python-django,代碼行數:17,代碼來源:test_middleware.py


注:本文中的opentracing.ext.tags.ERROR屬性示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。