@Override public int hashCode() { return Objects.hash( logName, resource, timestamp, receiveTimestamp, severity, insertId, httpRequest, labels, operation, getTrace(), getSpanId(), traceSampled, sourceLocation, payload); }
@Override public boolean equals(Object obj) { if (obj == this) { return true; } if (!(obj instanceof LogEntry)) { return false; } LogEntry other = (LogEntry) obj; return Objects.equals(logName, other.logName) && Objects.equals(resource, other.resource) && Objects.equals(timestamp, other.timestamp) && Objects.equals(receiveTimestamp, other.receiveTimestamp) && Objects.equals(severity, other.severity) && Objects.equals(insertId, other.insertId) && Objects.equals(httpRequest, other.httpRequest) && Objects.equals(labels, other.labels) && Objects.equals(operation, other.operation) && Objects.equals(getTrace(), other.getTrace()) && Objects.equals(getSpanId(), other.getSpanId()) && Objects.equals(traceSampled, other.traceSampled) && Objects.equals(sourceLocation, other.sourceLocation) && Objects.equals(payload, other.payload); }
builder.setSpanId(getSpanId());
assertNull(logEntry.getOperation()); assertNull(logEntry.getTrace()); assertNull(logEntry.getSpanId()); assertFalse(logEntry.getTraceSampled()); assertNull(logEntry.getSourceLocation()); assertNull(logEntry.getOperation()); assertNull(logEntry.getTrace()); assertNull(logEntry.getSpanId()); assertFalse(logEntry.getTraceSampled()); assertNull(logEntry.getSourceLocation());
private void compareLogEntry(LogEntry expected, LogEntry value) { assertEquals(expected, value); assertEquals(expected.getLogName(), value.getLogName()); assertEquals(expected.getResource(), value.getResource()); assertEquals(expected.getTimestamp(), value.getTimestamp()); assertEquals(expected.getReceiveTimestamp(), value.getReceiveTimestamp()); assertEquals(expected.getSeverity(), value.getSeverity()); assertEquals(expected.getInsertId(), value.getInsertId()); assertEquals(expected.getHttpRequest(), value.getHttpRequest()); assertEquals(expected.getLabels(), value.getLabels()); assertEquals(expected.getOperation(), value.getOperation()); assertEquals(expected.getTrace(), value.getTrace()); assertEquals(expected.getSpanId(), value.getSpanId()); assertEquals(expected.getTraceSampled(), value.getTraceSampled()); assertEquals(expected.getSourceLocation(), value.getSourceLocation()); assertEquals(expected.getPayload(), value.getPayload()); assertEquals(expected.hashCode(), value.hashCode()); } }
assertEquals(OPERATION, STRING_ENTRY.getOperation()); assertEquals(TRACE, STRING_ENTRY.getTrace()); assertEquals(SPAN_ID, STRING_ENTRY.getSpanId()); assertEquals(TRACE_SAMPLED, STRING_ENTRY.getTraceSampled()); assertEquals(SOURCE_LOCATION, STRING_ENTRY.getSourceLocation()); assertEquals(OPERATION, JSON_ENTRY.getOperation()); assertEquals(TRACE, JSON_ENTRY.getTrace()); assertEquals(SPAN_ID, JSON_ENTRY.getSpanId()); assertEquals(TRACE_SAMPLED, JSON_ENTRY.getTraceSampled()); assertEquals(SOURCE_LOCATION, JSON_ENTRY.getSourceLocation()); assertEquals(OPERATION, PROTO_ENTRY.getOperation()); assertEquals(TRACE, PROTO_ENTRY.getTrace()); assertEquals(SPAN_ID, PROTO_ENTRY.getSpanId()); assertEquals(TRACE_SAMPLED, PROTO_ENTRY.getTraceSampled()); assertEquals(SOURCE_LOCATION, PROTO_ENTRY.getSourceLocation()); assertEquals(OPERATION, logEntry.getOperation()); assertEquals(TRACE, logEntry.getTrace()); assertEquals(SPAN_ID, logEntry.getSpanId()); assertEquals(TRACE_SAMPLED, logEntry.getTraceSampled()); assertEquals(SOURCE_LOCATION, logEntry.getSourceLocation());
assertEquals(Operation.of("otherId", "otherProducer"), logEntry.getOperation()); assertEquals("otherTrace", logEntry.getTrace()); assertEquals("otherSpanId", logEntry.getSpanId()); assertFalse(logEntry.getTraceSampled()); assertEquals(
@Override public int hashCode() { return Objects.hash( logName, resource, timestamp, receiveTimestamp, severity, insertId, httpRequest, labels, operation, getTrace(), getSpanId(), traceSampled, sourceLocation, payload); }
@Override public boolean equals(Object obj) { if (obj == this) { return true; } if (!(obj instanceof LogEntry)) { return false; } LogEntry other = (LogEntry) obj; return Objects.equals(logName, other.logName) && Objects.equals(resource, other.resource) && Objects.equals(timestamp, other.timestamp) && Objects.equals(receiveTimestamp, other.receiveTimestamp) && Objects.equals(severity, other.severity) && Objects.equals(insertId, other.insertId) && Objects.equals(httpRequest, other.httpRequest) && Objects.equals(labels, other.labels) && Objects.equals(operation, other.operation) && Objects.equals(getTrace(), other.getTrace()) && Objects.equals(getSpanId(), other.getSpanId()) && Objects.equals(traceSampled, other.traceSampled) && Objects.equals(sourceLocation, other.sourceLocation) && Objects.equals(payload, other.payload); }
@Test public void enhanceLogEntry_AddBlankSpanToLogEntry() { LogEntry logEntry = getEnhancedLogEntry( new OpenCensusTraceLoggingEnhancer("my-test-project-7"), BlankSpan.INSTANCE); assertFalse(logEntry.getTraceSampled()); assertThat(logEntry.getTrace()) .isEqualTo("projects/my-test-project-7/traces/00000000000000000000000000000000"); assertThat(logEntry.getSpanId()).isEqualTo("0000000000000000"); }
@Test public void enhanceLogEntry_AddNonSampledSpanToLogEntry() { LogEntry logEntry = getEnhancedLogEntry( new OpenCensusTraceLoggingEnhancer("my-test-project-6"), new TestSpan( SpanContext.create( TraceId.fromLowerBase16("72c905c76f99e99974afd84dc053a480"), SpanId.fromLowerBase16("731e102335b7a5a0"), TraceOptions.builder().setIsSampled(false).build(), EMPTY_TRACESTATE))); assertFalse(logEntry.getTraceSampled()); assertThat(logEntry.getTrace()) .isEqualTo("projects/my-test-project-6/traces/72c905c76f99e99974afd84dc053a480"); assertThat(logEntry.getSpanId()).isEqualTo("731e102335b7a5a0"); }
@Test public void enhanceLogEntry_AddSampledSpanToLogEntry() { LogEntry logEntry = getEnhancedLogEntry( new OpenCensusTraceLoggingEnhancer("my-test-project-3"), new TestSpan( SpanContext.create( TraceId.fromLowerBase16("4c6af40c499951eb7de2777ba1e4fefa"), SpanId.fromLowerBase16("de52e84d13dd232d"), TraceOptions.builder().setIsSampled(true).build(), EMPTY_TRACESTATE))); assertTrue(logEntry.getTraceSampled()); assertThat(logEntry.getTrace()) .isEqualTo("projects/my-test-project-3/traces/4c6af40c499951eb7de2777ba1e4fefa"); assertThat(logEntry.getSpanId()).isEqualTo("de52e84d13dd232d"); }
builder.setSpanId(getSpanId());