Skip to content

Commit

Permalink
[awsappsignals] Add hostname as an emf attribute for generic (onprem) (
Browse files Browse the repository at this point in the history
  • Loading branch information
lisguo authored Feb 29, 2024
1 parent 6a6f928 commit ad93eb1
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ import (
const AttributePlatformGeneric = "Generic"

var DefaultHostedInAttributes = map[string]string{
attr.AWSHostedInEnvironment: attr.HostedInEnvironment,
attr.AWSHostedInEnvironment: attr.HostedInEnvironment,
attr.ResourceDetectionHostName: attr.ResourceDetectionHostName,
}

type subResolver interface {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,19 @@ func TestHostedInAttributeResolverWithConflictedName(t *testing.T) {
assert.Equal(t, "self-defined", envAttr.AsString())
}

func TestHostedInAttributeResolverWithHostname(t *testing.T) {
resolver := newHostedInAttributeResolver("test", DefaultHostedInAttributes)

attributes := pcommon.NewMap()
resourceAttributes := pcommon.NewMap()
resourceAttributes.PutStr(attr.ResourceDetectionHostName, "hostname")

resolver.Process(attributes, resourceAttributes)
envAttr, ok := attributes.Get(attr.ResourceDetectionHostName)
assert.True(t, ok)
assert.Equal(t, "hostname", envAttr.AsString())
}

func TestAttributesResolver_Process(t *testing.T) {
attributes := pcommon.NewMap()
resourceAttributes := pcommon.NewMap()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ exporters:
- aws.span.kind
regex: ^(SERVER|LOCAL_ROOT)$
separator: ;
- label_names:
- host.name
regex: .*
separator: ;
metric_name_selectors:
- Latency
- Fault
Expand Down Expand Up @@ -66,6 +70,10 @@ exporters:
- aws.span.kind
regex: ^(CLIENT|PRODUCER|CONSUMER)$
separator: ;
- label_names:
- host.name
regex: .*
separator: ;
metric_name_selectors:
- Latency
- Fault
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ metric_declarations:
- label_names:
- aws.span.kind
regex: '^(SERVER|LOCAL_ROOT)$'
- label_names:
- host.name
regex: '.*'
metric_name_selectors:
- Latency
- Fault
Expand All @@ -27,6 +30,9 @@ metric_declarations:
- label_names:
- aws.span.kind
regex: '^(CLIENT|PRODUCER|CONSUMER)$'
- label_names:
- host.name
regex: '.*'
metric_name_selectors:
- Latency
- Fault
Expand Down

0 comments on commit ad93eb1

Please sign in to comment.