diff --git a/spartan/aztec-network/templates/boot-node.yaml b/spartan/aztec-network/templates/boot-node.yaml index 8a9e8900341..246d9ff3246 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 16d09668221..be8479acb15 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 c945f89e4aa..ef7399d2e7f 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 f722e5108aa..8c0ee46d94e 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 452ccb00251..3cdfb76721c 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 3fee3e64181..b4ba7d10c12 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 dc107937325..218db443662 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 2d3e2d8b393..99b395ca987 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 942c130c609..bc88443986d 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 cc86e585953..cb43781825f 100644 --- a/yarn-project/foundation/src/config/env_var.ts +++ b/yarn-project/foundation/src/config/env_var.ts @@ -188,4 +188,6 @@ export type EnvVar = | 'FAUCET_MNEMONIC_ACCOUNT_INDEX' | 'FAUCET_ETH_AMOUNT' | 'FAUCET_INTERVAL_MS' - | 'FAUCET_L1_ASSETS'; + | 'FAUCET_L1_ASSETS' + | 'K8S_POD_NAME' + | 'K8S_POD_UID'; diff --git a/yarn-project/telemetry-client/src/aztec_resource_detector.ts b/yarn-project/telemetry-client/src/aztec_resource_detector.ts index 24da4e0d92e..bb438dd49a9 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 dcb5d8a8a0c..bef8275cf2a 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 7566520afba..8690584ec35 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 3810d3e73be..d0a8ec7677c 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) {