Skip to content

Commit

Permalink
Adjust resourcedetection for ecs
Browse files Browse the repository at this point in the history
  • Loading branch information
bjrara committed Sep 10, 2024
1 parent 82a0d1e commit c5e73ec
Show file tree
Hide file tree
Showing 16 changed files with 753 additions and 99 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ var attributesRenamingForMetric = map[string]string{
}

var resourceAttributesRenamingForTrace = map[string]string{
// these kubernetes resource attributes are set by the openTelemetry operator
// these kubernetes resource attributes are set by the OpenTelemetry operator
// see the code references from upstream:
// * https://github.com/open-telemetry/opentelemetry-operator/blob/0e39ee77693146e0924da3ca474a0fe14dc30b3a/pkg/instrumentation/sdk.go#L245
// * https://github.com/open-telemetry/opentelemetry-operator/blob/0e39ee77693146e0924da3ca474a0fe14dc30b3a/pkg/instrumentation/sdk.go#L305C43-L305C43
Expand All @@ -62,8 +62,8 @@ var attributesRenamingForTrace = map[string]string{
attr.AWSRemoteTarget: attr.AWSRemoteResourceIdentifier,
}

var resourceAttributesToMetric = map[string]string{
// these kubernetes resource attributes are set by the openTelemtry operator
var resourceToMetricAttributes = map[string]string{
// these kubernetes resource attributes are set by the OpenTelemetry operator
// see the code references from upstream:
// * https://github.com/open-telemetry/opentelemetry-operator/blob/0e39ee77693146e0924da3ca474a0fe14dc30b3a/pkg/instrumentation/sdk.go#L245
// * https://github.com/open-telemetry/opentelemetry-operator/blob/0e39ee77693146e0924da3ca474a0fe14dc30b3a/pkg/instrumentation/sdk.go#L305C43-L305C43
Expand Down Expand Up @@ -110,7 +110,7 @@ func (n *attributesNormalizer) copyResourceAttributesToAttributes(attributes, re
if isTrace {
return
}
for k, v := range resourceAttributesToMetric {
for k, v := range resourceToMetricAttributes {
if resourceAttrValue, ok := resourceAttributes.Get(k); ok {
// print some debug info when an attribute value is overwritten
if originalAttrValue, ok := attributes.Get(k); ok {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ func TestCopyResourceAttributesToAttributes(t *testing.T) {

// Create a pcommon.Map for resourceAttributes with some attributes
resourceAttributes := pcommon.NewMap()
for resourceAttrKey, attrKey := range resourceAttributesToMetric {
for resourceAttrKey, attrKey := range resourceToMetricAttributes {
resourceAttributes.PutStr(resourceAttrKey, attrKey+"-value")
}
resourceAttributes.PutStr("host.id", "i-01ef7d37f42caa168")
Expand All @@ -98,7 +98,7 @@ func TestCopyResourceAttributesToAttributes(t *testing.T) {
normalizer.copyResourceAttributesToAttributes(attributes, resourceAttributes, false)

// Check that the attribute has been copied correctly
for _, attrKey := range resourceAttributesToMetric {
for _, attrKey := range resourceToMetricAttributes {
if value, ok := attributes.Get(attrKey); !ok || value.AsString() != attrKey+"-value" {
t.Errorf("Attribute was not copied correctly: got %v, want %v", value.AsString(), attrKey+"-value")
}
Expand Down
27 changes: 27 additions & 0 deletions translator/tocwconfig/sampleConfig/appsignals_and_ecs_config.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
[agent]
collection_jitter = "0s"
debug = false
flush_interval = "1s"
flush_jitter = "0s"
hostname = "host_name_from_env"
interval = "60s"
logfile = ""
logtarget = "lumberjack"
metric_batch_size = 1000
metric_buffer_limit = 10000
omit_hostname = false
precision = ""
quiet = false
round_interval = false

[inputs]

[outputs]

[[outputs.cloudwatchlogs]]
endpoint_override = "https://fake_endpoint"
force_flush_interval = "5s"
log_stream_name = "arn_aws_ecs_us-east-1_account_id_task/task_id"
region = "us-east-1"

[processors]
26 changes: 26 additions & 0 deletions translator/tocwconfig/sampleConfig/appsignals_and_ecs_config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
"agent": {
"region": "us-east-1"
},
"logs": {
"metrics_collected": {
"application_signals": {
"tls": {
"cert_file": "path/to/cert.crt",
"key_file": "path/to/key.key"
},
"limiter": {
"log_dropped_metrics": true,
"rotation_interval": "10m"
}
}
},
"force_flush_interval": 5,
"endpoint_override":"https://fake_endpoint"
},
"traces": {
"traces_collected": {
"application_signals": {}
}
}
}
Loading

0 comments on commit c5e73ec

Please sign in to comment.