Skip to content

Commit

Permalink
Bump config file format version (#6786)
Browse files Browse the repository at this point in the history
  • Loading branch information
trask authored Oct 15, 2024
1 parent 3e650f0 commit 83b30b5
Show file tree
Hide file tree
Showing 8 changed files with 23 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class FileConfigurationTest {
@Test
void configFile(@TempDir Path tempDir) throws IOException {
String yaml =
"file_format: \"0.1\"\n"
"file_format: \"0.3\"\n"
+ "resource:\n"
+ " attributes:\n"
+ " - name: service.name\n"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ class FileConfigurationTest {
@BeforeEach
void setup() throws IOException {
String yaml =
"file_format: \"0.1\"\n"
"file_format: \"0.3\"\n"
+ "resource:\n"
+ " attributes:\n"
+ " - name: service.name\n"
Expand Down Expand Up @@ -160,7 +160,7 @@ void configFile_setResultAsGlobalTrue() {
@Test
void configFile_Error(@TempDir Path tempDir) throws IOException {
String yaml =
"file_format: \"0.1\"\n"
"file_format: \"0.3\"\n"
+ "resource:\n"
+ " attributes:\n"
+ " - name: service.name\n"
Expand Down
7 changes: 5 additions & 2 deletions sdk-extensions/incubator/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,11 @@ dependencies {
// 7. deleteJs2pTmp - delete tmp directory
// ... proceed with normal sourcesJar, compileJava, etc

val configurationTag = "0.3.0"
val configurationRef = "refs/tags/v$configurationTag" // Replace with commit SHA to point to experiment with a specific commit
// TODO (trask) revert after the 0.4.0 release
// it was needed after 0.3.0 release because file_format in the examples weren't updated prior to the release tag
// val configurationTag = "0.3.0"
// val configurationRef = "refs/tags/v$configurationTag" // Replace with commit SHA to point to experiment with a specific commit
val configurationRef = "cea3905ce0a542d573968c3c47d413143d473cf4"
val configurationRepoZip = "https://github.com/open-telemetry/opentelemetry-configuration/archive/$configurationRef.zip"
val buildDirectory = layout.buildDirectory.asFile.get()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ static OpenTelemetryConfigurationFactory getInstance() {
public OpenTelemetrySdk create(
OpenTelemetryConfigurationModel model, SpiHelper spiHelper, List<Closeable> closeables) {
OpenTelemetrySdkBuilder builder = OpenTelemetrySdk.builder();
if (!"0.1".equals(model.getFileFormat())) {
throw new ConfigurationException("Unsupported file format. Supported formats include: 0.1");
if (!"0.3".equals(model.getFileFormat())) {
throw new ConfigurationException("Unsupported file format. Supported formats include: 0.3");
}

if (Objects.equals(Boolean.TRUE, model.getDisabled())) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ void parseAndCreate_Exception_CleansUpPartials() {
// exporter with OTLP exporter, following by invalid batch exporter which references invalid
// exporter "foo".
String yaml =
"file_format: \"0.1\"\n"
"file_format: \"0.3\"\n"
+ "logger_provider:\n"
+ " processors:\n"
+ " - batch:\n"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ void parse_BadInputStream() {
void parse_KitchenSinkExampleFile() throws IOException {
OpenTelemetryConfigurationModel expected = new OpenTelemetryConfigurationModel();

expected.withFileFormat("0.1");
expected.withFileFormat("0.3");
expected.withDisabled(false);

// General config
Expand Down Expand Up @@ -449,7 +449,7 @@ void parse_KitchenSinkExampleFile() throws IOException {
OpenTelemetryConfigurationModel config = FileConfiguration.parse(configExampleFile);

// General config
assertThat(config.getFileFormat()).isEqualTo("0.1");
assertThat(config.getFileFormat()).isEqualTo("0.3");
assertThat(config.getResource()).isEqualTo(resource);
assertThat(config.getAttributeLimits()).isEqualTo(attributeLimits);
assertThat(config.getPropagator()).isEqualTo(propagator);
Expand Down Expand Up @@ -485,7 +485,7 @@ void parse_KitchenSinkExampleFile() throws IOException {
@Test
void parse_nullValuesParsedToEmptyObjects() {
String objectPlaceholderString =
"file_format: \"0.1\"\n"
"file_format: \"0.3\"\n"
+ "tracer_provider:\n"
+ " processors:\n"
+ " - batch:\n"
Expand All @@ -503,7 +503,7 @@ void parse_nullValuesParsedToEmptyObjects() {
new ByteArrayInputStream(objectPlaceholderString.getBytes(StandardCharsets.UTF_8)));

String noOjbectPlaceholderString =
"file_format: \"0.1\"\n"
"file_format: \"0.3\"\n"
+ "tracer_provider:\n"
+ " processors:\n"
+ " - batch:\n"
Expand Down Expand Up @@ -672,7 +672,7 @@ private static Map<String, Object> mapOf(Map.Entry<String, ?>... entries) {
@Test
void read_WithEnvironmentVariables() {
String yaml =
"file_format: \"0.1\"\n"
"file_format: \"0.3\"\n"
+ "tracer_provider:\n"
+ " processors:\n"
+ " - batch:\n"
Expand All @@ -691,7 +691,7 @@ void read_WithEnvironmentVariables() {
assertThat(model)
.isEqualTo(
new OpenTelemetryConfigurationModel()
.withFileFormat("0.1")
.withFileFormat("0.3")
.withTracerProvider(
new TracerProviderModel()
.withProcessors(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ void create_InvalidFileFormat() {
OpenTelemetryConfigurationFactory.getInstance()
.create(testCase, spiHelper, closeables))
.isInstanceOf(ConfigurationException.class)
.hasMessage("Unsupported file format. Supported formats include: 0.1");
.hasMessage("Unsupported file format. Supported formats include: 0.3");
cleanup.addCloseables(closeables);
}
}
Expand All @@ -97,7 +97,7 @@ void create_Defaults() {
OpenTelemetrySdk sdk =
OpenTelemetryConfigurationFactory.getInstance()
.create(
new OpenTelemetryConfigurationModel().withFileFormat("0.1"), spiHelper, closeables);
new OpenTelemetryConfigurationModel().withFileFormat("0.3"), spiHelper, closeables);
cleanup.addCloseable(sdk);
cleanup.addCloseables(closeables);

Expand All @@ -114,7 +114,7 @@ void create_Disabled() {
OpenTelemetryConfigurationFactory.getInstance()
.create(
new OpenTelemetryConfigurationModel()
.withFileFormat("0.1")
.withFileFormat("0.3")
.withDisabled(true)
// Logger provider configuration should be ignored since SDK is disabled
.withLoggerProvider(
Expand Down Expand Up @@ -208,7 +208,7 @@ void create_Configured() {
OpenTelemetryConfigurationFactory.getInstance()
.create(
new OpenTelemetryConfigurationModel()
.withFileFormat("0.1")
.withFileFormat("0.3")
.withPropagator(
new PropagatorModel()
.withComposite(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
class YamlStructuredConfigPropertiesTest {

private static final String extendedSchema =
"file_format: \"0.1\"\n"
"file_format: \"0.3\"\n"
+ "disabled: false\n"
+ "\n"
+ "resource:\n"
Expand Down Expand Up @@ -69,7 +69,7 @@ void setup() {
@Test
void configurationSchema() {
// Validate can read file configuration schema properties
assertThat(structuredConfigProps.getString("file_format")).isEqualTo("0.1");
assertThat(structuredConfigProps.getString("file_format")).isEqualTo("0.3");
StructuredConfigProperties resourceProps = structuredConfigProps.getStructured("resource");
assertThat(resourceProps).isNotNull();
List<StructuredConfigProperties> resourceAttributesList =
Expand Down

0 comments on commit 83b30b5

Please sign in to comment.