|
@@ -18,42 +18,6 @@ import promise from 'es6-promise';
|
|
|
import {W3CTraceContextPropagator} from "@opentelemetry/core";
|
|
|
|
|
|
promise.polyfill();
|
|
|
-
|
|
|
-const testSendSpan = (tracer) => {
|
|
|
- tracer.startActiveSpan('main', (span) => {
|
|
|
- for (let i = 0; i < 10; i += 1) {
|
|
|
- console.log(i);
|
|
|
- }
|
|
|
-
|
|
|
- //一定要写end()方法结束
|
|
|
- span.end();
|
|
|
- });
|
|
|
-
|
|
|
- const mainWork = () => {
|
|
|
- tracer.startActiveSpan('box', (parentSpan) => {
|
|
|
- for (let i = 0; i < 3; i += 1) {
|
|
|
- doWork(i);
|
|
|
- }
|
|
|
- // Be sure to end the parent span!
|
|
|
- parentSpan.end();
|
|
|
- });
|
|
|
- };
|
|
|
-
|
|
|
- const doWork = (i) => {
|
|
|
- tracer.startActiveSpan(`doWork:${i}`, (span) => {
|
|
|
- // simulate some random work.
|
|
|
- for (let i = 0; i <= Math.floor(Math.random() * 40000000); i += 1) {
|
|
|
- // empty
|
|
|
- }
|
|
|
-
|
|
|
- // Make sure to end this child span! If you don't,
|
|
|
- // it will continue to track work beyond 'doWork'!
|
|
|
- span.end();
|
|
|
- });
|
|
|
- };
|
|
|
-}
|
|
|
-
|
|
|
-
|
|
|
let tracer;
|
|
|
const initOTELReport = (collectorURL) => {
|
|
|
const resource =
|
|
@@ -61,13 +25,13 @@ const initOTELReport = (collectorURL) => {
|
|
|
new Resource({
|
|
|
[ATTR_SERVICE_NAME]: "ob-front",
|
|
|
[ATTR_SERVICE_VERSION]: "0.1.0",
|
|
|
+ "process.command_line":"OBSERVE",
|
|
|
})
|
|
|
);
|
|
|
|
|
|
const provider = new WebTracerProvider({
|
|
|
resource: resource,
|
|
|
spanProcessors: [
|
|
|
- new SimpleSpanProcessor(new ConsoleSpanExporter()),
|
|
|
new BatchSpanProcessor(new OTLPTraceExporter({
|
|
|
url: collectorURL,
|
|
|
headers: {}
|
|
@@ -136,7 +100,7 @@ function spanSendInterceptorResponse(response) {
|
|
|
span.end();
|
|
|
})
|
|
|
}
|
|
|
- return response.data;
|
|
|
+ return response;
|
|
|
}
|
|
|
|
|
|
function spanSendInterceptorError(error) {
|