Skip to content

Commit

Permalink
remove hardcoded version in otel conf
Browse files Browse the repository at this point in the history
  • Loading branch information
8naama committed Aug 7, 2024
1 parent 5c49655 commit 9eab4f9
Show file tree
Hide file tree
Showing 7 changed files with 31 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -504,6 +504,11 @@ function Add-LogsProcessorsToOtelConfig {
foreach ($LogsOtelProcessor in $LogsOtelProcessors) {
$local:ProcessorName = $LogsOtelProcessor.Replace('_', '/')

if ($ProcessorName -eq 'resource_agent') {
$local:AgentVersion = Get-Content "$env:TEMP\Logzio\version"
$Err = Add-YamlFileFieldValue "$script:OtelResourcesDir\$script:OtelConfigName" '.processors.resource/agent.attributes[0].value' $AgentVersion
}

$Err = Add-YamlFileFieldValue "$script:OtelResourcesDir\$script:OtelConfigName" '.service.pipelines.logs.processors' $ProcessorName
if ($Err.Count -ne 0) {
$Message = "logs.ps1 ($ExitCode): $($Err[0])"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,11 @@ function Add-MetricsProcessorsToOtelConfig {
foreach ($MetricsOtelProcessor in $MetricsOtelProcessors) {
$local:ProcessorName = $MetricsOtelProcessor.Replace('_', '/')

if ($ProcessorName -eq 'resource_agent') {
$local:AgentVersion = Get-Content "$env:TEMP\Logzio\version"
$Err = Add-YamlFileFieldValue "$script:OtelResourcesDir\$script:OtelConfigName" '.processors.resource/agent.attributes[0].value' $AgentVersion
}

$Err = Add-YamlFileFieldValue "$script:OtelResourcesDir\$script:OtelConfigName" '.service.pipelines.metrics.processors' $ProcessorName
if ($Err.Count -ne 0) {
$Message = "metrics.ps1 ($ExitCode): $($Err[0])"
Expand Down
5 changes: 5 additions & 0 deletions resources-linux/otel/datasource_logs_utils.bash
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,11 @@ function add_logs_processors_to_otel_config {
for logs_otel_processor in "${LOGS_OTEL_PROCESSORS[@]}"; do
local processor_name="${logs_otel_processor//_//}"

if [[ $processor_name == 'resource_agent' ]] ; then
AGENT_VERSION=$(cat '/tmp/logzio/version')
add_yaml_file_field_value "$OTEL_RESOURCES_DIR/$OTEL_CONFIG_NAME" '.processors.resource/agent.attributes[0].value' "$AGENT_VERSION"
fi

add_yaml_file_field_value "$OTEL_RESOURCES_DIR/$OTEL_CONFIG_NAME" '.service.pipelines.logs.processors' $processor_name
if [[ $? -ne 0 ]]; then
message="logs.bash ($EXIT_CODE): $(get_task_error_message)"
Expand Down
5 changes: 5 additions & 0 deletions resources-linux/otel/datasource_metrics_utils.bash
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,11 @@ function add_metrics_processors_to_otel_config {
for metrics_otel_processor in "${METRICS_OTEL_PROCESSORS[@]}"; do
local processor_name="${metrics_otel_processor//_//}"

if [[ $processor_name == 'resource_agent' ]] ; then
AGENT_VERSION=$(cat '/tmp/logzio/version')
add_yaml_file_field_value "$OTEL_RESOURCES_DIR/$OTEL_CONFIG_NAME" '.processors.resource/agent.attributes[0].value' "$AGENT_VERSION"
fi

add_yaml_file_field_value "$OTEL_RESOURCES_DIR/$OTEL_CONFIG_NAME" '.service.pipelines.metrics.processors' "$processor_name"
if [[ $? -ne 0 ]]; then
message="metrics.bash ($EXIT_CODE): $(get_task_error_message)"
Expand Down
5 changes: 5 additions & 0 deletions resources-mac/otel/datasource_logs_utils.bash
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,11 @@ function add_logs_processors_to_otel_config {
for logs_otel_processor in "${LOGS_OTEL_PROCESSORS[@]}"; do
local processor_name="${logs_otel_processor//_//}"

if [[ $processor_name == 'resource_agent' ]] ; then
AGENT_VERSION=$(cat '/tmp/logzio/version')
add_yaml_file_field_value "$OTEL_RESOURCES_DIR/$OTEL_CONFIG_NAME" '.processors.resource/agent.attributes[0].value' "$AGENT_VERSION"
fi

add_yaml_file_field_value "$OTEL_RESOURCES_DIR/$OTEL_CONFIG_NAME" '.service.pipelines.logs.processors' $processor_name
if [[ $? -ne 0 ]]; then
message="logs.bash ($EXIT_CODE): $(get_task_error_message)"
Expand Down
5 changes: 5 additions & 0 deletions resources-mac/otel/datasource_metrics_utils.bash
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,11 @@ function add_metrics_processors_to_otel_config {
for metrics_otel_processor in "${METRICS_OTEL_PROCESSORS[@]}"; do
local processor_name="${metrics_otel_processor//_//}"

if [[ $processor_name == 'resource_agent' ]] ; then
AGENT_VERSION=$(cat '/tmp/logzio/version')
add_yaml_file_field_value "$OTEL_RESOURCES_DIR/$OTEL_CONFIG_NAME" '.processors.resource/agent.attributes[0].value' "$AGENT_VERSION"
fi

add_yaml_file_field_value "$OTEL_RESOURCES_DIR/$OTEL_CONFIG_NAME" '.service.pipelines.metrics.processors' "$processor_name"
if [[ $? -ne 0 ]]; then
message="metrics.bash ($EXIT_CODE): $(get_task_error_message)"
Expand Down
2 changes: 1 addition & 1 deletion resources/otel/processors/resource_agent.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
resource/agent:
attributes:
- key: logzio_agent_version
value: v1.1.34
value:
action: upsert

0 comments on commit 9eab4f9

Please sign in to comment.