transform

package
v0.69.2 Latest Latest
Warning

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

Go to latest
Published: Aug 19, 2025 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Overview

Package transform implements mappings from OTLP to DD semantics, and helpers

Index

Constants

View Source
const (
	// TagRedisRawCommand represents a redis raw command tag
	TagRedisRawCommand = "redis.raw_command"
	// TagValkeyRawCommand represents a redis raw command tag
	TagValkeyRawCommand = "valkey.raw_command"
	// TagMemcachedCommand represents a memcached command tag
	TagMemcachedCommand = "memcached.command"
	// TagMongoDBQuery represents a MongoDB query tag
	TagMongoDBQuery = "mongodb.query"
	// TagElasticBody represents an Elasticsearch body tag
	TagElasticBody = "elasticsearch.body"
	// TagOpenSearchBody represents an OpenSearch body tag
	TagOpenSearchBody = "opensearch.body"
	// TagSQLQuery represents a SQL query tag
	TagSQLQuery = "sql.query"
	// TagHTTPURL represents an HTTP URL tag
	TagHTTPURL = "http.url"
	// TagDBMS represents a DBMS tag
	TagDBMS = "db.type"
)
View Source
const (
	// KeyDatadogService is the key for the service name in the Datadog namespace
	KeyDatadogService = "datadog.service"
	// KeyDatadogName is the key for the operation name in the Datadog namespace
	KeyDatadogName = "datadog.name"
	// KeyDatadogResource is the key for the resource name in the Datadog namespace
	KeyDatadogResource = "datadog.resource"
	// KeyDatadogSpanKind is the key for the span kind in the Datadog namespace
	KeyDatadogSpanKind = "datadog.span.kind"
	// KeyDatadogType is the key for the span type in the Datadog namespace
	KeyDatadogType = "datadog.type"
	// KeyDatadogError is the key for the error flag in the Datadog namespace
	KeyDatadogError = "datadog.error"
	// KeyDatadogErrorMsg is the key for the error message in the Datadog namespace
	KeyDatadogErrorMsg = "datadog.error.msg"
	// KeyDatadogErrorType is the key for the error type in the Datadog namespace
	KeyDatadogErrorType = "datadog.error.type"
	// KeyDatadogErrorStack is the key for the error stack in the Datadog namespace
	KeyDatadogErrorStack = "datadog.error.stack"
	// KeyDatadogVersion is the key for the version in the Datadog namespace
	KeyDatadogVersion = "datadog.version"
	// KeyDatadogHTTPStatusCode is the key for the HTTP status code in the Datadog namespace
	KeyDatadogHTTPStatusCode = "datadog.http_status_code"
	// KeyDatadogHost is the key for the host in the Datadog namespace
	KeyDatadogHost = "datadog.host"
	// KeyDatadogEnvironment is the key for the environment in the Datadog namespace
	KeyDatadogEnvironment = "datadog.env"
	// KeyDatadogContainerID is the key for the container ID in the Datadog namespace
	KeyDatadogContainerID = "datadog.container_id"
	// KeyDatadogContainerTags is the key for the container tags in the Datadog namespace
	KeyDatadogContainerTags = "datadog.container_tags"
)
View Source
const (
	// TextNonParsable is the error text used when a query is non-parsable
	TextNonParsable = "Non-parsable SQL query"
)

Variables

This section is empty.

Functions

func GetDDKeyForOTLPAttribute added in v0.65.0

func GetDDKeyForOTLPAttribute(k string) string

GetDDKeyForOTLPAttribute looks for a key in the Datadog HTTP convention that matches the given key from the OTLP HTTP convention. Otherwise, check if it is a Datadog APM convention key - if it is, it will be handled with specialized logic elsewhere, so return an empty string. If it isn't, return the original key.

func GetFirstFromMap

func GetFirstFromMap(m map[string]string, keys ...string) (string, string)

GetFirstFromMap checks each key in the given keys in the map and returns the first key-value pair whose key matches, or empty strings if none matches.

func GetOTelContainerID added in v0.68.0

func GetOTelContainerID(span ptrace.Span, res pcommon.Resource, ignoreMissingDatadogFields bool) string

GetOTelContainerID returns the container ID based on OTel span and resource attributes, with span taking precedence.

func GetOTelContainerTags added in v0.68.0

func GetOTelContainerTags(rattrs pcommon.Map, tagKeys []string) []string

GetOTelContainerTags returns a list of DD container tags in the OTel resource attributes. Tags are always normalized.

func GetOTelEnv added in v0.68.0

func GetOTelEnv(span ptrace.Span, res pcommon.Resource, ignoreMissingDatadogFields bool) string

