MCPcopy
hub / github.com/redis/go-redis / addServerAttributes

Function addServerAttributes

extra/redisotel/tracing.go:229–250  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

227// Database span attributes semantic conventions recommended server address and port
228// https://opentelemetry.io/docs/specs/semconv/database/database-spans/#connection-level-attributes
229func 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}

Callers 1

InstrumentTracingFunction · 0.85

Calls 1

WithAttributesFunction · 0.85

Tested by

no test coverage detected