mirror of
https://github.com/HeyPuter/puter.git
synced 2026-05-08 08:01:05 -05:00
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:
@@ -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();
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user