Database span attributes semantic conventions recommended server address and port https://opentelemetry.io/docs/specs/semconv/database/database-spans/#connection-level-attributes
(opts []TracingOption, addr string)
| 227 | // Database span attributes semantic conventions recommended server address and port |
| 228 | // https://opentelemetry.io/docs/specs/semconv/database/database-spans/#connection-level-attributes |
| 229 | func addServerAttributes(opts []TracingOption, addr string) []TracingOption { |
| 230 | host, portString, err := net.SplitHostPort(addr) |
| 231 | if err != nil { |
| 232 | return opts |
| 233 | } |
| 234 | |
| 235 | opts = append(opts, WithAttributes( |
| 236 | semconv.ServerAddress(host), |
| 237 | )) |
| 238 | |
| 239 | // Parse the port string to an integer |
| 240 | port, err := strconv.Atoi(portString) |
| 241 | if err != nil { |
| 242 | return opts |
| 243 | } |
| 244 | |
| 245 | opts = append(opts, WithAttributes( |
| 246 | semconv.ServerPort(port), |
| 247 | )) |
| 248 | |
| 249 | return opts |
| 250 | } |
no test coverage detected