Documentation
¶
Index ¶
Constants ¶
View Source
const ( AttributeHttpHost = "http.host" AttributeHttpMethod = "http.method" AttributeHttpPath = "http.path" AttributeHttpQuery = "http.query" AttributeHttpUserAgent = "http.userAgent" AttributeHttpClientIP = "http.clientIp" AttributeHttpStatusCode = "http.statusCode" AttributeHttpStatusClass = "http.statusClass" AttributeHttpBytesWritten = "http.bytesWritten" AttributeHttpRequestID = "http.requestId" AttributeHttpLatencyMS = "http.latencyMS" AttributeExceptionMessage = "exception.message" AttributeExceptionType = "exception.type" AttributeExceptionStack = "exception.stacktrace" AttributeExceptionCode = "exception.code" )
View Source
const ( DefaultSampleRate float64 = 0.5 DefaultTracerExporter TracerExporterType = TracerExporterOTLP DefaultMeterExporter MeterExporterType = MeterExporterOTLP DefaultLoggerExporter LoggerExporterType = LoggerExporterOTLP // application environments EnvProduction EnvironmentType = "production" EnvStaging EnvironmentType = "staging" EnvDevelopment EnvironmentType = "development" // tracer exporters TracerExporterOTLP TracerExporterType = "OTLP" // meter exporters MeterExporterOTLP MeterExporterType = "OTLP" // logger exporters LoggerExporterOTLP LoggerExporterType = "otlp" )
Variables ¶
This section is empty.
Functions ¶
func ConvertToAttributes ¶
ConvertToAttributes converts a plain map[string]interface{} into OTEL []attribute.KeyValue, supporting all common primitive types.
Types ¶
type EnvironmentType ¶
type EnvironmentType string // e.g., "production", "staging", "development"
type LoggerExporterType ¶
type LoggerExporterType string // e.g., "OTLP", "Prometheus", etc.
type MeterExporterType ¶
type MeterExporterType string // e.g., "OTLP", "Prometheus", etc.
type Options ¶
type Options struct {
ServiceName string // Name of the service
SampleRate float64 // Between 0.0 and 1.0 for trace sampling rate
Environment EnvironmentType // e.g., "production", "staging", "development"
NoOpTracer bool // If true, no tracing will be performed
TracerExporter TracerExporterType // exporter type, e.g., grafana tempo
TracerEndpoint *RemoteEndpoint // remote endpoint for tracing
NoOpMeter bool // If true, no metrics will be collected
MeterExporter MeterExporterType // exporter type, e.g., otel-collector+prometheus
MeterEndpoint *RemoteEndpoint // remote endpoint for metrics collection
NoOpLogger bool // If true, no logging will be performed
LoggerExporter LoggerExporterType // exporter type, e.g., otel-collector+prometheus
LoggerEndpoint *RemoteEndpoint // remote endpoint for logging
}
type RemoteEndpoint ¶
func (*RemoteEndpoint) AsString ¶
func (oe *RemoteEndpoint) AsString() string
type Telemetry ¶
type Telemetry struct {
Tracer trace.Tracer
Meter metric.Meter
Logger log.Logger
// contains filtered or unexported fields
}
func Get ¶
func Get() *Telemetry
Get returns the initialized Telemetry instance or a no-op instance when telemetry has not been initialized.
func InitTelemetry ¶
InitTelemetry initializes OpenTelemetry with the provided options.
func InitTelemetryContext ¶
InitTelemetryContext initializes OpenTelemetry with the provided context and options.
type TracerExporterType ¶
type TracerExporterType string // e.g., "OTLP", "Jaeger", etc.
Source Files
¶
Click to show internal directories.
Click to hide internal directories.