# README
Go Agent for OpenTelemetry
Go Agent provides a set of complementary features for OpenTelemetry instrumentation
Package net/hyperhttp
HTTP server
The server instrumentation relies on the http.Handler
component of the server declarations.
import (
"net/http"
"github.com/gorilla/mux"
"github.com/hypertrace/goagent/instrumentation/opentelemetry/net/hyperhttp"
"go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp"
)
func main() {
// ...
r := mux.NewRouter()
r.Handle("/foo/{bar}", otelhttp.NewHandler(
hyperhttp.WrapHandler(fooHandler),
"/foo/{bar}",
))
// ...
}
HTTP client
The client instrumentation relies on the http.Transport
component of the HTTP client in Go.
import (
"net/http"
"github.com/hypertrace/goagent/instrumentation/opentelemetry/net/hyperhttp"
"go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp"
)
// ...
client := http.Client{
Transport: otelhttp.NewTransport(
hyperhttp.WrapDefaultTransport(),
...
),
}
req, _ := http.NewRequest("GET", "http://example.com", nil)
res, err := client.Do(req)
// ...
Running HTTP examples
In terminal 1 run the client:
go run ./net/http/examples/client/main.go
In terminal 2 run the server:
go run ./net/http/examples/server/main.go
Package google.golang.org/hypergrpc
GRPC server
The server instrumentation relies on the grpc.UnaryServerInterceptor
component of the server declarations.
server := grpc.NewServer(
grpc.UnaryInterceptor(
hypergrpc.WrapUnaryServerInterceptor(
otelgrpc.UnaryServerInterceptor(myTracer),
),
),
)
GRPC client
The client instrumentation relies on the http.Transport
component of the HTTP client in Go.
import (
// ...
hypergrpc "github.com/hypertrace/goagent/instrumentation/opentelemetry/google.golang.org/hypergrpc"
"go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc"
"google.golang.org/grpc"
)
func main() {
// ...
conn, err := grpc.Dial(
address,
grpc.WithInsecure(),
grpc.WithBlock(),
grpc.WithUnaryInterceptor(
hypergrpc.WrapUnaryClientInterceptor(
otelgrpc.UnaryClientInterceptor(myTracer),
),
),
)
if err != nil {
log.Fatalf("could not dial: %v", err)
}
defer conn.Close()
client := pb.NewCustomClient(conn)
// ...
}
Running GRPC examples
In terminal 1 run the client:
go run ./google.golang.org/hypergrpc/examples/client/main.go
In terminal 2 run the server:
go run ./google.golang.org/hypergrpc/examples/server/main.go
# Packages
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
# Functions
Init initializes opentelemetry tracing and returns a shutdown function to flush data immediately on a termination signal.
InitAsAdditional initializes opentelemetry tracing and returns a span processor and a shutdown function to flush data immediately on a termination signal.
InitWithSpanProcessorWrapper initializes opentelemetry tracing with a wrapper over span processor and returns a shutdown function to flush data immediately on a termination signal.
RemoveGoAgentAttrs removes custom goagent attributes from the spans so that other tracing servers don't receive them and don't have to handle the load.
No description provided by the author
RegisterService creates tracerprovider for a new service and returns a func which can be used to create spans and the TracerProvider.
RegisterServiceWithSpanProcessorWrapper creates a tracerprovider for a new service with a wrapper over opentelemetry span processor and returns a func which can be used to create spans and the TracerProvider.
No description provided by the author
# Constants
TracerDomain represents the tracer name for the Hypertrace instrumentation.
# Variables
No description provided by the author
No description provided by the author
No description provided by the author
# Structs
No description provided by the author
No description provided by the author
No description provided by the author
# Interfaces
SpanProcessorWrapper wraps otel span processor and is responsible to delegate calls to the wrapped processor.