Skip to content
Merged
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 @@ -12,6 +12,7 @@
import static io.opentelemetry.contrib.aws.resource.IncubatingAttributes.SERVICE_INSTANCE_ID;
import static io.opentelemetry.contrib.aws.resource.IncubatingAttributes.SERVICE_NAMESPACE;
import static io.opentelemetry.semconv.ServiceAttributes.SERVICE_VERSION;
import static java.util.logging.Level.WARNING;

import com.fasterxml.jackson.core.JsonFactory;
import com.fasterxml.jackson.core.JsonParser;
Expand All @@ -22,7 +23,6 @@
import io.opentelemetry.semconv.SchemaUrls;
import java.io.File;
import java.io.IOException;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
Expand Down Expand Up @@ -65,7 +65,7 @@ static Resource buildResource(String configPath) {
parser.nextToken();

if (!parser.isExpectedStartObjectToken()) {
logger.log(Level.WARNING, "Invalid Beanstalk config: ", configPath);
logger.log(WARNING, "Invalid Beanstalk config: ", configPath);
return Resource.create(attrBuilders.build(), SchemaUrls.V1_25_0);
}

Expand All @@ -87,7 +87,7 @@ static Resource buildResource(String configPath) {
}
}
} catch (IOException e) {
logger.log(Level.WARNING, "Could not parse Beanstalk config.", e);
logger.log(WARNING, "Could not parse Beanstalk config.", e);
return Resource.empty();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,12 @@

package io.opentelemetry.contrib.aws.resource;

import static java.util.logging.Level.WARNING;

import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.util.logging.Level;
import java.util.logging.Logger;

class DockerHelper {
Expand Down Expand Up @@ -44,9 +45,9 @@ public String getContainerId() {
}
}
} catch (FileNotFoundException e) {
logger.log(Level.WARNING, "Failed to read container id, cgroup file does not exist.");
logger.log(WARNING, "Failed to read container id, cgroup file does not exist.");
} catch (IOException e) {
logger.log(Level.WARNING, "Unable to read container id: " + e.getMessage());
logger.log(WARNING, "Unable to read container id: " + e.getMessage());
}

return "";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import static io.opentelemetry.contrib.aws.resource.IncubatingAttributes.HOST_IMAGE_ID;
import static io.opentelemetry.contrib.aws.resource.IncubatingAttributes.HOST_NAME;
import static io.opentelemetry.contrib.aws.resource.IncubatingAttributes.HOST_TYPE;
import static java.util.logging.Level.WARNING;

