otlp

package
v0.29.1 Latest Latest
Warning

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

Go to latest
Published: Jan 25, 2026 License: MIT Imports: 21 Imported by: 1

README

Example of using with otlp https://opentelemetry.io/docs/languages/go/getting-started/

Utilized this command to simplify debugging, submitting otlp to alloy agent:

  • ssh -t -L 4318:127.0.0.1:3000 darklab 'docker run -it --rm --network grafana -p 127.0.0.1:3000:3000 caddy:2.9.1 caddy reverse-proxy --from :3000 --to alloy-traces:4318'

how it looks like in json way

$ TYPELOG_JSON=true TYPELOG_SCOPES=true go run .
{"time":"2025-04-13T19:09:28.151092151+02:00","level":"INFO","msg":"started run","scope":"infra.main"}
{"time":"2025-04-13T19:09:32.797456967+02:00","level":"INFO","msg":"rolldice started","span_id":"adaa7d084fba8784","trace_id":"38f8c0869d753c3c484a57c654944b82","scope":"infra.main"}
{"time":"2025-04-13T19:09:32.797536016+02:00","level":"INFO","msg":"Alice is rolling the dice","result":1,"span_id":"adaa7d084fba8784","trace_id":"38f8c0869d753c3c484a57c654944b82","scope":"infra"}
{"time":"2025-04-13T19:09:32.797561367+02:00","level":"ERROR","msg":"Alice is rolling the dice","is_attr":true,"span_id":"adaa7d084fba8784","trace_id":"38f8c0869d753c3c484a57c654944b82","scope":"infra.main"}

without json:

time=2025-04-13T19:12:15.035+02:00 level=INFO msg="started run" scope=infra.main
time=2025-04-13T19:12:15.545+02:00 level=INFO msg="rolldice started" span_id=0c18debe976dd4d8 trace_id=f9bfc5d805a7960aaabbfe4aa2ca87da scope=infra.main
time=2025-04-13T19:12:15.545+02:00 level=INFO msg="Alice is rolling the dice" result=4 span_id=0c18debe976dd4d8 trace_id=f9bfc5d805a7960aaabbfe4aa2ca87da scope=infra
time=2025-04-13T19:12:15.545+02:00 level=ERROR msg="Alice is rolling the dice" is_attr=true span_id=0c18debe976dd4d8 trace_id=f9bfc5d805a7960aaabbfe4aa2ca87da scope=infra.main

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetResource

func GetResource() *resource.Resource

func NewHTTPHandler

func NewHTTPHandler(
	mux *http.ServeMux,
	register func(handleFunc func(pattern string, handlerFunc func(http.ResponseWriter, *http.Request))),
) http.Handler

func SetupOTelSDK

func SetupOTelSDK(ctx context.Context) (shutdown func(context.Context) error, err error)

SetupOTelSDK bootstraps the OpenTelemetry pipeline. If it does not return an error, make sure to call shutdown for proper cleanup.

Types

type OtlpEnvVars

type OtlpEnvVars struct {
	utils_settings.UtilsEnvs
	HttpOn          bool
	MetricsInterval int
}
var Env OtlpEnvVars

func GetEnvs

func GetEnvs() OtlpEnvVars

Jump to

Keyboard shortcuts

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