py_zipkin/thrift/__init__.py
def create_endpoint(port=0, service_name='unknown', ipv4=None, ipv6=None):
    """Create a zipkin Endpoint object.

    An Endpoint object holds information about the network context of a span.

    :param port: int value of the port. Defaults to 0
    :param service_name: service name as a str. Defaults to 'unknown'
    :param ipv4: ipv4 host address
    :param ipv6: ipv6 host address
    :returns: thrift Endpoint object
    """
    ipv4_int = 0
    ipv6_binary = None

    # Convert ip address to network byte order
    if ipv4:
        ipv4_int = struct.unpack('!i', socket.inet_pton(socket.AF_INET, ipv4))[0]

    if ipv6:
        ipv6_binary = socket.inet_pton(socket.AF_INET6, ipv6)

    # Zipkin passes unsigned values in signed types because Thrift has no
    # unsigned types, so we have to convert the value.
    port = struct.unpack('h', struct.pack('H', port))[0]
    return zipkin_core.Endpoint(
        ipv4=ipv4_int,
        ipv6=ipv6_binary,
        port=port,
        service_name=service_name,
    )
def create_endpoint(port=0, service_name='unknown', ipv4=None, ipv6=None):
    ipv4_int = 0
    ipv6_binary = None

    # Convert ip address to network byte order
    if ipv4:
        ipv4_int = struct.unpack('!i', socket.inet_pton(socket.AF_INET, ipv4))[0]

    if ipv6:
        ipv6_binary = socket.inet_pton(socket.AF_INET6, ipv6)

    # Zipkin passes unsigned values in signed types because Thrift has no
    # unsigned types, so we have to convert the value.
    port = struct.unpack('h', struct.pack('H', port))[0]
    return zipkin_core.Endpoint(
        ipv4=ipv4_int,
        ipv6=ipv6_binary,
        port=port,
        service_name=service_name,
    )
def create_endpoint ( port = 0 , service_name = 'unknown' , ipv4 = None , ipv6 = None ) : ipv4_int = 0 ipv6_binary = None # Convert ip address to network byte order if ipv4 : ipv4_int = struct . unpack ( '!i' , socket . inet_pton ( socket . AF_INET , ipv4 ) ) [ 0 ] if ipv6 : ipv6_binary = socket . inet_pton ( socket . AF_INET6 , ipv6 ) # Zipkin passes unsigned values in signed types because Thrift has no # unsigned types, so we have to convert the value. port = struct . unpack ( 'h' , struct . pack ( 'H' , port ) ) [ 0 ] return zipkin_core . Endpoint ( ipv4 = ipv4_int , ipv6 = ipv6_binary , port = port , service_name = service_name , )
Create a zipkin Endpoint object.

    An Endpoint object holds information about the network context of a span.

    :param port: int value of the port. Defaults to 0
    :param service_name: service name as a str. Defaults to 'unknown'
    :param ipv4: ipv4 host address
    :param ipv6: ipv6 host address
    :returns: thrift Endpoint object
Create a zipkin Endpoint object .