Skip to content
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

Replace inferred-spans extension with upstream contrib extension #370

Draft
wants to merge 5 commits into
base: main
Choose a base branch
from
Draft
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
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,11 @@ public interface ElasticAttributes {
AttributeKey<String> SPAN_TYPE = AttributeKey.stringKey("elastic.span.type");
AttributeKey<String> SPAN_SUBTYPE = AttributeKey.stringKey("elastic.span.subtype");

/** Marker attribute for inferred spans. */
AttributeKey<Boolean> IS_INFERRED = AttributeKey.booleanKey("elastic.is_inferred");

/** Used as marker on span-links to override the parent-child relationship for inferred spans. */
AttributeKey<Boolean> IS_CHILD = AttributeKey.booleanKey("elastic.is_child");
/**
* Marker attribute for inferred spans. Does not have the elastic-prefix anymore because it has
* been contributed upstream
*/
AttributeKey<Boolean> IS_INFERRED = AttributeKey.booleanKey("is_inferred");

AttributeKey<List<String>> PROFILER_STACK_TRACE_IDS =
AttributeKey.stringArrayKey("elastic.profiler_stack_trace_ids");
Expand Down
1 change: 1 addition & 0 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ awsContribResources = { group = "io.opentelemetry.contrib", name = "opentelemetr
gcpContribResources = { group = "io.opentelemetry.contrib", name = "opentelemetry-gcp-resources", version.ref = "opentelemetryContribAlpha" }
contribResources = { group = "io.opentelemetry.contrib", name = "opentelemetry-resource-providers", version.ref = "opentelemetryContribAlpha" }
contribSpanStacktrace = { group = "io.opentelemetry.contrib", name = "opentelemetry-span-stacktrace", version.ref = "opentelemetryContribAlpha" }
contribInferredSpans = { group = "io.opentelemetry.contrib", name = "opentelemetry-inferred-spans", version.ref = "opentelemetryContribAlpha" }

opentelemetrySemconv = { group = "io.opentelemetry.semconv", name = "opentelemetry-semconv", version.ref = "opentelemetrySemconvAlpha"}
opentelemetrySemconvIncubating = { group = "io.opentelemetry.semconv", name = "opentelemetry-semconv-incubating", version.ref = "opentelemetrySemconvAlpha"}
Expand Down
199 changes: 3 additions & 196 deletions inferred-spans/README.md

Large diffs are not rendered by default.

8 changes: 1 addition & 7 deletions inferred-spans/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,11 @@ description = "Elastic Inferred Spans extension for OpenTelemetry Java"
dependencies {
compileOnly("io.opentelemetry:opentelemetry-sdk")
compileOnly("io.opentelemetry:opentelemetry-sdk-extension-autoconfigure-spi")
implementation(libs.lmax.disruptor)
implementation(libs.jctools)
implementation(libs.asyncprofiler)
implementation(libs.bundles.semconv)
implementation(project(":common"))
implementation(libs.contribInferredSpans)

testImplementation(project(":testing-common"))
testImplementation("io.opentelemetry:opentelemetry-sdk")
testImplementation("io.opentelemetry:opentelemetry-sdk-extension-autoconfigure")
testImplementation(libs.github.api)
testImplementation(libs.apachecommons.compress)
testImplementation(libs.bundles.semconv)
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
/*
* 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.sdk.autoconfigure.spi.AutoConfigurationCustomizer;
import io.opentelemetry.sdk.autoconfigure.spi.AutoConfigurationCustomizerProvider;
import java.util.HashMap;
import java.util.Map;
import java.util.logging.Level;
import java.util.logging.Logger;

@AutoService(AutoConfigurationCustomizerProvider.class)
public class InferredSpansConfigMigration implements AutoConfigurationCustomizerProvider {

private static final Logger log = Logger.getLogger(InferredSpansConfigMigration.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);
}
}
}
return overrides;
});
}
}
Loading