我正在尝试实现从Azure函数应用到Spring Boot应用的分布式跟踪。我已经在功能应用程序中编写了以下代码:
@FunctionName("functiontest")
public HttpResponseMessage carrierMaster(@HttpTrigger(name = "req", methods = {HttpMethod.GET},
authLevel = AuthorizationLevel.ANONYMOUS) HttpRequestMessage<Optional<String>> request,
final ExecutionContext context) throws Exception {
//String body = request.getBody().orElse(request.getQueryParameters().get("body"));
//System.out.println("data is " +body);
//test
RequestTelemetryContext context1 = ThreadContext.getRequestTelemetryContext();
RequestTelemetry requestTelemetry = context1.getHttpRequestTelemetry();
String dependencyId = TelemetryCorrelationUtils.generateChildDependencyId();
RemoteDependencyTelemetry dependencyTelemetry = new RemoteDependencyTelemetry("Send Data");
dependencyTelemetry.setId(dependencyId);
dependencyTelemetry.getContext().getOperation().setId(requestTelemetry.getContext().getOperation().getId());
dependencyTelemetry.getContext().getOperation().setParentId(requestTelemetry.getId());
Duration duration = new Duration(0,0,0,0,10); // set the duration 10 millisec as an example.
dependencyTelemetry.setDuration(duration);
TelemetryConfiguration configuration = TelemetryConfiguration.getActive();
TelemetryClient telemetryClient = new TelemetryClient();
telemetryClient.trackDependency(dependencyTelemetry);
return request.createResponseBuilder(HttpStatus.OK).body("hello world")
.build();
}
我有以下问题:
有人可以帮我吗?