当前位置: 首页>>代码示例>>Java>>正文


Java Span.tag方法代码示例

本文整理汇总了Java中org.springframework.cloud.sleuth.Span.tag方法的典型用法代码示例。如果您正苦于以下问题:Java Span.tag方法的具体用法?Java Span.tag怎么用?Java Span.tag使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.springframework.cloud.sleuth.Span的用法示例。


在下文中一共展示了Span.tag方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: afterQuery

import org.springframework.cloud.sleuth.Span; //导入方法依赖的package包/类
@Override
public void afterQuery(ExecutionInfo execInfo, List<QueryInfo> queryInfoList) {
    Span span = tracer.getCurrentSpan();
    if (execInfo.getThrowable() != null) {
        span.tag(Span.SPAN_ERROR_TAG_NAME, ExceptionUtils.getExceptionMessage(execInfo.getThrowable()));
    }
    if (execInfo.getMethod().getName().equals("executeUpdate")) {
        span.tag(SleuthListenerAutoConfiguration.SPAN_ROW_COUNT_TAG_NAME, String.valueOf(execInfo.getResult()));
    }
    tracer.close(span);
}
 
开发者ID:gavlyukovskiy,项目名称:spring-boot-data-source-decorator,代码行数:12,代码来源:TracingQueryExecutionListener.java

示例2: beforeMethod

import org.springframework.cloud.sleuth.Span; //导入方法依赖的package包/类
@Override
public void beforeMethod(MethodExecutionContext executionContext) {
    Object target = executionContext.getTarget();
    String methodName = executionContext.getMethod().getName();
    if (target instanceof DataSource) {
        if (methodName.equals("getConnection")) {
            String dataSourceName = executionContext.getProxyConfig().getDataSourceName();
            Span connectionSpan = tracer.createSpan("jdbc:/" + dataSourceName + SleuthListenerAutoConfiguration.SPAN_CONNECTION_POSTFIX);
            connectionSpan.tag(Span.SPAN_LOCAL_COMPONENT_TAG_NAME, "database");
            connectionSpans.put(executionContext.getConnectionInfo(), connectionSpan);
        }
    }
}
 
开发者ID:gavlyukovskiy,项目名称:spring-boot-data-source-decorator,代码行数:14,代码来源:TracingQueryExecutionListener.java

示例3: onBeforeGetConnection

import org.springframework.cloud.sleuth.Span; //导入方法依赖的package包/类
@Override
public void onBeforeGetConnection(ConnectionInformation connectionInformation) {
    String dataSourceName = dataSourceNameResolver.resolveDataSourceName(connectionInformation.getDataSource());
    Span connectionSpan = tracer.createSpan("jdbc:/" + dataSourceName + SleuthListenerAutoConfiguration.SPAN_CONNECTION_POSTFIX);
    connectionSpan.tag(Span.SPAN_LOCAL_COMPONENT_TAG_NAME, "database");
    connectionSpans.put(connectionInformation, connectionSpan);
}
 
开发者ID:gavlyukovskiy,项目名称:spring-boot-data-source-decorator,代码行数:8,代码来源:TracingJdbcEventListener.java

示例4: onAfterGetConnection

import org.springframework.cloud.sleuth.Span; //导入方法依赖的package包/类
@Override
public void onAfterGetConnection(ConnectionInformation connectionInformation, SQLException e) {
    Span connectionSpan = connectionSpans.get(connectionInformation);
    if (e != null) {
        connectionSpans.remove(connectionInformation);
        connectionSpan.tag(Span.SPAN_ERROR_TAG_NAME, ExceptionUtils.getExceptionMessage(e));
        tracer.close(connectionSpan);
    }
}
 
开发者ID:gavlyukovskiy,项目名称:spring-boot-data-source-decorator,代码行数:10,代码来源:TracingJdbcEventListener.java

示例5: onAfterAnyExecute

import org.springframework.cloud.sleuth.Span; //导入方法依赖的package包/类
@Override
public void onAfterAnyExecute(StatementInformation statementInformation, long timeElapsedNanos, SQLException e) {
    Span statementSpan = tracer.getCurrentSpan();
    statementSpan.tag(SleuthListenerAutoConfiguration.SPAN_SQL_QUERY_TAG_NAME, getSql(statementInformation));
    if (e != null) {
        statementSpan.tag(Span.SPAN_ERROR_TAG_NAME, ExceptionUtils.getExceptionMessage(e));
    }
    tracer.close(statementSpan);
}
 
