template.py 文件源码

python
阅读 27 收藏 0 点赞 0 评论 0

项目:dd-trace-py 作者: DataDog 项目源码 文件源码
def generate(func, renderer, args, kwargs):
    """
    Wrap the ``generate`` method used in templates rendering. Because the method
    may be called everywhere, the execution is traced in a tracer StackContext that
    inherits the current one if it's already available.
    """
    # get the module pin
    pin = Pin.get_from(template)
    if not pin or not pin.enabled():
        return func(*args, **kwargs)

    # change the resource and the template name
    # if it's created from a string instead of a file
    if '<string>' in renderer.name:
        resource = template_name = 'render_string'
    else:
        resource = template_name = renderer.name

    # trace the original call
    with pin.tracer.trace('tornado.template', service=pin.service) as span:
        span.span_type = http.TEMPLATE
        span.resource = resource
        span.set_meta('tornado.template_name', template_name)
        return func(*args, **kwargs)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号