@Override
  public void appendDataInfluence(String entityName, String entityId, String fieldName,
      String fieldCurrentValue) {
    // might be
    if (traceContext.tracer() == null) {
      return;
    }
    if (traceContext.tracer().getActiveSpan() == null) {
      return;
    }
    String spanId = traceContext.tracer().getActiveSpan().spanId();
    OpType type = traceContext.tracer().getActiveSpan().getOpType();
    ApolloAuditLogDataInfluence.Builder builder = ApolloAuditLogDataInfluence.builder().spanId(spanId)
        .entityName(entityName).entityId(entityId).fieldName(fieldName);
    if (type == null) {
      return;
    }
    switch (type) {
      case CREATE:
      case UPDATE:
        builder.newVal(fieldCurrentValue);
        break;
      case DELETE:
        builder.oldVal(fieldCurrentValue);
    }
    dataInfluenceService.save(builder.build());
  }
@Test
  public void testAppendDataInfluenceCaseCreateOrUpdate() {
    {
      ApolloAuditSpan span = Mockito.mock(ApolloAuditSpan.class);
      Mockito.when(tracer.getActiveSpan()).thenReturn(span);
      Mockito.when(span.spanId()).thenReturn(spanId);
      Mockito.when(span.getOpType()).thenReturn(create);
    }

    api.appendDataInfluence(entityName, entityId, fieldName, fieldCurrentValue);

    Mockito.verify(dataInfluenceService, Mockito.times(1)).save(influenceCaptor.capture());

    ApolloAuditLogDataInfluence capturedInfluence = influenceCaptor.getValue();
    assertEquals(entityId, capturedInfluence.getInfluenceEntityId());
    assertEquals(entityName, capturedInfluence.getInfluenceEntityName());
    assertEquals(fieldName, capturedInfluence.getFieldName());
    assertNull(capturedInfluence.getFieldOldValue());
    assertEquals(fieldCurrentValue, capturedInfluence.getFieldNewValue());
    assertEquals(spanId, capturedInfluence.getSpanId());
  }