Skip to content

Commit a31fbd0

Browse files
authored
fix(deployment): adjust the resources needed for otel-collector in each env (#6576)
1 parent 30339b6 commit a31fbd0

File tree

3 files changed

+13
-18
lines changed

3 files changed

+13
-18
lines changed

deployment/index.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -72,10 +72,7 @@ const environment = prepareEnvironment({
7272
rootDns: new pulumi.Config('common').require('dnsZone'),
7373
});
7474
deploySentryEventsMonitor({ docker, environment, sentry });
75-
const observability = deployObservability({
76-
envName,
77-
tableSuffix: envName === 'prod' ? 'production' : envName,
78-
});
75+
const observability = deployObservability({ environment });
7976
const clickhouse = deployClickhouse();
8077
const postgres = deployPostgres();
8178
const redis = deployRedis({ environment });

deployment/services/observability.ts

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,13 @@
11
import * as pulumi from '@pulumi/pulumi';
22
import { serviceLocalHost } from '../utils/local-endpoint';
33
import { Observability as ObservabilityInstance } from '../utils/observability';
4+
import { Environment } from './environment';
45
import { deployGrafana } from './grafana';
56

67
// Change this to control OTEL tracing for usage service
78
const enableTracingForUsageService = true;
89

9-
export function deployObservability(config: {
10-
envName: string;
11-
/**
12-
* Suffix for the table names (production, staging, dev).
13-
* It can't be envName as "prod" is not a valid table suffix.
14-
*/
15-
tableSuffix: string;
16-
}) {
10+
export function deployObservability(config: { environment: Environment }) {
1711
const observabilityConfig = new pulumi.Config('observability');
1812

1913
if (!observabilityConfig.getBoolean('enabled')) {
@@ -25,7 +19,7 @@ export function deployObservability(config: {
2519
const useLocal = observabilityConfig.getBoolean('local');
2620

2721
const observability = new ObservabilityInstance(
28-
config.envName,
22+
config.environment,
2923
useLocal
3024
? 'local'
3125
: {
@@ -53,12 +47,15 @@ export function deployObservability(config: {
5347
throw new Error('OTLP collector service is required for observability');
5448
}
5549

50+
const tableSuffix =
51+
config.environment.envName === 'prod' ? 'production' : config.environment.envName;
52+
5653
return {
5754
tracingEndpoint: serviceLocalHost(observabilityInstance.otlpCollectorService).apply(
5855
host => `http://${host}:4318/v1/traces`,
5956
),
6057
observability: observabilityInstance,
61-
grafana: useLocal ? undefined : deployGrafana(config.envName, config.tableSuffix),
58+
grafana: useLocal ? undefined : deployGrafana(config.environment.envName, tableSuffix),
6259
enabled: true,
6360
enabledForUsageService: enableTracingForUsageService,
6461
};

deployment/utils/observability.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import * as k8s from '@pulumi/kubernetes';
22
import { interpolate, Output } from '@pulumi/pulumi';
3+
import { Environment } from '../services/environment';
34
import { helmChart } from './helm';
45
import { Values as OpenTelemetryCollectorValues } from './opentelemetry-collector.types';
56
import { VectorValues } from './vector.types';
@@ -31,7 +32,7 @@ export const VECTOR_HELM_CHART = helmChart('https://helm.vector.dev', 'vector',
3132

3233
export class Observability {
3334
constructor(
34-
private envName: string,
35+
private environment: Environment,
3536
private config: ObservabilityConfig,
3637
) {}
3738

@@ -92,7 +93,7 @@ export class Observability {
9293
labels: {
9394
namespace: '{{`{{ kubernetes.pod_namespace }}`}}',
9495
container_name: '{{`{{ kubernetes.container_name }}`}}',
95-
env: this.envName,
96+
env: this.environment.envName,
9697
},
9798
encoding: {
9899
codec: 'text',
@@ -111,8 +112,8 @@ export class Observability {
111112
replicaCount: 1,
112113
resources: {
113114
limits: {
114-
cpu: '512m',
115-
memory: '1000Mi',
115+
cpu: this.environment.isProduction ? '512m' : '150m',
116+
memory: this.environment.isProduction ? '1000Mi' : '300Mi',
116117
},
117118
},
118119
podAnnotations: {

0 commit comments

Comments
 (0)