@Test public void shouldReturnDependencyWithConsumerAndProducer() { SpansToDependencyLinks spansToDependencyLinks = new SpansToDependencyLinks(""); Set<Span> sharedSpans = new HashSet<>(); sharedSpans.add(createSpan("consumerName", Tags.SPAN_KIND_CONSUMER)); sharedSpans.add(createSpan("producerName", Tags.SPAN_KIND_PRODUCER)); Optional<Dependency> result = spansToDependencyLinks.sharedSpanDependency(sharedSpans); assertTrue(result.isPresent()); assertEquals(new Dependency("producerName", "consumerName"), result.get()); }
protected Optional<Dependency> sharedSpanDependency(Set<Span> sharedSpans) { String clientService = null; String serverService = null; for (Span span: sharedSpans) { for (KeyValue tag: span.getTags()) { if (Tags.SPAN_KIND_CLIENT.equals(tag.getValueString()) || Tags.SPAN_KIND_PRODUCER.equals(tag.getValueString())) { clientService = span.getProcess().getServiceName(); } else if (Tags.SPAN_KIND_SERVER.equals(tag.getValueString()) || Tags.SPAN_KIND_CONSUMER.equals(tag.getValueString())) { serverService = span.getProcess().getServiceName(); } if (clientService != null && serverService != null) { return Optional.of(new Dependency(clientService, serverService)); } } } return Optional.empty(); }
SpansToDependencyLinks implements Function<Iterable<Span>, Iterable<Dependency>> { protected Optional<Dependency> sharedSpanDependency(Set<Span> sharedSpans) { String clientService = null; String serverService = null; for (Span span: sharedSpans) { for (KeyValue tag: span.getTags()) { if (Tags.SPAN_KIND_CLIENT.equals(tag.getValueString()) || Tags.SPAN_KIND_PRODUCER.equals(tag.getValueString())) { clientService = span.getProcess().getServiceName(); } else if (Tags.SPAN_KIND_SERVER.equals(tag.getValueString()) || Tags.SPAN_KIND_CONSUMER.equals(tag.getValueString())) { serverService = span.getProcess().getServiceName(); } if (clientService != null && serverService != null) { return Optional.of(new Dependency(clientService, serverService)); } } } return Optional.empty(); } }
SpansToDependencyLinks implements Function<Iterable<Span>, Iterable<Dependency>> { protected Optional<Dependency> sharedSpanDependency(Set<Span> sharedSpans) { String clientService = null; String serverService = null; for (Span span: sharedSpans) { for (KeyValue tag: span.getTags()) { if (Tags.SPAN_KIND_CLIENT.equals(tag.getValueString()) || Tags.SPAN_KIND_PRODUCER.equals(tag.getValueString())) { clientService = span.getProcess().getServiceName(); } else if (Tags.SPAN_KIND_SERVER.equals(tag.getValueString()) || Tags.SPAN_KIND_CONSUMER.equals(tag.getValueString())) { serverService = span.getProcess().getServiceName(); } if (clientService != null && serverService != null) { return Optional.of(new Dependency(clientService, serverService)); } } } return Optional.empty(); } SpansToDependencyLinks(String peerServiceTag); }
SpansToDependencyLinks implements Function<Iterable<Span>, Iterable<Dependency>> { protected Optional<Dependency> sharedSpanDependency(Set<Span> sharedSpans) { String clientService = null; String serverService = null; for (Span span: sharedSpans) { for (KeyValue tag: span.getTags()) { if (Tags.SPAN_KIND_CLIENT.equals(tag.getValueString()) || Tags.SPAN_KIND_PRODUCER.equals(tag.getValueString())) { clientService = span.getProcess().getServiceName(); } else if (Tags.SPAN_KIND_SERVER.equals(tag.getValueString()) || Tags.SPAN_KIND_CONSUMER.equals(tag.getValueString())) { serverService = span.getProcess().getServiceName(); } if (clientService != null && serverService != null) { return Optional.of(new Dependency(clientService, serverService)); } } } return Optional.empty(); } SpansToDependencyLinks(String peerServiceTag); @Override Iterable<Dependency> call(Iterable<Span> trace); }
SpansToDependencyLinks implements Function<Iterable<Span>, Iterable<Dependency>> { protected Optional<Dependency> sharedSpanDependency(Set<Span> sharedSpans) { String clientService = null; String serverService = null; for (Span span: sharedSpans) { for (KeyValue tag: span.getTags()) { if (Tags.SPAN_KIND_CLIENT.equals(tag.getValueString()) || Tags.SPAN_KIND_PRODUCER.equals(tag.getValueString())) { clientService = span.getProcess().getServiceName(); } else if (Tags.SPAN_KIND_SERVER.equals(tag.getValueString()) || Tags.SPAN_KIND_CONSUMER.equals(tag.getValueString())) { serverService = span.getProcess().getServiceName(); } if (clientService != null && serverService != null) { return Optional.of(new Dependency(clientService, serverService)); } } } return Optional.empty(); } SpansToDependencyLinks(String peerServiceTag); @Override Iterable<Dependency> call(Iterable<Span> trace); public String peerServiceTag; }