-
Notifications
You must be signed in to change notification settings - Fork 42
[File based config] Snapshot profiling config refactoring #2558
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
Changes from all commits
3a1d6b2
e0f2eec
da19a8e
85861c7
1bd5046
786afa1
e06e9f7
a85a0cc
825d939
0bffa0d
c2b4bbc
3ba5dc3
c826d32
3c4cb1e
af2ecaf
d0df429
b95828b
ad5bf03
9a100f3
971f598
58c0e59
2623404
ad9a91c
5baaa91
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -22,9 +22,17 @@ | |
| import io.opentelemetry.api.incubator.ExtendedOpenTelemetry; | ||
| import io.opentelemetry.api.incubator.config.ConfigProvider; | ||
| import io.opentelemetry.api.incubator.config.DeclarativeConfigProperties; | ||
| import io.opentelemetry.common.ComponentLoader; | ||
| import io.opentelemetry.instrumentation.config.bridge.ConfigPropertiesBackedConfigProvider; | ||
| import io.opentelemetry.sdk.autoconfigure.spi.ConfigProperties; | ||
| import io.opentelemetry.sdk.extension.incubator.fileconfig.YamlDeclarativeConfigProperties; | ||
| import io.opentelemetry.sdk.extension.incubator.fileconfig.internal.model.ExperimentalInstrumentationModel; | ||
| import io.opentelemetry.sdk.extension.incubator.fileconfig.internal.model.ExperimentalLanguageSpecificInstrumentationModel; | ||
| import io.opentelemetry.sdk.extension.incubator.fileconfig.internal.model.ExperimentalLanguageSpecificInstrumentationPropertyModel; | ||
| import io.opentelemetry.sdk.extension.incubator.fileconfig.internal.model.OpenTelemetryConfigurationModel; | ||
| import io.opentelemetry.sdk.resources.Resource; | ||
| import java.util.HashMap; | ||
| import java.util.Map; | ||
| import java.util.logging.Logger; | ||
| import javax.annotation.Nullable; | ||
|
|
||
|
|
@@ -57,6 +65,8 @@ public static boolean isDeclarativeConfig(AutoConfiguredOpenTelemetrySdk sdk) { | |
| return false; | ||
| } | ||
|
|
||
| // TODO: This is temporary solution. For now assume that distribution node is located under | ||
| // .instrumentation/development.java.distribution | ||
| @Nullable | ||
| public static DeclarativeConfigProperties getDistributionConfig( | ||
| AutoConfiguredOpenTelemetrySdk sdk) { | ||
|
|
@@ -69,18 +79,38 @@ public static DeclarativeConfigProperties getDistributionConfig( | |
| return null; | ||
| } | ||
|
|
||
| // TODO: This is temporary solution until distribution config support is implemented in the | ||
| // upstream. For now assume that distribution node is located under | ||
| // .instrumentation/development.java.distribution | ||
| // Replace this code with `return sdk.getConfigProvider().getDistributionConfig()` once is | ||
| // implemented | ||
| DeclarativeConfigProperties instrumentationConfig = configProvider.getInstrumentationConfig(); | ||
| if (instrumentationConfig == null) { | ||
| return null; | ||
| } | ||
| return instrumentationConfig | ||
| .getStructured("java", empty()) | ||
| .getStructured("distribution", empty()); | ||
| return instrumentationConfig.getStructured("java", empty()).getStructured("distribution"); | ||
| } | ||
|
|
||
| public static DeclarativeConfigProperties getDistributionConfig( | ||
| OpenTelemetryConfigurationModel model) { | ||
| ExperimentalInstrumentationModel instrumentationModel = model.getInstrumentationDevelopment(); | ||
| if (instrumentationModel == null) { | ||
| return empty(); | ||
| } | ||
|
|
||
| ExperimentalLanguageSpecificInstrumentationModel javaModel = instrumentationModel.getJava(); | ||
| if (javaModel == null) { | ||
| return empty(); | ||
| } | ||
|
|
||
| ComponentLoader componentLoader = | ||
| ComponentLoader.forClassLoader(DeclarativeConfigProperties.class.getClassLoader()); | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not really sure what the |
||
| Map<String, ExperimentalLanguageSpecificInstrumentationPropertyModel> original = | ||
| javaModel.getAdditionalProperties(); | ||
| Map<String, Object> properties = new HashMap<>(); | ||
| ExperimentalLanguageSpecificInstrumentationPropertyModel distribution = | ||
| original.get("distribution"); | ||
| properties.put( | ||
| "distribution", distribution != null ? distribution.getAdditionalProperties() : null); | ||
| DeclarativeConfigProperties config = | ||
| YamlDeclarativeConfigProperties.create(properties, componentLoader); | ||
|
|
||
| return config.getStructured("distribution", empty()); // Should this empty() be there? | ||
| } | ||
|
|
||
| public static Resource getResource(AutoConfiguredOpenTelemetrySdk sdk) { | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -23,6 +23,7 @@ | |
| import io.opentelemetry.exporter.otlp.http.logs.OtlpHttpLogRecordExporter; | ||
| import io.opentelemetry.exporter.otlp.http.logs.OtlpHttpLogRecordExporterBuilder; | ||
| import io.opentelemetry.exporter.otlp.internal.OtlpConfigUtil; | ||
| import io.opentelemetry.exporter.otlp.internal.OtlpGrpcLogRecordExporterComponentProvider; | ||
| import io.opentelemetry.exporter.otlp.internal.OtlpHttpLogRecordExporterComponentProvider; | ||
| import io.opentelemetry.exporter.otlp.logs.OtlpGrpcLogRecordExporter; | ||
| import io.opentelemetry.exporter.otlp.logs.OtlpGrpcLogRecordExporterBuilder; | ||
|
|
@@ -39,17 +40,19 @@ class LogExporterBuilder { | |
| static LogRecordExporter fromConfig(DeclarativeConfigProperties exporterConfigProperties) { | ||
| if (exporterConfigProperties != null) { | ||
|
|
||
| DeclarativeConfigProperties otlpHttp = exporterConfigProperties.getStructured("otlp_http"); | ||
| DeclarativeConfigProperties otlpHttp = | ||
| exporterConfigProperties.getStructured("otlp_log_http"); | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [for reviewer] Logger name updated due to GDI spec |
||
| if (otlpHttp != null) { | ||
| OtlpHttpLogRecordExporterComponentProvider provider = | ||
| new OtlpHttpLogRecordExporterComponentProvider(); | ||
| return provider.create(otlpHttp); | ||
| } | ||
|
|
||
| DeclarativeConfigProperties otlpGrpc = exporterConfigProperties.getStructured("otlp_grpc"); | ||
| DeclarativeConfigProperties otlpGrpc = | ||
| exporterConfigProperties.getStructured("otlp_log_grpc"); | ||
| if (otlpGrpc != null) { | ||
| OtlpHttpLogRecordExporterComponentProvider provider = | ||
| new OtlpHttpLogRecordExporterComponentProvider(); | ||
| OtlpGrpcLogRecordExporterComponentProvider provider = | ||
| new OtlpGrpcLogRecordExporterComponentProvider(); | ||
| return provider.create(otlpGrpc); | ||
| } | ||
| } | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.
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.
[for reviewer]
distributionnode will be moved to the root in subsequent PR