Skip to content

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
wants to merge 21 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/ISSUE_TEMPLATE/bug_report.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ body:
- aws-xray
- aws-xray-propagator
- consistent-sampling
- declarative-config-bridge
- disk-buffering
- gcp-auth-extension
- gcp-resources
Expand Down
1 change: 1 addition & 0 deletions .github/ISSUE_TEMPLATE/feature_request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ body:
- aws-xray
- aws-xray-propagator
- consistent-sampling
- declarative-config-bridge
- disk-buffering
- gcp-auth-extension
- gcp-resources
Expand Down
3 changes: 3 additions & 0 deletions .github/component_owners.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ components:
consistent-sampling:
- oertl
- PeterF778
declarative-config-bridge:
- jaydeluca
- zeitlinger
disk-buffering:
- LikeTheSalad
- zeitlinger
Expand Down
1 change: 1 addition & 0 deletions .github/scripts/draft-change-log-entries.sh
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ component_names["baggage-processor/"]="Baggage processor"
component_names["cloudfoundry-resources/"]="CloudFoundry resources"
component_names["compressors/"]="Compressors"
component_names["consistent-sampling/"]="Consistent sampling"
component_names["declarative-config-bridge"]="Declarative config bridge"
component_names["disk-buffering/"]="Disk buffering"
component_names["gcp-resources/"]="GCP resources"
component_names["gcp-auth-extension/"]="GCP authentication extension"
Expand Down
55 changes: 28 additions & 27 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,33 +14,34 @@ feature or via instrumentation, this project is hopefully for you.

## Provided Libraries

| Status* | Library |
|---------|-------------------------------------------------------------------|
| beta | [AWS Resources](./aws-resources/README.md) |
| stable | [AWS X-Ray SDK Support](./aws-xray/README.md) |
| alpha | [AWS X-Ray Propagator](./aws-xray-propagator/README.md) |
| alpha | [Baggage Processors](./baggage-processor/README.md) |
| alpha | [zstd Compressor](./compressors/compressor-zstd/README.md) |
| alpha | [Consistent Sampling](./consistent-sampling/README.md) |
| alpha | [Disk Buffering](./disk-buffering/README.md) |
| alpha | [GCP Authentication Extension](./gcp-auth-extension/README.md) |
| beta | [GCP Resources](./gcp-resources/README.md) |
| beta | [Inferred Spans](./inferred-spans/README.md) |
| alpha | [IBM MQ Metrics](./ibm-mq-metrics/README.md) |
| alpha | [JFR Connection](./jfr-connection/README.md) |
| alpha | [JFR Events](./jfr-events/README.md) |
| alpha | [JMX Metric Gatherer](./jmx-metrics/README.md) |
| alpha | [JMX Metric Scraper](./jmx-scraper/README.md) |
| alpha | [Kafka Support](./kafka-exporter/README.md) |
| alpha | [OpenTelemetry Maven Extension](./maven-extension/README.md) |
| alpha | [Micrometer MeterProvider](./micrometer-meter-provider/README.md) |
| alpha | [No-Op API](./noop-api/README.md) |
| alpha | [Intercept and Process Signals Globally](./processors/README.md) |
| alpha | [Prometheus Client Bridge](./prometheus-client-bridge/README.md) |
| alpha | [Resource Providers](./resource-providers/README.md) |
| alpha | [Runtime Attach](./runtime-attach/README.md) |
| alpha | [Samplers](./samplers/README.md) |
| beta | [Span Stacktrace Capture](./span-stacktrace/README.md) |
| Status* | Library |
|---------|--------------------------------------------------------------------|
| beta | [AWS Resources](./aws-resources/README.md) |
| stable | [AWS X-Ray SDK Support](./aws-xray/README.md) |
| alpha | [AWS X-Ray Propagator](./aws-xray-propagator/README.md) |
| alpha | [Baggage Processors](./baggage-processor/README.md) |
| alpha | [zstd Compressor](./compressors/compressor-zstd/README.md) |
| alpha | [Consistent Sampling](./consistent-sampling/README.md) |
| alpha | [Declarative Config Bridge](./declarative-config-bridge/README.md) |
| alpha | [Disk Buffering](./disk-buffering/README.md) |
| alpha | [GCP Authentication Extension](./gcp-auth-extension/README.md) |
| beta | [GCP Resources](./gcp-resources/README.md) |
| beta | [Inferred Spans](./inferred-spans/README.md) |
| alpha | [IBM MQ Metrics](./ibm-mq-metrics/README.md) |
| alpha | [JFR Connection](./jfr-connection/README.md) |
| alpha | [JFR Events](./jfr-events/README.md) |
| alpha | [JMX Metric Gatherer](./jmx-metrics/README.md) |
| alpha | [JMX Metric Scraper](./jmx-scraper/README.md) |
| alpha | [Kafka Support](./kafka-exporter/README.md) |
| alpha | [OpenTelemetry Maven Extension](./maven-extension/README.md) |
| alpha | [Micrometer MeterProvider](./micrometer-meter-provider/README.md) |
| alpha | [No-Op API](./noop-api/README.md) |
| alpha | [Intercept and Process Signals Globally](./processors/README.md) |
| alpha | [Prometheus Client Bridge](./prometheus-client-bridge/README.md) |
| alpha | [Resource Providers](./resource-providers/README.md) |
| alpha | [Runtime Attach](./runtime-attach/README.md) |
| alpha | [Samplers](./samplers/README.md) |
| beta | [Span Stacktrace Capture](./span-stacktrace/README.md) |

\* `alpha`, `beta` and `stable` are currently used to denote library status per [otep 0232](https://github.com/open-telemetry/oteps/blob/main/text/0232-maturity-of-otel.md).
To reach stable status, the library needs to have stable APIs, stable semantic conventions, and be production ready.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class AwsComponentProviderTest {
@Test
void endToEnd() {
String yaml =
"file_format: 0.4\n"
"file_format: 1.0-rc.1\n"
+ "propagator:\n"
+ " composite:\n"
+ " - xray:\n"
Expand Down
91 changes: 91 additions & 0 deletions declarative-config-bridge/README.md
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).
18 changes: 18 additions & 0 deletions declarative-config-bridge/build.gradle.kts
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")
Comment on lines +6 to +7
Copy link
Member

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

Copy link
Member Author

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

Copy link
Member

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


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")
}
Loading
Loading