Skip to content

Commit

Permalink
Updated otlp network connection attributes per otel semconv (#196)
Browse files Browse the repository at this point in the history
* Updated otlp network connection attributes per otel semconv

added attribute processing for otlp log to include network connection type.

* update span tests to accommodate semconv changes
  • Loading branch information
bryce-b authored Jan 5, 2024
1 parent 343d74e commit 4f1a8bc
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 24 deletions.
12 changes: 6 additions & 6 deletions input/elasticapm/internal/modeldecoder/v2/span_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -460,12 +460,12 @@ func TestDecodeMapToSpanModel(t *testing.T) {

t.Run("network", func(t *testing.T) {
attrs := map[string]interface{}{
"net.host.connection.type": "cell",
"net.host.connection.subtype": "LTE",
"net.host.carrier.name": "Vodafone",
"net.host.carrier.mnc": "01",
"net.host.carrier.mcc": "101",
"net.host.carrier.icc": "UK",
"network.connection.type": "cell",
"network.connection.subtype": "LTE",
"network.carrier.name": "Vodafone",
"network.carrier.mnc": "01",
"network.carrier.mcc": "101",
"network.carrier.icc": "UK",
}
var input span
var event modelpb.APMEvent
Expand Down
12 changes: 6 additions & 6 deletions input/elasticapm/internal/modeldecoder/v2/transaction_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -563,12 +563,12 @@ func TestDecodeMapToTransactionModel(t *testing.T) {

t.Run("network", func(t *testing.T) {
attrs := map[string]interface{}{
"net.host.connection.type": "cell",
"net.host.connection.subtype": "LTE",
"net.host.carrier.name": "Vodafone",
"net.host.carrier.mnc": "01",
"net.host.carrier.mcc": "101",
"net.host.carrier.icc": "UK",
"network.connection.type": "cell",
"network.connection.subtype": "LTE",
"network.carrier.name": "Vodafone",
"network.carrier.mnc": "01",
"network.carrier.mcc": "101",
"network.carrier.icc": "UK",
}
var input transaction
var event modelpb.APMEvent
Expand Down
8 changes: 8 additions & 0 deletions input/otlp/logs.go
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,14 @@ func (c *Consumer) convertLogRecord(
event.Session = modelpb.SessionFromVTPool()
}
event.Session.Id = v.Str()
case attributeNetworkConnectionType:
if event.Network == nil {
event.Network = modelpb.NetworkFromVTPool()
}
if event.Network.Connection == nil {
event.Network.Connection = modelpb.NetworkConnectionFromVTPool()
}
event.Network.Connection.Type = v.Str()
default:
setLabel(replaceDots(k), event, ifaceAttributeValue(v))
}
Expand Down
12 changes: 6 additions & 6 deletions input/otlp/traces.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,12 +63,12 @@ const (
outcomeFailure = "failure"
outcomeUnknown = "unknown"

attributeNetworkConnectionType = "net.host.connection.type"
attributeNetworkConnectionSubtype = "net.host.connection.subtype"
attributeNetworkMCC = "net.host.carrier.mcc"
attributeNetworkMNC = "net.host.carrier.mnc"
attributeNetworkCarrierName = "net.host.carrier.name"
attributeNetworkICC = "net.host.carrier.icc"
attributeNetworkConnectionType = "network.connection.type"
attributeNetworkConnectionSubtype = "network.connection.subtype"
attributeNetworkMCC = "network.carrier.mcc"
attributeNetworkMNC = "network.carrier.mnc"
attributeNetworkCarrierName = "network.carrier.name"
attributeNetworkICC = "network.carrier.icc"
attributeHttpRequestMethod = "http.request.method"
attributeHttpResponseStatusCode = "http.response.status_code"
attributeServerAddress = "server.address"
Expand Down
12 changes: 6 additions & 6 deletions input/otlp/traces_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -752,12 +752,12 @@ func TestSpanTypePriorities(t *testing.T) {

func TestSpanNetworkAttributes(t *testing.T) {
networkAttributes := map[string]interface{}{
"net.host.connection.type": "cell",
"net.host.connection.subtype": "LTE",
"net.host.carrier.name": "Vodafone",
"net.host.carrier.mnc": "01",
"net.host.carrier.mcc": "101",
"net.host.carrier.icc": "UK",
"network.connection.type": "cell",
"network.connection.subtype": "LTE",
"network.carrier.name": "Vodafone",
"network.carrier.mnc": "01",
"network.carrier.mcc": "101",
"network.carrier.icc": "UK",
}
txEvent := transformTransactionWithAttributes(t, networkAttributes)
spanEvent := transformSpanWithAttributes(t, networkAttributes)
Expand Down

0 comments on commit 4f1a8bc

Please sign in to comment.