开发者ID:gavlyukovskiy,项目名称:spring-boot-data-source-decorator,代码行数:10,代码来源:TracingJdbcEventListener.java

示例6: onAfterResultSetClose

import org.springframework.cloud.sleuth.Span; //导入方法依赖的package包/类
@Override
public void onAfterResultSetClose(ResultSetInformation resultSetInformation, SQLException e) {
    Span resultSetSpan = resultSetSpans.remove(resultSetInformation.getStatementInformation());
    int rowCount = resultSetInformation.getCurrRow() + 1;
    resultSetSpan.tag(SleuthListenerAutoConfiguration.SPAN_ROW_COUNT_TAG_NAME, String.valueOf(rowCount));
    if (e != null) {
        resultSetSpan.tag(Span.SPAN_ERROR_TAG_NAME, ExceptionUtils.getExceptionMessage(e));
    }
    tracer.close(resultSetSpan);
}
 
开发者ID:gavlyukovskiy,项目名称:spring-boot-data-source-decorator,代码行数:11,代码来源:TracingJdbcEventListener.java

示例7: onAfterStatementClose

import org.springframework.cloud.sleuth.Span; //导入方法依赖的package包/类
@Override
public void onAfterStatementClose(StatementInformation statementInformation, SQLException e) {
    // if result set is not closed statement span may be open at this moment, double checking it here
    Span resultSetSpan = resultSetSpans.remove(statementInformation);
    if (resultSetSpan != null) {
        if (e != null) {
            resultSetSpan.tag(Span.SPAN_ERROR_TAG_NAME, ExceptionUtils.getExceptionMessage(e));
        }
        tracer.close(resultSetSpan);
    }
}
 
开发者ID:gavlyukovskiy,项目名称:spring-boot-data-source-decorator,代码行数:12,代码来源:TracingJdbcEventListener.java

示例8: onAfterCommit

import org.springframework.cloud.sleuth.Span; //导入方法依赖的package包/类
@Override
public void onAfterCommit(ConnectionInformation connectionInformation, long timeElapsedNanos, SQLException e) {
    Span connectionSpan = connectionSpans.get(connectionInformation);
    if (e != null) {
        connectionSpan.tag(Span.SPAN_ERROR_TAG_NAME, ExceptionUtils.getExceptionMessage(e));
    }
    connectionSpan.logEvent("commit");
}
 
开发者ID:gavlyukovskiy,项目名称:spring-boot-data-source-decorator,代码行数:9,代码来源:TracingJdbcEventListener.java

示例9: onAfterRollback

import org.springframework.cloud.sleuth.Span; //导入方法依赖的package包/类
@Override
public void onAfterRollback(ConnectionInformation connectionInformation, long timeElapsedNanos, SQLException e) {
    Span connectionSpan = connectionSpans.get(connectionInformation);
    if (e != null) {
        connectionSpan.tag(Span.SPAN_ERROR_TAG_NAME, ExceptionUtils.getExceptionMessage(e));
    }
    else {
        connectionSpan.tag(Span.SPAN_ERROR_TAG_NAME, "Transaction rolled back");
    }
    connectionSpan.logEvent("rollback");
}
 
开发者ID:gavlyukovskiy,项目名称:spring-boot-data-source-decorator,代码行数:12,代码来源:TracingJdbcEventListener.java

示例10: onAfterConnectionClose

import org.springframework.cloud.sleuth.Span; //导入方法依赖的package包/类
@Override
public void onAfterConnectionClose(ConnectionInformation connectionInformation, SQLException e) {
    Span connectionSpan = connectionSpans.remove(connectionInformation);
    if (e != null) {
        connectionSpan.tag(Span.SPAN_ERROR_TAG_NAME, ExceptionUtils.getExceptionMessage(e));
    }
    Span currentSpan = tracer.getCurrentSpan();
    // result set and statement were not closed but connection was, closing result set span as well
    if (currentSpan.getSpanId() != connectionSpan.getSpanId()
            && currentSpan.getName().contains(SleuthListenerAutoConfiguration.SPAN_FETCH_POSTFIX)) {
        tracer.close(currentSpan);
    }
    tracer.close(connectionSpan);
}
 
