Skip to content

Commit

Permalink
[extension/observer, receiver/dockerstats] Correct examples with api_…
Browse files Browse the repository at this point in the history
…version (#33992)

Changes examples for `api_version` to make sure they use a string
instead of a float

**Link to tracking Issue:** Required for
open-telemetry/opentelemetry-collector/pull/10554
  • Loading branch information
mx-psi authored Jul 10, 2024
1 parent 4115aad commit 9a13dee
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 18 deletions.
6 changes: 3 additions & 3 deletions extension/observer/dockerobserver/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ extensions:
# list of container image names to exclude
excluded_images: ['redis', 'another_image_name']
# client API version, default to 1.24
api_version: 1.25
api_version: "1.25"
# max amount of time to wait for a response from Docker API , default to 5s
timeout: 15s

Expand Down Expand Up @@ -63,9 +63,9 @@ default: `5s`

### `api_version`

The client API version. If using one with a terminating zero, input as a string to prevent undesired truncation (e.g. `"1.40"` instead of `1.40`, which is parsed as `1.4`).
The client API version. Make sure you input it as a string instead of a float (e.g. `"1.4"` instead of `1.4`).

default: `1.24`
default: `"1.24"`

### `excluded_images`

Expand Down
10 changes: 0 additions & 10 deletions extension/observer/dockerobserver/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,16 +43,6 @@ func TestLoadConfig(t *testing.T) {
DockerAPIVersion: version,
},
},
{
id: component.NewIDWithName(metadata.Type, "unsupported_api_version"),
expected: &Config{
Endpoint: "unix:///var/run/docker.sock",
CacheSyncInterval: time.Hour,
Timeout: 5 * time.Second,
DockerAPIVersion: "1.4",
},
expectedError: `"api_version" 1.4 must be at least 1.24`,
},
}
for _, tt := range tests {
t.Run(tt.id.String(), func(t *testing.T) {
Expand Down
3 changes: 0 additions & 3 deletions extension/observer/dockerobserver/testdata/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,3 @@ docker_observer/ignore_non_host_bindings:
ignore_non_host_bindings: true
docker_observer/exclude_nginx:
excluded_images: ["nginx"]
docker_observer/unsupported_api_version:
# intentionally a float since it will be parsed as 1.4
api_version: 1.40
4 changes: 2 additions & 2 deletions receiver/dockerstatsreceiver/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ only unmatched container image names should be excluded.
- Globs are non-regex items (e.g. `/items/`) containing any of the following: `*[]{}?`. Negations are supported:
`!my*container` will exclude all containers whose image name doesn't match the blob `my*container`.
- `timeout` (default = `5s`): The request timeout for any docker daemon query.
- `api_version` (default = `1.25`): The Docker client API version (must be 1.25+). If using one with a terminating zero, input as a string to prevent undesired truncation (e.g. `"1.40"` instead of `1.40`, which is parsed as `1.4`). [Docker API versions](https://docs.docker.com/engine/api/).
- `api_version` (default = `"1.25"`): The Docker client API version (must be 1.25+). Must be input as a string, not a float (e.g. `"1.40"` instead of `1.40`). [Docker API versions](https://docs.docker.com/engine/api/).
- `metrics` (defaults at [./documentation.md](./documentation.md)): Enables/disables individual metrics. See [./documentation.md](./documentation.md) for full detail.

Example:
Expand All @@ -51,7 +51,7 @@ receivers:
endpoint: http://example.com/
collection_interval: 2s
timeout: 20s
api_version: 1.24
api_version: "1.24"
container_labels_to_metric_labels:
my.container.label: my-metric-label
my.other.container.label: my-other-metric-label
Expand Down

0 comments on commit 9a13dee

Please sign in to comment.