diff --git a/spartan/aztec-network/templates/boot-node.yaml b/spartan/aztec-network/templates/boot-node.yaml index 1774c16fd66c..2579b48aafb7 100644 --- a/spartan/aztec-network/templates/boot-node.yaml +++ b/spartan/aztec-network/templates/boot-node.yaml @@ -94,6 +94,14 @@ spec: value: "{{ .Values.aztec.epochDuration }}" - name: AZTEC_EPOCH_PROOF_CLAIM_WINDOW_IN_L2_SLOTS value: "{{ .Values.aztec.epochProofClaimWindow }}" + - name: K8S_POD_UID + valueFrom: + fieldRef: + fieldPath: metadata.uid + - name: K8S_POD_NAME + valueFrom: + fieldRef: + fieldPath: metadata.name {{- end }} containers: - name: boot-node @@ -142,6 +150,14 @@ spec: valueFrom: fieldRef: fieldPath: status.podIP + - name: K8S_POD_UID + valueFrom: + fieldRef: + fieldPath: metadata.uid + - name: K8S_POD_NAME + valueFrom: + fieldRef: + fieldPath: metadata.name - name: AZTEC_PORT value: "{{ .Values.bootNode.service.nodePort }}" - name: LOG_LEVEL diff --git a/spartan/aztec-network/templates/deploy-l1-verifier.yaml b/spartan/aztec-network/templates/deploy-l1-verifier.yaml index 16d096682212..be8479acb155 100644 --- a/spartan/aztec-network/templates/deploy-l1-verifier.yaml +++ b/spartan/aztec-network/templates/deploy-l1-verifier.yaml @@ -74,6 +74,14 @@ spec: done || { echo "All L1 verifier deploy attempts failed." >&2; exit 1; } echo "L1 verifier deployed" env: + - name: K8S_POD_UID + valueFrom: + fieldRef: + fieldPath: metadata.uid + - name: K8S_POD_NAME + valueFrom: + fieldRef: + fieldPath: metadata.name - name: NODE_NO_WARNINGS value: "1" - name: LOG_LEVEL diff --git a/spartan/aztec-network/templates/prover-agent.yaml b/spartan/aztec-network/templates/prover-agent.yaml index c945f89e4aa4..ef7399d2e7ff 100644 --- a/spartan/aztec-network/templates/prover-agent.yaml +++ b/spartan/aztec-network/templates/prover-agent.yaml @@ -80,6 +80,14 @@ spec: source /shared/config/service-addresses && \ node --no-warnings /usr/src/yarn-project/aztec/dest/bin/index.js start --prover-agent env: + - name: K8S_POD_UID + valueFrom: + fieldRef: + fieldPath: metadata.uid + - name: K8S_POD_NAME + valueFrom: + fieldRef: + fieldPath: metadata.name - name: AZTEC_PORT value: "{{ .Values.proverAgent.service.nodePort }}" - name: LOG_LEVEL diff --git a/spartan/aztec-network/templates/prover-broker.yaml b/spartan/aztec-network/templates/prover-broker.yaml index f722e5108aa5..8c0ee46d94e0 100644 --- a/spartan/aztec-network/templates/prover-broker.yaml +++ b/spartan/aztec-network/templates/prover-broker.yaml @@ -62,6 +62,14 @@ spec: source /shared/config/service-addresses && \ node --no-warnings /usr/src/yarn-project/aztec/dest/bin/index.js start --prover-broker env: + - name: K8S_POD_UID + valueFrom: + fieldRef: + fieldPath: metadata.uid + - name: K8S_POD_NAME + valueFrom: + fieldRef: + fieldPath: metadata.name - name: AZTEC_PORT value: "{{ .Values.proverBroker.service.nodePort }}" - name: LOG_LEVEL diff --git a/spartan/aztec-network/templates/prover-node.yaml b/spartan/aztec-network/templates/prover-node.yaml index 452ccb002516..3cdfb76721c1 100644 --- a/spartan/aztec-network/templates/prover-node.yaml +++ b/spartan/aztec-network/templates/prover-node.yaml @@ -107,6 +107,14 @@ spec: - name: config mountPath: /shared/config env: + - name: K8S_POD_UID + valueFrom: + fieldRef: + fieldPath: metadata.uid + - name: K8S_POD_NAME + valueFrom: + fieldRef: + fieldPath: metadata.name - name: POD_IP valueFrom: fieldRef: diff --git a/spartan/aztec-network/templates/pxe.yaml b/spartan/aztec-network/templates/pxe.yaml index 3fee3e641811..b4ba7d10c129 100644 --- a/spartan/aztec-network/templates/pxe.yaml +++ b/spartan/aztec-network/templates/pxe.yaml @@ -81,6 +81,14 @@ spec: echo "AZTEC_NODE_URL=${AZTEC_NODE_URL}" node --no-warnings /usr/src/yarn-project/aztec/dest/bin/index.js start --pxe env: + - name: K8S_POD_UID + valueFrom: + fieldRef: + fieldPath: metadata.uid + - name: K8S_POD_NAME + valueFrom: + fieldRef: + fieldPath: metadata.name - name: AZTEC_PORT value: "{{ .Values.pxe.service.nodePort }}" - name: LOG_JSON diff --git a/spartan/aztec-network/templates/setup-l2-contracts.yaml b/spartan/aztec-network/templates/setup-l2-contracts.yaml index dc107937325c..218db443662c 100644 --- a/spartan/aztec-network/templates/setup-l2-contracts.yaml +++ b/spartan/aztec-network/templates/setup-l2-contracts.yaml @@ -66,6 +66,14 @@ spec: node --no-warnings /usr/src/yarn-project/aztec/dest/bin/index.js setup-protocol-contracts --skipProofWait --l1-chain-id {{ .Values.ethereum.chainId }} echo "L2 contracts initialized" env: + - name: K8S_POD_UID + valueFrom: + fieldRef: + fieldPath: metadata.uid + - name: K8S_POD_NAME + valueFrom: + fieldRef: + fieldPath: metadata.name - name: TELEMETRY value: "{{ .Values.telemetry.enabled }}" - name: LOG_LEVEL diff --git a/spartan/aztec-network/templates/transaction-bot.yaml b/spartan/aztec-network/templates/transaction-bot.yaml index 2d3e2d8b393c..99b395ca987d 100644 --- a/spartan/aztec-network/templates/transaction-bot.yaml +++ b/spartan/aztec-network/templates/transaction-bot.yaml @@ -75,6 +75,14 @@ spec: echo "AZTEC_NODE_URL=${AZTEC_NODE_URL}" node --no-warnings /usr/src/yarn-project/aztec/dest/bin/index.js start --pxe --bot env: + - name: K8S_POD_UID + valueFrom: + fieldRef: + fieldPath: metadata.uid + - name: K8S_POD_NAME + valueFrom: + fieldRef: + fieldPath: metadata.name - name: AZTEC_PORT value: "{{ .Values.bot.service.nodePort }}" - name: LOG_JSON diff --git a/spartan/aztec-network/templates/validator.yaml b/spartan/aztec-network/templates/validator.yaml index 942c130c6093..bc88443986d0 100644 --- a/spartan/aztec-network/templates/validator.yaml +++ b/spartan/aztec-network/templates/validator.yaml @@ -144,6 +144,14 @@ spec: - name: validator-data mountPath: {{ .Values.validator.dataDir }} env: + - name: K8S_POD_UID + valueFrom: + fieldRef: + fieldPath: metadata.uid + - name: K8S_POD_NAME + valueFrom: + fieldRef: + fieldPath: metadata.name - name: POD_IP valueFrom: fieldRef: diff --git a/yarn-project/foundation/src/config/env_var.ts b/yarn-project/foundation/src/config/env_var.ts index 8f6bd085fd34..806d44aa38dd 100644 --- a/yarn-project/foundation/src/config/env_var.ts +++ b/yarn-project/foundation/src/config/env_var.ts @@ -184,4 +184,6 @@ export type EnvVar = | 'L1_TX_MONITOR_MAX_ATTEMPTS' | 'L1_TX_MONITOR_CHECK_INTERVAL_MS' | 'L1_TX_MONITOR_STALL_TIME_MS' - | 'L1_TX_MONITOR_TX_TIMEOUT_MS'; + | 'L1_TX_MONITOR_TX_TIMEOUT_MS' + | 'K8S_POD_NAME' + | 'K8S_POD_UID'; diff --git a/yarn-project/package.json b/yarn-project/package.json index 436b2ac0a494..7a3e3eef7b12 100644 --- a/yarn-project/package.json +++ b/yarn-project/package.json @@ -85,4 +85,4 @@ "@noir-lang/noir_js": "file:../noir/packages/noir_js", "jest-runner@^29.7.0": "patch:jest-runner@npm%3A29.7.0#./.yarn/patches/jest-runner-npm-29.7.0-3bc9f82b58.patch" } -} \ No newline at end of file +} diff --git a/yarn-project/telemetry-client/src/aztec_resource_detector.ts b/yarn-project/telemetry-client/src/aztec_resource_detector.ts index 24da4e0d92e7..bb438dd49a91 100644 --- a/yarn-project/telemetry-client/src/aztec_resource_detector.ts +++ b/yarn-project/telemetry-client/src/aztec_resource_detector.ts @@ -1,4 +1,5 @@ import { type DetectorSync, type IResource, Resource } from '@opentelemetry/resources'; +import { ATTR_K8S_POD_NAME, ATTR_K8S_POD_UID } from '@opentelemetry/semantic-conventions/incubating'; import { NETWORK_NAME } from './attributes.js'; import { getConfigEnvVars } from './config.js'; @@ -12,6 +13,8 @@ class AztecDetector implements DetectorSync { return new Resource({ [NETWORK_NAME]: config.networkName, + [ATTR_K8S_POD_UID]: config.k8sPodUid, + [ATTR_K8S_POD_NAME]: config.k8sPodName, }); } } diff --git a/yarn-project/telemetry-client/src/config.ts b/yarn-project/telemetry-client/src/config.ts index dcb5d8a8a0c5..bef8275cf2aa 100644 --- a/yarn-project/telemetry-client/src/config.ts +++ b/yarn-project/telemetry-client/src/config.ts @@ -8,6 +8,8 @@ export interface TelemetryClientConfig { networkName: string; otelCollectIntervalMs: number; otelExportTimeoutMs: number; + k8sPodUid?: string; + k8sPodName?: string; } export const telemetryClientConfigMappings: ConfigMappingsType = { @@ -48,6 +50,14 @@ export const telemetryClientConfigMappings: ConfigMappingsType parseInt(val), }, + k8sPodUid: { + env: 'K8S_POD_UID', + description: 'The UID of the Kubernetes pod (injected automatically by k8s)', + }, + k8sPodName: { + env: 'K8S_POD_NAME', + description: 'The name of the Kubernetes pod (injected automatically by k8s)', + }, }; export function getConfigEnvVars(): TelemetryClientConfig { diff --git a/yarn-project/telemetry-client/src/otel_logger_provider.ts b/yarn-project/telemetry-client/src/otel_logger_provider.ts index 7566520afbaa..8690584ec35d 100644 --- a/yarn-project/telemetry-client/src/otel_logger_provider.ts +++ b/yarn-project/telemetry-client/src/otel_logger_provider.ts @@ -30,5 +30,6 @@ export async function registerOtelLoggerProvider(resource?: IResource, otelLogsU ); otelLogs.setGlobalLoggerProvider(loggerProvider); + return loggerProvider; } diff --git a/yarn-project/telemetry-client/src/otel_resource.ts b/yarn-project/telemetry-client/src/otel_resource.ts index 3810d3e73be6..d0a8ec7677c2 100644 --- a/yarn-project/telemetry-client/src/otel_resource.ts +++ b/yarn-project/telemetry-client/src/otel_resource.ts @@ -1,4 +1,3 @@ -import { awsEc2Detector, awsEcsDetector } from '@opentelemetry/resource-detector-aws'; import { type IResource, detectResourcesSync, @@ -11,17 +10,8 @@ import { import { aztecDetector } from './aztec_resource_detector.js'; export async function getOtelResource(): Promise { - // TODO(palla/log): Do we really need *all* this info? const resource = detectResourcesSync({ - detectors: [ - osDetectorSync, - envDetectorSync, - processDetectorSync, - serviceInstanceIdDetectorSync, - awsEc2Detector, - awsEcsDetector, - aztecDetector, - ], + detectors: [osDetectorSync, envDetectorSync, processDetectorSync, serviceInstanceIdDetectorSync, aztecDetector], }); if (resource.asyncAttributesPending) {