Search in sources :

Example 1 with AttributeValue

use of org.hypertrace.entity.data.service.v1.AttributeValue in project XobotOS by xamarin.

the class DNParser method parse.

/**
     * Parses DN
     *
     * @return a list of Relative Distinguished Names(RND),
     *         each RDN is represented as a list of AttributeTypeAndValue objects
     */
public List<List<AttributeTypeAndValue>> parse() throws IOException {
    List<List<AttributeTypeAndValue>> list = new ArrayList<List<AttributeTypeAndValue>>();
    String attType = nextAT();
    if (attType == null) {
        //empty list of RDNs
        return list;
    }
    List<AttributeTypeAndValue> atav = new ArrayList<AttributeTypeAndValue>();
    while (true) {
        if (pos == chars.length) {
            //empty Attribute Value
            atav.add(new AttributeTypeAndValue(attType, new AttributeValue("", false)));
            list.add(0, atav);
            return list;
        }
        switch(chars[pos]) {
            case '"':
                atav.add(new AttributeTypeAndValue(attType, new AttributeValue(quotedAV(), hasQE)));
                break;
            case '#':
                atav.add(new AttributeTypeAndValue(attType, new AttributeValue(hexAV(), encoded)));
                break;
            case '+':
            case ',':
            case // compatibility with RFC 1779: semicolon can separate RDNs
            ';':
                //empty attribute value
                atav.add(new AttributeTypeAndValue(attType, new AttributeValue("", false)));
                break;
            default:
                atav.add(new AttributeTypeAndValue(attType, new AttributeValue(escapedAV(), hasQE)));
        }
        if (pos >= chars.length) {
            list.add(0, atav);
            return list;
        }
        if (chars[pos] == ',' || chars[pos] == ';') {
            list.add(0, atav);
            atav = new ArrayList<AttributeTypeAndValue>();
        } else if (chars[pos] != '+') {
            throw new IOException("Invalid distinguished name string");
        }
        pos++;
        attType = nextAT();
        if (attType == null) {
            throw new IOException("Invalid distinguished name string");
        }
    }
}
Also used : AttributeValue(org.apache.harmony.security.x501.AttributeValue) ArrayList(java.util.ArrayList) List(java.util.List) ArrayList(java.util.ArrayList) IOException(java.io.IOException) AttributeTypeAndValue(org.apache.harmony.security.x501.AttributeTypeAndValue)

Example 2 with AttributeValue

use of org.hypertrace.entity.data.service.v1.AttributeValue in project robovm by robovm.

the class DNParser method parse.

/**
     * Parses DN
     *
     * @return a list of Relative Distinguished Names(RDN),
     *         each RDN is represented as a list of AttributeTypeAndValue objects
     */
public List<List<AttributeTypeAndValue>> parse() throws IOException {
    List<List<AttributeTypeAndValue>> list = new ArrayList<List<AttributeTypeAndValue>>();
    String attType = nextAT();
    if (attType == null) {
        //empty list of RDNs
        return list;
    }
    ObjectIdentifier oid = AttributeTypeAndValue.getObjectIdentifier(attType);
    List<AttributeTypeAndValue> atav = new ArrayList<AttributeTypeAndValue>();
    while (true) {
        if (pos == chars.length) {
            //empty Attribute Value
            atav.add(new AttributeTypeAndValue(oid, new AttributeValue("", false, oid)));
            list.add(0, atav);
            return list;
        }
        switch(chars[pos]) {
            case '"':
                atav.add(new AttributeTypeAndValue(oid, new AttributeValue(quotedAV(), hasQE, oid)));
                break;
            case '#':
                atav.add(new AttributeTypeAndValue(oid, new AttributeValue(hexAV(), encoded)));
                break;
            case '+':
            case ',':
            case // compatibility with RFC 1779: semicolon can separate RDNs
            ';':
                //empty attribute value
                atav.add(new AttributeTypeAndValue(oid, new AttributeValue("", false, oid)));
                break;
            default:
                atav.add(new AttributeTypeAndValue(oid, new AttributeValue(escapedAV(), hasQE, oid)));
        }
        if (pos >= chars.length) {
            list.add(0, atav);
            return list;
        }
        if (chars[pos] == ',' || chars[pos] == ';') {
            list.add(0, atav);
            atav = new ArrayList<AttributeTypeAndValue>();
        } else if (chars[pos] != '+') {
            throw new IOException("Invalid distinguished name string");
        }
        pos++;
        attType = nextAT();
        if (attType == null) {
            throw new IOException("Invalid distinguished name string");
        }
        oid = AttributeTypeAndValue.getObjectIdentifier(attType);
    }
}
Also used : AttributeValue(org.apache.harmony.security.x501.AttributeValue) ArrayList(java.util.ArrayList) List(java.util.List) ArrayList(java.util.ArrayList) IOException(java.io.IOException) AttributeTypeAndValue(org.apache.harmony.security.x501.AttributeTypeAndValue) ObjectIdentifier(org.apache.harmony.security.utils.ObjectIdentifier)

