diff --git a/apps/armory/src/armory.constant.ts b/apps/armory/src/armory.constant.ts index 8ca78e0ec..5ce9a7fbe 100644 --- a/apps/armory/src/armory.constant.ts +++ b/apps/armory/src/armory.constant.ts @@ -132,11 +132,3 @@ export const CHAINS = new Map([ [1, ETHEREUM], [137, POLYGON] ]) - -// -// OpenTelemetry -// - -export const OTEL_ATTR = { - CLIENT_ID: 'domain.client.id' -} as const diff --git a/apps/armory/src/managed-data-store/core/service/entity-data-store.service.ts b/apps/armory/src/managed-data-store/core/service/entity-data-store.service.ts index 94d1466a5..fbda6a312 100644 --- a/apps/armory/src/managed-data-store/core/service/entity-data-store.service.ts +++ b/apps/armory/src/managed-data-store/core/service/entity-data-store.service.ts @@ -1,8 +1,7 @@ -import { MetricService, TraceService } from '@narval/nestjs-shared' +import { MetricService, OTEL_ATTR_CLIENT_ID, TraceService } from '@narval/nestjs-shared' import { EntityStore } from '@narval/policy-engine-shared' import { HttpStatus, Inject, Injectable, NotFoundException } from '@nestjs/common' import { Counter } from '@opentelemetry/api' -import { OTEL_ATTR } from '../../../armory.constant' import { ClientService } from '../../../client/core/service/client.service' import { ClusterService } from '../../../policy-engine/core/service/cluster.service' import { SetEntityStoreResponse } from '../../http/rest/dto/set-entity-store.dto' @@ -28,10 +27,10 @@ export class EntityDataStoreService extends SignatureService { } async getEntities(clientId: string): Promise { - this.getCounter.add(1, { [OTEL_ATTR.CLIENT_ID]: clientId }) + this.getCounter.add(1, { [OTEL_ATTR_CLIENT_ID]: clientId }) const span = this.traceService.startSpan(`${EntityDataStoreService.name}.getEntities`, { - attributes: { [OTEL_ATTR.CLIENT_ID]: clientId } + attributes: { [OTEL_ATTR_CLIENT_ID]: clientId } }) const entityStore = await this.entityDataStoreRepository.getLatestDataStore(clientId) @@ -44,10 +43,10 @@ export class EntityDataStoreService extends SignatureService { } async setEntities(clientId: string, payload: EntityStore) { - this.setCounter.add(1, { [OTEL_ATTR.CLIENT_ID]: clientId }) + this.setCounter.add(1, { [OTEL_ATTR_CLIENT_ID]: clientId }) const span = this.traceService.startSpan(`${EntityDataStoreService.name}.setEntities`, { - attributes: { [OTEL_ATTR.CLIENT_ID]: clientId } + attributes: { [OTEL_ATTR_CLIENT_ID]: clientId } }) const client = await this.clientService.findById(clientId) diff --git a/apps/armory/src/managed-data-store/core/service/policy-data-store.service.ts b/apps/armory/src/managed-data-store/core/service/policy-data-store.service.ts index 0097f1f61..96017cbb6 100644 --- a/apps/armory/src/managed-data-store/core/service/policy-data-store.service.ts +++ b/apps/armory/src/managed-data-store/core/service/policy-data-store.service.ts @@ -1,8 +1,7 @@ -import { MetricService, TraceService } from '@narval/nestjs-shared' +import { MetricService, OTEL_ATTR_CLIENT_ID, TraceService } from '@narval/nestjs-shared' import { PolicyStore } from '@narval/policy-engine-shared' import { HttpStatus, Inject, Injectable, NotFoundException } from '@nestjs/common' import { Counter } from '@opentelemetry/api' -import { OTEL_ATTR } from '../../../armory.constant' import { ClientService } from '../../../client/core/service/client.service' import { ClusterService } from '../../../policy-engine/core/service/cluster.service' import { PolicyDataStoreRepository } from '../../persistence/repository/policy-data-store.repository' @@ -27,10 +26,10 @@ export class PolicyDataStoreService extends SignatureService { } async getPolicies(clientId: string): Promise { - this.getCounter.add(1, { [OTEL_ATTR.CLIENT_ID]: clientId }) + this.getCounter.add(1, { [OTEL_ATTR_CLIENT_ID]: clientId }) const span = this.traceService.startSpan(`${PolicyDataStoreService.name}.getPolicies`, { - attributes: { [OTEL_ATTR.CLIENT_ID]: clientId } + attributes: { [OTEL_ATTR_CLIENT_ID]: clientId } }) const policyStore = await this.policyDataStoreRepository.getLatestDataStore(clientId) @@ -43,10 +42,10 @@ export class PolicyDataStoreService extends SignatureService { } async setPolicies(clientId: string, payload: PolicyStore) { - this.setCounter.add(1, { [OTEL_ATTR.CLIENT_ID]: clientId }) + this.setCounter.add(1, { [OTEL_ATTR_CLIENT_ID]: clientId }) const span = this.traceService.startSpan(`${PolicyDataStoreService.name}.setPolicies`, { - attributes: { [OTEL_ATTR.CLIENT_ID]: clientId } + attributes: { [OTEL_ATTR_CLIENT_ID]: clientId } }) const client = await this.clientService.findById(clientId) diff --git a/apps/policy-engine/src/engine/core/service/evaluation.service.ts b/apps/policy-engine/src/engine/core/service/evaluation.service.ts index e3b62c179..e34d02018 100644 --- a/apps/policy-engine/src/engine/core/service/evaluation.service.ts +++ b/apps/policy-engine/src/engine/core/service/evaluation.service.ts @@ -6,7 +6,6 @@ import { HttpStatus, Inject, Injectable } from '@nestjs/common' import { resolve } from 'path' import { OpenPolicyAgentEngine } from '../../../open-policy-agent/core/open-policy-agent.engine' import { Config } from '../../../policy-engine.config' -import { OTEL_ATTR } from '../../../policy-engine.constant' import { ApplicationException } from '../../../shared/exception/application.exception' import { buildTransactionRequestHashWildcard } from '../util/wildcard-transaction-fields.util' import { ClientService } from './client.service' @@ -99,9 +98,7 @@ export class EvaluationService { }) } - const fetchDataSpan = this.traceService.startSpan(`${EvaluationService.name}.evaluate.fetchData`, { - attributes: { [OTEL_ATTR.CLIENT_ID]: clientId } - }) + const fetchDataSpan = this.traceService.startSpan(`${EvaluationService.name}.evaluate.fetchData`) const [entityStore, policyStore] = await Promise.all([ this.clientService.findEntityStore(clientId), this.clientService.findPolicyStore(clientId) diff --git a/apps/policy-engine/src/policy-engine.constant.ts b/apps/policy-engine/src/policy-engine.constant.ts index f5ecc12cc..f6e742923 100644 --- a/apps/policy-engine/src/policy-engine.constant.ts +++ b/apps/policy-engine/src/policy-engine.constant.ts @@ -29,11 +29,3 @@ export const ENCRYPTION_WRAPPING_SUITE = RawAesWrappingSuiteIdentifier.AES256_GC export const ADMIN_SECURITY = adminApiKeySecurity(REQUEST_HEADER_API_KEY) export const CLIENT_ID_SECURITY = clientIdSecurity(REQUEST_HEADER_CLIENT_ID) export const CLIENT_SECRET_SECURITY = clientSecretSecurity(REQUEST_HEADER_CLIENT_SECRET) - -// -// OpenTelemetry -// - -export const OTEL_ATTR = { - CLIENT_ID: 'domain.client.id' -} as const