Skip to content

Commit

Permalink
fix(infra): change otel_endpoint env name (#1574)
Browse files Browse the repository at this point in the history
fix: change otel_endpoint env name
  • Loading branch information
k1g99 authored Mar 19, 2024
1 parent 4984ff3 commit 3cde213
Show file tree
Hide file tree
Showing 12 changed files with 17 additions and 15 deletions.
4 changes: 2 additions & 2 deletions apps/backend/apps/admin/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ const bootstrap = async () => {
// otel instrumentation
if (process.env.NODE_ENV == 'production') {
if (
process.env.OTEL_EXPORTER_OTLP_ENDPOINT == undefined ||
process.env.OTEL_EXPORTER_OTLP_ENDPOINT == ''
process.env.OTEL_EXPORTER_OTLP_ENDPOINT_URL == undefined ||
process.env.OTEL_EXPORTER_OTLP_ENDPOINT_URL == ''
) {
console.log('The exporter url is not defined')
} else {
Expand Down
3 changes: 2 additions & 1 deletion apps/backend/apps/admin/src/metric.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ import { SemanticResourceAttributes } from '@opentelemetry/semantic-conventions'

const startMetricsExporter = () => {
const options = {
url: 'http://' + process.env.OTEL_EXPORTER_OTLP_ENDPOINT + '/v1/metrics', // Grafana Agent Metric을 받는 url
url:
'http://' + process.env.OTEL_EXPORTER_OTLP_ENDPOINT_URL + '/v1/metrics', // Grafana Agent Metric을 받는 url
headers: {},
concurrencyLimit: 5
}
Expand Down
2 changes: 1 addition & 1 deletion apps/backend/apps/admin/src/tracer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class Tracer {

// http://localhost:4318/v1/traces
private exporter = new OTLPTraceExporter({
url: 'http://' + process.env.OTEL_EXPORTER_OTLP_ENDPOINT + '/v1/traces'
url: 'http://' + process.env.OTEL_EXPORTER_OTLP_ENDPOINT_URL + '/v1/traces'
})

private provider = new BasicTracerProvider({
Expand Down
4 changes: 2 additions & 2 deletions apps/backend/apps/client/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ const bootstrap = async () => {
// otel instrumentation
if (process.env.NODE_ENV == 'production') {
if (
process.env.OTEL_EXPORTER_OTLP_ENDPOINT == undefined ||
process.env.OTEL_EXPORTER_OTLP_ENDPOINT == ''
process.env.OTEL_EXPORTER_OTLP_ENDPOINT_URL == undefined ||
process.env.OTEL_EXPORTER_OTLP_ENDPOINT_URL == ''
) {
console.log('The exporter url is not defined')
} else {
Expand Down
3 changes: 2 additions & 1 deletion apps/backend/apps/client/src/metric.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ import { SemanticResourceAttributes } from '@opentelemetry/semantic-conventions'

const startMetricsExporter = () => {
const options = {
url: 'http://' + process.env.OTEL_EXPORTER_OTLP_ENDPOINT + '/v1/metrics', // Grafana Agent Metric을 받는 url
url:
'http://' + process.env.OTEL_EXPORTER_OTLP_ENDPOINT_URL + '/v1/metrics', // Grafana Agent Metric을 받는 url
headers: {},
concurrencyLimit: 5
}
Expand Down
2 changes: 1 addition & 1 deletion apps/backend/apps/client/src/tracer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class Tracer {

// http://localhost:4318/v1/traces
private exporter = new OTLPTraceExporter({
url: 'http://' + process.env.OTEL_EXPORTER_OTLP_ENDPOINT + '/v1/traces'
url: 'http://' + process.env.OTEL_EXPORTER_OTLP_ENDPOINT_URL + '/v1/traces'
})

private provider = new BasicTracerProvider({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@
"value" : "${media_secret_key}"
},
{
"name" : "OTEL_EXPORTER_OTLP_ENDPOINT",
"name" : "OTEL_EXPORTER_OTLP_ENDPOINT_URL",
"value" : "${otel_endpoint}"
}
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@
"value": "${kakao_client_secret}"
},
{
"name" : "OTEL_EXPORTER_OTLP_ENDPOINT",
"name" : "OTEL_EXPORTER_OTLP_ENDPOINT_URL",
"value" : "${otel_endpoint}"
}
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
"value": "${redis_port}"
},
{
"name" : "OTEL_EXPORTER_OTLP_ENDPOINT",
"name" : "OTEL_EXPORTER_OTLP_ENDPOINT_URL",
"value" : "${otel_endpoint}"
}
],
Expand Down
4 changes: 2 additions & 2 deletions apps/iris/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,15 @@ func main() {
ctx := context.Background()
cache := cache.NewCache(ctx)
if env == "production" {
if utils.Getenv("OTEL_EXPORTER_OTLP_ENDPOINT", "") != "" {
if utils.Getenv("OTEL_EXPORTER_OTLP_ENDPOINT_URL", "") != "" {
shutdown := observability.InitTracer(ctx)
defer shutdown()
observability.SetGlobalMeterProvider()
// Aynchronous Instruments로써, go routine 불필요
observability.GetMemoryMeter(otel.Meter("memory-metrics"))
observability.GetCPUMeter(otel.Meter("cpu-metrics"), 15*time.Second)
} else {
logProvider.Log(logger.INFO, "Cannot find OTEL_EXPORTER_OTLP_ENDPOINT")
logProvider.Log(logger.INFO, "Cannot find OTEL_EXPORTER_OTLP_ENDPOINT_URL")
}
} else {
logProvider.Log(logger.INFO, "Running in development mode")
Expand Down
2 changes: 1 addition & 1 deletion apps/iris/src/observability/metric.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ func newMetricResource() (*resource.Resource, error) {

func newMeterProvider(res *resource.Resource, second time.Duration) (*sdkmetric.MeterProvider, error) {
// Use OLTP Exporter for Grafana Agent (Recommended)
entryPoint := os.Getenv("OTEL_EXPORTER_OTLP_ENDPOINT")
entryPoint := os.Getenv("OTEL_EXPORTER_OTLP_ENDPOINT_URL")
otlpExporter, err := otlpmetrichttp.New(context.Background(), otlpmetrichttp.WithEndpointURL("http://"+entryPoint+"/v1/metrics"))
if err != nil {
return nil, err
Expand Down
2 changes: 1 addition & 1 deletion apps/iris/src/observability/tracer.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ func newResource(ctx context.Context) (*resource.Resource, error) {
}

func newExporter(ctx context.Context) (*otlptrace.Exporter, error) {
oltpEndpoint := utils.Getenv("OTEL_EXPORTER_OTLP_ENDPOINT", "")
oltpEndpoint := utils.Getenv("OTEL_EXPORTER_OTLP_ENDPOINT_URL", "")
exp, err := otlptracehttp.New(ctx, otlptracehttp.WithEndpoint(oltpEndpoint), otlptracehttp.WithInsecure())
if err != nil {
return nil, err
Expand Down

0 comments on commit 3cde213

Please sign in to comment.