Example 3 with AttributeValue

use of org.hypertrace.entity.data.service.v1.AttributeValue in project instrumentation-java by census-instrumentation.

the class StackdriverV2ExporterHandlerProtoTest method mapHttpAttributes.

@Test
public void mapHttpAttributes() {
    Map<String, io.opencensus.trace.AttributeValue> attributesMap = new HashMap<String, io.opencensus.trace.AttributeValue>();
    attributesMap.put("http.host", io.opencensus.trace.AttributeValue.stringAttributeValue("host"));
    attributesMap.put("http.method", io.opencensus.trace.AttributeValue.stringAttributeValue("method"));
    attributesMap.put("http.path", io.opencensus.trace.AttributeValue.stringAttributeValue("path"));
    attributesMap.put("http.route", io.opencensus.trace.AttributeValue.stringAttributeValue("route"));
    attributesMap.put("http.user_agent", io.opencensus.trace.AttributeValue.stringAttributeValue("user_agent"));
    attributesMap.put("http.status_code", io.opencensus.trace.AttributeValue.longAttributeValue(200L));
    SpanData.Attributes httpAttributes = SpanData.Attributes.create(attributesMap, 0);
    SpanData spanData = SpanData.create(spanContext, parentSpanId, /* hasRemoteParent= */
    true, SPAN_NAME, null, startTimestamp, httpAttributes, annotations, messageEvents, links, CHILD_SPAN_COUNT, status, endTimestamp);
    Span span = handler.generateSpan(spanData, EMPTY_RESOURCE_LABELS, Collections.<String, AttributeValue>emptyMap());
    Map<String, AttributeValue> attributes = span.getAttributes().getAttributeMapMap();
    assertThat(attributes).containsEntry("/http/host", toStringAttributeValueProto("host"));
    assertThat(attributes).containsEntry("/http/method", toStringAttributeValueProto("method"));
    assertThat(attributes).containsEntry("/http/path", toStringAttributeValueProto("path"));
    assertThat(attributes).containsEntry("/http/route", toStringAttributeValueProto("route"));
    assertThat(attributes).containsEntry("/http/user_agent", toStringAttributeValueProto("user_agent"));
    assertThat(attributes).containsEntry("/http/status_code", AttributeValue.newBuilder().setIntValue(200L).build());
}
Also used : AttributeValue(com.google.devtools.cloudtrace.v2.AttributeValue) SpanData(io.opencensus.trace.export.SpanData) HashMap(java.util.HashMap) TruncatableString(com.google.devtools.cloudtrace.v2.TruncatableString) Span(com.google.devtools.cloudtrace.v2.Span) Test(org.junit.Test)

Example 4 with AttributeValue

use of org.hypertrace.entity.data.service.v1.AttributeValue 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 5 with AttributeValue

use of org.hypertrace.entity.data.service.v1.AttributeValue 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)

Aggregations

Test (org.junit.jupiter.api.Test)39 Entity (org.hypertrace.entity.data.service.v1.Entity)37 AttributeValue (org.hypertrace.entity.data.service.v1.AttributeValue)24 AttributeValue (org.hypertrace.core.datamodel.AttributeValue)22 BackendInfo (org.hypertrace.traceenricher.enrichment.enrichers.resolver.backend.BackendInfo)20 Event (org.hypertrace.core.datamodel.Event)12 EnrichedEntity (org.hypertrace.entity.data.service.v1.EnrichedEntity)11 AttributeValue (com.google.devtools.cloudtrace.v2.AttributeValue)10 Test (org.junit.Test)10 HashMap (java.util.HashMap)9 ByTypeAndIdentifyingAttributes (org.hypertrace.entity.data.service.v1.ByTypeAndIdentifyingAttributes)9 TestUtil.buildAttributeValue (org.hypertrace.traceenricher.TestUtil.buildAttributeValue)7 Span (zipkin2.Span)7 AttributesExtractor.toAttributeValue (zipkin2.translation.stackdriver.AttributesExtractor.toAttributeValue)7 ArrayList (java.util.ArrayList)5 List (java.util.List)5 Map (java.util.Map)4 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)4 Span (com.google.devtools.cloudtrace.v2.Span)3 TruncatableString (com.google.devtools.cloudtrace.v2.TruncatableString)3