@Override public void addTag(String key, String value) { context.getTags().put(key, value); }
private void validateJsonStructure(TransactionPayload payload) throws IOException { JsonNode serializedSpans = getSerializedSpans(payload); validateDbSpanSchema(serializedSpans, true); validateHttpSpanSchema(serializedSpans); for (Span span : payload.getSpans()) { if (span.getType() != null && span.getType().equals("db")) { span.getContext().getTags().clear(); validateDbSpanSchema(getSerializedSpans(payload), false); break; } } }
public void captureException(long epochMicros, @Nullable Throwable e, @Nullable TraceContextHolder<?> active) { if (e != null) { ErrorCapture error = errorPool.createInstance(); error.withTimestamp(epochMicros); error.setException(e); Transaction currentTransaction = currentTransaction(); if (currentTransaction != null) { error.setTransactionType(currentTransaction.getType()); error.setTransactionSampled(currentTransaction.isSampled()); } if (active != null) { if (active instanceof Transaction) { Transaction transaction = (Transaction) active; // The error might have occurred in a different thread than the one the transaction was recorded // That's why we have to ensure the visibility of the transaction properties error.getContext().copyFrom(transaction.getContextEnsureVisibility()); } else if (active instanceof Span) { Span span = (Span) active; error.getContext().getTags().putAll(span.getContext().getTags()); } error.asChildOf(active.getTraceContext()); } else { error.getTraceContext().getId().setToRandomValue(); } reporter.report(error); } }
private void serializeSpanContext(SpanContext context) { writeFieldName("context"); jw.writeByte(OBJECT_START); boolean spanContextWritten = false; Db db = context.getDb(); if (db.hasContent()) { serializeDbContext(db); spanContextWritten = true; } Http http = context.getHttp(); if (http.hasContent()) { if (spanContextWritten) { jw.writeByte(COMMA); } serializeHttpContext(http); spanContextWritten = true; } Map<String, String> tags = context.getTags(); if (!tags.isEmpty()) { if (spanContextWritten) { jw.writeByte(COMMA); } writeFieldName("tags"); serializeTags(tags); } jw.writeByte(OBJECT_END); jw.writeByte(COMMA); }