Skip to content

Commit

Permalink
Remove usage of deprecated host.hostname (open-telemetry#2139)
Browse files Browse the repository at this point in the history
Fixes open-telemetry#2029

Signed-off-by: Bogdan Drutu <[email protected]>
  • Loading branch information
bogdandrutu authored Nov 18, 2020
1 parent 8431b67 commit 8b9b7d5
Show file tree
Hide file tree
Showing 8 changed files with 11 additions and 15 deletions.
6 changes: 2 additions & 4 deletions internal/goldendataset/resource_generator.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,9 +92,8 @@ func generateCloudVMAttributes() map[string]interface{} {
attrMap[conventions.AttributeTelemetrySDKLanguage] = conventions.AttributeSDKLangValueJava
attrMap[conventions.AttributeTelemetrySDKName] = "opentelemetry"
attrMap[conventions.AttributeTelemetrySDKVersion] = "0.3.0"
attrMap[conventions.AttributeHostHostname] = "env-check"
attrMap[conventions.AttributeHostID] = "57e8add1f79a454bae9fb1f7756a009a"
attrMap[conventions.AttributeHostName] = "10.0.0.4"
attrMap[conventions.AttributeHostName] = "env-check"
attrMap[conventions.AttributeHostImageID] = "5.3.0-1020-azure"
attrMap[conventions.AttributeHostType] = "B1ms"
attrMap[conventions.AttributeCloudProvider] = "azure"
Expand All @@ -111,8 +110,7 @@ func generateOnpremK8sAttributes() map[string]interface{} {
attrMap[conventions.AttributeK8sNamespace] = "cert-manager"
attrMap[conventions.AttributeK8sDeployment] = "cm-1-cert-manager"
attrMap[conventions.AttributeK8sPod] = "cm-1-cert-manager-6448b4949b-t2jtd"
attrMap[conventions.AttributeHostHostname] = "docker-desktop"
attrMap[conventions.AttributeHostName] = "192.168.65.3"
attrMap[conventions.AttributeHostName] = "docker-desktop"
return attrMap
}

Expand Down
4 changes: 2 additions & 2 deletions receiver/otlpreceiver/otlp_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ var traceJSON = []byte(`
"resource": {
"attributes": [
{
"key": "host.hostname",
"key": "host.name",
"value": { "stringValue": "testHost" }
}
]
Expand Down Expand Up @@ -98,7 +98,7 @@ var resourceSpansOtlp = otlptrace.ResourceSpans{
Resource: otlpresource.Resource{
Attributes: []otlpcommon.KeyValue{
{
Key: conventions.AttributeHostHostname,
Key: conventions.AttributeHostName,
Value: &otlpcommon.AnyValue{Value: &otlpcommon.AnyValue_StringValue{StringValue: "testHost"}},
},
},
Expand Down
2 changes: 0 additions & 2 deletions translator/conventions/opentelemetry.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ const (
AttributeFaasInstance = "faas.instance"
AttributeFaasName = "faas.name"
AttributeFaasVersion = "faas.version"
AttributeHostHostname = "host.hostname"
AttributeHostID = "host.id"
AttributeHostImageID = "host.image.id"
AttributeHostImageName = "host.image.name"
Expand Down Expand Up @@ -111,7 +110,6 @@ func GetResourceSemanticConventionAttributeNames() []string {
AttributeFaasInstance,
AttributeFaasName,
AttributeFaasVersion,
AttributeHostHostname,
AttributeHostID,
AttributeHostImageID,
AttributeHostImageName,
Expand Down
2 changes: 1 addition & 1 deletion translator/internaldata/metrics_to_oc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ import (
func TestMetricsToOC(t *testing.T) {
sampleMetricData := testdata.GeneratMetricsAllTypesWithSampleDatapoints()
attrs := sampleMetricData.ResourceMetrics().At(0).Resource().Attributes()
attrs.Upsert(conventions.AttributeHostHostname, pdata.NewAttributeValueString("host1"))
attrs.Upsert(conventions.AttributeHostName, pdata.NewAttributeValueString("host1"))
attrs.Upsert(conventions.OCAttributeProcessID, pdata.NewAttributeValueInt(123))
attrs.Upsert(conventions.OCAttributeProcessStartTime, pdata.NewAttributeValueString("2020-02-11T20:26:00Z"))
attrs.Upsert(conventions.AttributeTelemetrySDKLanguage, pdata.NewAttributeValueString("cpp"))
Expand Down
2 changes: 1 addition & 1 deletion translator/internaldata/oc_testdata_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -498,7 +498,7 @@ func generateResourceWithOcNodeAndResource() pdata.Resource {
resource := pdata.NewResource()
resource.Attributes().InitFromMap(map[string]pdata.AttributeValue{
conventions.OCAttributeProcessStartTime: pdata.NewAttributeValueString("2020-02-11T20:26:00Z"),
conventions.AttributeHostHostname: pdata.NewAttributeValueString("host1"),
conventions.AttributeHostName: pdata.NewAttributeValueString("host1"),
conventions.OCAttributeProcessID: pdata.NewAttributeValueInt(123),
conventions.AttributeTelemetrySDKVersion: pdata.NewAttributeValueString("v2.0.1"),
conventions.OCAttributeExporterVersion: pdata.NewAttributeValueString("v1.2.0"),
Expand Down
2 changes: 1 addition & 1 deletion translator/internaldata/oc_to_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ func ocNodeResourceToInternal(ocNode *occommon.Node, ocResource *ocresource.Reso
attrs.UpsertString(conventions.OCAttributeProcessStartTime, ocNode.Identifier.StartTimestamp.AsTime().Format(time.RFC3339Nano))
}
if ocNode.Identifier.HostName != "" {
attrs.UpsertString(conventions.AttributeHostHostname, ocNode.Identifier.HostName)
attrs.UpsertString(conventions.AttributeHostName, ocNode.Identifier.HostName)
}
if ocNode.Identifier.Pid != 0 {
attrs.UpsertInt(conventions.OCAttributeProcessID, int64(ocNode.Identifier.Pid))
Expand Down
2 changes: 1 addition & 1 deletion translator/internaldata/resource_to_oc.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ func internalResourceToOC(resource pdata.Resource) (*occommon.Node, *ocresource.
ocNode.Identifier = &occommon.ProcessIdentifier{}
}
ocNode.Identifier.StartTimestamp = ts
case conventions.AttributeHostHostname:
case conventions.AttributeHostName:
if ocNode.Identifier == nil {
ocNode.Identifier = &occommon.ProcessIdentifier{}
}
Expand Down
6 changes: 3 additions & 3 deletions translator/trace/jaeger/jaegerproto_to_traces.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,9 +118,9 @@ func jProcessToInternalResource(process *model.Process, dest pdata.Resource) {
// translateHostnameAttr translates "hostname" atttribute
func translateHostnameAttr(attrs pdata.AttributeMap) {
hostname, hostnameFound := attrs.Get("hostname")
_, convHostnameFound := attrs.Get(conventions.AttributeHostHostname)
if hostnameFound && !convHostnameFound {
attrs.Insert(conventions.AttributeHostHostname, hostname)
_, convHostNameFound := attrs.Get(conventions.AttributeHostName)
if hostnameFound && !convHostNameFound {
attrs.Insert(conventions.AttributeHostName, hostname)
attrs.Delete("hostname")
}
}
Expand Down

0 comments on commit 8b9b7d5

Please sign in to comment.