1 // Copyright The OpenTelemetry Authors 2 // 3 // Licensed under the Apache License, Version 2.0 (the "License"); 4 // you may not use this file except in compliance with the License. 5 // You may obtain a copy of the License at 6 // 7 // http://www.apache.org/licenses/LICENSE-2.0 8 // 9 // Unless required by applicable law or agreed to in writing, software 10 // distributed under the License is distributed on an "AS IS" BASIS, 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 // See the License for the specific language governing permissions and 13 // limitations under the License. 14 15 // Package netconv provides OpenTelemetry network semantic conventions for 16 // tracing telemetry. 17 package netconv // import "go.opentelemetry.io/otel/semconv/v1.19.0/netconv" 18 19 import ( 20 "net" 21 22 "go.opentelemetry.io/otel/attribute" 23 "go.opentelemetry.io/otel/semconv/internal/v3" 24 semconv "go.opentelemetry.io/otel/semconv/v1.19.0" 25 ) 26 27 var nc = &internal.NetConv{ 28 NetHostNameKey: semconv.NetHostNameKey, 29 NetHostPortKey: semconv.NetHostPortKey, 30 NetPeerNameKey: semconv.NetPeerNameKey, 31 NetPeerPortKey: semconv.NetPeerPortKey, 32 NetSockFamilyKey: semconv.NetSockFamilyKey, 33 NetSockPeerAddrKey: semconv.NetSockPeerAddrKey, 34 NetSockPeerPortKey: semconv.NetSockPeerPortKey, 35 NetSockHostAddrKey: semconv.NetSockHostAddrKey, 36 NetSockHostPortKey: semconv.NetSockHostPortKey, 37 NetTransportOther: semconv.NetTransportOther, 38 NetTransportTCP: semconv.NetTransportTCP, 39 NetTransportUDP: semconv.NetTransportUDP, 40 NetTransportInProc: semconv.NetTransportInProc, 41 } 42 43 // Transport returns a trace attribute describing the transport protocol of the 44 // passed network. See the net.Dial for information about acceptable network 45 // values. 46 func Transport(network string) attribute.KeyValue { 47 return nc.Transport(network) 48 } 49 50 // Client returns trace attributes for a client network connection to address. 51 // See net.Dial for information about acceptable address values, address should 52 // be the same as the one used to create conn. If conn is nil, only network 53 // peer attributes will be returned that describe address. Otherwise, the 54 // socket level information about conn will also be included. 55 func Client(address string, conn net.Conn) []attribute.KeyValue { 56 return nc.Client(address, conn) 57 } 58 59 // Server returns trace attributes for a network listener listening at address. 60 // See net.Listen for information about acceptable address values, address 61 // should be the same as the one used to create ln. If ln is nil, only network 62 // host attributes will be returned that describe address. Otherwise, the 63 // socket level information about ln will also be included. 64 func Server(address string, ln net.Listener) []attribute.KeyValue { 65 return nc.Server(address, ln) 66 } 67