ppgoelastic

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: 5 Imported by: 0

README

ppgoelastic

This package instruments the elastic/go-elasticsearch package.

Installation

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

Usage

PkgGoDev

This package instruments the elasticsearch calls. Use the NewTransport function as the elasticsearch.Client's Transport.

es, err := elasticsearch.NewClient(
    elasticsearch.Config{
        Transport: ppgoelastic.NewTransport(nil),
})

It is necessary to pass the context containing the pinpoint.Tracer to elasticsearch.Client.

ctx := pinpoint.NewContext(context.Background(), tracer)
res, err = es.Search(
    es.Search.WithContext(ctx),
    es.Search.WithIndex("test"),
    ...
)
import (
    "github.com/elastic/go-elasticsearch/v8"
    "github.com/elastic/go-elasticsearch/v8/esapi"
    "github.com/pinpoint-apm/pinpoint-go-agent"
    "github.com/pinpoint-apm/pinpoint-go-agent/plugin/goelastic"
)

func goelastic(w http.ResponseWriter, req *http.Request) {
    ctx := req.Context()
    es, err := elasticsearch.NewClient(
        elasticsearch.Config{Transport: ppgoelastic.NewTransport(nil)}
    )

    ...
    
    res, err = es.Search(
        es.Search.WithContext(ctx),
        es.Search.WithIndex("test"),
        es.Search.WithBody(&buf),
    )

    ...
}

Full Example Source

Documentation

Overview

Package ppgoelastic instruments the elastic/go-elasticsearch package (https://github.com/elastic/go-elasticsearch).

This package instruments the elasticsearch calls. Use the NewTransport as the elasticsearch.Client's Transport.

elasticsearch.NewClient(elasticsearch.Config{Transport: ppgoelastic.NewTransport(nil)})

It is necessary to pass the context containing the pinpoint.Tracer to elasticsearch.Client.

ctx := pinpoint.NewContext(context.Background(), tracer)
es.Search(es.Search.WithContext(ctx), es.Search.WithIndex("test"))

Index

Constants

View Source
const (
	MaxDslLength           = 256
	ServiceTypeHttpClient4 = 9052
)

Variables

This section is empty.

Functions

func NewTransport

func NewTransport(r http.RoundTripper) http.RoundTripper

NewTransport returns a new http.RoundTripper to instrument elasticsearch calls. If a http.RoundTripper parameter is not provided, http.DefaultTransport will be instrumented.

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