-
Notifications
You must be signed in to change notification settings - Fork 858
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Initialize file configuration #5399
Merged
Merged
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
035b854
Initialize file configuration
jack-berg 5366a07
Include providers
jack-berg 908256b
limits
jack-berg 7fa20aa
Add resource configuration
jack-berg 7a2db44
wip
jack-berg a7e944c
Reflect latest config
jack-berg c2b7370
Merge branch 'main' of https://github.com/open-telemetry/opentelemetr…
jack-berg 2b0e475
Update to latest opentelemetry-configuration
jack-berg d77b1c1
Generate builders, ensure @Generated annotation is added
jack-berg 55f3829
PR feedback
jack-berg 4e87de1
Rename replaceGeneratedAnnotation to jsonSchema2PojoPostProcessing
jack-berg d9b0350
PR feedback
jack-berg File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 25 additions & 0 deletions
25
...rc/main/java/io/opentelemetry/sdk/extension/incubator/fileconfig/ConfigurationReader.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
/* | ||
* Copyright The OpenTelemetry Authors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package io.opentelemetry.sdk.extension.incubator.fileconfig; | ||
|
||
import com.fasterxml.jackson.databind.ObjectMapper; | ||
import io.opentelemetry.sdk.extension.incubator.fileconfig.internal.model.OpenTelemetryConfiguration; | ||
import java.io.InputStream; | ||
import org.yaml.snakeyaml.Yaml; | ||
|
||
class ConfigurationReader { | ||
|
||
private static final ObjectMapper MAPPER = new ObjectMapper(); | ||
private static final Yaml YAML = new Yaml(); | ||
|
||
private ConfigurationReader() {} | ||
|
||
/** Parse the {@code configuration} YAML and return the {@link OpenTelemetryConfiguration}. */ | ||
static OpenTelemetryConfiguration parse(InputStream configuration) { | ||
Object yamlObj = YAML.load(configuration); | ||
return MAPPER.convertValue(yamlObj, OpenTelemetryConfiguration.class); | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will this eventually make jackson a hard dependency for the sdk or just this extension?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
jackson-databind
gets CVEs very often, I'd sleep better if we don't include it in the SDK (at some point); wouldjackson-jr
be able to handle the generated POJOs?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This would likely eventually be merged into the autoconfigure module, rather than the SDK itself.
I can investigate
jackson-jr
.Also, there's the more hands on option of doing something like we do with YAML view configuration, where we use snake YAML to parse to a generic type, then extract the fields manually. Maybe we use jackson-databind / jackson-jr to prototype, and consider switching to the manual method when its looking more complete.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Considering this is for configuration, which is likely only done at startup I feel we should go with a potentially less performant option and not use jackson in exchange for fewer dependencies and CVE exposure.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's less of the performance I'm worried about and more the additional complexity to manually do the parsing that jackson does automatically. Additionally, there is likely to be a fair amount of churn in the early versions of the configuration schema - I'm happy enough writing manual parsing code once, but won't sign up to rewrite the manual parsing code for each of the early iterations.