Skip to content

Commit

Permalink
fix(collector): move to an otel collector
Browse files Browse the repository at this point in the history
  • Loading branch information
bassrock committed Oct 8, 2024
1 parent 91565de commit f7d6854
Show file tree
Hide file tree
Showing 25 changed files with 69 additions and 248 deletions.
4 changes: 3 additions & 1 deletion infrastructure/client-api/src/config/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ export const config = {
},
},
tracing: {
host: 'localhost',
url: isDev
? 'https://otlp-collector.getpocket.dev'
: 'https://otlp-collector.readitlater.com',
},
};
38 changes: 2 additions & 36 deletions infrastructure/client-api/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down Expand Up @@ -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,
Expand Down
5 changes: 5 additions & 0 deletions infrastructure/list-api/src/config/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,4 +50,9 @@ export const config = {
userEvents: `PocketEventBridge-${environment}-UserEventTopic`,
},
},
tracing: {
url: isDev
? 'https://otlp-collector.getpocket.dev'
: 'https://otlp-collector.readitlater.com',
},
};
38 changes: 4 additions & 34 deletions infrastructure/list-api/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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: [
{
Expand Down Expand Up @@ -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,
Expand Down
5 changes: 5 additions & 0 deletions infrastructure/parser-graphql-wrapper/src/config/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
},
};
38 changes: 4 additions & 34 deletions infrastructure/parser-graphql-wrapper/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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: [
Expand Down Expand Up @@ -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,
Expand Down
4 changes: 3 additions & 1 deletion infrastructure/user-api/src/config/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
},
};
38 changes: 4 additions & 34 deletions infrastructure/user-api/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down Expand Up @@ -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,
Expand Down
6 changes: 5 additions & 1 deletion infrastructure/user-list-search/apollo_ecs.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
55 changes: 0 additions & 55 deletions infrastructure/user-list-search/ecs.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
2 changes: 2 additions & 0 deletions infrastructure/user-list-search/locals.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand All @@ -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"
}
}

Expand Down
2 changes: 1 addition & 1 deletion infrastructure/user-list-search/queue_users_ecs.tf
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ module "queue_users" {

resource "aws_ecs_task_definition" "queue_users" {
family = "${local.prefix}-QueueUsers"
container_definitions = "[${module.queue_users.json_map_encoded}, ${module.otel.json_map_encoded}]"
container_definitions = "[${module.queue_users.json_map_encoded}]"

task_role_arn = aws_iam_role.ecs_task_role.arn
execution_role_arn = aws_iam_role.ecs_execution_role.arn
Expand Down
5 changes: 5 additions & 0 deletions infrastructure/v3-proxy-api/src/config/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
},
};
Loading

0 comments on commit f7d6854

Please sign in to comment.