Skip to content

Commit

Permalink
Remove OTEL_ATTR
Browse files Browse the repository at this point in the history
  • Loading branch information
wcalderipe committed Nov 13, 2024
1 parent 81771de commit db44679
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 32 deletions.
8 changes: 0 additions & 8 deletions apps/armory/src/armory.constant.ts
Original file line number Diff line number Diff line change
Expand Up @@ -132,11 +132,3 @@ export const CHAINS = new Map<number, Chain>([
[1, ETHEREUM],
[137, POLYGON]
])

//
// OpenTelemetry
//

export const OTEL_ATTR = {
CLIENT_ID: 'domain.client.id'
} as const
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import { MetricService, TraceService } from '@narval/nestjs-shared'
import { MetricService, OTEL_ATTR_CLIENT_ID, TraceService } from '@narval/nestjs-shared'

Check failure on line 1 in apps/armory/src/managed-data-store/core/service/entity-data-store.service.ts

View workflow job for this annotation

GitHub Actions / Test

Module '"@narval/nestjs-shared"' has no exported member 'OTEL_ATTR_CLIENT_ID'.
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'
Expand All @@ -28,10 +27,10 @@ export class EntityDataStoreService extends SignatureService {
}

async getEntities(clientId: string): Promise<EntityStore | null> {
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)
Expand All @@ -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)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import { MetricService, TraceService } from '@narval/nestjs-shared'
import { MetricService, OTEL_ATTR_CLIENT_ID, TraceService } from '@narval/nestjs-shared'

Check failure on line 1 in apps/armory/src/managed-data-store/core/service/policy-data-store.service.ts

View workflow job for this annotation

GitHub Actions / Test

Module '"@narval/nestjs-shared"' has no exported member 'OTEL_ATTR_CLIENT_ID'.
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'
Expand All @@ -27,10 +26,10 @@ export class PolicyDataStoreService extends SignatureService {
}

async getPolicies(clientId: string): Promise<PolicyStore | null> {
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)
Expand All @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -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)
Expand Down
8 changes: 0 additions & 8 deletions apps/policy-engine/src/policy-engine.constant.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit db44679

Please sign in to comment.