Spring Cloud Sleuth-tracer.getCurrentSpan()。getTraceId()不会在日志中返回traceid

时间:2019-08-12 12:33:50

标签: spring-boot spring-cloud-sleuth

当我打印traceId时,我得到514775860170850477,但是在日志中,跟踪ID为724d9eadc6e00ad。 知道这里会发生什么吗?

我的pom

// Below is the array value 
financialTransactionDetail: Array(3)
0:
AdjustedAmount: "0"
NetTransactionAmount: "1050"
TransactionAmount: 1050
1:
AdjustedAmount: "0"
NetTransactionAmount: "1050"
TransactionAmount: 1050

2:
AdjustedAmount: "0"
NetTransactionAmount: "1050"
Status: "Unpaid"
TransactionAmount: 1050

__typename: "FinancialTransactionDetail"
///////////////////////     
<Tab heading="INVOICE SPECIFIC">
                      { !_.isEmpty(financialTransactionDetail.financialTransactionDetail) && financialTransactionDetail.financialTransactionDetail.map(
                        (data, index) => {
                         // this.state.sum+= Sum(parseInt( data.TransactionAmount));
                          this.state.transactionAmount=_.sum(data.TransactionAmount) ;
                          console.log("sum data ",this.state.transactionAmount);
                          return(
                            <View key={index} style={{flexDirection:'row', padding:10, alignItems:'center', justifyContent:'space-between'}}>
                          <View style={{paddingRight:10, marginRight:10}}>
                            <CheckBox style={styles.checkBox} color="#00678f" checked={this.state.isChecked} onPress={() =>this.handleChange()}/>
                          </View>
                          <View style={{flexDirection:'column',flex:1, padding:10, borderWidth:1, borderColor:'lightgrey', borderRadius:10}}>
                            <View style={{flexDirection:'row', alignItems:'center'}}>
                              {!this.state.isChecked && <RegularText text={`₦ ${data.TransactionAmount}`} style={{paddingBottom:10, paddingRight:5}}/>}
                              <SmallText text="From 1-Jan-2019 to 31-Jan-2019" style={{paddingBottom:10}}/>
                            </View>
                            {this.state.isChecked && 
                            <RegularText text={`₦ ${data.TransactionAmount}`} style={{borderColor: '#00fff', borderBottomWidth:1}}>
                              </RegularText>
                              /* <Input
                                value={this.state.transactionAmount}
                                onChangeText={(text) => this.setState({value1:text})}
                              /> */
                            }
                          </View>
                        </View>

我如何打印traceId

    <parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>1.5.2.RELEASE</version>
    <relativePath /> <!-- lookup parent from repository -->
</parent>

<dependencyManagement> 
  <dependencies>
      <dependency>
          <groupId>org.springframework.cloud</groupId>
          <artifactId>spring-cloud-dependencies</artifactId>
          <version>Brixton.RELEASE</version>
          <type>pom</type>
          <scope>import</scope>
      </dependency>
  </dependencies>
 </dependencyManagement>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-sleuth</artifactId>

1 个答案:

答案 0 :(得分:0)

tracer.currentSpan()。context()。traceIdString()