Skip to content

Commit

Permalink
First commit
Browse files Browse the repository at this point in the history
  • Loading branch information
Anuraag Agrawal committed Jul 28, 2020
0 parents commit 9de652f
Show file tree
Hide file tree
Showing 18 changed files with 1,003 additions and 0 deletions.
6 changes: 6 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#
# https://help.github.com/articles/dealing-with-line-endings/
#
# These are explicitly windows files and should use crlf
*.bat text eol=crlf

43 changes: 43 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
### Gradle template
.gradle
build/

.DS_Store

# Ignore Gradle GUI config
gradle-app.setting

# Avoid ignoring Gradle wrapper jar file (.jar files are usually ignored)
!gradle-wrapper.jar

# Cache of project
.gradletasknamecache

# # Work around https://youtrack.jetbrains.com/issue/IDEA-116898
# gradle/wrapper/gradle-wrapper.properties
### JetBrains template
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and Webstorm
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839

# We modify the template to remove everything - we use the gradle idea plugin, instead of checking
# in config.

.idea
.ideaDatasources
dataSources

## File-based project format:
*.iml
*.ipr
*.iws

## Plugin-specific files:

# IntelliJ
/out/

# mpeltonen/sbt-idea plugin
.idea_modules/

# JIRA plugin
atlassian-ide-plugin.xml
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# AWS OpenTelemetry Java Instrumentatio

Libraries and integrations for improving the experience using OpenTelemetry
with AWS.

62 changes: 62 additions & 0 deletions awsagentprovider/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
/*
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License").
* You may not use this file except in compliance with the License.
* A copy of the License is located at
*
* http://aws.amazon.com/apache2.0
*
* or in the "license" file accompanying this file. This file 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.
*/

plugins {
java
id("com.github.johnrengelman.shadow") version "5.2.0"
}

java {
sourceCompatibility = JavaVersion.VERSION_1_7
targetCompatibility = JavaVersion.VERSION_1_7
}

dependencies {
compileOnly("io.opentelemetry.instrumentation.auto", "opentelemetry-javaagent", classifier = "all")
compileOnly("io.opentelemetry:opentelemetry-sdk")
compileOnly("org.slf4j:slf4j-api:1.7.30")

implementation("io.opentelemetry:opentelemetry-sdk-contrib-aws-v1-support")

compileOnly("com.google.code.findbugs:jsr305:3.0.2")
}

tasks {
shadowJar {
archiveClassifier.set("")

mergeServiceFiles()

exclude("**/module-info.class")

// Prevents conflict with other SLF4J instances. Important for premain.
relocate("org.slf4j", "io.opentelemetry.auto.slf4j")
// rewrite dependencies calling Logger.getLogger
relocate("java.util.logging.Logger", "io.opentelemetry.auto.bootstrap.PatchLogger")

// relocate OpenTelemetry API
relocate("io.opentelemetry.OpenTelemetry", "io.opentelemetry.auto.shaded.io.opentelemetry.OpenTelemetry")
relocate("io.opentelemetry.common", "io.opentelemetry.auto.shaded.io.opentelemetry.common")
relocate("io.opentelemetry.context", "io.opentelemetry.auto.shaded.io.opentelemetry.context")
relocate("io.opentelemetry.correlationcontext", "io.opentelemetry.auto.shaded.io.opentelemetry.correlationcontext")
relocate("io.opentelemetry.internal", "io.opentelemetry.auto.shaded.io.opentelemetry.internal")
relocate("io.opentelemetry.metrics", "io.opentelemetry.auto.shaded.io.opentelemetry.metrics")
relocate("io.opentelemetry.trace", "io.opentelemetry.auto.shaded.io.opentelemetry.trace")
relocate("io.opentelemetry.contrib.auto.annotations", "io.opentelemetry.auto.shaded.io.opentelemetry.contrib.auto.annotations")

// relocate OpenTelemetry API dependency
relocate("io.grpc", "io.opentelemetry.auto.shaded.io.grpc")
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/*
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License").
* You may not use this file except in compliance with the License.
* A copy of the License is located at
*
* http://aws.amazon.com/apache2.0
*
* or in the "license" file accompanying this file. This file 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 com.softwareaws.xray.opentelemetry.exporters;

import io.opentelemetry.OpenTelemetry;
import io.opentelemetry.auto.bootstrap.spi.TracerCustomizer;
import io.opentelemetry.context.propagation.DefaultContextPropagators;
import io.opentelemetry.sdk.trace.TracerSdkProvider;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class AwsTracerCustomizer implements TracerCustomizer {

private static final Logger logger = LoggerFactory.getLogger(AwsTracerProviderFactory.class);

@Override
public void configure(TracerSdkProvider unused) {
logger.info("AwsTracerCustomizer");
OpenTelemetry.setPropagators(DefaultContextPropagators.builder()
.addHttpTextFormat(new AwsXRayPropagator())
.build());
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/*
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License").
* You may not use this file except in compliance with the License.
* A copy of the License is located at
*
* http://aws.amazon.com/apache2.0
*
* or in the "license" file accompanying this file. This file 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 com.softwareaws.xray.opentelemetry.exporters;

import io.opentelemetry.sdk.contrib.trace.aws.AwsXRayIdsGenerator;
import io.opentelemetry.sdk.contrib.trace.aws.resource.AwsResource;
import io.opentelemetry.sdk.resources.EnvVarResource;
import io.opentelemetry.sdk.resources.Resource;
import io.opentelemetry.sdk.trace.TracerSdkProvider;
import io.opentelemetry.trace.TracerProvider;
import io.opentelemetry.trace.spi.TracerProviderFactory;

public class AwsTracerProviderFactory implements TracerProviderFactory {

private static final TracerSdkProvider TRACER_PROVIDER;
static {
Resource resource = EnvVarResource.getResource().merge(AwsResource.create());

TRACER_PROVIDER = TracerSdkProvider.builder()
.setIdsGenerator(new AwsXRayIdsGenerator())
.setResource(resource)
.build();
}

@Override
public TracerProvider create() {
System.out.println("AwsTraceProvider");
return TRACER_PROVIDER;
}
}
Loading

0 comments on commit 9de652f

Please sign in to comment.