Search in sources :

Example 46 with Endpoint

use of com.google.cloud.servicedirectory.v1.Endpoint in project zipkin-gcp by openzipkin.

the class AttributesExtractorTest method testEndpointWithNullServiceName.

@Test
public void testEndpointWithNullServiceName() {
    Endpoint.Builder serverEndpointBuilder = Endpoint.newBuilder().port(80);
    Endpoint serverEndpoint = serverEndpointBuilder.build();
    Span serverSpan = Span.newBuilder().kind(Kind.SERVER).traceId("4").name("test-span").id("5").localEndpoint(serverEndpoint).build();
    AttributesExtractor extractor = new AttributesExtractor(Collections.emptyMap());
    Map<String, AttributeValue> serverLabels = extractor.extract(serverSpan).getAttributeMapMap();
    assertThat(serverLabels).doesNotContainKey("endpoint.serviceName");
}
Also used : AttributeValue(com.google.devtools.cloudtrace.v2.AttributeValue) AttributesExtractor.toAttributeValue(zipkin2.translation.stackdriver.AttributesExtractor.toAttributeValue) Endpoint(zipkin2.Endpoint) Span(zipkin2.Span) Test(org.junit.Test)

Example 47 with Endpoint

use of com.google.cloud.servicedirectory.v1.Endpoint in project zipkin-gcp by openzipkin.

the class AttributesExtractorTest method testEndpointIsSetIpv4.

@Test
public void testEndpointIsSetIpv4() {
    Endpoint.Builder serverEndpointBuilder = Endpoint.newBuilder().serviceName("service1").port(80);
    serverEndpointBuilder.parseIp("10.0.0.1");
    Endpoint serverEndpoint = serverEndpointBuilder.build();
    Endpoint.Builder clientEndpointBuilder = Endpoint.newBuilder().serviceName("service2").port(80);
    clientEndpointBuilder.parseIp("10.0.0.1");
    Endpoint clientEndpoint = clientEndpointBuilder.build();
    Span serverSpan = Span.newBuilder().kind(Kind.SERVER).traceId("4").name("test-span").id("5").localEndpoint(serverEndpoint).build();
    Span clientSpan = Span.newBuilder().kind(Kind.CLIENT).traceId("4").name("test-span").id("6").parentId("5").localEndpoint(clientEndpoint).build();
    AttributesExtractor extractor = new AttributesExtractor(Collections.emptyMap());
    Map<String, AttributeValue> serverLabels = extractor.extract(serverSpan).getAttributeMapMap();
    assertThat(serverLabels).containsEntry("endpoint.ipv4", toAttributeValue("10.0.0.1"));
    assertThat(serverLabels).doesNotContainKey("endpoint.ipv6");
    Map<String, AttributeValue> clientLabels = extractor.extract(clientSpan).getAttributeMapMap();
    assertThat(clientLabels).doesNotContainKeys("endpoint.ipv4", "endpoint.ipv6");
}
Also used : AttributeValue(com.google.devtools.cloudtrace.v2.AttributeValue) AttributesExtractor.toAttributeValue(zipkin2.translation.stackdriver.AttributesExtractor.toAttributeValue) Endpoint(zipkin2.Endpoint) Span(zipkin2.Span) Test(org.junit.Test)

Example 48 with Endpoint

use of com.google.cloud.servicedirectory.v1.Endpoint in project easeagent by megaease.

the class ConvertSpanReporter method convert.

static ReportSpan convert(MutableSpan span) {
    ReportSpanBuilder result = ReportSpanBuilder.newBuilder().traceId(span.traceId()).parentId(span.parentId()).id(span.id()).name(span.name());
    long start = span.startTimestamp();
    long finish = span.finishTimestamp();
    result.timestamp(start);
    if (start != 0 && finish != 0L) {
        result.duration(Math.max(finish - start, 1));
    }
    // use ordinal comparison to defend against version skew
    Kind kind = span.kind();
    if (kind != null) {
        result.kind(BRAVE_TO_ZIPKIN_KIND.get(kind));
    }
    String localServiceName = span.localServiceName();
    String localIp = span.localIp();
    if (localServiceName != null || localIp != null) {
        zipkin2.Endpoint e = Endpoint.newBuilder().serviceName(localServiceName).ip(localIp).port(span.localPort()).build();
        result.localEndpoint(ReportSpanBuilder.endpoint(e));
    }
    String remoteServiceName = span.remoteServiceName();
    String remoteIp = span.remoteIp();
    if (remoteServiceName != null || remoteIp != null) {
        zipkin2.Endpoint e = Endpoint.newBuilder().serviceName(remoteServiceName).ip(remoteIp).port(span.remotePort()).build();
        result.remoteEndpoint(ReportSpanBuilder.endpoint(e));
    }
    span.forEachTag(Consumer.INSTANCE, result);
    span.forEachAnnotation(Consumer.INSTANCE, result);
    if (span.shared())
        result.shared(true);
    if (span.debug())
        result.debug(true);
    return result.build();
}
Also used : ReportSpanBuilder(com.megaease.easeagent.report.trace.ReportSpanBuilder) Endpoint(zipkin2.Endpoint) Kind(brave.Span.Kind)

