Documentation
¶
Overview ¶
Package attributes provides attributes for the OpenTelemetry Collector.
Index ¶
- Constants
- Variables
- func ContainerTagFromAttributes(attr map[string]string) map[string]string
- func ContainerTagsFromResourceAttributes(attrs pcommon.Map) map[string]string
- func OriginIDFromAttributes(attrs pcommon.Map) (originID string)
- func SourceFromAttrs(attrs pcommon.Map, hostFromAttributesHandler HostFromAttributesHandler) (source.Source, bool)
- func TagsFromAttributes(attrs pcommon.Map) []string
- type GatewayUsage
- type HostFromAttributesHandler
- type Translator
Constants ¶
const ( // AttributeDatadogHostname the datadog host name attribute AttributeDatadogHostname = "datadog.host.name" // AttributeK8sNodeName the datadog k8s node name attribute AttributeK8sNodeName = "k8s.node.name" // AttributeHost is a literal host tag. // We check for this to avoid double tagging. AttributeHost = "host" )
Variables ¶
var ( // ContainerMappings defines the mapping between OpenTelemetry semantic conventions // and Datadog Agent conventions for containers. ContainerMappings = map[string]string{ string(semconv127.ContainerIDKey): "container_id", string(semconv127.ContainerNameKey): "container_name", string(semconv127.ContainerImageNameKey): "image_name", string(conventions.ContainerImageTagKey): "image_tag", string(semconv127.ContainerRuntimeKey): "runtime", string(semconv127.CloudProviderKey): "cloud_provider", string(semconv127.CloudRegionKey): "region", string(semconv127.CloudAvailabilityZoneKey): "zone", string(semconv127.AWSECSTaskFamilyKey): "task_family", string(semconv127.AWSECSTaskARNKey): "task_arn", string(semconv127.AWSECSClusterARNKey): "ecs_cluster_name", string(semconv127.AWSECSTaskRevisionKey): "task_version", string(semconv127.AWSECSContainerARNKey): "ecs_container_name", string(semconv127.K8SContainerNameKey): "kube_container_name", string(semconv127.K8SClusterNameKey): "kube_cluster_name", string(semconv127.K8SDeploymentNameKey): "kube_deployment", string(semconv127.K8SReplicaSetNameKey): "kube_replica_set", string(semconv127.K8SStatefulSetNameKey): "kube_stateful_set", string(semconv127.K8SDaemonSetNameKey): "kube_daemon_set", string(semconv127.K8SJobNameKey): "kube_job", string(semconv127.K8SCronJobNameKey): "kube_cronjob", string(semconv127.K8SNamespaceNameKey): "kube_namespace", string(semconv127.K8SPodNameKey): "pod_name", } // HTTPMappings defines the mapping between OpenTelemetry semantic conventions // and Datadog Agent conventions for HTTP attributes. HTTPMappings = map[string]string{ string(semconv127.ClientAddressKey): "http.client_ip", string(semconv127.HTTPResponseBodySizeKey): "http.response.content_length", string(semconv127.HTTPResponseStatusCodeKey): "http.status_code", string(semconv127.HTTPRequestBodySizeKey): "http.request.content_length", "http.request.header.referrer": "http.referrer", string(semconv127.HTTPRequestMethodKey): "http.method", string(semconv127.HTTPRouteKey): "http.route", string(semconv127.NetworkProtocolVersionKey): "http.version", string(semconv127.ServerAddressKey): "http.server_name", string(semconv127.URLFullKey): "http.url", string(semconv127.UserAgentOriginalKey): "http.useragent", } )
Functions ¶
func ContainerTagFromAttributes ¶
ContainerTagFromAttributes extracts the value of _dd.tags.container from the given set of attributes. Deprecated: Deprecated in favor of ContainerTagFromResourceAttributes.
func ContainerTagsFromResourceAttributes ¶
ContainerTagsFromResourceAttributes extracts container tags from the given set of resource attributes. Container tags are extracted via semantic conventions. Customer container tags are extracted via resource attributes prefixed by datadog.container.tag. Custom container tag values of a different type than ValueTypeStr will be ignored. In the case of duplicates between semantic conventions and custom resource attributes (e.g. container.id, datadog.container.tag.container_id) the semantic convention takes precedence.
func OriginIDFromAttributes ¶
OriginIDFromAttributes gets the origin IDs from resource attributes. If not found, an empty string is returned for each of them.
func SourceFromAttrs ¶
func SourceFromAttrs(attrs pcommon.Map, hostFromAttributesHandler HostFromAttributesHandler) (source.Source, bool)
SourceFromAttrs gets a telemetry signal source from its attributes. Deprecated: Use Translator.ResourceToSource or Translator.AttributesToSource instead.
func TagsFromAttributes ¶
TagsFromAttributes converts a selected list of attributes to a tag list that can be added to metrics.
Types ¶
type GatewayUsage ¶
type GatewayUsage struct {
// contains filtered or unexported fields
}
GatewayUsage is a HostFromAttributesHandler that detects if the setup is a gateway. If two attributes have different hostnames, then we consider the setup is a gateway.
func NewGatewayUsage ¶
func NewGatewayUsage() *GatewayUsage
NewGatewayUsage returns a new GatewayUsage. If two attributes have different hostnames, then we consider the setup is a gateway.
func (*GatewayUsage) GatewayUsage ¶
func (g *GatewayUsage) GatewayUsage() bool
GatewayUsage returns true if the GatewayUsage was detected.
func (*GatewayUsage) Gauge ¶
func (g *GatewayUsage) Gauge() float64
Gauge returns 1 if the GatewayUsage was detected, 0 otherwise.
func (*GatewayUsage) OnHost ¶
func (g *GatewayUsage) OnHost(host string)
OnHost implements HostFromAttributesHandler.
type HostFromAttributesHandler ¶
type HostFromAttributesHandler interface {
OnHost(string)
}
HostFromAttributesHandler calls OnHost when a hostname is extracted from attributes.
type Translator ¶
type Translator struct {
// contains filtered or unexported fields
}
Translator of attributes.
func NewTranslator ¶
func NewTranslator(set component.TelemetrySettings) (*Translator, error)
NewTranslator returns a new attributes translator.
func (*Translator) AttributesToSource ¶
AttributesToSource gets a telemetry signal source from a set of attributes. As opposed to ResourceToSource, this does not keep track of failed requests.
NOTE: This method SHOULD NOT generally be used: it is only used in the logs implementation because of a fallback logic that will be removed. The attributes detected are resource attributes, not attributes from a telemetry signal.
func (*Translator) ResourceToSource ¶
func (p *Translator) ResourceToSource(ctx context.Context, res pcommon.Resource, set attribute.Set, hostFromAttributesHandler HostFromAttributesHandler) (source.Source, bool)
ResourceToSource gets a telemetry signal source from its resource attributes.
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
Package ec2 provides EC2 attributes.
|
Package ec2 provides EC2 attributes. |
|
internal
|
|
|
testutils
Package testutils provides utilities for testing the OpenTelemetry Collector.
|
Package testutils provides utilities for testing the OpenTelemetry Collector. |
|
Package source provides a source provider for the OpenTelemetry Collector.
|
Package source provides a source provider for the OpenTelemetry Collector. |