otel

package
v0.19.1221 Latest Latest
Warning

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

Go to latest
Published: Oct 1, 2026 License: AGPL-3.0 Imports: 6 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetValue

func GetValue(intValue int64, floatValue float64, dataType any) float64

https://github.com/open-telemetry/opentelemetry-proto/blob/main/opentelemetry/proto/metrics/v1/metrics.proto#L358 define two types for one datapoint value, clickhouse only use one value of float64 to store them

func SpanIDToHexOrEmptyString

func SpanIDToHexOrEmptyString(id pcommon.SpanID) string

SpanIDToHexOrEmptyString returns a hex string from SpanID. An empty string is returned, if SpanID is empty.

func SpanKindStr

func SpanKindStr(sk ptrace.SpanKind) string

SpanKindStr returns a string representation of the SpanKind as it's defined in the proto. The function provides old behavior of ptrace.SpanKind.String() to support graceful adoption of https://github.com/open-telemetry/opentelemetry-collector/pull/6250.

func StatusCodeStr

func StatusCodeStr(sk ptrace.StatusCode) string

StatusCodeStr returns a string representation of the StatusCode as it's defined in the proto. The function provides old behavior of ptrace.StatusCode.String() to support graceful adoption of https://github.com/open-telemetry/opentelemetry-collector/pull/6250.

func TraceIDToHexOrEmptyString

func TraceIDToHexOrEmptyString(id pcommon.TraceID) string

TraceIDToHexOrEmptyString returns a hex string from TraceID. An empty string is returned, if TraceID is empty.

Types

type Attribute

type Attribute struct {
	Key   string `json:"key"`
	Value struct {
		StringValue string `json:"stringValue"`
	} `json:"value,omitempty"`
	Value0 struct {
		BoolValue bool `json:"boolValue"`
	} `json:"value,omitempty"`
	Value1 struct {
		IntValue string `json:"intValue"`
	} `json:"value,omitempty"`
	Value2 struct {
		DoubleValue float64 `json:"doubleValue"`
	} `json:"value,omitempty"`
	Value3 struct {
		ArrayValue struct {
			Values []struct {
				StringValue string `json:"stringValue"`
			} `json:"values"`
		} `json:"arrayValue"`
	} `json:"value,omitempty"`
	Value4 struct {
		KvlistValue struct {
			Values []struct {
				Key   string `json:"key"`
				Value struct {
					StringValue string `json:"stringValue"`
				} `json:"value"`
			} `json:"values"`
		} `json:"kvlistValue"`
	} `json:"value,omitempty"`
}

type Body

type Body struct {
	StringValue string `json:"stringValue"`
}

type OTLPLogExportRequest

type OTLPLogExportRequest struct {
	ResourceLogs []struct {
		Resource  `json:"resource"`
		ScopeLogs []struct {
			SchemaURL  string `json:"schemaUrl,omitempty"`
			Scope      Scope  `json:"scope"`
			LogRecords []struct {
				TimeUnixNano           string      `json:"timeUnixNano"`
				SeverityNumber         int         `json:"severityNumber"`
				SeverityText           string      `json:"severityText"`
				ServiceName            string      `json:"serviceName"`
				Flags                  int         `json:"flags,omitempty"`
				DroppedAttributesCount int         `json:"droppedAttributesCount"`
				TraceID                string      `json:"traceId"`
				SpanID                 string      `json:"spanId"`
				Body                   Body        `json:"body"`
				Attributes             []Attribute `json:"attributes"`
			} `json:"logRecords"`
		} `json:"scopeLogs"`
	} `json:"resourceLogs"`
}

type OTLPMetricExportRequest

type OTLPMetricExportRequest struct {
	ResourceMetrics []struct {
		Resource struct {
			Attributes []struct {
				Key   string `json:"key"`
				Value struct {
					StringValue string `json:"stringValue"`
				} `json:"value"`
			} `json:"attributes"`
		} `json:"resource"`
		ScopeMetrics []struct {
			Scope   struct{} `json:"scope"`
			Metrics []struct {
				Name string `json:"name"`
				Unit string `json:"unit"`
				Sum  struct {
					DataPoints []struct {
						Attributes []struct {
							Key   string `json:"key"`
							Value struct {
								StringValue string `json:"stringValue"`
							} `json:"value"`
						} `json:"attributes"`
						StartTimeUnixNano string `json:"startTimeUnixNano"`
						TimeUnixNano      string `json:"timeUnixNano"`
						AsInt             string `json:"asInt"`
					} `json:"dataPoints"`
					AggregationTemporality int  `json:"aggregationTemporality"`
					IsMonotonic            bool `json:"isMonotonic"`
				} `json:"sum"`
			} `json:"metrics"`
		} `json:"scopeMetrics"`
	} `json:"resourceMetrics"`
}

NOTE(jm): we have to define this here, because the `pmetricotlp.ExportRequest` type is actually a hidden type and means we would have to define this otherwise.

Instead, we use https://mholt.github.io/json-to-go/ to generate the types from the example JSON in the OTEL examples here: https://opentelemetry.io/docs/specs/otel/protocol/file-exporter/#examples

type OTLPTraceExportRequest

type OTLPTraceExportRequest struct {
	ResourceSpans []struct {
		Resource struct {
			Attributes []struct {
				Key   string `json:"key"`
				Value struct {
					StringValue string `json:"stringValue"`
				} `json:"value"`
			} `json:"attributes"`
		} `json:"resource"`
		ScopeSpans []struct {
			Scope struct {
				Name       string `json:"name"`
				Version    string `json:"version"`
				Attributes []struct {
					Key   string `json:"key"`
					Value struct {
						StringValue string `json:"stringValue"`
					} `json:"value"`
				} `json:"attributes"`
			} `json:"scope"`
			Spans []struct {
				TraceID           string `json:"traceId"`
				SpanID            string `json:"spanId"`
				ParentSpanID      string `json:"parentSpanId"`
				Name              string `json:"name"`
				StartTimeUnixNano string `json:"startTimeUnixNano"`
				EndTimeUnixNano   string `json:"endTimeUnixNano"`
				Kind              int    `json:"kind"`
				Attributes        []struct {
					Key   string `json:"key"`
					Value struct {
						StringValue string `json:"stringValue"`
					} `json:"value"`
				} `json:"attributes"`
			} `json:"spans"`
		} `json:"scopeSpans"`
	} `json:"resourceSpans"`
}

NOTE(jm): we have to define this here, because the `ptraceotlp.ExportRequest` type is actually a hidden type and means we would have to define this otherwise.

Instead, we use https://mholt.github.io/json-to-go/ to generate the types from the example JSON in the OTEL examples here: https://github.com/open-telemetry/opentelemetry-proto/blob/main/examples/trace.json

type Resource

type Resource struct {
	Attributes []Attribute `json:"attributes"`
}

type Scope

type Scope struct {
	Name                   string      `json:"name,omitempty"`
	Version                string      `json:"version,omitempty"`
	Attributes             []Attribute `json:"attributes,omitempty"`
	DroppedAttributesCount uint32      `json:"droppedAttributesCount,omitempty"`
}

Jump to

Keyboard shortcuts

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