-
Notifications
You must be signed in to change notification settings - Fork 163
declarative config: declarative config bridge, support Inferred spans #2030
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
Open
zeitlinger
wants to merge
21
commits into
open-telemetry:main
Choose a base branch
from
zeitlinger:inferred-spans
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+972
−173
Open
Changes from all commits
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
ebe5948
add property translation for inferred spans
zeitlinger 2b19f85
inferred spans
zeitlinger ccbfd7b
inferred spans
zeitlinger 26f5b97
inferred spans
zeitlinger 15034cf
format
zeitlinger aa4e56d
fix
zeitlinger 214c0e1
make temp dir more reliable
zeitlinger 716014a
make temp dir more reliable
zeitlinger 686053c
test starts async profiler (?)
zeitlinger 671f9b2
Revert "test starts async profiler (?)"
zeitlinger 649f2a0
leave profiler disabled in test
zeitlinger b755c6b
leave profiler disabled in test
zeitlinger e30c8cf
copy declarative config from agent
zeitlinger 9171cd8
fix
zeitlinger 41310b8
fix package
zeitlinger 7d18f20
update file format
zeitlinger de96376
add comment
zeitlinger 2e024c5
extract common class
zeitlinger 7da5600
add description and owner of the declarative config bridge
zeitlinger 7e7c939
./gradlew spotlessApply
otelbot[bot] 1fea00e
add description and owner of the declarative config bridge
zeitlinger 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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,91 @@ | ||
# Declarative Config Bridge | ||
|
||
Declarative Config Bridge allows instrumentation authors to access configuration in a uniform way, | ||
regardless of the configuration source. | ||
|
||
The bridge allows you to read configuration using the system property style when dealing with | ||
declarative configuration. | ||
|
||
## Example | ||
|
||
As an example, let's look at the inferred spans configuration. | ||
First, there is a configuration method that reads the properties and is unaware of the source of the | ||
configuration: | ||
|
||
```java | ||
class InferredSpansConfig { | ||
static SpanProcessor create(ConfigProperties properties) { | ||
// read properties here | ||
boolean backupDiagnosticFiles = | ||
properties.getBoolean("otel.inferred.spans.backup.diagnostic.files", false); | ||
} | ||
} | ||
``` | ||
|
||
The auto configuration **without declarative config** passes the provided properties directly: | ||
|
||
```java | ||
|
||
@AutoService(AutoConfigurationCustomizerProvider.class) | ||
public class InferredSpansAutoConfig implements AutoConfigurationCustomizerProvider { | ||
|
||
@Override | ||
public void customize(AutoConfigurationCustomizer config) { | ||
config.addTracerProviderCustomizer( | ||
(providerBuilder, properties) -> { | ||
providerBuilder.addSpanProcessor(InferredSpansConfig.create(properties)); | ||
return providerBuilder; | ||
}); | ||
} | ||
} | ||
``` | ||
|
||
The auto configuration **with declarative config** uses the Declarative Config Bridge to be able to | ||
use common configuration method: | ||
|
||
Let's first look at the yaml file that is used to configure the inferred spans processor: | ||
|
||
```yaml | ||
file_format: 1.0-rc.1 | ||
tracer_provider: | ||
processors: | ||
- inferred_spans: | ||
backup: | ||
diagnostic: | ||
files: true | ||
``` | ||
|
||
And now the component provider that uses the Declarative Config Bridge: | ||
|
||
```java | ||
|
||
@AutoService(ComponentProvider.class) | ||
public class InferredSpansComponentProvider implements ComponentProvider<SpanProcessor> { | ||
|
||
@Override | ||
public String getName() { | ||
return "inferred_spans"; | ||
} | ||
|
||
@Override | ||
public SpanProcessor create(DeclarativeConfigProperties config) { | ||
return InferredSpansConfig.create( | ||
new DeclarativeConfigPropertiesBridgeBuilder() | ||
// crop the prefix, because the properties are under the "inferred_spans" processor | ||
.addMapping("otel.inferred.spans.", "") | ||
.build(config)); | ||
} | ||
|
||
@Override | ||
public Class<SpanProcessor> getType() { | ||
return SpanProcessor.class; | ||
} | ||
} | ||
``` | ||
|
||
## Component owners | ||
|
||
- [Gregor Zeitlinger](https://github.com/zeitlinger), Grafana | ||
- [Jay DeLuca](https://github.com/jaydeluca), Grafana | ||
|
||
Learn more about component owners in [component_owners.yml](../.github/component_owners.yml). |
This file contains hidden or 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,18 @@ | ||
plugins { | ||
id("otel.java-conventions") | ||
id("otel.publish-conventions") | ||
} | ||
|
||
description = "OpenTelemetry extension that provides a bridge for declarative configuration." | ||
otelJava.moduleName.set("io.opentelemetry.contrib.sdk.config.bridge") | ||
|
||
dependencies { | ||
// We use `compileOnly` dependency because during runtime all necessary classes are provided by | ||
// javaagent itself. | ||
compileOnly("io.opentelemetry:opentelemetry-sdk-extension-autoconfigure") | ||
compileOnly("io.opentelemetry:opentelemetry-sdk-extension-incubator") | ||
|
||
testImplementation("io.opentelemetry:opentelemetry-sdk-extension-autoconfigure") | ||
testImplementation("io.opentelemetry:opentelemetry-sdk-extension-incubator") | ||
testImplementation("org.mockito:mockito-inline") | ||
} |
Oops, something went wrong.
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.
can you add a README for this module, and describe why it's needed? thanks
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.
done - as agreed, I've also added @jaydeluca as co-component owner
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.
thanks, makes sense now
would you mind doing this in two steps, first adding declarative config support without creating a reusable bridge component, and then we can circle back to the reusable bridge concept afterwards? if we are going to create a reusable bridge, it might make sense for it to be in core, but that will require more consideration and discussions