开发者ID:gavlyukovskiy,项目名称:spring-boot-data-source-decorator,代码行数:15,代码来源:TracingJdbcEventListener.java

示例11: filterRequest

import org.springframework.cloud.sleuth.Span; //导入方法依赖的package包/类
@Override
public JsonApiResponse filterRequest(RepositoryFilterContext context, RepositoryRequestFilterChain chain) {
	RepositoryRequestSpec request = context.getRequest();
	String query = SleuthUtil.getQuery(request, moduleContext.getResourceRegistry());

	Span span = tracer.createSpan(SleuthUtil.getSpanName(request));

	JsonApiResponse result = null;
	Exception exception = null;
	try {
		span.tag("lc", COMPONENT_NAME);

		result = chain.doFilter(context);
		return result;
	}
	catch (RuntimeException e) {
		exception = e;
		throw e;
	}
	finally {
		boolean resultError = result != null && result.getErrors() != null && result.getErrors().iterator().hasNext();
		boolean failed = exception != null || resultError;
		String status = failed ? STRING_EXCEPTION : STRING_OK;

		span.tag(STATUS_CODE_ANNOTATION, status);
		writeQuery(span, query);
		writeResults(span, result);
		tracer.close(span);
	}
}
 
开发者ID:crnk-project,项目名称:crnk-framework,代码行数:31,代码来源:SleuthRepositoryFilter.java

示例12: beforeQuery

import org.springframework.cloud.sleuth.Span; //导入方法依赖的package包/类
@Override
public void beforeQuery(ExecutionInfo execInfo, List<QueryInfo> queryInfoList) {
    Span span = tracer.createSpan("jdbc:/" + execInfo.getDataSourceName() + SleuthListenerAutoConfiguration.SPAN_QUERY_POSTFIX);
    span.tag(SleuthListenerAutoConfiguration.SPAN_SQL_QUERY_TAG_NAME, queryInfoList.stream().map(QueryInfo::getQuery).collect(Collectors.joining("\n")));
    span.tag(Span.SPAN_LOCAL_COMPONENT_TAG_NAME, "database");
}
 
开发者ID:gavlyukovskiy,项目名称:spring-boot-data-source-decorator,代码行数:7,代码来源:TracingQueryExecutionListener.java

示例13: onBeforeAnyExecute

import org.springframework.cloud.sleuth.Span; //导入方法依赖的package包/类
@Override
public void onBeforeAnyExecute(StatementInformation statementInformation) {
    String dataSourceName = dataSourceNameResolver.resolveDataSourceName(statementInformation.getConnectionInformation().getDataSource());
    Span statementSpan = tracer.createSpan("jdbc:/" + dataSourceName + SleuthListenerAutoConfiguration.SPAN_QUERY_POSTFIX);
    statementSpan.tag(Span.SPAN_LOCAL_COMPONENT_TAG_NAME, "database");
}
 
开发者ID:gavlyukovskiy,项目名称:spring-boot-data-source-decorator,代码行数:7,代码来源:TracingJdbcEventListener.java

示例14: createResultSetSpan

import org.springframework.cloud.sleuth.Span; //导入方法依赖的package包/类
private void createResultSetSpan(StatementInformation statementInformation) {
    String dataSourceName = dataSourceNameResolver.resolveDataSourceName(statementInformation.getConnectionInformation().getDataSource());
    Span resultSetSpan = tracer.createSpan("jdbc:/" + dataSourceName + SleuthListenerAutoConfiguration.SPAN_FETCH_POSTFIX);
    resultSetSpan.tag(Span.SPAN_LOCAL_COMPONENT_TAG_NAME, "database");
    resultSetSpans.put(statementInformation, resultSetSpan);
}
 
开发者ID:gavlyukovskiy,项目名称:spring-boot-data-source-decorator,代码行数:7,代码来源:TracingJdbcEventListener.java

示例15: writeQuery

import org.springframework.cloud.sleuth.Span; //导入方法依赖的package包/类
private void writeQuery(Span span, String query) {
	if (query != null) {
		span.tag(QUERY_ANNOTATION, query);
	}
}
 
开发者ID:crnk-project,项目名称:crnk-framework,代码行数:6,代码来源:SleuthRepositoryFilter.java


注:本文中的org.springframework.cloud.sleuth.Span.tag方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。