Skip to content

Commit eee19bc

Browse files
[chore][config/configcompression] Migrate to schema-based configuration (#15489)
<!--Ex. Fixing a bug - Describe the bug and how this fixes the issue. Ex. Adding a feature - Explain what this achieves.--> #### Description Migrated `config/configcompression` from a hand-written Config struct to `mdatagen` schema-based configuration. Part of https://github.com/open-telemetry/opentelemetry-collector/blob/main/docs/rfcs/component-configuration-schema-roadmap.md <!--Authorship attestation. See AGENTS.md for details. AI agents must not check this box on behalf of the user; the human author must check it themselves before the PR is ready for review.--> #### Authorship - [x] I, a human, wrote this pull request description myself. <!--Please delete paragraphs that you did not use before submitting.--> --------- Co-authored-by: Evan Bradley <11745660+evan-bradley@users.noreply.github.com>
1 parent 4f8bbff commit eee19bc

7 files changed

Lines changed: 82 additions & 13 deletions

File tree

config/configcompression/compressiontype.go

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,6 @@ import (
88
"fmt"
99
)
1010

11-
// Type represents a compression method
12-
type Type string
13-
14-
type Level int
15-
16-
type CompressionParams struct {
17-
Level Level `mapstructure:"level"`
18-
// prevent unkeyed literal initialization
19-
_ struct{}
20-
}
21-
2211
const (
2312
TypeGzip Type = "gzip"
2413
TypeZlib Type = "zlib"
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
{
2+
"$schema": "https://json-schema.org/draft/2020-12/schema",
3+
"$id": "go.opentelemetry.io/collector/config/configcompression",
4+
"title": "pkg/config/configcompression",
5+
"$defs": {
6+
"compression_params": {
7+
"type": "object",
8+
"properties": {
9+
"level": {
10+
"type": "integer"
11+
}
12+
}
13+
},
14+
"level": {
15+
"type": "integer"
16+
},
17+
"type": {
18+
"description": "Type represents a compression method",
19+
"type": "string",
20+
"enum": [
21+
"gzip",
22+
"zlib",
23+
"deflate",
24+
"snappy",
25+
"x-snappy-framed",
26+
"zstd",
27+
"lz4",
28+
"none",
29+
""
30+
]
31+
}
32+
}
33+
}

config/configcompression/doc.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
// Copyright The OpenTelemetry Authors
2+
// SPDX-License-Identifier: Apache-2.0
3+
4+
// Generate a test metrics builder from a sample metrics set covering all configuration options.
5+
//go:generate mdatagen metadata.yaml
6+
7+
package configcompression // import "go.opentelemetry.io/collector/config/configcompression"

config/configcompression/generated_config.go

Lines changed: 14 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

config/configcompression/generated_config_test.go

Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

config/configcompression/package_test.go renamed to config/configcompression/generated_package_test.go

Lines changed: 1 addition & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

config/configcompression/metadata.yaml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,25 @@ github_project: open-telemetry/opentelemetry-collector
55
status:
66
disable_codecov_badge: true
77
class: pkg
8+
9+
exported_configs:
10+
compression_params:
11+
type: object
12+
properties:
13+
level:
14+
$ref: level
15+
level:
16+
type: integer
17+
type:
18+
description: Type represents a compression method
19+
type: string
20+
enum:
21+
- "gzip"
22+
- "zlib"
23+
- "deflate"
24+
- "snappy"
25+
- "x-snappy-framed"
26+
- "zstd"
27+
- "lz4"
28+
- "none"
29+
- ""

0 commit comments

Comments
 (0)