| 1 |
// Copyright The OpenTelemetry Authors |
| 2 |
// SPDX-License-Identifier: Apache-2.0 |
| 3 |
|
| 4 |
// Package netconv provides OpenTelemetry network semantic conventions for |
| 5 |
// tracing telemetry. |
| 6 |
package netconv // import "go.opentelemetry.io/otel/semconv/v1.17.0/netconv" |
| 7 |
|
| 8 |
import ( |
| 9 |
"net" |
| 10 |
|
| 11 |
"go.opentelemetry.io/otel/attribute" |
| 12 |
"go.opentelemetry.io/otel/semconv/internal/v2" |
| 13 |
semconv "go.opentelemetry.io/otel/semconv/v1.17.0" |
| 14 |
) |
| 15 |
|
| 16 |
var nc = &internal.NetConv{ |
| 17 |
NetHostNameKey: semconv.NetHostNameKey, |
| 18 |
NetHostPortKey: semconv.NetHostPortKey, |
| 19 |
NetPeerNameKey: semconv.NetPeerNameKey, |
| 20 |
NetPeerPortKey: semconv.NetPeerPortKey, |
| 21 |
NetSockFamilyKey: semconv.NetSockFamilyKey, |
| 22 |
NetSockPeerAddrKey: semconv.NetSockPeerAddrKey, |
| 23 |
NetSockPeerPortKey: semconv.NetSockPeerPortKey, |
| 24 |
NetSockHostAddrKey: semconv.NetSockHostAddrKey, |
| 25 |
NetSockHostPortKey: semconv.NetSockHostPortKey, |
| 26 |
NetTransportOther: semconv.NetTransportOther, |
| 27 |
NetTransportTCP: semconv.NetTransportTCP, |
| 28 |
NetTransportUDP: semconv.NetTransportUDP, |
| 29 |
NetTransportInProc: semconv.NetTransportInProc, |
| 30 |
} |
| 31 |
|
| 32 |
// Transport returns a trace attribute describing the transport protocol of the |
| 33 |
// passed network. See the net.Dial for information about acceptable network |
| 34 |
// values. |
| 35 |
func Transport(network string) attribute.KeyValue { |
| 36 |
return nc.Transport(network) |
| 37 |
} |
| 38 |
|
| 39 |
// Client returns trace attributes for a client network connection to address. |
| 40 |
// See net.Dial for information about acceptable address values, address should |
| 41 |
// be the same as the one used to create conn. If conn is nil, only network |
| 42 |
// peer attributes will be returned that describe address. Otherwise, the |
| 43 |
// socket level information about conn will also be included. |
| 44 |
func Client(address string, conn net.Conn) []attribute.KeyValue { |
| 45 |
return nc.Client(address, conn) |
| 46 |
} |
| 47 |
|
| 48 |
// Server returns trace attributes for a network listener listening at address. |
| 49 |
// See net.Listen for information about acceptable address values, address |
| 50 |
// should be the same as the one used to create ln. If ln is nil, only network |
| 51 |
// host attributes will be returned that describe address. Otherwise, the |
| 52 |
// socket level information about ln will also be included. |
| 53 |
func Server(address string, ln net.Listener) []attribute.KeyValue { |
| 54 |
return nc.Server(address, ln) |
| 55 |
} |