Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 47 additions & 0 deletions REFERENCE.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,41 @@ A description of what this class does
class { 'prosa': }
```

##### Setting custom telemetry attributes

```puppet
class { 'prosa':
telemetry_attributes => {
'service.name' => 'prosa-service',
'host.id' => 'fdbf79e8af94cb7f9e8df36789187052',
}
}
```

##### Setting custom observability configuration

```puppet
class { 'prosa':
observability => {
'metrics' => {
'stdout' => {
'level' => 'info',
},
},
'traces' => {
'stdout' => {
'level' => 'info',
},
},
'logs' => {
'stdout' => {
'level' => 'info',
},
},
}
}
```

#### Parameters

The following parameters are available in the `prosa` class:
Expand All @@ -56,6 +91,7 @@ The following parameters are available in the `prosa` class:
* [`user`](#-prosa--user)
* [`group`](#-prosa--group)
* [`telemetry_level`](#-prosa--telemetry_level)
* [`telemetry_attributes`](#-prosa--telemetry_attributes)
* [`observability`](#-prosa--observability)

##### <a name="-prosa--prosa_name"></a>`prosa_name`
Expand Down Expand Up @@ -185,12 +221,23 @@ which adjusts the verbosity of telemetry messages recorded.

Default value: `$prosa::params::telemetry_level`

##### <a name="-prosa--telemetry_attributes"></a>`telemetry_attributes`

Data type: `Optional[Hash[String, String]]`

Configures the ProSA [Telemetry Attributes](https://docs.rs/prosa-utils/latest/prosa_utils/config/observability/struct.Observability.html) directive
which allows to add custom attributes to telemetry messages.
Refer to the [ProSA book](https://worldline.github.io/ProSA/ch01-02-01-observability.html) for more details on how to configure this directive.

Default value: `undef`

##### <a name="-prosa--observability"></a>`observability`

Data type: `Hash[String, Hash[String, Hash[String, String]]]`

Configures the ProSA [Observability](https://docs.rs/prosa-utils/latest/prosa_utils/config/observability/struct.Observability.html) directive
which configure metrics, traces and logs export.
Refer to the [ProSA book](https://worldline.github.io/ProSA/ch01-02-01-observability.html) for more details on how to configure this directive.

Default value: `$prosa::params::observability`

Expand Down
43 changes: 40 additions & 3 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,44 @@
# Configures the ProSA [TelemetryLevel](https://docs.rs/prosa-utils/latest/prosa_utils/config/tracing/enum.TelemetryLevel.html) directive
# which adjusts the verbosity of telemetry messages recorded.
#
# @param telemetry_attributes
# Configures the ProSA [Telemetry Attributes](https://docs.rs/prosa-utils/latest/prosa_utils/config/observability/struct.Observability.html) directive
# which allows to add custom attributes to telemetry messages.
# Refer to the [ProSA book](https://worldline.github.io/ProSA/ch01-02-01-observability.html) for more details on how to configure this directive.
#
# @example Setting custom telemetry attributes
# class { 'prosa':
# telemetry_attributes => {
# 'service.name' => 'prosa-service',
# 'host.id' => 'fdbf79e8af94cb7f9e8df36789187052',
# }
# }
#
# @param observability
# Configures the ProSA [Observability](https://docs.rs/prosa-utils/latest/prosa_utils/config/observability/struct.Observability.html) directive
# which configure metrics, traces and logs export.
# Refer to the [ProSA book](https://worldline.github.io/ProSA/ch01-02-01-observability.html) for more details on how to configure this directive.
#
# @example Setting custom observability configuration
# class { 'prosa':
# observability => {
# 'metrics' => {
# 'stdout' => {
# 'level' => 'info',
# },
# },
# 'traces' => {
# 'stdout' => {
# 'level' => 'info',
# },
# },
# 'logs' => {
# 'stdout' => {
# 'level' => 'info',
# },
# },
# }
# }
#
class prosa (
String $prosa_name = $prosa::params::prosa_name,
Expand All @@ -82,6 +117,7 @@
String $user = $prosa::params::user,
String $group = $prosa::params::group,
ProSA::TelemetryLevel $telemetry_level = $prosa::params::telemetry_level,
Optional[Hash[String, String]] $telemetry_attributes = undef,
Hash[String, Hash[String, Hash[String, String]]] $observability = $prosa::params::observability,
) inherits prosa::params {
# declare ProSA user and group
Expand Down Expand Up @@ -113,9 +149,10 @@
group => $group,
mode => '0644',
content => epp('prosa/prosa.yml.epp', {
'prosa_name' => $prosa_name,
'telemetry_level' => $telemetry_level,
'observability' => $observability,
'prosa_name' => $prosa_name,
'telemetry_level' => $telemetry_level,
'telemetry_attributes' => $telemetry_attributes,
'observability' => $observability,
}),
require => File[$conf_dir],
notify => Class['prosa::service'],
Expand Down
6 changes: 6 additions & 0 deletions spec/acceptance/processors_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ class { 'prosa':
prosa_name => #{prosa_hash['prosa_name']},
service_manage => false,
telemetry_level => 'warn',
telemetry_attributes => {
'service.name' => 'prosa-service',
'host.id' => 'fdbf79e8af94cb7f9e8df36789187052',
},
observability => {
'metrics' => {
'prometheus' => {
Expand Down Expand Up @@ -70,6 +74,8 @@ class { 'prosa::processors':

describe file("#{prosa_hash['conf_dir']}/prosa.yml") do
it { is_expected.to contain 'name: prosa-acceptance' }
it { is_expected.to contain ' service.name: prosa-service' }
it { is_expected.to contain ' host.id: fdbf79e8af94cb7f9e8df36789187052' }
it { is_expected.to contain ' prometheus:' }
end

Expand Down
7 changes: 7 additions & 0 deletions templates/prosa.yml.epp
Original file line number Diff line number Diff line change
@@ -1,12 +1,19 @@
<%- | String $prosa_name,
ProSA::TelemetryLevel $telemetry_level = 'warn',
Optional[Hash[String, String]] $telemetry_attributes = undef,
Hash[String, Hash[String, Hash[String, String]]] $observability
| -%>
# Main configuration file for ProSA: Managed by Puppet.
# It contain the configuration that every ProSA instance must have
name: <%= $prosa_name %>
observability:
level: <%= $telemetry_level %>
<%- if $telemetry_attributes { -%>
attributes:
<%- $telemetry_attributes.each |$key, $value| { -%>
<%= $key %>: <%= $value %>
<%- } -%>
<%- } -%>
<%- if $observability { -%>
<%- $observability.keys.each |$telemetry_type| { -%>
<%= $telemetry_type %>:
Expand Down
Loading