mirror of
https://github.com/jambonz/jambonz-feature-server.git
synced 2025-12-22 01:27:55 +00:00
Add span parameter to Task.getTracingPropagation. Pass proper span to getTracingPropagation calls in Task methods to propagate the proper spanId (#91)
This commit is contained in:
@@ -90,8 +90,11 @@ class Task extends Emitter {
|
||||
return {span, ctx};
|
||||
}
|
||||
|
||||
getTracingPropagation(encoding) {
|
||||
getTracingPropagation(encoding, span) {
|
||||
// TODO: support encodings beyond b3 https://github.com/openzipkin/b3-propagation
|
||||
if (span) {
|
||||
return `${span.spanContext().traceId}-${span.spanContext().spanId}-1`;
|
||||
}
|
||||
if (this.span) {
|
||||
return `${this.span.spanContext().traceId}-${this.span.spanContext().spanId}-1`;
|
||||
}
|
||||
@@ -137,9 +140,9 @@ class Task extends Emitter {
|
||||
async performAction(results, expectResponse = true) {
|
||||
if (this.actionHook) {
|
||||
const params = results ? Object.assign(results, this.cs.callInfo.toJSON()) : this.cs.callInfo.toJSON();
|
||||
const b3 = this.getTracingPropagation();
|
||||
const httpHeaders = b3 && {b3};
|
||||
const span = this.startSpan('verb:hook', {'hook.url': this.actionHook});
|
||||
const b3 = this.getTracingPropagation('b3', span);
|
||||
const httpHeaders = b3 && {b3};
|
||||
span.setAttributes({'http.body': JSON.stringify(params)});
|
||||
try {
|
||||
const json = await this.cs.requestor.request('verb:hook', this.actionHook, params, httpHeaders);
|
||||
@@ -162,9 +165,9 @@ class Task extends Emitter {
|
||||
}
|
||||
|
||||
async performHook(cs, hook, results) {
|
||||
const b3 = this.getTracingPropagation();
|
||||
const httpHeaders = b3 && {b3};
|
||||
const span = this.startSpan('verb:hook', {'hook.url': hook});
|
||||
const b3 = this.getTracingPropagation('b3', span);
|
||||
const httpHeaders = b3 && {b3};
|
||||
span.setAttributes({'http.body': JSON.stringify(results)});
|
||||
try {
|
||||
const json = await cs.requestor.request('verb:hook', hook, results, httpHeaders);
|
||||
|
||||
Reference in New Issue
Block a user