ppredigo

package module
v1.4.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 10, 2024 License: Apache-2.0 Imports: 6 Imported by: 0

README

ppredigo

This package instruments the gomodule/redigo package.

Installation

$ go get github.com/pinpoint-apm/pinpoint-go-agent/plugin/redigo
import "github.com/pinpoint-apm/pinpoint-go-agent/plugin/redigo"

Usage

PkgGoDev

This package instruments the gomodule/redigo calls. Use the Dial, DialContext (or DialURL, DialURLContext) as the redis.Dial.

c, err := ppredigo.Dial("tcp", "127.0.0.1:6379")

It is necessary to propagate the context that contains the pinpoint.Tracer to redis.Conn. You can call WithContext to propagate a context containing a pinpoint.Tracer to the operations:

ppredigo.WithContext(c, pinpoint.NewContext(context.Background(), tracer))
c.Do("SET", "vehicle", "truck")

Also, you can use function taking the context like redis.DoContext.

redis.DoContext(c, pinpoint.NewContext(context.Background(), tracer), "GET", "vehicle")
package main

import (
    "github.com/gomodule/redigo/redis"
    "github.com/pinpoint-apm/pinpoint-go-agent"
    "github.com/pinpoint-apm/pinpoint-go-agent/plugin/redigo"
)

func redigo_test(w http.ResponseWriter, r *http.Request) {
    c, err := ppredigo.Dial("tcp", "127.0.0.1:6379")
    ppredigo.WithContext(c, r.Context())

    c.Do("SET", "vehicle", "truck")
    redis.DoWithTimeout(c, 1000*time.Millisecond, "GET", "vehicle")
    
    //or 
    //redis.DoContext(c, r.Context(), "GET", "vehicle")

Full Example Source

Documentation

Overview

Package ppredigo instruments the gomodule/redigo package (https://github.com/gomodule/redigo).

This package instruments the gomodule/redigo calls. Use the Dial, DialContext (or DialURL, DialURLContext) as the redis.Dial.

c, err := ppredigo.Dial("tcp", "127.0.0.1:6379")

It is necessary to pass the context containing the pinpoint.Tracer to redis.Conn.

ppredigo.WithContext(c, pinpoint.NewContext(context.Background(), tracer))
c.Do("SET", "vehicle", "truck")

or

redis.DoContext(c, pinpoint.NewContext(context.Background(), tracer), "GET", "vehicle")

or

c, err := ppredigo.DialContext(pinpoint.NewContext(context.Background(), tracer), "tcp", "127.0.0.1:6379")
c.Do("SET", "vehicle", "truck")

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Dial

func Dial(network string, address string, options ...redis.DialOption) (redis.Conn, error)

Dial wraps redis.Dial and returns a new redis.Conn ready to instrument.

func DialContext

func DialContext(ctx context.Context, network string, address string, options ...redis.DialOption) (redis.Conn, error)

DialContext wraps redis.DialContext and returns a new redis.Conn ready to instrument. It is possible to trace only when the given context contains a pinpoint.Tracer.

func DialURL

func DialURL(rawurl string, options ...redis.DialOption) (redis.Conn, error)

DialURL wraps redis.DialURL and returns a new redis.Conn ready to instrument.

func DialURLContext

func DialURLContext(ctx context.Context, rawurl string, options ...redis.DialOption) (redis.Conn, error)

DialURLContext wraps redis.DialURLContext and returns a new redis.Conn ready to instrument. It is possible to trace only when the given context contains a pinpoint.Tracer.

func WithContext

func WithContext(c redis.Conn, ctx context.Context)

WithContext passes the context to the provided redis.Conn. It is possible to trace only when the given context contains a pinpoint.Tracer.

Types

This section is empty.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL