Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

modify baggage tests for nodejs + add associated nodejs endpoints #3299

Merged
merged 12 commits into from
Dec 31, 2024
1 change: 0 additions & 1 deletion tests/parametric/test_headers_baggage.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ def test_headers_baggage_only_D002(self, test_library):
assert "x-datadog-trace-id" not in headers.keys()
assert "x-datadog-parent-id" not in headers.keys()
assert "baggage" in headers.keys()
assert len(headers.keys()) == 1
assert headers["baggage"] == "foo=bar"

@disable_baggage()
Expand Down
35 changes: 35 additions & 0 deletions utils/build/docker/nodejs/parametric/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,41 @@ app.post('/trace/span/error', (req, res) => {
res.json({});
});

app.post('/trace/span/set_baggage', (req, res) => {
const request = req.body;
const span = spans[request.span_id]
span.setBaggageItem(request.key, request.value)
res.json({});
});

app.get('/trace/span/get_baggage', (req, res) => {
const request = req.body;
const span = spans[request.span_id]
const baggage = span.getBaggageItem(request.key)
res.json({ baggage });
});

app.get('/trace/span/get_all_baggage', (req, res) => {
const request = req.body;
const span = spans[request.span_id]
const baggage = span.getAllBaggageItems()
res.json({ baggage: JSON.parse(baggage) });
});

app.post('/trace/span/remove_baggage', (req, res) => {
const request = req.body;
const span = spans[request.span_id]
const baggages = span.removeBaggageItem(request.key)
res.json({});
});

app.post('/trace/span/remove_all_baggage', (req, res) => {
const request = req.body;
const span = spans[request.span_id]
const baggages = span.removeAllBaggageItems()
res.json({});
});

app.post('/trace/otel/start_span', (req, res) => {
const request = req.body;
const otelTracer = tracerProvider.getTracer()
Expand Down
Loading