Example #1
0
    def _traced_execute_pipeline(func, instance, args, kwargs):
        try:
            command_stack = (instance.command_stack if hasattr(
                instance, "command_stack") else instance._command_stack)

            cmds = [
                _format_command_args(c.args if hasattr(c, "args") else c[0])
                for c in command_stack
            ]
            resource = "\n".join(cmds)

            span_name = " ".join([
                (c.args[0] if hasattr(c, "args") else c[0][0])
                for c in command_stack
            ])
        except (AttributeError, IndexError):
            command_stack = []
            resource = ""
            span_name = ""

        with tracer.start_as_current_span(span_name,
                                          kind=trace.SpanKind.CLIENT) as span:
            if span.is_recording():
                span.set_attribute(SpanAttributes.DB_STATEMENT, resource)
                _set_connection_attributes(span, instance)
                span.set_attribute("db.redis.pipeline_length",
                                   len(command_stack))
            response = func(*args, **kwargs)
            if callable(response_hook):
                response_hook(span, instance, response)
            return response
Example #2
0
def _traced_execute_command(func, instance, args, kwargs):
    tracer = getattr(redis, "_opentelemetry_tracer")
    query = _format_command_args(args)
    with tracer.start_as_current_span(_CMD) as span:
        span.set_attribute("service", tracer.instrumentation_info.name)
        span.set_attribute(_RAWCMD, query)
        _set_connection_attributes(span, instance)
        span.set_attribute("redis.args_length", len(args))
        return func(*args, **kwargs)
Example #3
0
def _traced_execute_pipeline(func, instance, args, kwargs):
    tracer = getattr(redis, "_opentelemetry_tracer")

    cmds = [_format_command_args(c) for c, _ in instance.command_stack]
    resource = "\n".join(cmds)

    with tracer.start_as_current_span(_CMD) as span:
        span.set_attribute("service", tracer.instrumentation_info.name)
        span.set_attribute(_RAWCMD, resource)
        _set_connection_attributes(span, instance)
        span.set_attribute("redis.pipeline_length",
                           len(instance.command_stack))
        return func(*args, **kwargs)
def _traced_execute_command(func, instance, args, kwargs):
    tracer = getattr(redis, "_opentelemetry_tracer")
    query = _format_command_args(args)
    name = ""
    if len(args) > 0 and args[0]:
        name = args[0]
    else:
        name = instance.connection_pool.connection_kwargs.get("db", 0)
    with tracer.start_as_current_span(name,
                                      kind=trace.SpanKind.CLIENT) as span:
        if span.is_recording():
            span.set_attribute(SpanAttributes.DB_STATEMENT, query)
            _set_connection_attributes(span, instance)
            span.set_attribute("db.redis.args_length", len(args))
        return func(*args, **kwargs)
def _traced_execute_pipeline(func, instance, args, kwargs):
    tracer = getattr(redis, "_opentelemetry_tracer")

    cmds = [_format_command_args(c) for c, _ in instance.command_stack]
    resource = "\n".join(cmds)

    span_name = " ".join([args[0] for args, _ in instance.command_stack])

    with tracer.start_as_current_span(span_name,
                                      kind=trace.SpanKind.CLIENT) as span:
        if span.is_recording():
            span.set_attribute(SpanAttributes.DB_STATEMENT, resource)
            _set_connection_attributes(span, instance)
            span.set_attribute("db.redis.pipeline_length",
                               len(instance.command_stack))
        return func(*args, **kwargs)
Example #6
0
 def _traced_execute_command(func, instance, args, kwargs):
     query = _format_command_args(args)
     name = ""
     if len(args) > 0 and args[0]:
         name = args[0]
     else:
         name = instance.connection_pool.connection_kwargs.get("db", 0)
     with tracer.start_as_current_span(name,
                                       kind=trace.SpanKind.CLIENT) as span:
         if span.is_recording():
             span.set_attribute(SpanAttributes.DB_STATEMENT, query)
             _set_connection_attributes(span, instance)
             span.set_attribute("db.redis.args_length", len(args))
         if callable(request_hook):
             request_hook(span, instance, args, kwargs)
         response = func(*args, **kwargs)
         if callable(response_hook):
             response_hook(span, instance, response)
         return response