@@ -84,6 +84,13 @@ namespace telemetry
84
84
}
85
85
86
86
87
+ /*
88
+ Note: See [1] for relevant OTel semantic conventions for connection-level
89
+ attributes.
90
+
91
+ [1] https://github.com/open-telemetry/semantic-conventions/blob/main/docs/database/database-spans.md#connection-level-attributes
92
+ */
93
+
87
94
void
88
95
Telemetry_base<MySQL_Connection>::set_attribs(
89
96
MySQL_Connection* con,
@@ -98,19 +105,23 @@ namespace telemetry
98
105
switch (endpoint.Protocol ())
99
106
{
100
107
case NativeAPI::PROTOCOL_TCP:
101
- transport = " ip_tcp" ;
108
+ transport = " tcp" ;
109
+ // TODO: If we can somehow detect IPv6 connections then "network.type"
110
+ // should be set to "ipv6"
111
+ span->SetAttribute (" network.type" , " ipv4" );
102
112
break ;
103
113
case NativeAPI::PROTOCOL_SOCKET:
104
- span->SetAttribute (" net.sock.family" , " unix" );
114
+ transport = " socket" ;
115
+ span->SetAttribute (" network.type" , " unix" );
105
116
case NativeAPI::PROTOCOL_PIPE:
106
117
transport = " pipe" ;
107
118
break ;
108
119
default :
109
120
transport = " other" ;
110
121
}
111
122
112
- span->SetAttribute (" net .transport" , transport);
113
- span->SetAttribute (" net.peer.name " , endpoint.Host ().c_str ());
123
+ span->SetAttribute (" network .transport" , transport);
124
+ span->SetAttribute (" server.address " , endpoint.Host ().c_str ());
114
125
115
126
/*
116
127
Note: `endpoint.hasPort()` alone is not good because it tells whether
@@ -122,7 +133,7 @@ namespace telemetry
122
133
123
134
if (options.count (OPT_PORT) || endpoint.hasPort ())
124
135
{
125
- span->SetAttribute (" net.peer .port" , endpoint.Port ());
136
+ span->SetAttribute (" server .port" , endpoint.Port ());
126
137
}
127
138
}
128
139
0 commit comments