Skip to content

Initial commit of JmxScraper code. #1

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 20 commits into from
Sep 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
165fcb8
Initial commit of JmxScraper code. Application compiles and runs as s…
robsunday Sep 10, 2024
164679f
Cleanup of config.
robsunday Sep 11, 2024
f847561
Code review changes:
robsunday Sep 17, 2024
fb25c79
Update dependency gradle to v8.10.1 (#1447)
renovate[bot] Sep 9, 2024
d36106e
Update micrometer packages to v1.13.4 (#1448)
renovate[bot] Sep 10, 2024
b45cdab
Update dependency com.linecorp.armeria:armeria-bom to v1.30.1 (#1449)
renovate[bot] Sep 10, 2024
460470b
Update plugin com.gradle.develocity to v3.18.1 (#1451)
renovate[bot] Sep 10, 2024
19357e6
Update dependency com.gradle.enterprise:com.gradle.enterprise.gradle.…
renovate[bot] Sep 10, 2024
791df4b
Update dependency io.opentelemetry.instrumentation:opentelemetry-inst…
renovate[bot] Sep 16, 2024
27b631d
Update errorProneVersion to v2.32.0 (#1453)
renovate[bot] Sep 16, 2024
b3386de
Update plugin com.squareup.wire to v5.1.0 (#1452)
renovate[bot] Sep 16, 2024
11f2111
Composite Samplers prototype (#1443)
PeterF778 Sep 16, 2024
9fa44be
Fix incorrect cloud.platform value for GCF (#1454)
psx95 Sep 16, 2024
11a2e1a
Fix Tomcat metric definitions to aggregate multiple MBeans. (#1366)
jefchien Sep 16, 2024
9ee5fb1
Issue-1034 Short XRay Trace (#1036)
yurybubnov Sep 16, 2024
151b744
add span stacktrace config option (#1414)
SylvainJuge Sep 16, 2024
5ffa348
Add declarative config support for aws xray propagators (#1442)
jack-berg Sep 16, 2024
eb5dc6f
Fix native mode error cause by static init of random (#862)
brunobat Sep 16, 2024
6d39e93
Update dependency com.uber.nullaway:nullaway to v0.11.3 (#1457)
renovate[bot] Sep 16, 2024
40a2591
Add declarative config support for RuleBasedRoutingSampler (#1440)
jack-berg Sep 16, 2024
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
5 changes: 5 additions & 0 deletions .github/component_owners.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@ components:
- sfriberg
jmx-metrics:
- breedx-splk
jmx-scraper:
- breedx-splk
- robsunday
- sylvainjuge
maven-extension:
- cyrille-leclerc
- kenfinnigan
Expand All @@ -61,6 +65,7 @@ components:
- jeanbisutti
samplers:
- trask
- jack-berg
static-instrumenter:
- anosek-an
kafka-exporter:
Expand Down
2 changes: 2 additions & 0 deletions aws-xray-propagator/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,7 @@ dependencies {
testImplementation("io.opentelemetry:opentelemetry-sdk-extension-autoconfigure")
testImplementation("io.opentelemetry:opentelemetry-sdk-trace")
testImplementation("io.opentelemetry:opentelemetry-sdk-testing")

testImplementation("io.opentelemetry:opentelemetry-sdk-extension-incubator")
testImplementation("uk.org.webcompere:system-stubs-jupiter:2.0.3")
}
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,11 @@ public <C> Context extract(Context context, @Nullable C carrier, TextMapGetter<C
MapGetter.INSTANCE);
}

@Override
public String toString() {
return "AwsXrayLambdaPropagator";
}

private static boolean isEmptyOrNull(@Nullable String value) {
return value == null || value.isEmpty();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,11 @@ public <C> Context extract(Context context, @Nullable C carrier, TextMapGetter<C
return getContextFromHeader(context, carrier, getter);
}

@Override
public String toString() {
return "AwsXrayPropagator";
}

private static <C> Context getContextFromHeader(
Context context, @Nullable C carrier, TextMapGetter<C> getter) {
String traceHeader = getter.get(carrier, TRACE_HEADER_KEY);
Expand Down Expand Up @@ -290,7 +295,8 @@ private static String parseShortTraceId(String xrayTraceId) {
int secondDelimiter = xrayTraceId.indexOf(TRACE_ID_DELIMITER, firstDelimiter + 2);
if (firstDelimiter != TRACE_ID_DELIMITER_INDEX_1
|| secondDelimiter == -1
|| secondDelimiter > TRACE_ID_DELIMITER_INDEX_2) {
|| secondDelimiter > TRACE_ID_DELIMITER_INDEX_2
|| xrayTraceId.length() < secondDelimiter + 25) {
return TraceId.getInvalid();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@
* SPDX-License-Identifier: Apache-2.0
*/

package io.opentelemetry.contrib.awsxray.propagator;
package io.opentelemetry.contrib.awsxray.propagator.internal;

import io.opentelemetry.context.propagation.TextMapPropagator;
import io.opentelemetry.contrib.awsxray.propagator.AwsXrayPropagator;
import io.opentelemetry.sdk.autoconfigure.spi.ConfigProperties;
import io.opentelemetry.sdk.autoconfigure.spi.ConfigurablePropagatorProvider;

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/*
* Copyright The OpenTelemetry Authors
* SPDX-License-Identifier: Apache-2.0
*/

package io.opentelemetry.contrib.awsxray.propagator.internal;

import io.opentelemetry.context.propagation.TextMapPropagator;
import io.opentelemetry.contrib.awsxray.propagator.AwsXrayPropagator;
import io.opentelemetry.sdk.autoconfigure.spi.internal.ComponentProvider;
import io.opentelemetry.sdk.autoconfigure.spi.internal.StructuredConfigProperties;

public class AwsXrayComponentProvider implements ComponentProvider<TextMapPropagator> {
@Override
public Class<TextMapPropagator> getType() {
return TextMapPropagator.class;
}

@Override
public String getName() {
return "xray";
}

@Override
public TextMapPropagator create(StructuredConfigProperties config) {
return AwsXrayPropagator.getInstance();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/*
* Copyright The OpenTelemetry Authors
* SPDX-License-Identifier: Apache-2.0
*/

package io.opentelemetry.contrib.awsxray.propagator.internal;

import io.opentelemetry.context.propagation.TextMapPropagator;
import io.opentelemetry.contrib.awsxray.propagator.AwsXrayLambdaPropagator;
import io.opentelemetry.sdk.autoconfigure.spi.internal.ComponentProvider;
import io.opentelemetry.sdk.autoconfigure.spi.internal.StructuredConfigProperties;

public class AwsXrayLambdaComponentProvider implements ComponentProvider<TextMapPropagator> {
@Override
public Class<TextMapPropagator> getType() {
return TextMapPropagator.class;
}

@Override
public String getName() {
return "xray-lambda";
}

@Override
public TextMapPropagator create(StructuredConfigProperties config) {
return AwsXrayLambdaPropagator.getInstance();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@
* SPDX-License-Identifier: Apache-2.0
*/

package io.opentelemetry.contrib.awsxray.propagator;
package io.opentelemetry.contrib.awsxray.propagator.internal;

import io.opentelemetry.context.propagation.TextMapPropagator;
import io.opentelemetry.contrib.awsxray.propagator.AwsXrayLambdaPropagator;
import io.opentelemetry.sdk.autoconfigure.spi.ConfigProperties;
import io.opentelemetry.sdk.autoconfigure.spi.ConfigurablePropagatorProvider;

Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
io.opentelemetry.contrib.awsxray.propagator.AwsConfigurablePropagator
io.opentelemetry.contrib.awsxray.propagator.internal.AwsConfigurablePropagator
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
io.opentelemetry.contrib.awsxray.propagator.internal.AwsXrayComponentProvider
io.opentelemetry.contrib.awsxray.propagator.internal.AwsXrayLambdaComponentProvider
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@ void extract_InvalidTraceId() {
}

@Test
void extract_InvalidTraceId_Size() {
void extract_InvalidTraceId_Size_TooBig() {
Map<String, String> invalidHeaders = new LinkedHashMap<>();
invalidHeaders.put(
TRACE_HEADER_KEY,
Expand All @@ -306,6 +306,16 @@ void extract_InvalidTraceId_Size() {
verifyInvalidBehavior(invalidHeaders);
}

@Test
void extract_InvalidTraceId_Size_TooShort() {
Map<String, String> invalidHeaders = new LinkedHashMap<>();
invalidHeaders.put(
TRACE_HEADER_KEY,
"Root=1-64fbd5a9-2202432c9dfed25ae1e6996;Parent=53995c3f42cd8ad8;Sampled=0");

verifyInvalidBehavior(invalidHeaders);
}

@Test
void extract_InvalidSpanId() {
Map<String, String> invalidHeaders = new LinkedHashMap<>();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/*
* Copyright The OpenTelemetry Authors
* SPDX-License-Identifier: Apache-2.0
*/

package io.opentelemetry.contrib.awsxray.propagator.internal;

import static org.assertj.core.api.Assertions.assertThat;

import io.opentelemetry.context.propagation.TextMapPropagator;
import io.opentelemetry.contrib.awsxray.propagator.AwsXrayLambdaPropagator;
import io.opentelemetry.contrib.awsxray.propagator.AwsXrayPropagator;
import io.opentelemetry.sdk.OpenTelemetrySdk;
import io.opentelemetry.sdk.extension.incubator.fileconfig.FileConfiguration;
import java.io.ByteArrayInputStream;
import java.nio.charset.StandardCharsets;
import org.junit.jupiter.api.Test;

class AwsComponentProviderTest {

@Test
void endToEnd() {
String yaml = "file_format: 0.1\n" + "propagator:\n" + " composite: [xray, xray-lambda]\n";

OpenTelemetrySdk openTelemetrySdk =
FileConfiguration.parseAndCreate(
new ByteArrayInputStream(yaml.getBytes(StandardCharsets.UTF_8)));
TextMapPropagator expectedPropagator =
TextMapPropagator.composite(
AwsXrayPropagator.getInstance(), AwsXrayLambdaPropagator.getInstance());
assertThat(openTelemetrySdk.getPropagators().getTextMapPropagator().toString())
.isEqualTo(expectedPropagator.toString());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.ScheduledFuture;
import java.util.concurrent.ThreadLocalRandom;
import java.util.concurrent.TimeUnit;
import java.util.function.Function;
import java.util.logging.Level;
Expand All @@ -40,7 +41,6 @@ public final class AwsXrayRemoteSampler implements Sampler, Closeable {

static final long DEFAULT_TARGET_INTERVAL_NANOS = TimeUnit.SECONDS.toNanos(10);

private static final Random RANDOM = new Random();
private static final Logger logger = Logger.getLogger(AwsXrayRemoteSampler.class.getName());

private final Resource resource;
Expand Down Expand Up @@ -97,7 +97,7 @@ public static AwsXrayRemoteSamplerBuilder newBuilder(Resource resource) {

this.pollingIntervalNanos = pollingIntervalNanos;
// Add ~1% of jitter
jitterNanos = RANDOM.longs(0, pollingIntervalNanos / 100).iterator();
jitterNanos = ThreadLocalRandom.current().longs(0, pollingIntervalNanos / 100).iterator();

// Execute first update right away on the executor thread.
executor.execute(this::getAndUpdateSampler);
Expand Down
2 changes: 1 addition & 1 deletion buildSrc/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ dependencies {
implementation("com.diffplug.spotless:spotless-plugin-gradle:6.25.0")
implementation("net.ltgt.gradle:gradle-errorprone-plugin:4.0.1")
implementation("net.ltgt.gradle:gradle-nullaway-plugin:2.0.0")
implementation("com.gradle.enterprise:com.gradle.enterprise.gradle.plugin:3.18")
implementation("com.gradle.enterprise:com.gradle.enterprise.gradle.plugin:3.18.1")
}

spotless {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/*
* Copyright The OpenTelemetry Authors
* SPDX-License-Identifier: Apache-2.0
*/

package io.opentelemetry.contrib.sampler.consistent56;

import io.opentelemetry.api.common.Attributes;
import io.opentelemetry.api.trace.SpanKind;
import io.opentelemetry.context.Context;
import io.opentelemetry.sdk.trace.data.LinkData;
import java.util.List;

/** An interface for components to be used by composite consistent probability samplers. */
public interface ComposableSampler {

/**
* Returns the SamplingIntent that is used for the sampling decision. The SamplingIntent includes
* the threshold value which will be used for the sampling decision.
*
* <p>NOTE: Keep in mind, that in any case the returned threshold value must not depend directly
* or indirectly on the random value. In particular this means that the parent sampled flag must
* not be used for the calculation of the threshold as the sampled flag depends itself on the
* random value.
*/
SamplingIntent getSamplingIntent(
Context parentContext,
String name,
SpanKind spanKind,
Attributes attributes,
List<LinkData> parentLinks);

/** Return the string providing a description of the implementation. */
String getDescription();
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,13 @@

package io.opentelemetry.contrib.sampler.consistent56;

import static io.opentelemetry.contrib.sampler.consistent56.ConsistentSamplingUtil.getInvalidThreshold;

import io.opentelemetry.api.common.Attributes;
import io.opentelemetry.api.trace.SpanKind;
import io.opentelemetry.context.Context;
import io.opentelemetry.sdk.trace.data.LinkData;
import java.util.List;
import javax.annotation.concurrent.Immutable;

@Immutable
Expand All @@ -19,8 +26,14 @@ static ConsistentAlwaysOffSampler getInstance() {
}

@Override
protected long getThreshold(long parentThreshold, boolean isRoot) {
return ConsistentSamplingUtil.getMaxThreshold();
public SamplingIntent getSamplingIntent(
Context parentContext,
String name,
SpanKind spanKind,
Attributes attributes,
List<LinkData> parentLinks) {

return () -> getInvalidThreshold();
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@

import static io.opentelemetry.contrib.sampler.consistent56.ConsistentSamplingUtil.getMinThreshold;

import io.opentelemetry.api.common.Attributes;
import io.opentelemetry.api.trace.SpanKind;
import io.opentelemetry.context.Context;
import io.opentelemetry.sdk.trace.data.LinkData;
import java.util.List;
import javax.annotation.concurrent.Immutable;

@Immutable
Expand All @@ -21,8 +26,14 @@ static ConsistentAlwaysOnSampler getInstance() {
}

@Override
protected long getThreshold(long parentThreshold, boolean isRoot) {
return getMinThreshold();
public SamplingIntent getSamplingIntent(
Context parentContext,
String name,
SpanKind spanKind,
Attributes attributes,
List<LinkData> parentLinks) {

return () -> getMinThreshold();
}

@Override
Expand Down
Loading