fix: improvements to jaeger trace service

- migrate config location (legacy location still supported)
- allow passing additional otel options when creating spans
This commit is contained in:
KernelDeimos
2025-07-06 15:42:48 -04:00
parent bddc872e00
commit fd956cb1cd
2 changed files with 11 additions and 4 deletions
@@ -87,8 +87,8 @@ class TelemetryService extends BaseService {
}
getConfiguredExporter_() {
if ( config.jaeger ) {
return new OTLPTraceExporter(config.jaeger);
if ( config.jaeger ?? this.config.jaeger ) {
return new OTLPTraceExporter(config.jaeger ?? this.config.jaeger);
}
const exporter = new ConsoleSpanExporter();
}
+9 -2
View File
@@ -53,10 +53,15 @@ class TraceService {
*
* @param {string} name - The name of the span.
* @param {Function} fn - The asynchronous function to execute within the span.
* @param {opentelemetry.SpanOptions} [options] - The opentelemetry options object
* @returns {Promise} - A promise that resolves to the return value of `fn`.
*/
async spanify (name, fn) {
return await this.tracer.startActiveSpan(name, async span => {
async spanify (name, fn, options) {
const args = [name];
if ( options !== null && typeof options === 'object' ) {
args.push(options);
}
args.push(async span => {
try {
return await fn({ span });
} catch (error) {
@@ -66,6 +71,8 @@ class TraceService {
span.end();
}
});
this.tracer.startActiveSpan('name', { }, () => {})
return await this.tracer.startActiveSpan(...args);
}
}