当前位置: 首页>>代码示例>>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;未经允许,请勿转载。