diff --git a/infrastructure/client-api/src/config/index.ts b/infrastructure/client-api/src/config/index.ts index 00ecb8fbd..09a495fda 100644 --- a/infrastructure/client-api/src/config/index.ts +++ b/infrastructure/client-api/src/config/index.ts @@ -47,6 +47,8 @@ export const config = { }, }, tracing: { - host: 'localhost', + url: isDev + ? 'https://otlp-collector.getpocket.dev' + : 'https://otlp-collector.readitlater.com', }, }; diff --git a/infrastructure/client-api/src/main.ts b/infrastructure/client-api/src/main.ts index 0aab79814..2f7f737a8 100644 --- a/infrastructure/client-api/src/main.ts +++ b/infrastructure/client-api/src/main.ts @@ -235,8 +235,8 @@ class ClientAPI extends TerraformStack { value: config.isProd ? 'production' : 'development', }, { - name: 'OTLP_COLLECTOR_HOST', - value: `${config.tracing.host}`, + name: 'OTLP_COLLECTOR_URL', + value: `${config.tracing.url}`, }, { name: 'REDIS_ENDPOINT', @@ -266,40 +266,6 @@ class ClientAPI extends TerraformStack { startPeriod: 0, }, }, - { - name: 'otel-collector', - containerImage: 'pocket/opentelemetry-collector-contrib', - essential: true, - logMultilinePattern: '^\\S.+', - logGroup: this.createCustomLogGroup('otel-collector'), - portMappings: [ - { - hostPort: 4138, - containerPort: 4138, - }, - { - hostPort: 4137, - containerPort: 4137, - }, - { - hostPort: 55681, - containerPort: 55681, - }, - ], - envVars: [ - { - name: 'DEPLOYMENT_ENVIRONMENT_NAME', - value: config.tags.env_code, - }, - ], - secretEnvVars: [ - { - name: 'GOOGLE_APPLICATION_CREDENTIALS_JSON', - valueFrom: `arn:aws:secretsmanager:${region.name}:${caller.accountId}:secret:Shared/GCP_SA_TRACES:::`, - }, - ], - repositoryCredentialsParam: `arn:aws:secretsmanager:${region.name}:${caller.accountId}:secret:Shared/DockerHub`, - }, ], codeDeploy: { useCodeDeploy: true, diff --git a/infrastructure/list-api/src/config/index.ts b/infrastructure/list-api/src/config/index.ts index 773fd1e9b..9fbde0aee 100644 --- a/infrastructure/list-api/src/config/index.ts +++ b/infrastructure/list-api/src/config/index.ts @@ -50,4 +50,9 @@ export const config = { userEvents: `PocketEventBridge-${environment}-UserEventTopic`, }, }, + tracing: { + url: isDev + ? 'https://otlp-collector.getpocket.dev' + : 'https://otlp-collector.readitlater.com', + }, }; diff --git a/infrastructure/list-api/src/main.ts b/infrastructure/list-api/src/main.ts index 052cb348d..b93d8cb5a 100644 --- a/infrastructure/list-api/src/main.ts +++ b/infrastructure/list-api/src/main.ts @@ -230,6 +230,10 @@ class ListAPI extends TerraformStack { name: 'EVENT_BUS_NAME', value: config.envVars.eventBusName, }, + { + name: 'OTLP_COLLECTOR_URL', + value: config.tracing.url, + }, ], secretEnvVars: [ { @@ -304,40 +308,6 @@ class ListAPI extends TerraformStack { logGroup: this.createCustomLogGroup('app'), logMultilinePattern: '^\\S.+', }, - { - name: 'otel-collector', - containerImage: 'pocket/opentelemetry-collector-contrib', - essential: true, - logMultilinePattern: '^\\S.+', - logGroup: this.createCustomLogGroup('otel-collector'), - portMappings: [ - { - hostPort: 4138, - containerPort: 4138, - }, - { - hostPort: 4137, - containerPort: 4137, - }, - { - hostPort: 55681, - containerPort: 55681, - }, - ], - envVars: [ - { - name: 'DEPLOYMENT_ENVIRONMENT_NAME', - value: config.tags.env_code, - }, - ], - secretEnvVars: [ - { - name: 'GOOGLE_APPLICATION_CREDENTIALS_JSON', - valueFrom: `arn:aws:secretsmanager:${region.name}:${caller.accountId}:secret:Shared/GCP_SA_TRACES:::`, - }, - ], - repositoryCredentialsParam: `arn:aws:secretsmanager:${region.name}:${caller.accountId}:secret:Shared/DockerHub`, - }, ], codeDeploy: { useCodeDeploy: true, diff --git a/infrastructure/parser-graphql-wrapper/src/config/index.ts b/infrastructure/parser-graphql-wrapper/src/config/index.ts index 5c5243439..7d864b46c 100644 --- a/infrastructure/parser-graphql-wrapper/src/config/index.ts +++ b/infrastructure/parser-graphql-wrapper/src/config/index.ts @@ -42,4 +42,9 @@ export const config = { databaseName: 'readitla_shares', masterUsername: 'share_urls', }, + tracing: { + url: isDev + ? 'https://otlp-collector.getpocket.dev' + : 'https://otlp-collector.readitlater.com', + }, }; diff --git a/infrastructure/parser-graphql-wrapper/src/main.ts b/infrastructure/parser-graphql-wrapper/src/main.ts index 247b798e5..a6e6d6960 100644 --- a/infrastructure/parser-graphql-wrapper/src/main.ts +++ b/infrastructure/parser-graphql-wrapper/src/main.ts @@ -176,6 +176,10 @@ class ParserGraphQLWrapper extends TerraformStack { name: 'ITEM_SUMMARY_TABLE', value: dynamodb.itemSummaryTable.dynamodb.name, }, + { + name: 'OTLP_COLLECTOR_URL', + value: config.tracing.url, + }, ], healthCheck: { command: [ @@ -278,40 +282,6 @@ class ParserGraphQLWrapper extends TerraformStack { }, ], }, - { - name: 'otel-collector', - containerImage: 'pocket/opentelemetry-collector-contrib', - essential: true, - logMultilinePattern: '^\\S.+', - logGroup: this.createCustomLogGroup('otel-collector'), - portMappings: [ - { - hostPort: 4138, - containerPort: 4138, - }, - { - hostPort: 4137, - containerPort: 4137, - }, - { - hostPort: 55681, - containerPort: 55681, - }, - ], - envVars: [ - { - name: 'DEPLOYMENT_ENVIRONMENT_NAME', - value: config.tags.env_code, - }, - ], - secretEnvVars: [ - { - name: 'GOOGLE_APPLICATION_CREDENTIALS_JSON', - valueFrom: `arn:aws:secretsmanager:${region.name}:${caller.accountId}:secret:Shared/GCP_SA_TRACES`, - }, - ], - repositoryCredentialsParam: `arn:aws:secretsmanager:${region.name}:${caller.accountId}:secret:Shared/DockerHub`, - }, ], codeDeploy: { useCodeDeploy: true, diff --git a/infrastructure/user-api/src/config/index.ts b/infrastructure/user-api/src/config/index.ts index 53765fc99..0cf3ad5dd 100644 --- a/infrastructure/user-api/src/config/index.ts +++ b/infrastructure/user-api/src/config/index.ts @@ -37,6 +37,8 @@ export const config = { env_code: isDev ? 'dev' : 'prod', }, tracing: { - host: 'localhost', + url: isDev + ? 'https://otlp-collector.getpocket.dev' + : 'https://otlp-collector.readitlater.com', }, }; diff --git a/infrastructure/user-api/src/main.ts b/infrastructure/user-api/src/main.ts index 3cf4c6a2d..5e99ca5d7 100644 --- a/infrastructure/user-api/src/main.ts +++ b/infrastructure/user-api/src/main.ts @@ -112,6 +112,10 @@ class UserAPI extends TerraformStack { startPeriod: 0, }, envVars: [ + { + name: 'OTLP_COLLECTOR_URL', + value: config.tracing.url, + }, { name: 'NODE_ENV', value: process.env.NODE_ENV ?? 'development', @@ -198,40 +202,6 @@ class UserAPI extends TerraformStack { logGroup: this.createCustomLogGroup('app'), logMultilinePattern: '^\\S.+', }, - { - name: 'otel-collector', - containerImage: 'pocket/opentelemetry-collector-contrib', - essential: true, - logMultilinePattern: '^\\S.+', - logGroup: this.createCustomLogGroup('otel-collector'), - portMappings: [ - { - hostPort: 4138, - containerPort: 4138, - }, - { - hostPort: 4137, - containerPort: 4137, - }, - { - hostPort: 55681, - containerPort: 55681, - }, - ], - envVars: [ - { - name: 'DEPLOYMENT_ENVIRONMENT_NAME', - value: config.tags.env_code, - }, - ], - secretEnvVars: [ - { - name: 'GOOGLE_APPLICATION_CREDENTIALS_JSON', - valueFrom: `arn:aws:secretsmanager:${region.name}:${caller.accountId}:secret:Shared/GCP_SA_TRACES:::`, - }, - ], - repositoryCredentialsParam: `arn:aws:secretsmanager:${region.name}:${caller.accountId}:secret:Shared/DockerHub`, - }, ], codeDeploy: { useCodeDeploy: true, diff --git a/infrastructure/user-list-search/apollo_ecs.tf b/infrastructure/user-list-search/apollo_ecs.tf index e520b710c..d38dc55de 100644 --- a/infrastructure/user-list-search/apollo_ecs.tf +++ b/infrastructure/user-list-search/apollo_ecs.tf @@ -110,13 +110,17 @@ module "apollo" { { name = "CORPUS_SEARCH_ENDPOINT" value = module.corpus_embeddings.opensearch_endpoint + }, + { + name = "OTLP_COLLECTOR_URL" + value = local.workspace.otlpCollectorUrl } ] } resource "aws_ecs_task_definition" "apollo" { family = "${local.prefix}-Apollo" - container_definitions = "[${module.apollo.json_map_encoded}, ${module.otel.json_map_encoded}]" + container_definitions = "[${module.apollo.json_map_encoded}]" task_role_arn = aws_iam_role.ecs_task_role.arn execution_role_arn = aws_iam_role.ecs_execution_role.arn diff --git a/infrastructure/user-list-search/ecs.tf b/infrastructure/user-list-search/ecs.tf index 9780df9ba..e10d1ff5e 100644 --- a/infrastructure/user-list-search/ecs.tf +++ b/infrastructure/user-list-search/ecs.tf @@ -101,58 +101,3 @@ resource "aws_security_group" "ecs_security_group" { depends_on = [aws_security_group.alb_security_group] } -resource "aws_cloudwatch_log_group" "xray" { - name = "/ecs/${local.name}/${local.env}/xray" - retention_in_days = 30 -} - -module "otel" { - source = "cloudposse/ecs-container-definition/aws" - version = "0.61.1" - - essential = true - container_name = "otel-collector" - container_image = "pocket/opentelemetry-collector-contrib" - - repository_credentials = { - credentialsParameter : local.container_credential - } - - log_configuration = { - logDriver = "awslogs" - secretOptions = [] - options = { - awslogs-region = data.aws_region.current.name - awslogs-group = aws_cloudwatch_log_group.xray.name - awslogs-stream-prefix = "ecs" - } - } - - environment = [{ - name = "DEPLOYMENT_ENVIRONMENT_NAME", - value = local.tags.env_code, - }] - - secrets = [{ - name = "GOOGLE_APPLICATION_CREDENTIALS_JSON" - valueFrom = "${local.secret_path_shared}GCP_SA_TRACES:::" - }] - - port_mappings = [ - { - containerPort = 4138 - hostPort = 4138 - }, - { - containerPort = 4137 - hostPort = 4137 - }, - { - containerPort = 55681 - hostPort = 55681 - } - ] - container_cpu = null - container_memory = null - container_memory_reservation = null -} diff --git a/infrastructure/user-list-search/locals.tf b/infrastructure/user-list-search/locals.tf index 0c30dc3bd..d9f3b27bc 100644 --- a/infrastructure/user-list-search/locals.tf +++ b/infrastructure/user-list-search/locals.tf @@ -81,6 +81,7 @@ locals { sns_topic_corpus_events = "PocketEventBridge-Dev-CorpusEventsTopic" sns_topic_collection_events = "PocketEventBridge-Dev-CollectionEventTopic" userApiUri = "https://user-list-search.getpocket.dev" + otlpCollectorUrl = "https://otlp-collector.getpocket.dev" } UserListSearch-Prod = { @@ -97,6 +98,7 @@ locals { sns_topic_corpus_events = "PocketEventBridge-Prod-CorpusEventsTopic" sns_topic_collection_events = "PocketEventBridge-Prod-CollectionEventTopic" userApiUri = "https://user-list-search.readitlater.com" + otlpCollectorUrl = "https://otlp-collector.readitlater.com" } } diff --git a/infrastructure/v3-proxy-api/src/config/index.ts b/infrastructure/v3-proxy-api/src/config/index.ts index fae3a2019..d54e34cac 100644 --- a/infrastructure/v3-proxy-api/src/config/index.ts +++ b/infrastructure/v3-proxy-api/src/config/index.ts @@ -38,4 +38,9 @@ export const config = { component_code: `pocket-${name.toLowerCase()}`, env_code: isDev ? 'dev' : 'prod', }, + tracing: { + url: isDev + ? 'https://otlp-collector.getpocket.dev' + : 'https://otlp-collector.readitlater.com', + }, }; diff --git a/infrastructure/v3-proxy-api/src/main.ts b/infrastructure/v3-proxy-api/src/main.ts index 24f8f7527..87d636b52 100644 --- a/infrastructure/v3-proxy-api/src/main.ts +++ b/infrastructure/v3-proxy-api/src/main.ts @@ -112,6 +112,10 @@ class Stack extends TerraformStack { name: 'ENVIRONMENT', value: process.env.NODE_ENV ?? 'development', // this gives us a nice lowercase production and development }, + { + name: 'OTLP_COLLECTOR_URL', + value: config.tracing.url, + }, ], secretEnvVars: [ { @@ -128,40 +132,6 @@ class Stack extends TerraformStack { }, ], }, - { - name: 'otel-collector', - containerImage: 'pocket/opentelemetry-collector-contrib', - essential: true, - logMultilinePattern: '^\\S.+', - logGroup: this.createCustomLogGroup('otel-collector'), - portMappings: [ - { - hostPort: 4138, - containerPort: 4138, - }, - { - hostPort: 4137, - containerPort: 4137, - }, - { - hostPort: 55681, - containerPort: 55681, - }, - ], - envVars: [ - { - name: 'DEPLOYMENT_ENVIRONMENT_NAME', - value: config.tags.env_code, - }, - ], - secretEnvVars: [ - { - name: 'GOOGLE_APPLICATION_CREDENTIALS_JSON', - valueFrom: `arn:aws:secretsmanager:${region.name}:${caller.accountId}:secret:Shared/GCP_SA_TRACES:::`, - }, - ], - repositoryCredentialsParam: `arn:aws:secretsmanager:${region.name}:${caller.accountId}:secret:Shared/DockerHub`, - }, ], codeDeploy: { useCodeDeploy: true, diff --git a/servers/client-api/config/router.yaml b/servers/client-api/config/router.yaml index af931ab75..8564477dd 100644 --- a/servers/client-api/config/router.yaml +++ b/servers/client-api/config/router.yaml @@ -169,8 +169,8 @@ telemetry: header_name: 'pocket-trace-id' otlp: enabled: true - endpoint: 'http://${env.OTLP_COLLECTOR_HOST:-localhost}:4317' - protocol: grpc + endpoint: '${env.OTLP_COLLECTOR_URL:-http://localhost:4318}' + protocol: http batch_processor: scheduled_delay: 100ms max_concurrent_exports: 1000 diff --git a/servers/list-api/src/config/index.ts b/servers/list-api/src/config/index.ts index 7e1d0b135..2a37e084f 100644 --- a/servers/list-api/src/config/index.ts +++ b/servers/list-api/src/config/index.ts @@ -123,7 +123,7 @@ export default { }, }, tracing: { - host: process.env.OTLP_COLLECTOR_HOST || 'localhost', + url: process.env.OTLP_COLLECTOR_URL || 'http://localhost:4318', release: process.env.GIT_SHA || '', serviceName, graphQLDepth: 8, diff --git a/servers/otel-collector/httpd.conf b/servers/otel-collector/httpd.conf index de64d156b..23c74fed9 100644 --- a/servers/otel-collector/httpd.conf +++ b/servers/otel-collector/httpd.conf @@ -3,7 +3,6 @@ server { listen 3000 default_server; listen [::]:3000 default_server; - # Everything is a 200 location /status { proxy_pass http://localhost:13133; } diff --git a/servers/otel-collector/otel-collector-config.yaml b/servers/otel-collector/otel-collector-config.yaml index 6659e8fd5..66a097d8b 100644 --- a/servers/otel-collector/otel-collector-config.yaml +++ b/servers/otel-collector/otel-collector-config.yaml @@ -11,8 +11,6 @@ receivers: extensions: health_check: endpoint: localhost:13133 - - exporters: googlecloud: @@ -52,7 +50,11 @@ processors: - key: host.id from_attribute: aws.ecs.task.id action: upsert +<<<<<<< HEAD # https://opentelemetry.io/docs/specs/semconv/resource/deployment-environment/ +======= + # https://opentelemetry.io/docs/specs/semconv/resource/deployment-environment/ +>>>>>>> 78c069da (fix(collector): move to an otel collector) - key: deployment.environment.name value: ${env:DEPLOYMENT_ENVIRONMENT_NAME} action: upsert diff --git a/servers/parser-graphql-wrapper/src/config/index.ts b/servers/parser-graphql-wrapper/src/config/index.ts index 8faf0d953..10f124fa7 100644 --- a/servers/parser-graphql-wrapper/src/config/index.ts +++ b/servers/parser-graphql-wrapper/src/config/index.ts @@ -14,7 +14,7 @@ export default { graphQLDepth: 8, // very permissive limit on depth tracing release: process.env.GIT_SHA || 'local', serviceName: 'parser-graphql-wrapper', - host: process.env.OTLP_COLLECTOR_HOST || 'localhost', + url: process.env.OTLP_COLLECTOR_URL || 'http://localhost:4318', }, app: { environment: process.env.NODE_ENV || 'development', diff --git a/servers/user-api/src/config/index.ts b/servers/user-api/src/config/index.ts index bb539fea6..35c694aee 100644 --- a/servers/user-api/src/config/index.ts +++ b/servers/user-api/src/config/index.ts @@ -81,7 +81,7 @@ export default { }, serviceName, tracing: { - host: process.env.OTLP_COLLECTOR_HOST || 'localhost', + url: process.env.OTLP_COLLECTOR_URL || 'http://localhost:4318', serviceName: serviceName, release: process.env.GIT_SHA || 'local', }, diff --git a/servers/user-list-search/src/config/index.ts b/servers/user-list-search/src/config/index.ts index 1408424d5..5213e49ae 100644 --- a/servers/user-list-search/src/config/index.ts +++ b/servers/user-list-search/src/config/index.ts @@ -7,7 +7,7 @@ const localAwsEndpoint = export const config = { serviceName: 'user-list-search', tracing: { - host: process.env.OTLP_COLLECTOR_HOST || 'localhost', + url: process.env.OTLP_COLLECTOR_URL || 'http://localhost:4318', release: process.env.GIT_SHA || '', serviceName: 'user-list-search', }, diff --git a/servers/v3-proxy-api/src/config/index.ts b/servers/v3-proxy-api/src/config/index.ts index f95b4b9c7..0db6fc665 100644 --- a/servers/v3-proxy-api/src/config/index.ts +++ b/servers/v3-proxy-api/src/config/index.ts @@ -13,7 +13,7 @@ export default { 9346, 7035, 15449, 22931, 23283, 53720, 60289, 70018, 73360, ], tracing: { - host: process.env.OTLP_COLLECTOR_HOST || 'localhost', + url: process.env.OTLP_COLLECTOR_URL || 'http://localhost:4318', serviceName: 'v3-api-proxy', release: process.env.GIT_SHA || 'local', },