import com.fasterxml.jackson.core.JsonFactory;
import com.fasterxml.jackson.core.JsonParser;
Expand All @@ -28,7 +29,6 @@
import java.net.URL;
import java.util.HashMap;
import java.util.Map;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
Expand Down Expand Up @@ -125,7 +125,7 @@ static Resource buildResource(String endpoint) {
}
}
} catch (IOException e) {
logger.log(Level.WARNING, "Could not parse identity document, resource not filled.", e);
logger.log(WARNING, "Could not parse identity document, resource not filled.", e);
return Resource.empty();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@
import static io.opentelemetry.contrib.aws.resource.IncubatingAttributes.CONTAINER_NAME;
import static io.opentelemetry.contrib.aws.resource.IncubatingAttributes.CloudPlatformIncubatingValues.AWS_ECS;
import static io.opentelemetry.contrib.aws.resource.IncubatingAttributes.CloudProviderIncubatingValues.AWS;
import static java.util.Collections.emptyMap;
import static java.util.Collections.singletonList;
import static java.util.logging.Level.WARNING;

import com.fasterxml.jackson.core.JsonFactory;
import com.fasterxml.jackson.core.JsonParser;
Expand All @@ -35,11 +38,9 @@
import io.opentelemetry.sdk.resources.Resource;
import io.opentelemetry.semconv.SchemaUrls;
import java.io.IOException;
import java.util.Collections;
import java.util.Locale;
import java.util.Map;
import java.util.Optional;
import java.util.logging.Level;
import java.util.logging.Logger;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
Expand Down Expand Up @@ -88,7 +89,7 @@ static Resource buildResource(Map<String, String> sysEnv, SimpleHttpClient httpC

static void fetchMetadata(
SimpleHttpClient httpClient, String url, AttributesBuilder attrBuilders) {
String json = httpClient.fetchString("GET", url, Collections.emptyMap(), null);
String json = httpClient.fetchString("GET", url, emptyMap(), null);
if (json.isEmpty()) {
return;
}
Expand All @@ -103,17 +104,17 @@ static void fetchMetadata(
.getLogGroupArn()
.ifPresent(
logGroupArn -> {
attrBuilders.put(AWS_LOG_GROUP_ARNS, Collections.singletonList(logGroupArn));
attrBuilders.put(AWS_LOG_GROUP_ARNS, singletonList(logGroupArn));
});

logArnBuilder
.getLogStreamArn()
.ifPresent(
logStreamArn -> {
attrBuilders.put(AWS_LOG_STREAM_ARNS, Collections.singletonList(logStreamArn));
attrBuilders.put(AWS_LOG_STREAM_ARNS, singletonList(logStreamArn));
});
} catch (IOException e) {
logger.log(Level.WARNING, "Can't get ECS metadata", e);
logger.log(WARNING, "Can't get ECS metadata", e);
}
}

Expand Down Expand Up @@ -156,7 +157,7 @@ static void parseResponse(
JsonParser parser, AttributesBuilder attrBuilders, LogArnBuilder logArnBuilder)
throws IOException {
if (!parser.isExpectedStartObjectToken()) {
logger.log(Level.WARNING, "Couldn't parse ECS metadata, invalid JSON");
logger.log(WARNING, "Couldn't parse ECS metadata, invalid JSON");
return;
}

Expand Down Expand Up @@ -339,7 +340,7 @@ static DockerImage parse(@Nullable String image) {
}
Matcher matcher = imagePattern.matcher(image);
if (!matcher.matches()) {
logger.log(Level.WARNING, "Couldn't parse image '" + image + "'");
logger.log(WARNING, "Couldn't parse image '" + image + "'");
return null;
}
String repository = matcher.group("repository");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
import static io.opentelemetry.contrib.aws.resource.IncubatingAttributes.CloudPlatformIncubatingValues.AWS_EKS;
import static io.opentelemetry.contrib.aws.resource.IncubatingAttributes.CloudProviderIncubatingValues.AWS;
import static io.opentelemetry.contrib.aws.resource.IncubatingAttributes.K8S_CLUSTER_NAME;
import static java.util.logging.Level.FINE;
import static java.util.logging.Level.WARNING;

import com.fasterxml.jackson.core.JsonFactory;
import com.fasterxml.jackson.core.JsonParser;
Expand All @@ -26,7 +28,6 @@
import java.nio.file.Paths;
import java.util.HashMap;
import java.util.Map;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
Expand Down Expand Up @@ -91,7 +92,7 @@ static Resource buildResource(
private static boolean isEks(
String k8sTokenPath, String k8sKeystorePath, SimpleHttpClient httpClient) {
if (!isK8s(k8sTokenPath, k8sKeystorePath)) {
logger.log(Level.FINE, "Not running on k8s.");
logger.log(FINE, "Not running on k8s.");
return false;
}

Expand Down Expand Up @@ -145,7 +146,7 @@ private static String getClusterName(SimpleHttpClient httpClient) {
}
}
} catch (IOException e) {
logger.log(Level.WARNING, "Can't get cluster name on EKS.", e);
logger.log(WARNING, "Can't get cluster name on EKS.", e);
}
return "";
}
Expand All @@ -156,7 +157,7 @@ private static String getK8sCredHeader() {
new String(Files.readAllBytes(Paths.get(K8S_TOKEN_PATH)), StandardCharsets.UTF_8);
return "Bearer " + content;
} catch (IOException e) {
logger.log(Level.WARNING, "Unable to load K8s client token.", e);
logger.log(WARNING, "Unable to load K8s client token.", e);
}
return "";
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@

package io.opentelemetry.contrib.aws.resource;

import static java.util.logging.Level.FINE;
import static java.util.logging.Level.WARNING;

import java.io.FileInputStream;
import java.io.IOException;
import java.security.KeyStore;
Expand All @@ -13,7 +16,6 @@
import java.time.Duration;
import java.util.Collection;
import java.util.Map;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.annotation.Nullable;
import javax.net.ssl.SSLContext;
Expand Down Expand Up @@ -72,7 +74,7 @@ public String fetchString(
int responseCode = response.code();
if (responseCode != 200) {
logger.log(
Level.FINE,
FINE,
"Error response from "
+ urlStr
+ " code ("
Expand All @@ -84,7 +86,7 @@ public String fetchString(
ResponseBody body = response.body();
return body != null ? body.string() : "";
} catch (IOException e) {
logger.log(Level.FINE, "SimpleHttpClient fetch string failed.", e);
logger.log(FINE, "SimpleHttpClient fetch string failed.", e);
}

return "";
Expand All @@ -101,7 +103,7 @@ private static X509TrustManager buildTrustManager(@Nullable KeyStore keyStore) {
tmf.init(keyStore);
return (X509TrustManager) tmf.getTrustManagers()[0];
} catch (Exception e) {
logger.log(Level.WARNING, "Build SslSocketFactory for K8s restful client exception.", e);
logger.log(WARNING, "Build SslSocketFactory for K8s restful client exception.", e);
return null;
}
}
Expand All @@ -117,7 +119,7 @@ private static SSLSocketFactory buildSslSocketFactory(@Nullable TrustManager tru
return context.getSocketFactory();

} catch (Exception e) {
logger.log(Level.WARNING, "Build SslSocketFactory for K8s restful client exception.", e);
logger.log(WARNING, "Build SslSocketFactory for K8s restful client exception.", e);
}
return null;
}
Expand All @@ -138,7 +140,7 @@ private static KeyStore getKeystoreForTrustedCert(String certPath) {
}
return trustStore;
} catch (Exception e) {
logger.log(Level.WARNING, "Cannot load KeyStore from " + certPath);
logger.log(WARNING, "Cannot load KeyStore from " + certPath);
return null;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,13 @@

package io.opentelemetry.contrib.awsxray.propagator;

import static java.util.Collections.singletonMap;

import io.opentelemetry.api.trace.Span;
import io.opentelemetry.context.Context;
import io.opentelemetry.context.propagation.TextMapGetter;
import io.opentelemetry.context.propagation.TextMapPropagator;
import io.opentelemetry.context.propagation.TextMapSetter;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.Set;
Expand Down Expand Up @@ -75,7 +76,7 @@ public <C> Context extract(Context context, @Nullable C carrier, TextMapGetter<C
}
return xrayPropagator.extract(
xrayContext,
Collections.singletonMap(AwsXrayPropagator.TRACE_HEADER_KEY, traceHeader),
singletonMap(AwsXrayPropagator.TRACE_HEADER_KEY, traceHeader),
MapGetter.INSTANCE);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
package io.opentelemetry.contrib.awsxray.propagator;

import static io.opentelemetry.api.internal.OtelEncodingUtils.isValidBase16String;
import static java.util.Collections.singletonList;

import io.opentelemetry.api.baggage.Baggage;
import io.opentelemetry.api.baggage.BaggageBuilder;
Expand All @@ -20,7 +21,6 @@
import io.opentelemetry.context.propagation.TextMapGetter;
import io.opentelemetry.context.propagation.TextMapPropagator;
import io.opentelemetry.context.propagation.TextMapSetter;
import java.util.Collections;
import java.util.List;
import java.util.Set;
import java.util.logging.Logger;
Expand Down Expand Up @@ -80,7 +80,7 @@ public final class AwsXrayPropagator implements TextMapPropagator {
private static final String INVALID_LINEAGE = "-1:11111111:0";
private static final int NUM_OF_LINEAGE_DELIMITERS = 2;

private static final List<String> FIELDS = Collections.singletonList(TRACE_HEADER_KEY);
private static final List<String> FIELDS = singletonList(TRACE_HEADER_KEY);

private static final AwsXrayPropagator INSTANCE = new AwsXrayPropagator();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,35 +5,34 @@

package io.opentelemetry.contrib.awsxray;

import static io.opentelemetry.api.common.AttributeKey.stringKey;

import io.opentelemetry.api.common.AttributeKey;

/** Utility class holding attribute keys with special meaning to AWS components */
final class AwsAttributeKeys {

private AwsAttributeKeys() {}

static final AttributeKey<String> AWS_SPAN_KIND = AttributeKey.stringKey("aws.span.kind");
static final AttributeKey<String> AWS_SPAN_KIND = stringKey("aws.span.kind");

static final AttributeKey<String> AWS_LOCAL_SERVICE = AttributeKey.stringKey("aws.local.service");
static final AttributeKey<String> AWS_LOCAL_SERVICE = stringKey("aws.local.service");

static final AttributeKey<String> AWS_LOCAL_OPERATION =
AttributeKey.stringKey("aws.local.operation");
static final AttributeKey<String> AWS_LOCAL_OPERATION = stringKey("aws.local.operation");

static final AttributeKey<String> AWS_REMOTE_SERVICE =
AttributeKey.stringKey("aws.remote.service");
static final AttributeKey<String> AWS_REMOTE_SERVICE = stringKey("aws.remote.service");

static final AttributeKey<String> AWS_REMOTE_OPERATION =
AttributeKey.stringKey("aws.remote.operation");
static final AttributeKey<String> AWS_REMOTE_OPERATION = stringKey("aws.remote.operation");

static final AttributeKey<String> AWS_REMOTE_TARGET = AttributeKey.stringKey("aws.remote.target");
static final AttributeKey<String> AWS_REMOTE_TARGET = stringKey("aws.remote.target");

// use the same AWS Resource attribute name defined by OTel java auto-instr for aws_sdk_v_1_1
// TODO: all AWS specific attributes should be defined in semconv package and reused cross all
// otel packages. Related sim -
// https://github.com/open-telemetry/opentelemetry-java-instrumentation/issues/8710

static final AttributeKey<String> AWS_BUCKET_NAME = AttributeKey.stringKey("aws.bucket.name");
static final AttributeKey<String> AWS_QUEUE_NAME = AttributeKey.stringKey("aws.queue.name");
static final AttributeKey<String> AWS_STREAM_NAME = AttributeKey.stringKey("aws.stream.name");
static final AttributeKey<String> AWS_TABLE_NAME = AttributeKey.stringKey("aws.table.name");
static final AttributeKey<String> AWS_BUCKET_NAME = stringKey("aws.bucket.name");
static final AttributeKey<String> AWS_QUEUE_NAME = stringKey("aws.queue.name");
static final AttributeKey<String> AWS_STREAM_NAME = stringKey("aws.stream.name");
static final AttributeKey<String> AWS_TABLE_NAME = stringKey("aws.table.name");
}
Loading
Loading