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");
}
}
}
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);
}
}
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());
}
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");
}
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");
}
Aggregations