Skip to content

Commit c826fa0

Browse files
committed
updating env variables
1 parent 2883c2f commit c826fa0

File tree

4 files changed

+21
-12
lines changed

4 files changed

+21
-12
lines changed

sample-apps/python/django_frontend_service/frontend_service_app/views.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,8 @@
2424

2525
# Initialize custom OTEL metrics export pipeline - OTLP approach (OTEL/Span export 1) Agent based
2626
custom_resource = Resource.create({
27-
"service.name": "OTEL_SERVICE_NAME",
27+
"service.name": os.getenv("OTEL_SERVICE_NAME", "python-sample-application"),
2828
"deployment.environment.name": "custom_export",
29-
#"test" being overridden by python-sample-application-${var.test_id} in main.tf
3029
})
3130
custom_otlp_exporter = OTLPMetricExporter(
3231
endpoint="http://localhost:4317",
@@ -46,7 +45,7 @@
4645

4746
# Custom Export Pipeline - HTTP Direct
4847
resource = Resource.create({
49-
"service.name": "OTEL_SERVICE_NAME",
48+
"service.name": os.getenv("OTEL_SERVICE_NAME", "python-sample-application"),
5049
"deployment.environment.name": "agent_export",
5150
})
5251

terraform/python/ec2/default/amazon-cloudwatch-agent.json

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,16 @@
1010
},
1111
"logs": {
1212
"metrics_collected": {
13-
"application_signals": {},
14-
"otlp": {
15-
"grpc_endpoint": "0.0.0.0:4317",
16-
"http_endpoint": "0.0.0.0:4318"
17-
}
13+
"application_signals": {}
14+
}
15+
},
16+
"metrics": {
17+
"metrics_collected": {
18+
"application_signals": {}
19+
},
20+
"otlp": {
21+
"grpc_endpoint": "0.0.0.0:4317",
22+
"http_endpoint": "0.0.0.0:4318"
1823
}
1924
}
2025
}

terraform/python/ec2/default/main.tf

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ resource "null_resource" "main_service_setup" {
180180
export OTEL_EXPORTER_OTLP_METRICS_PROTOCOL=grpc
181181
export OTEL_SERVICE_NAME=python-sample-application-${var.test_id}
182182
export OTEL_TRACES_SAMPLER=always_on
183-
export OTEL_RESOURCE_ATTRIBUTES="service.name=GOAT_Service,deployment.environment.name=GOAT_Pen"
183+
export OTEL_RESOURCE_ATTRIBUTES="service.name=python-sample-application-${var.test_id},deployment.environment.name=ec2:default"
184184
export AWS_REGION='${var.aws_region}'
185185
export CUSTOM_METRICS_ENABLED='${var.custom_metrics_enabled}'
186186
export RDS_MYSQL_CLUSTER_ENDPOINT='dummy-endpoint'
@@ -283,8 +283,8 @@ resource "null_resource" "remote_service_setup" {
283283
sudo yum install ec2-instance-connect -y
284284
285285
# Copy in CW Agent configuration
286-
agent_config='${replace(replace(file(var.custom_metrics_enabled ? "./amazon-cloudwatch-custom-agent.json" : "./amazon-cloudwatch-agent.json"), "/\\s+/", ""), "$REGION", var.aws_region)}'
287-
echo $agent_config > amazon-cloudwatch-agent.json
286+
agent_config='${replace(file(var.custom_metrics_enabled ? "./amazon-cloudwatch-custom-agent.json" : "./amazon-cloudwatch-agent.json"), "$REGION", var.aws_region)}'
287+
echo "$agent_config" > amazon-cloudwatch-agent.json
288288
289289
# Get and run CW agent rpm
290290
${var.get_cw_agent_rpm_command}

validator/src/main/resources/expected-data-template/python/ec2/default/aws-otel-custom-metrics.mustache

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@
66
-
77
name: deployment.environment.name
88
value: custom_export
9+
-
10+
name: service.name
11+
value: {{serviceName}}
912
-
1013
name: telemetry.sdk.language
1114
value: python
@@ -22,10 +25,12 @@
2225
metricName: agent_export_counter
2326
namespace: {{customMetricNamespace}}
2427
dimensions:
25-
2628
-
2729
name: deployment.environment.name
2830
value: agent_export
31+
-
32+
name: service.name
33+
value: {{serviceName}}
2934
-
3035
name: telemetry.sdk.language
3136
value: python

0 commit comments

Comments
 (0)