-
Notifications
You must be signed in to change notification settings - Fork 31
Replace inferred-spans extension with upstream contrib extension #370
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
Merged
Merged
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
577f4f2
Replace inferred-spans extension with upstream contrib extension
JonasKunz c607606
Merge remote-tracking branch 'elastic/main' into inferred-spans-upstream
JonasKunz 8aa033c
move dependency to catalog
JonasKunz 95e3056
Merge remote-tracking branch 'elastic/main' into inferred-spans-upstream
JonasKunz e9ef009
fix merge conflicts
JonasKunz 81df382
Merge remote-tracking branch 'elastic/main' into inferred-spans-upstream
JonasKunz 2578847
Added backwards compatible span link attributes
JonasKunz da27de3
spotless
JonasKunz bfeb539
Remove println
JonasKunz ad2eb5c
spotless
JonasKunz 8ee3820
Merge remote-tracking branch 'elastic/main' into inferred-spans-upstream
JonasKunz 6d34d58
Replace reflection with package accessor
JonasKunz 38532ee
Added test validating legacy config option priority
JonasKunz 6b62114
Removed maven central publishing
JonasKunz 969a37b
spotless
JonasKunz 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
Large diffs are not rendered by default.
Oops, something went wrong.
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
112 changes: 112 additions & 0 deletions
112
inferred-spans/src/main/java/co/elastic/otel/InferredSpansBackwardsCompatibilityConfig.java
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,112 @@ | ||
| /* | ||
| * Licensed to Elasticsearch B.V. under one or more contributor | ||
| * license agreements. See the NOTICE file distributed with | ||
| * this work for additional information regarding copyright | ||
| * ownership. Elasticsearch B.V. licenses this file to you under | ||
| * the Apache License, Version 2.0 (the "License"); you may | ||
| * not use this file except in compliance with the License. | ||
| * You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, | ||
| * software distributed under the License is distributed on an | ||
| * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
| * KIND, either express or implied. See the License for the | ||
| * specific language governing permissions and limitations | ||
| * under the License. | ||
| */ | ||
| package co.elastic.otel; | ||
|
|
||
| import com.google.auto.service.AutoService; | ||
| import io.opentelemetry.api.common.AttributeKey; | ||
| import io.opentelemetry.api.common.Attributes; | ||
| import io.opentelemetry.api.trace.SpanBuilder; | ||
| import io.opentelemetry.api.trace.SpanContext; | ||
| import io.opentelemetry.sdk.autoconfigure.spi.AutoConfigurationCustomizer; | ||
| import io.opentelemetry.sdk.autoconfigure.spi.AutoConfigurationCustomizerProvider; | ||
| import java.util.HashMap; | ||
| import java.util.Map; | ||
| import java.util.function.BiConsumer; | ||
| import java.util.logging.Level; | ||
| import java.util.logging.Logger; | ||
|
|
||
| @AutoService(AutoConfigurationCustomizerProvider.class) | ||
| public class InferredSpansBackwardsCompatibilityConfig | ||
| implements AutoConfigurationCustomizerProvider { | ||
|
|
||
| private static final Logger log = | ||
| Logger.getLogger(InferredSpansBackwardsCompatibilityConfig.class.getName()); | ||
|
|
||
| private static final Map<String, String> CONFIG_MAPPING = new HashMap<>(); | ||
|
|
||
| static { | ||
| CONFIG_MAPPING.put("elastic.otel.inferred.spans.enabled", "otel.inferred.spans.enabled"); | ||
| CONFIG_MAPPING.put( | ||
| "elastic.otel.inferred.spans.logging.enabled", "otel.inferred.spans.logging.enabled"); | ||
| CONFIG_MAPPING.put( | ||
| "elastic.otel.inferred.spans.backup.diagnostic.files", | ||
| "otel.inferred.spans.backup.diagnostic.files"); | ||
| CONFIG_MAPPING.put("elastic.otel.inferred.spans.safe.mode", "otel.inferred.spans.safe.mode"); | ||
| CONFIG_MAPPING.put( | ||
| "elastic.otel.inferred.spans.post.processing.enabled", | ||
| "otel.inferred.spans.post.processing.enabled"); | ||
| CONFIG_MAPPING.put( | ||
| "elastic.otel.inferred.spans.sampling.interval", "otel.inferred.spans.sampling.interval"); | ||
| CONFIG_MAPPING.put( | ||
| "elastic.otel.inferred.spans.min.duration", "otel.inferred.spans.min.duration"); | ||
| CONFIG_MAPPING.put( | ||
| "elastic.otel.inferred.spans.included.classes", "otel.inferred.spans.included.classes"); | ||
| CONFIG_MAPPING.put( | ||
| "elastic.otel.inferred.spans.excluded.classes", "otel.inferred.spans.excluded.classes"); | ||
| CONFIG_MAPPING.put("elastic.otel.inferred.spans.interval", "otel.inferred.spans.interval"); | ||
| CONFIG_MAPPING.put("elastic.otel.inferred.spans.duration", "otel.inferred.spans.duration"); | ||
| CONFIG_MAPPING.put( | ||
| "elastic.otel.inferred.spans.lib.directory", "otel.inferred.spans.lib.directory"); | ||
| } | ||
|
|
||
| @Override | ||
| public void customize(AutoConfigurationCustomizer config) { | ||
| config.addPropertiesCustomizer( | ||
| props -> { | ||
| Map<String, String> overrides = new HashMap<>(); | ||
| for (String oldKey : CONFIG_MAPPING.keySet()) { | ||
| String value = props.getString(oldKey); | ||
| if (value != null) { | ||
| String newKey = CONFIG_MAPPING.get(oldKey); | ||
| if (props.getString(newKey) == null) { // new value has not been configured | ||
| log.log( | ||
| Level.WARNING, | ||
| "The configuration property {0} is deprecated, use {1} instead", | ||
| new Object[] {oldKey, newKey}); | ||
| overrides.put(newKey, value); | ||
| } | ||
| } | ||
| } | ||
|
|
||
| String userDefinedHandler = | ||
| props.getString("otel.inferred.spans.parent.override.handler"); | ||
| if (userDefinedHandler == null || userDefinedHandler.isEmpty()) { | ||
| overrides.put( | ||
| "otel.inferred.spans.parent.override.handler", | ||
| BackwardsCompatibilitySpanLinkHandler.class.getName()); | ||
| } | ||
|
|
||
| return overrides; | ||
| }); | ||
| } | ||
|
|
||
| public static class BackwardsCompatibilitySpanLinkHandler | ||
| implements BiConsumer<SpanBuilder, SpanContext> { | ||
|
|
||
| private static final Attributes LINK_ATTRIBUTES = | ||
| Attributes.of( | ||
| AttributeKey.booleanKey("is_child"), true, | ||
| AttributeKey.booleanKey("elastic.is_child"), true); | ||
|
|
||
| @Override | ||
| public void accept(SpanBuilder spanBuilder, SpanContext spanContext) { | ||
| spanBuilder.addLink(spanContext, LINK_ATTRIBUTES); | ||
| } | ||
| } | ||
| } |
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.
Uh oh!
There was an error while loading. Please reload this page.