Example 49 with Endpoint

use of com.google.cloud.servicedirectory.v1.Endpoint in project java-servicedirectory by googleapis.

the class RegistrationServiceClientTest method listEndpointsTest.

@Test
public void listEndpointsTest() throws Exception {
    Endpoint responsesElement = Endpoint.newBuilder().build();
    ListEndpointsResponse expectedResponse = ListEndpointsResponse.newBuilder().setNextPageToken("").addAllEndpoints(Arrays.asList(responsesElement)).build();
    mockRegistrationService.addResponse(expectedResponse);
    ServiceName parent = ServiceName.of("[PROJECT]", "[LOCATION]", "[NAMESPACE]", "[SERVICE]");
    ListEndpointsPagedResponse pagedListResponse = client.listEndpoints(parent);
    List<Endpoint> resources = Lists.newArrayList(pagedListResponse.iterateAll());
    Assert.assertEquals(1, resources.size());
    Assert.assertEquals(expectedResponse.getEndpointsList().get(0), resources.get(0));
    List<AbstractMessage> actualRequests = mockRegistrationService.getRequests();
    Assert.assertEquals(1, actualRequests.size());
    ListEndpointsRequest actualRequest = ((ListEndpointsRequest) actualRequests.get(0));
    Assert.assertEquals(parent.toString(), actualRequest.getParent());
    Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
Also used : AbstractMessage(com.google.protobuf.AbstractMessage) ListEndpointsPagedResponse(com.google.cloud.servicedirectory.v1.RegistrationServiceClient.ListEndpointsPagedResponse) Test(org.junit.Test)

Example 50 with Endpoint

use of com.google.cloud.servicedirectory.v1.Endpoint in project java-servicedirectory by googleapis.

the class EndpointsCreate method createEndpoint.

// Create a new endpoint.
public static void createEndpoint(String projectId, String locationId, String namespaceId, String serviceId, String endpointId) throws IOException {
    // the "close" method on the client to safely clean up any remaining background resources.
    try (RegistrationServiceClient client = RegistrationServiceClient.create()) {
        // The service to create the endpoint in.
        ServiceName parent = ServiceName.of(projectId, locationId, namespaceId, serviceId);
        // The endpoint to create, with fields filled in.
        // Optionally set an IP address and port for the endpoint.
        Endpoint endpoint = Endpoint.newBuilder().setAddress("10.0.0.1").setPort(443).build();
        // Send the request to create the endpoint.
        Endpoint createdEndpoint = client.createEndpoint(parent, endpoint, endpointId);
        // Process the response.
        System.out.println("Created Endpoint: " + createdEndpoint.getName());
        System.out.println("IP Address: " + createdEndpoint.getAddress());
        System.out.println("Port: " + createdEndpoint.getPort());
    }
}
Also used : Endpoint(com.google.cloud.servicedirectory.v1.Endpoint) ServiceName(com.google.cloud.servicedirectory.v1.ServiceName) RegistrationServiceClient(com.google.cloud.servicedirectory.v1.RegistrationServiceClient)

Aggregations

Endpoint (zipkin2.Endpoint)73 Span (zipkin2.Span)33 Test (org.junit.Test)26 Test (org.junit.jupiter.api.Test)20 Endpoint (org.jboss.remoting3.Endpoint)18 V1Span (zipkin2.v1.V1Span)16 NoopHealthCheckManager (com.wavefront.agent.channel.NoopHealthCheckManager)10 SpanSampler (com.wavefront.agent.sampler.SpanSampler)10 ByteBuf (io.netty.buffer.ByteBuf)10 ChannelHandlerContext (io.netty.channel.ChannelHandlerContext)10 DefaultFullHttpRequest (io.netty.handler.codec.http.DefaultFullHttpRequest)10 FullHttpRequest (io.netty.handler.codec.http.FullHttpRequest)10 Span (wavefront.report.Span)10 Annotation (wavefront.report.Annotation)8 ServiceName (org.jboss.msc.service.ServiceName)7 RateSampler (com.wavefront.sdk.entities.tracing.sampling.RateSampler)6 IOException (java.io.IOException)6 SaslAuthenticationFactory (org.wildfly.security.auth.server.SaslAuthenticationFactory)6 SpanBytesEncoder (zipkin2.codec.SpanBytesEncoder)6 ArrayList (java.util.ArrayList)5