GetOTelEnv returns the environment based on OTel span and resource attributes, with span taking precedence.

func GetOTelHostname added in v0.68.0

func GetOTelHostname(span ptrace.Span, res pcommon.Resource, tr *attributes.Translator, fallbackHost string, ignoreMissingDatadogFields bool) string

GetOTelHostname returns the DD hostname based on OTel span and resource attributes, with span taking precedence.

func GetOTelStatusCode added in v0.68.0

func GetOTelStatusCode(span ptrace.Span, res pcommon.Resource, ignoreMissingDatadogFields bool) uint32

GetOTelStatusCode returns the HTTP status code based on OTel span and resource attributes, with span taking precedence.

func GetOTelVersion added in v0.68.0

func GetOTelVersion(span ptrace.Span, res pcommon.Resource, ignoreMissingDatadogFields bool) string

GetOTelVersion returns the version based on OTel span and resource attributes, with span taking precedence.

func MarshalEvents

func MarshalEvents(events ptrace.SpanEventSlice) string

MarshalEvents marshals events into JSON.

func MarshalLinks(links ptrace.SpanLinkSlice) string

MarshalLinks marshals span links into JSON.

func ObfuscateRedisSpan added in v0.63.0

func ObfuscateRedisSpan(o *obfuscate.Obfuscator, span *pb.Span, removeAllArgs bool)

ObfuscateRedisSpan obfuscates a Redis span using pkg/obfuscate logic

func ObfuscateSQLSpan added in v0.63.0

func ObfuscateSQLSpan(o *obfuscate.Obfuscator, span *pb.Span) (*obfuscate.ObfuscatedQuery, error)

ObfuscateSQLSpan obfuscates a SQL span using pkg/obfuscate logic

func ObfuscateValkeySpan added in v0.64.0

func ObfuscateValkeySpan(o *obfuscate.Obfuscator, span *pb.Span, removeAllArgs bool)

ObfuscateValkeySpan obfuscates a Valkey span using pkg/obfuscate logic

func OperationAndResourceNameV2Enabled added in v0.61.0

func OperationAndResourceNameV2Enabled(conf *config.AgentConfig) bool

OperationAndResourceNameV2Enabled checks if the new operation and resource name logic should be used

func OtelSpanToDDSpan

func OtelSpanToDDSpan(
	otelspan ptrace.Span,
	otelres pcommon.Resource,
	lib pcommon.InstrumentationScope,
	conf *config.AgentConfig,
) *pb.Span

OtelSpanToDDSpan converts an OTel span to a DD span.

func OtelSpanToDDSpanMinimal

func OtelSpanToDDSpanMinimal(
	otelspan ptrace.Span,
	otelres pcommon.Resource,
	lib pcommon.InstrumentationScope,
	isTopLevel, topLevelByKind bool,
	conf *config.AgentConfig,
	peerTagKeys []string,
) *pb.Span

OtelSpanToDDSpanMinimal otelSpanToDDSpan converts an OTel span to a DD span. The converted DD span only has the minimal number of fields for APM stats calculation and is only meant to be used in OTLPTracesToConcentratorInputs. Do not use them for other purposes.

func SetMetaOTLP

func SetMetaOTLP(s *pb.Span, k, v string)

SetMetaOTLP sets the k/v OTLP attribute pair as a tag on span s.

func SetMetaOTLPIfEmpty added in v0.68.0

func SetMetaOTLPIfEmpty(s *pb.Span, k, v string)

SetMetaOTLPIfEmpty sets the k/v OTLP attribute pair as a tag on span s, if the corresponding value hasn't been set already.

func SetMetricOTLP

func SetMetricOTLP(s *pb.Span, k string, v float64)

SetMetricOTLP sets the k/v OTLP attribute pair as a metric on span s.

func SetMetricOTLPIfEmpty added in v0.68.0

func SetMetricOTLPIfEmpty(s *pb.Span, k string, v float64)

SetMetricOTLPIfEmpty sets the k/v OTLP attribute pair as a metric on span s, if the corresponding value hasn't been set already.

func Status2Error

func Status2Error(status ptrace.Status, events ptrace.SpanEventSlice, metaMap map[string]string) int32

Status2Error checks the given status and events and applies any potential error and messages to the given span attributes.

func TagSpanIfContainsExceptionEvent added in v0.61.0

func TagSpanIfContainsExceptionEvent(otelspan ptrace.Span, ddspan *pb.Span)

TagSpanIfContainsExceptionEvent tags spans that contain at least on exception span event.

Types

This section is empty.

Jump to

Keyboard shortcuts

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