Documentation
¶
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" // Attribute host 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{ semconv127.AttributeContainerID: "container_id", semconv127.AttributeContainerName: "container_name", semconv127.AttributeContainerImageName: "image_name", conventions.AttributeContainerImageTag: "image_tag", semconv127.AttributeContainerRuntime: "runtime", semconv127.AttributeCloudProvider: "cloud_provider", semconv127.AttributeCloudRegion: "region", semconv127.AttributeCloudAvailabilityZone: "zone", semconv127.AttributeAWSECSTaskFamily: "task_family", semconv127.AttributeAWSECSTaskARN: "task_arn", semconv127.AttributeAWSECSClusterARN: "ecs_cluster_name", semconv127.AttributeAWSECSTaskRevision: "task_version", semconv127.AttributeAWSECSContainerARN: "ecs_container_name", semconv127.AttributeK8SContainerName: "kube_container_name", semconv127.AttributeK8SClusterName: "kube_cluster_name", semconv127.AttributeK8SDeploymentName: "kube_deployment", semconv127.AttributeK8SReplicaSetName: "kube_replica_set", semconv127.AttributeK8SStatefulSetName: "kube_stateful_set", semconv127.AttributeK8SDaemonSetName: "kube_daemon_set", semconv127.AttributeK8SJobName: "kube_job", semconv127.AttributeK8SCronJobName: "kube_cronjob", semconv127.AttributeK8SNamespaceName: "kube_namespace", semconv127.AttributeK8SPodName: "pod_name", } // HTTPMappings defines the mapping between OpenTelemetry semantic conventions // and Datadog Agent conventions for HTTP attributes. HTTPMappings = map[string]string{ semconv127.AttributeClientAddress: "http.client_ip", semconv127.AttributeHTTPResponseBodySize: "http.response.content_length", semconv127.AttributeHTTPResponseStatusCode: "http.status_code", semconv127.AttributeHTTPRequestBodySize: "http.request.content_length", "http.request.header.referrer": "http.referrer", semconv127.AttributeHTTPRequestMethod: "http.method", semconv127.AttributeHTTPRoute: "http.route", semconv127.AttributeNetworkProtocolVersion: "http.version", semconv127.AttributeServerAddress: "http.server_name", semconv127.AttributeURLFull: "http.url", semconv127.AttributeUserAgentOriginal: "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 ¶ added in v0.8.1
ContainerTagFromResourceAttributes 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 ¶ added in v0.1.3
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 ¶ added in v0.25.0
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 ¶ added in v0.25.0
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 ¶ added in v0.25.0
func (g *GatewayUsage) GatewayUsage() bool
GatewayUsage returns true if the GatewayUsage was detected.
func (*GatewayUsage) Gauge ¶ added in v0.25.0
func (g *GatewayUsage) Gauge() float64
Gauge returns 1 if the GatewayUsage was detected, 0 otherwise.
func (*GatewayUsage) OnHost ¶ added in v0.25.0
func (g *GatewayUsage) OnHost(host string)
OnHost implements HostFromAttributesHandler.
type HostFromAttributesHandler ¶ added in v0.25.0
type HostFromAttributesHandler interface {
OnHost(string)
}
HostFromAttributesHandler calls OnHost when a hostname is extracted from attributes.
type Translator ¶ added in v0.11.0
type Translator struct {
// contains filtered or unexported fields
}
Translator of attributes.
func NewTranslator ¶ added in v0.11.0
func NewTranslator(set component.TelemetrySettings) (*Translator, error)
NewTranslator returns a new attributes translator.
func (*Translator) AttributesToSource ¶ added in v0.11.0
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 ¶ added in v0.11.0
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.