-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
57 lines (42 loc) · 1.67 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
require("dotenv").config();
// you have to use the tracer before importing express!!
require("./tracer")();
const { context } = require("@opentelemetry/api");
const express = require("express");
var morgan = require("morgan");
console.log({ OTEL_API_HOST: process.env.OTEL_API_HOST });
const app = express();
app.use(morgan("dev"));
const permissions = {
consumers: [{ identifier: "My-Living-Room", permissions: "ALL" }],
};
app.get("/", async (req, res) => {
console.log({ headers: req.headers });
const activeSpanContext = context.active();
// const activeSpan = trace.getSpan(activeSpanContext);
// if (activeSpan) {
// console.log("Active Span Name:", activeSpan.name);
// console.log("Active Trace ID:", activeSpan.spanContext().traceId);
// console.log("Active Span ID:", activeSpan.spanContext().spanId);
// }
req.activeSpanContext = activeSpanContext;
console.log("REDIRECTING", { activeSpanContext });
return res.redirect(302, "/distributed-information-node");
});
app.get("/distributed-information-node", async (req, res) => {
const { sleep } = req.query;
console.log({ headers: req.headers });
// const activeSpanContext = req.activeSpanContext;
// const activeSpan = trace.getSpan(activeSpanContext);
// console.log("Active Span Name:", activeSpan.name);
// console.log("Active Trace ID:", activeSpan.spanContext().traceId);
// console.log("Active Span ID:", activeSpan.spanContext().spanId);
console.log({ permissions });
if (sleep) {
await new Promise((resolve) => setTimeout(resolve, sleep));
}
return res.json(permissions);
});
app.listen(process.env.PORT, () => {
console.log(`Running on port ${process.env.PORT}`);
});