Skip to content

Commit b76eeb4

Browse files
add headers
add
2 parents af61ebf + 543d103 commit b76eeb4

File tree

3 files changed

+12
-2
lines changed

3 files changed

+12
-2
lines changed

src/paymentservice/charge.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ const transactionsCounter = meter.createCounter('app.payment.transactions')
2525
module.exports.charge = request => {
2626
const span = tracer.startSpan('charge');
2727

28-
axios.post('http://localhost:8080/charge', { message: "I'm also in a body!", more: "Fingers crossed", num: 100, bool: true })
28+
axios.post('http://localhost:8080/charge', { message: "I'm also in a body!", more: "Fingers crossed", num: 100, bool: true }, { headers: { 'traceloop_id': '12345' } })
2929
.catch(() => undefined)
3030

3131
const {

src/paymentservice/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ const logger = require('./logger')
2424
function chargeServiceHandler(call, callback) {
2525
const span = opentelemetry.trace.getActiveSpan();
2626

27-
axios.post('http://localhost:8080/charge', { message: "I'm in a body!", more: "Let's hope this works" })
27+
axios.post('http://localhost:8080/charge', { message: "I'm in a body!", more: "Let's hope this works" }, { headers: { 'traceloop_id': '12345' } })
2828
.catch(() => undefined)
2929

3030
try {

src/paymentservice/otel-custom/http.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,16 @@ const httpInstrumentationConfig = {
8484
applyCustomAttributesOnSpan: httpCustomAttributes,
8585
requestHook: httpCustomAttributesOnRequest,
8686
responseHook: httpCustomAttributesOnResponse,
87+
headersToSpanAttributes: {
88+
client: {
89+
requestHeaders: ['traceloop_id'],
90+
responseHeaders: ['traceloop_id'],
91+
},
92+
server: {
93+
requestHeaders: ['traceloop_id'],
94+
responseHeaders: ['traceloop_id'],
95+
},
96+
},
8797
};
8898

8999
module.exports = {

0 commit comments

Comments
 (0)