mirror of
https://code.equilibrium.co.ao/ITO/doneit-web.git
synced 2026-04-20 13:26:08 +00:00
Improve telemetry
This commit is contained in:
@@ -22,6 +22,19 @@ export class HttpService {
|
||||
const result = await this.http.post(url, body, options).toPromise()
|
||||
return ok (result as T)
|
||||
} catch (e) {
|
||||
tracing?.setAttribute('url', url)
|
||||
if(isHttpError(e)) {
|
||||
tracing?.setAttribute('status.code', e.status.toString())
|
||||
if (e.status == 400) {
|
||||
tracing?.log("bad request "+url, {
|
||||
requestPath: url,
|
||||
requestBody: body,
|
||||
requestStatusCode: e.status.toString()
|
||||
})
|
||||
|
||||
}
|
||||
}
|
||||
tracing?.setAttribute('outcome', 'failed')
|
||||
return err(e as HttpErrorResponse)
|
||||
}
|
||||
}
|
||||
@@ -49,13 +62,18 @@ export class HttpService {
|
||||
if(isHttpError(e)) {
|
||||
tracing?.setAttribute('status.code', e.status.toString())
|
||||
if (e.status == 400) {
|
||||
tracing?.setAttribute('outcome', 'failed')
|
||||
tracing?.log("bad request "+url, {
|
||||
requestPath: url,
|
||||
queryParameter: httpParamsObj,
|
||||
requestStatusCode: e.status.toString()
|
||||
})
|
||||
}
|
||||
} else {
|
||||
tracing?.setAttribute('map.error', 'true')
|
||||
tracing?.setAttribute('map.error.context', JSON.stringify(e))
|
||||
tracing.setAttribute('outcome', 'failed')
|
||||
//tracing?.setAttribute('map.error', 'true')
|
||||
//tracing?.setAttribute('map.error.context', JSON.stringify(e))
|
||||
//tracing?.setAttribute('outcome', 'failed')
|
||||
}
|
||||
tracing?.setAttribute('outcome', 'failed')
|
||||
return err(e as HttpErrorResponse)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,8 +3,11 @@ import { WebTracerProvider } from '@opentelemetry/sdk-trace-web';
|
||||
import { ZipkinExporter } from '@opentelemetry/exporter-zipkin';
|
||||
import { SemanticResourceAttributes } from '@opentelemetry/semantic-conventions'
|
||||
import { Resource } from '@opentelemetry/resources';
|
||||
import { OTLPTraceExporter } from '@opentelemetry/exporter-otlp-http';
|
||||
//import { OTLPTraceExporter } from '@opentelemetry/exporter-otlp-http';
|
||||
import { context, trace, propagation } from '@opentelemetry/api';
|
||||
import { OTLPTraceExporter } from '@opentelemetry/exporter-trace-otlp-http';
|
||||
// const { OTLPTraceExporter: OTLPTraceExporterProto } = require("@opentelemetry/exporter-trace-otlp-proto");
|
||||
|
||||
|
||||
function createProvider(serviceName) {
|
||||
const provider = new WebTracerProvider({
|
||||
@@ -14,15 +17,19 @@ function createProvider(serviceName) {
|
||||
});
|
||||
|
||||
// provider.addSpanProcessor(new SimpleSpanProcessor(new ConsoleSpanExporter()));
|
||||
provider.addSpanProcessor(new SimpleSpanProcessor(new ZipkinExporter({
|
||||
//url: 'https://5-180-182-151.cloud-xip.com:85/zipkin-endpoint/api/v2/spans',
|
||||
url: 'https://185-229-224-75.cloud-xip.com:85/zipkin-endpoint/api/v2/spans',
|
||||
serviceName: serviceName,
|
||||
getExportRequestHeaders: () => {
|
||||
return {
|
||||
'Authorization': 'Basic ' + btoa('tabteste@006:tabteste@006'),
|
||||
};
|
||||
}
|
||||
// provider.addSpanProcessor(new SimpleSpanProcessor(new ZipkinExporter({
|
||||
// //url: 'https://5-180-182-151.cloud-xip.com:85/zipkin-endpoint/api/v2/spans',
|
||||
// url: 'https://185-229-224-75.cloud-xip.com:85/zipkin-endpoint/api/v2/spans',
|
||||
// serviceName: serviceName,
|
||||
// getExportRequestHeaders: () => {
|
||||
// return {
|
||||
// 'Authorization': 'Basic ' + btoa('tabteste@006:tabteste@006'),
|
||||
// };
|
||||
// }
|
||||
// })));
|
||||
|
||||
provider.addSpanProcessor(new SimpleSpanProcessor(new OTLPTraceExporter({
|
||||
url: 'https://185-229-224-75.cloud-xip.com:85/collector2/v1/traces',
|
||||
})));
|
||||
|
||||
provider.register();
|
||||
|
||||
Reference in New Issue
Block a user