grafanalgtm

package module
v0.34.0 Latest Latest
Warning

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

Go to latest
Published: Oct 21, 2024 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Examples

Constants

View Source
const (
	GrafanaPort    = "3000/tcp"
	LokiPort       = "3100/tcp"
	TempoPort      = "3200/tcp"
	OtlpGrpcPort   = "4317/tcp"
	OtlpHttpPort   = "4318/tcp"
	PrometheusPort = "9090/tcp"
)

Variables

This section is empty.

Functions

func WithAdminCredentials

func WithAdminCredentials(user, password string) testcontainers.ContainerCustomizer

WithAdminCredentials sets the admin credentials for the Grafana LGTM container

Types

type GrafanaLGTMContainer

type GrafanaLGTMContainer struct {
	testcontainers.Container
}

GrafanaLGTMContainer represents the Grafana LGTM container type used in the module

func Run

func Run(ctx context.Context, img string, opts ...testcontainers.ContainerCustomizer) (*GrafanaLGTMContainer, error)

Run creates an instance of the Grafana LGTM container type

Example
// runGrafanaLGTMContainer {
ctx := context.Background()

grafanaLgtmContainer, err := grafanalgtm.Run(ctx, "grafana/otel-lgtm:0.6.0")
defer func() {
	if err := testcontainers.TerminateContainer(grafanaLgtmContainer); err != nil {
		log.Printf("failed to terminate container: %s", err)
	}
}()
if err != nil {
	log.Printf("failed to start container: %s", err)
	return
}
// }

state, err := grafanaLgtmContainer.State(ctx)
if err != nil {
	log.Printf("failed to get container state: %s", err)
	return
}

fmt.Println(state.Running)
Output:

true
Example (OtelCollector)
ctx := context.Background()

ctr, err := grafanalgtm.Run(ctx, "grafana/otel-lgtm:0.6.0", grafanalgtm.WithAdminCredentials("admin", "123456789"))
defer func() {
	if err := testcontainers.TerminateContainer(ctr); err != nil {
		log.Printf("failed to terminate container: %s", err)
	}
}()
if err != nil {
	log.Printf("failed to start Grafana LGTM container: %s", err)
	return
}

// Set up OpenTelemetry.
otelShutdown, err := setupOTelSDK(ctx, ctr)
if err != nil {
	log.Printf("failed to set up OpenTelemetry: %s", err)
	return
}
// Handle shutdown properly so nothing leaks.
defer func() {
	if err := otelShutdown(context.Background()); err != nil {
		log.Printf("failed to shutdown OpenTelemetry: %s", err)
	}
}()

// roll dice 10000 times, concurrently
max := 10_000
var wg errgroup.Group
for i := 0; i < max; i++ {
	wg.Go(func() error {
		return rolldice(ctx)
	})
}

if err = wg.Wait(); err != nil {
	log.Printf("failed to roll dice: %s", err)
	return
}
Output:

func (*GrafanaLGTMContainer) HttpEndpoint

func (c *GrafanaLGTMContainer) HttpEndpoint(ctx context.Context) (string, error)

HttpEndpoint returns the HTTP URL

func (*GrafanaLGTMContainer) LokiEndpoint

func (c *GrafanaLGTMContainer) LokiEndpoint(ctx context.Context) (string, error)

LokiEndpoint returns the Loki endpoint

func (*GrafanaLGTMContainer) MustHttpEndpoint

func (c *GrafanaLGTMContainer) MustHttpEndpoint(ctx context.Context) string

MustHttpEndpoint returns the HTTP endpoint or panics if an error occurs

func (*GrafanaLGTMContainer) MustLokiEndpoint

func (c *GrafanaLGTMContainer) MustLokiEndpoint(ctx context.Context) string

MustLokiEndpoint returns the Loki endpoint or panics if an error occurs

func (*GrafanaLGTMContainer) MustOtlpGrpcEndpoint

func (c *GrafanaLGTMContainer) MustOtlpGrpcEndpoint(ctx context.Context) string

MustOtlpGrpcEndpoint returns the OTLP gRPC endpoint or panics if an error occurs

func (*GrafanaLGTMContainer) MustOtlpHttpEndpoint

func (c *GrafanaLGTMContainer) MustOtlpHttpEndpoint(ctx context.Context) string

MustOtlpHttpEndpoint returns the OTLP HTTP endpoint or panics if an error occurs

func (*GrafanaLGTMContainer) MustPrometheusHttpEndpoint

func (c *GrafanaLGTMContainer) MustPrometheusHttpEndpoint(ctx context.Context) string

MustPrometheusHttpEndpoint returns the Prometheus HTTP endpoint or panics if an error occurs

func (*GrafanaLGTMContainer) MustTempoEndpoint

func (c *GrafanaLGTMContainer) MustTempoEndpoint(ctx context.Context) string

MustTempoEndpoint returns the Tempo endpoint or panics if an error occurs

func (*GrafanaLGTMContainer) OtlpGrpcEndpoint

func (c *GrafanaLGTMContainer) OtlpGrpcEndpoint(ctx context.Context) (string, error)

OtlpGrpcEndpoint returns the OTLP gRPC endpoint

func (*GrafanaLGTMContainer) OtlpHttpEndpoint

func (c *GrafanaLGTMContainer) OtlpHttpEndpoint(ctx context.Context) (string, error)

OtlpHttpEndpoint returns the OTLP HTTP endpoint

func (*GrafanaLGTMContainer) PrometheusHttpEndpoint

func (c *GrafanaLGTMContainer) PrometheusHttpEndpoint(ctx context.Context) (string, error)

PrometheusHttpEndpoint returns the Prometheus HTTP endpoint

func (*GrafanaLGTMContainer) TempoEndpoint

func (c *GrafanaLGTMContainer) TempoEndpoint(ctx context.Context) (string, error)

TempoEndpoint returns the Tempo endpoint

Jump to

Keyboard shortcuts

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