@oxy.so/core 1.6.0 → 1.6.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/.tsbuildinfo +1 -1
- package/dist/cjs/server/traffic.js +29 -2
- package/dist/esm/.tsbuildinfo +1 -1
- package/dist/esm/server/traffic.js +29 -2
- package/dist/types/.tsbuildinfo +1 -1
- package/package.json +2 -2
- package/src/server/__tests__/traffic.test.ts +132 -1
- package/src/server/traffic.ts +31 -1
|
@@ -2,6 +2,12 @@ import { observeNodeHttp, withoutNodeHttpObservation } from './trafficNodeHttp.j
|
|
|
2
2
|
import { observeTrafficSocket, observeTrafficWebSocket } from '@oxy.so/telemetry/socket';
|
|
3
3
|
import { randomUUID } from 'node:crypto';
|
|
4
4
|
import { OxyServices } from '../OxyServices.js';
|
|
5
|
+
// Static, unlike the lazy import in `mixins/OxyServices.auth.ts`: that module is
|
|
6
|
+
// reachable from the root barrel, which ships to React Native, so pulling
|
|
7
|
+
// `node:crypto` in eagerly there would cost every mobile bundle. This file is
|
|
8
|
+
// server-only and the server barrel already exports `./workloadIdentity`, so
|
|
9
|
+
// there is nothing here for a phone to load.
|
|
10
|
+
import { canAttestWorkloadIdentity } from './workloadIdentity.js';
|
|
5
11
|
import { createTrafficCollector, instrumentTrafficFetch, trafficMiddleware, resolveOxyServiceEndpoint, infrastructureLocation } from '@oxy.so/telemetry/collector';
|
|
6
12
|
/** Install once per service process, before registering HTTP routes. */
|
|
7
13
|
export function createEcosystemTraffic(options) {
|
|
@@ -14,9 +20,30 @@ export function createEcosystemTraffic(options) {
|
|
|
14
20
|
}
|
|
15
21
|
const apiKey = activityKey || process.env.OXY_SERVICE_API_KEY;
|
|
16
22
|
const apiSecret = activitySecret || process.env.OXY_SERVICE_API_SECRET;
|
|
17
|
-
|
|
18
|
-
|
|
23
|
+
/**
|
|
24
|
+
* Having no key pair is a legitimate configuration now — but only where this
|
|
25
|
+
* process can prove what it IS (ADR 0026).
|
|
26
|
+
*
|
|
27
|
+
* This used to throw on a missing pair, full stop. Every service in the fleet
|
|
28
|
+
* boots with `OXY_ECOSYSTEM_ACTIVITY_ENABLED=true`, so deleting
|
|
29
|
+
* `OXY_SERVICE_API_KEY` and `OXY_SERVICE_API_SECRET` from a task definition —
|
|
30
|
+
* which is the entire migration ADR 0026 asks for — killed the process at
|
|
31
|
+
* boot. The ECS circuit breaker then rolled the deploy back and reported the
|
|
32
|
+
* service stable, so the operator saw a rollback with nothing naming its
|
|
33
|
+
* cause. That is what one line cost, multiplied by fourteen services holding
|
|
34
|
+
* a secret they no longer need.
|
|
35
|
+
*
|
|
36
|
+
* What is still refused: nothing to authenticate with AND nothing to attest.
|
|
37
|
+
* That is a laptop or a CI box, where the container credentials endpoint is
|
|
38
|
+
* not going to turn up later, and the honest answer is to say so at boot
|
|
39
|
+
* rather than to fail on the first heartbeat.
|
|
40
|
+
*/
|
|
41
|
+
if (!options.credential && (!apiKey || !apiSecret) && !canAttestWorkloadIdentity()) {
|
|
42
|
+
throw new Error('Ecosystem activity needs one of: an OXY_ACTIVITY_API_KEY and OXY_ACTIVITY_API_SECRET pair, an OXY_SERVICE_API_KEY and OXY_SERVICE_API_SECRET pair, or a workload identity this process can attest (ADR 0026).');
|
|
43
|
+
}
|
|
19
44
|
const oxy = new OxyServices({ baseURL });
|
|
45
|
+
// Left unconfigured when there is no pair on purpose: `getServiceToken()`
|
|
46
|
+
// attests instead of being handed half a credential to fail on.
|
|
20
47
|
if (apiKey && apiSecret)
|
|
21
48
|
oxy.configureServiceAuth(apiKey, apiSecret);
|
|
22
49
|
const credential = options.credential ?? (() => oxy.getServiceToken());
|