kubernetes

package
v1.62.0 Latest Latest
Warning

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

Go to latest
Published: Mar 22, 2024 License: Apache-2.0, BSD-3-Clause, Apache-2.0 Imports: 9 Imported by: 5

Documentation

Overview

Package kubernetes provides functions to trace k8s.io/client-go (https://github.com/kubernetes/client-go).

Example
package main

import (
	"context"
	"fmt"

	kubernetestrace "gopkg.in/DataDog/dd-trace-go.v1/contrib/k8s.io/client-go/kubernetes"

	meta_v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
	"k8s.io/client-go/kubernetes"
	"k8s.io/client-go/rest"

	_ "k8s.io/client-go/plugin/pkg/client/auth/oidc"
)

func main() {
	cfg, err := rest.InClusterConfig()
	if err != nil {
		panic(err.Error())
	}
	// Use this to trace all calls made to the Kubernetes API
	cfg.WrapTransport = kubernetestrace.WrapRoundTripper

	client, err := kubernetes.NewForConfig(cfg)
	if err != nil {
		panic(err.Error())
	}

	pods, err := client.CoreV1().Pods("default").List(context.TODO(), meta_v1.ListOptions{})
	if err != nil {
		panic(err)
	}

	fmt.Println(pods.Items)
}
Output:

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func RequestToResource added in v1.5.0

func RequestToResource(method, path string) string

RequestToResource parses a Kubernetes request and extracts a resource name from it.

func WrapRoundTripper

func WrapRoundTripper(rt http.RoundTripper) http.RoundTripper

WrapRoundTripper wraps a RoundTripper intended for interfacing with Kubernetes and traces all requests.

func WrapRoundTripperFunc added in v1.11.0

func WrapRoundTripperFunc(opts ...httptrace.RoundTripperOption) func(http.RoundTripper) http.RoundTripper

WrapRoundTripperFunc creates a new WrapTransport function using the given set of RoundTripperOption. It is useful when desiring to enable Trace Analytics or setting up a RoundTripperAfterFunc.

Types

This section is empty.

Jump to

Keyboard shortcuts

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