io.opentracing.Span Java Examples
The following examples show how to use
io.opentracing.Span.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: TracingRedisAdvancedClusterCommands.java From java-redis-client with Apache License 2.0 | 6 votes |
@Override @Deprecated public Long zrangebyscore(ValueStreamingChannel<V> channel, K key, String min, String max) { Span span = helper.buildSpan("zrangebyscore", key); span.setTag("min", min); span.setTag("max", max); try { return commands.zrangebyscore(channel, key, min, max); } catch (Exception e) { onError(e, span); throw e; } finally { span.finish(); } }
Example #2
Source File: TracingRedisAdvancedClusterCommands.java From java-redis-client with Apache License 2.0 | 6 votes |
@Override @Deprecated public List<V> zrangebylex(K key, String min, String max, long offset, long count) { Span span = helper.buildSpan("zrangebylex", key); span.setTag("min", min); span.setTag("max", max); span.setTag("offset", offset); span.setTag("count", count); try { return commands.zrangebylex(key, min, max, offset, count); } catch (Exception e) { onError(e, span); throw e; } finally { span.finish(); } }
Example #3
Source File: HandlerInterceptorSpanDecorator.java From java-specialagent with Apache License 2.0 | 6 votes |
@Override public void onPreHandle(HttpServletRequest httpServletRequest, Object handler, Span span) { Map<String, Object> logs = new HashMap<>(3); logs.put("event", "preHandle"); logs.put(HandlerUtils.HANDLER, handler); String metaData = HandlerUtils.className(handler); if (metaData != null) { logs.put(HandlerUtils.HANDLER_CLASS_NAME, metaData); } metaData = HandlerUtils.methodName(handler); if (metaData != null) { logs.put(HandlerUtils.HANDLER_METHOD_NAME, metaData); } span.log(logs); }
Example #4
Source File: ErrorReportingTest.java From opentracing-java with Apache License 2.0 | 6 votes |
@Test public void testCallbackError() { final Span span = tracer.buildSpan("one").start(); executor.submit(new Runnable() { @Override public void run() { try (Scope scope = tracer.activateSpan(span)) { throw new RuntimeException("Invalid state"); } catch (Exception exc) { Tags.ERROR.set(span, true); } finally { span.finish(); } } }); await().atMost(5, TimeUnit.SECONDS).until(finishedSpansSize(tracer), equalTo(1)); List<MockSpan> spans = tracer.finishedSpans(); assertEquals(spans.size(), 1); assertEquals(spans.get(0).tags().get(Tags.ERROR.getKey()), true); }
Example #5
Source File: SubscriptionService.java From nakadi with MIT License | 6 votes |
public ItemsWrapper<SubscriptionEventTypeStats> getSubscriptionStat(final String subscriptionId, final StatsMode statsMode, final Span span) throws InconsistentStateException, NoSuchEventTypeException, NoSuchSubscriptionException, ServiceTemporarilyUnavailableException { final Subscription subscription; try { subscription = subscriptionRepository.getSubscription(subscriptionId); authorizationValidator.authorizeSubscriptionView(subscription); } catch (final ServiceTemporarilyUnavailableException ex) { TracingService.logErrorInSpan(span, ex); throw new InconsistentStateException(ex.getMessage()); } final List<SubscriptionEventTypeStats> subscriptionStat = createSubscriptionStat(subscription, statsMode); return new ItemsWrapper<>(subscriptionStat); }
Example #6
Source File: TracingContextProvider.java From thorntail with Apache License 2.0 | 6 votes |
@Override public MiniConProp.ContextSnapshot capture() { Tracer tracer = GlobalTracer.get(); ScopeManager scopeManager = tracer.scopeManager(); Scope activeScope = scopeManager.active(); if (activeScope != null) { Span span = activeScope.span(); return () -> { Scope propagated = scopeManager.activate(span, false); return propagated::close; }; } return MiniConProp.ContextSnapshot.NOOP; }
Example #7
Source File: TracingRedisAdvancedClusterCommands.java From java-redis-client with Apache License 2.0 | 6 votes |
@Override public List<ScoredValue<V>> zrangebyscoreWithScores(K key, Range<? extends Number> range, Limit limit) { Span span = helper.buildSpan("zrangebyscoreWithScores", key); span.setTag("range", range == null ? "null" : range.toString()); span.setTag("limit", limit == null ? "null" : limit.toString()); try { return commands.zrangebyscoreWithScores(key, range, limit); } catch (Exception e) { onError(e, span); throw e; } finally { span.finish(); } }
Example #8
Source File: TracingJedisCluster.java From java-redis-client with Apache License 2.0 | 5 votes |
@Override public Long zremrangeByScore(String key, String start, String end) { Span span = helper.buildSpan("zremrangeByScore", key); span.setTag("start", start); span.setTag("end", end); try { return super.zremrangeByScore(key, start, end); } catch (Exception e) { onError(e, span); throw e; } finally { span.finish(); } }
Example #9
Source File: RequestHandler.java From opentelemetry-java with Apache License 2.0 | 5 votes |
/** beforeRequest handler....... */ public void beforeRequest(Object request) { logger.info("before send {}", request); Span span = tracer.buildSpan(OPERATION_NAME).start(); tlsScope.set(tracer.activateSpan(span)); }
Example #10
Source File: TracingRedisCommands.java From java-redis-client with Apache License 2.0 | 5 votes |
@Override public String clusterSetSlotMigrating(int slot, String nodeId) { Span span = helper.buildSpan("clusterSetSlotMigrating"); span.setTag("slot", slot); span.setTag("nodeId", nodeId); try { return commands.clusterSetSlotMigrating(slot, nodeId); } catch (Exception e) { onError(e, span); throw e; } finally { span.finish(); } }
Example #11
Source File: TracingJedisCluster.java From java-redis-client with Apache License 2.0 | 5 votes |
@Override public void psubscribe(BinaryJedisPubSub jedisPubSub, byte[]... patterns) { Span span = helper.buildSpan("psubscribe"); span.setTag("patterns", Arrays.toString(patterns)); try { super.psubscribe(jedisPubSub, patterns); } catch (Exception e) { onError(e, span); throw e; } finally { span.finish(); } }
Example #12
Source File: TracingRedisAdvancedClusterCommands.java From java-redis-client with Apache License 2.0 | 5 votes |
@Override public Long bitpos(K key, boolean state, long start) { Span span = helper.buildSpan("bitpos", key); span.setTag("state", state); span.setTag("start", start); try { return commands.bitpos(key, state, start); } catch (Exception e) { onError(e, span); throw e; } finally { span.finish(); } }
Example #13
Source File: TracingRedisAdvancedClusterCommands.java From java-redis-client with Apache License 2.0 | 5 votes |
@Override public Long zrank(K key, V member) { Span span = helper.buildSpan("zrank", key); try { return commands.zrank(key, member); } catch (Exception e) { onError(e, span); throw e; } finally { span.finish(); } }
Example #14
Source File: TracingJedisCluster.java From java-redis-client with Apache License 2.0 | 5 votes |
@Override public Set<Tuple> zrevrangeByScoreWithScores(byte[] key, double max, double min) { Span span = helper.buildSpan("zrevrangeByScoreWithScores", key); span.setTag("min", min); span.setTag("max", max); try { return super.zrevrangeByScoreWithScores(key, max, min); } catch (Exception e) { onError(e, span); throw e; } finally { span.finish(); } }
Example #15
Source File: TracingJedisCluster.java From java-redis-client with Apache License 2.0 | 5 votes |
@Override public Long zunionstore(byte[] dstkey, ZParams params, byte[]... sets) { Span span = helper.buildSpan("zunionstore"); span.setTag("dstkey", Arrays.toString(dstkey)); span.setTag("params", TracingHelper.toString(params.getParams())); span.setTag("sets", TracingHelper.toString(sets)); try { return super.zunionstore(dstkey, params, sets); } catch (Exception e) { onError(e, span); throw e; } finally { span.finish(); } }
Example #16
Source File: TracingRedisAdvancedClusterAsyncCommands.java From java-redis-client with Apache License 2.0 | 5 votes |
private <T> RedisFuture<T> continueScopeSpan(RedisFuture<T> redisFuture) { Tracer tracer = tracingConfiguration.getTracer(); Span span = tracer.activeSpan(); CompletableRedisFuture<T> customRedisFuture = new CompletableRedisFuture<>(redisFuture); redisFuture.whenComplete((v, throwable) -> { try (Scope ignored = tracer.scopeManager().activate(span)) { if (throwable != null) { customRedisFuture.completeExceptionally(throwable); } else { customRedisFuture.complete(v); } } }); return customRedisFuture; }
Example #17
Source File: TracingRedisAdvancedClusterCommands.java From java-redis-client with Apache License 2.0 | 5 votes |
@Override public V getrange(K key, long start, long end) { Span span = helper.buildSpan("getrange", key); span.setTag("start", start); span.setTag("end", end); try { return commands.getrange(key, start, end); } catch (Exception e) { onError(e, span); throw e; } finally { span.finish(); } }
Example #18
Source File: TracingRedisAdvancedClusterAsyncCommands.java From java-redis-client with Apache License 2.0 | 5 votes |
@Override @Deprecated public RedisFuture<Long> zcount(K key, double min, double max) { Span span = helper.buildSpan("zcount", key); span.setTag("min", min); span.setTag("max", max); return prepareRedisFuture(commands.zcount(key, min, max), span); }
Example #19
Source File: TracingRedisAdvancedClusterCommands.java From java-redis-client with Apache License 2.0 | 5 votes |
@Override public Long ttl(K key) { Span span = helper.buildSpan("ttl", key); try { return commands.ttl(key); } catch (Exception e) { onError(e, span); throw e; } finally { span.finish(); } }
Example #20
Source File: TracingRedisCommands.java From java-redis-client with Apache License 2.0 | 5 votes |
@Override public Long incrby(K key, long amount) { Span span = helper.buildSpan("incrby", key); span.setTag("amount", amount); try { return commands.incrby(key, amount); } catch (Exception e) { onError(e, span); throw e; } finally { span.finish(); } }
Example #21
Source File: FileBasedTenantService.java From hono with Eclipse Public License 2.0 | 5 votes |
/** * Adds a tenant. * * @param tenantId The identifier of the tenant. If null, an random ID will be generated. * @param tenantSpec The information to register for the tenant. * @return The outcome of the operation indicating success or failure. * @throws NullPointerException if any of the parameters are {@code null}. */ private OperationResult<Id> add(final String tenantId, final Tenant tenantSpec, final Span span) { Objects.requireNonNull(tenantId); Objects.requireNonNull(tenantSpec); if (tenants.containsKey(tenantId)) { TracingHelper.logError(span, "Conflict: tenantId already exists"); return OperationResult.empty(HttpURLConnection.HTTP_CONFLICT); } try { if (LOG.isTraceEnabled()) { LOG.trace("adding tenant [id: {}]: {}", tenantId, JsonObject.mapFrom(tenantSpec).encodePrettily()); } final boolean existsConflictingTenant = tenantSpec.getTrustedCertificateAuthoritySubjectDNs() .stream().anyMatch(subjectDn -> getByCa(subjectDn) != null); if (existsConflictingTenant) { // we are trying to use the same CA as an already existing tenant TracingHelper.logError(span, "Conflict: CA already used by an existing tenant"); return OperationResult.empty(HttpURLConnection.HTTP_CONFLICT); } else { final Versioned<Tenant> tenant = new Versioned<>(tenantSpec); tenants.put(tenantId, tenant); dirty.set(true); return OperationResult.ok(HttpURLConnection.HTTP_CREATED, Id.of(tenantId), Optional.empty(), Optional.of(tenant.getVersion())); } } catch (final IllegalArgumentException e) { LOG.debug("error parsing payload of add tenant request", e); TracingHelper.logError(span, e); return OperationResult.empty(HttpURLConnection.HTTP_BAD_REQUEST); } }
Example #22
Source File: TracingRedisAsyncCommands.java From java-redis-client with Apache License 2.0 | 5 votes |
@Override @Deprecated public RedisFuture<List<ScoredValue<V>>> zrevrangebyscoreWithScores( K key, String max, String min) { Span span = helper.buildSpan("zrevrangebyscoreWithScores", key); span.setTag("max", max); span.setTag("min", min); return prepareRedisFuture(commands.zrevrangebyscoreWithScores(key, max, min), span); }
Example #23
Source File: TracingJedisCluster.java From java-redis-client with Apache License 2.0 | 5 votes |
@Override public Long zcount(byte[] key, double min, double max) { Span span = helper.buildSpan("zcount", key); span.setTag("min", min); span.setTag("max", max); try { return super.zcount(key, min, max); } catch (Exception e) { onError(e, span); throw e; } finally { span.finish(); } }
Example #24
Source File: TracingHandler.java From java-vertx-web with Apache License 2.0 | 5 votes |
private Handler<Void> finishEndHandler(RoutingContext routingContext, Span span) { return handler -> { decorators.forEach(spanDecorator -> spanDecorator.onResponse(routingContext.request(), span)); span.finish(); }; }
Example #25
Source File: TracingJedisWrapper.java From java-redis-client with Apache License 2.0 | 5 votes |
@Override public List<GeoRadiusResponse> georadius(String key, double longitude, double latitude, double radius, GeoUnit unit) { Span span = helper.buildSpan("georadius", key); span.setTag("longitude", longitude); span.setTag("latitude", latitude); span.setTag("radius", radius); span.setTag("unit", unit.name()); return helper.decorate(span, () -> wrapped.georadius(key, longitude, latitude, radius, unit)); }
Example #26
Source File: TracingRedisCommands.java From java-redis-client with Apache License 2.0 | 5 votes |
@Override public String configSet(String parameter, String value) { Span span = helper.buildSpan("configSet"); span.setTag("parameter", parameter); try { return commands.configSet(parameter, value); } catch (Exception e) { onError(e, span); throw e; } finally { span.finish(); } }
Example #27
Source File: TracingJedisCluster.java From java-redis-client with Apache License 2.0 | 5 votes |
@Override public List<byte[]> srandmember(byte[] key, int count) { Span span = helper.buildSpan("srandmember", key); span.setTag("count", count); try { return super.srandmember(key, count); } catch (Exception e) { onError(e, span); throw e; } finally { span.finish(); } }
Example #28
Source File: SpanDecorator.java From opentracing-toolbox with MIT License | 5 votes |
@Override default void onRequest( final HttpServletRequest request, final Span span) { // nothing to do }
Example #29
Source File: TracingRedisAdvancedClusterCommands.java From java-redis-client with Apache License 2.0 | 5 votes |
@Override public String flushdb() { Span span = helper.buildSpan("flushdb"); try { return commands.flushdb(); } catch (Exception e) { onError(e, span); throw e; } finally { span.finish(); } }
Example #30
Source File: TracingRedisAdvancedClusterAsyncCommands.java From java-redis-client with Apache License 2.0 | 5 votes |
@Override public void reset() { Span span = helper.buildSpan("reset"); try { commands.reset(); } catch (Exception e) { onError(e, span); throw e; } finally { span.finish(); } }