├── .clomonitor.yml ├── .editorconfig ├── .fossa.yml ├── .gitattributes ├── .github ├── CODEOWNERS ├── ISSUE_TEMPLATE │ ├── bug_report.yml │ ├── config.yml │ └── feature_request.yml ├── component_owners.yml ├── config │ └── markdownlint.yml ├── pull_request_template.md ├── renovate.json5 ├── repository-settings.md ├── scripts │ ├── draft-change-log-entries.sh │ ├── generate-release-contributors.sh │ ├── get-version.sh │ ├── merge-change-log-after-release.sh │ ├── update-version.sh │ └── use-cla-approved-bot.sh └── workflows │ ├── assign-reviewers.yml │ ├── auto-spotless-apply.yml │ ├── auto-spotless-check.yml │ ├── backport.yml │ ├── build.yml │ ├── codeql.yml │ ├── fossa.yml │ ├── gradle-wrapper-validation.yml │ ├── issue-management-feedback-label.yml │ ├── issue-management-stale-action.yml │ ├── ossf-scorecard.yml │ ├── owasp-dependency-check-daily.yml │ ├── prepare-patch-release.yml │ ├── prepare-release-branch.yml │ ├── release.yml │ ├── reusable-markdown-link-check.yml │ ├── reusable-markdown-lint.yml │ ├── reusable-misspell-check.yml │ ├── reusable-shell-script-check.yml │ └── reusable-workflow-notification.yml ├── .gitignore ├── CHANGELOG.md ├── CONTRIBUTING.md ├── LICENSE ├── README.md ├── RELEASING.md ├── all ├── README.md └── build.gradle.kts ├── aws-resources ├── README.md ├── build.gradle.kts ├── gradle.properties └── src │ ├── main │ ├── java │ │ └── io │ │ │ └── opentelemetry │ │ │ └── contrib │ │ │ └── aws │ │ │ └── resource │ │ │ ├── BeanstalkResource.java │ │ │ ├── BeanstalkResourceProvider.java │ │ │ ├── CloudResourceProvider.java │ │ │ ├── DockerHelper.java │ │ │ ├── Ec2Resource.java │ │ │ ├── Ec2ResourceProvider.java │ │ │ ├── EcsResource.java │ │ │ ├── EcsResourceProvider.java │ │ │ ├── EksResource.java │ │ │ ├── EksResourceProvider.java │ │ │ ├── IncubatingAttributes.java │ │ │ ├── LambdaResource.java │ │ │ ├── LambdaResourceProvider.java │ │ │ ├── SimpleHttpClient.java │ │ │ └── package-info.java │ └── resources │ │ └── META-INF │ │ └── services │ │ └── io.opentelemetry.sdk.autoconfigure.spi.ResourceProvider │ └── test │ ├── java │ └── io │ │ └── opentelemetry │ │ └── contrib │ │ └── aws │ │ └── resource │ │ ├── BeanstalkResourceTest.java │ │ ├── DockerHelperTest.java │ │ ├── Ec2ResourceTest.java │ │ ├── EcsResourceTest.java │ │ ├── EksResourceTest.java │ │ ├── LambdaResourceTest.java │ │ └── SimpleHttpClientTest.java │ └── resources │ ├── ecs-container-metadata-v3.json │ ├── ecs-container-metadata-v4.json │ ├── ecs-task-metadata-v3.json │ ├── ecs-task-metadata-v4.json │ └── mockito-extensions │ └── org.mockito.plugins.MockMaker ├── aws-xray-propagator ├── README.md ├── build.gradle.kts ├── gradle.properties └── src │ ├── main │ ├── java │ │ └── io │ │ │ └── opentelemetry │ │ │ └── contrib │ │ │ └── awsxray │ │ │ └── propagator │ │ │ ├── AwsXrayLambdaPropagator.java │ │ │ ├── AwsXrayPropagator.java │ │ │ ├── internal │ │ │ ├── AwsConfigurablePropagator.java │ │ │ ├── AwsXrayComponentProvider.java │ │ │ ├── AwsXrayLambdaComponentProvider.java │ │ │ └── AwsXrayLambdaConfigurablePropagator.java │ │ │ └── package-info.java │ └── resources │ │ └── META-INF │ │ └── services │ │ ├── io.opentelemetry.sdk.autoconfigure.spi.ConfigurablePropagatorProvider │ │ └── io.opentelemetry.sdk.autoconfigure.spi.internal.ComponentProvider │ └── test │ └── java │ └── io │ └── opentelemetry │ └── contrib │ └── awsxray │ └── propagator │ ├── AwsXrayCompositePropagatorTest.java │ ├── AwsXrayLambdaPropagatorTest.java │ ├── AwsXrayPropagatorTest.java │ └── internal │ └── AwsComponentProviderTest.java ├── aws-xray ├── README.md ├── build.gradle.kts ├── gradle.properties └── src │ ├── awsTest │ ├── java │ │ └── io │ │ │ └── opentelemetry │ │ │ └── contrib │ │ │ └── aws │ │ │ └── xray │ │ │ └── AwsXrayRemoteSamplerIntegrationTest.java │ └── resources │ │ └── otel-collector.yml │ ├── main │ └── java │ │ └── io │ │ └── opentelemetry │ │ └── contrib │ │ └── awsxray │ │ ├── AlwaysRecordSampler.java │ │ ├── AttributePropagatingSpanProcessor.java │ │ ├── AttributePropagatingSpanProcessorBuilder.java │ │ ├── AwsAttributeKeys.java │ │ ├── AwsMetricAttributeGenerator.java │ │ ├── AwsMetricAttributesSpanExporter.java │ │ ├── AwsMetricAttributesSpanExporterBuilder.java │ │ ├── AwsSpanMetricsProcessor.java │ │ ├── AwsSpanMetricsProcessorBuilder.java │ │ ├── AwsXrayIdGenerator.java │ │ ├── AwsXrayRemoteSampler.java │ │ ├── AwsXrayRemoteSamplerBuilder.java │ │ ├── AwsXrayRemoteSamplerProvider.java │ │ ├── GetSamplingRulesRequest.java │ │ ├── GetSamplingRulesResponse.java │ │ ├── GetSamplingTargetsRequest.java │ │ ├── GetSamplingTargetsResponse.java │ │ ├── MetricAttributeGenerator.java │ │ ├── OrElseSampler.java │ │ ├── RateLimiter.java │ │ ├── RateLimitingSampler.java │ │ ├── ResourceHolder.java │ │ ├── SamplingRuleApplier.java │ │ ├── XrayRulesSampler.java │ │ ├── XraySamplerClient.java │ │ └── package-info.java │ └── test │ ├── java │ └── io │ │ └── opentelemetry │ │ └── contrib │ │ └── awsxray │ │ ├── AlwaysRecordSamplerTest.java │ │ ├── AttributePropagatingSpanProcessorTest.java │ │ ├── AwsMetricAttributeGeneratorTest.java │ │ ├── AwsMetricAttributesSpanExporterTest.java │ │ ├── AwsSpanMetricsProcessorTest.java │ │ ├── AwsXRayIdGeneratorTest.java │ │ ├── AwsXrayRemoteSamplerProviderTest.java │ │ ├── AwsXrayRemoteSamplerTest.java │ │ ├── OrElseSamplerTest.java │ │ ├── RateLimiterTest.java │ │ ├── RateLimitingSamplerTest.java │ │ ├── ResourceHolderTest.java │ │ ├── SamplingRuleApplierTest.java │ │ ├── XrayRulesSamplerTest.java │ │ └── XraySamplerClientTest.java │ └── resources │ ├── get-sampling-rules-response.json │ ├── get-sampling-targets-request.json │ ├── get-sampling-targets-response.json │ ├── mockito-extensions │ └── org.mockito.plugins.MockMaker │ ├── sampling-rule-awslambda.json │ ├── sampling-rule-exactmatch.json │ ├── sampling-rule-reservoir.json │ ├── sampling-rule-wildcards.json │ ├── test-sampling-rules-response-1.json │ ├── test-sampling-rules-response-2.json │ └── test-sampling-targets-response.json ├── azure-resources ├── README.md ├── build.gradle.kts └── src │ ├── main │ ├── java │ │ └── io │ │ │ └── opentelemetry │ │ │ └── contrib │ │ │ └── azure │ │ │ └── resource │ │ │ ├── AzureAksResourceProvider.java │ │ │ ├── AzureAppServiceResourceProvider.java │ │ │ ├── AzureContainersResourceProvider.java │ │ │ ├── AzureEnvVarPlatform.java │ │ │ ├── AzureFunctionsResourceProvider.java │ │ │ ├── AzureMetadataService.java │ │ │ ├── AzureVmResourceProvider.java │ │ │ ├── CloudResourceProvider.java │ │ │ └── IncubatingAttributes.java │ └── resources │ │ └── META-INF │ │ └── services │ │ └── io.opentelemetry.sdk.autoconfigure.spi.ResourceProvider │ └── test │ ├── java │ └── io │ │ └── opentelemetry │ │ └── contrib │ │ └── azure │ │ └── resource │ │ ├── AzureAksResourceProviderTest.java │ │ ├── AzureAppServiceResourceProviderTest.java │ │ ├── AzureContainersResourceProviderTest.java │ │ ├── AzureFunctionsResourceProviderTest.java │ │ ├── AzureVmResourceProviderTest.java │ │ └── MetadataBasedResourceProviderTest.java │ └── resources │ └── response.json ├── baggage-processor ├── README.md ├── build.gradle.kts ├── gradle.properties └── src │ ├── main │ ├── java │ │ └── io │ │ │ └── opentelemetry │ │ │ └── contrib │ │ │ └── baggage │ │ │ └── processor │ │ │ ├── BaggageLogRecordProcessor.java │ │ │ ├── BaggageProcessorCustomizer.java │ │ │ └── BaggageSpanProcessor.java │ └── resources │ │ └── META-INF │ │ └── services │ │ └── io.opentelemetry.sdk.autoconfigure.spi.AutoConfigurationCustomizerProvider │ └── test │ └── java │ └── io │ └── opentelemetry │ └── contrib │ └── baggage │ └── processor │ ├── BaggageProcessorCustomizerTest.java │ └── BaggageSpanProcessorTest.java ├── build.gradle.kts ├── buildSrc ├── build.gradle.kts └── src │ └── main │ └── kotlin │ ├── io │ └── opentelemetry │ │ └── gradle │ │ └── OtelJavaExtension.kt │ ├── otel.errorprone-conventions.gradle.kts │ ├── otel.groovy-conventions.gradle.kts │ ├── otel.java-conventions.gradle.kts │ ├── otel.publish-conventions.gradle.kts │ └── otel.spotless-conventions.gradle.kts ├── buildscripts ├── dependency-check-suppressions.xml └── spotless.license.java ├── cloudfoundry-resources ├── README.md ├── build.gradle.kts └── src │ ├── main │ ├── java │ │ └── io │ │ │ └── opentelemetry │ │ │ └── contrib │ │ │ └── cloudfoundry │ │ │ └── resources │ │ │ ├── CloudFoundryResource.java │ │ │ └── CloudFoundryResourceProvider.java │ └── resources │ │ └── META-INF │ │ └── services │ │ └── io.opentelemetry.sdk.autoconfigure.spi.ResourceProvider │ └── test │ ├── java │ └── io │ │ └── opentelemetry │ │ └── contrib │ │ └── cloudfoundry │ │ └── resources │ │ └── CloudFoundryResourceTest.java │ └── resources │ └── vcap_application.json ├── compressors └── compressor-zstd │ ├── README.md │ ├── build.gradle.kts │ └── src │ ├── main │ ├── java │ │ └── io │ │ │ └── opentelemetry │ │ │ └── contrib │ │ │ └── compressor │ │ │ └── zstd │ │ │ ├── ZstdCompressor.java │ │ │ └── ZstdCompressorProvider.java │ └── resources │ │ └── META-INF │ │ └── services │ │ └── io.opentelemetry.exporter.internal.compression.CompressorProvider │ └── test │ └── java │ └── io │ └── opentelemetry │ └── contrib │ └── compressor │ └── zstd │ ├── ZstdCompressorProviderTest.java │ └── ZstdCompressorTest.java ├── config └── license │ └── spotless.license.java ├── consistent-sampling ├── README.md ├── build.gradle.kts └── src │ ├── main │ ├── java │ │ └── io │ │ │ └── opentelemetry │ │ │ └── contrib │ │ │ └── sampler │ │ │ ├── consistent │ │ │ ├── ConsistentAlwaysOffSampler.java │ │ │ ├── ConsistentAlwaysOnSampler.java │ │ │ ├── ConsistentComposedAndSampler.java │ │ │ ├── ConsistentComposedOrSampler.java │ │ │ ├── ConsistentParentBasedSampler.java │ │ │ ├── ConsistentProbabilityBasedSampler.java │ │ │ ├── ConsistentRateLimitingSampler.java │ │ │ ├── ConsistentReservoirSamplingSpanProcessor.java │ │ │ ├── ConsistentSampler.java │ │ │ ├── OtelTraceState.java │ │ │ ├── ParentBasedConsistentProbabilitySamplerProvider.java │ │ │ ├── RValueGenerator.java │ │ │ ├── RValueGenerators.java │ │ │ └── RandomGenerator.java │ │ │ └── consistent56 │ │ │ ├── Composable.java │ │ │ ├── ConsistentAlwaysOffSampler.java │ │ │ ├── ConsistentAlwaysOnSampler.java │ │ │ ├── ConsistentAnyOf.java │ │ │ ├── ConsistentFixedThresholdSampler.java │ │ │ ├── ConsistentParentBasedSampler.java │ │ │ ├── ConsistentRateLimitingSampler.java │ │ │ ├── ConsistentRuleBasedSampler.java │ │ │ ├── ConsistentSampler.java │ │ │ ├── ConsistentSamplingUtil.java │ │ │ ├── OtelTraceState.java │ │ │ ├── Predicate.java │ │ │ ├── PredicatedSampler.java │ │ │ ├── RandomValueGenerator.java │ │ │ ├── RandomValueGenerators.java │ │ │ └── SamplingIntent.java │ └── resources │ │ └── META-INF │ │ └── services │ │ └── io.opentelemetry.sdk.autoconfigure.spi.traces.ConfigurableSamplerProvider │ └── test │ └── java │ └── io │ └── opentelemetry │ └── contrib │ └── sampler │ ├── consistent │ ├── ConsistentProbabilityBasedSamplerTest.java │ ├── ConsistentRateLimitingSamplerTest.java │ ├── ConsistentReservoirSamplingSpanProcessorTest.java │ ├── ConsistentSamplerTest.java │ ├── OtelTraceStateTest.java │ ├── RandomGeneratorTest.java │ └── TestUtil.java │ └── consistent56 │ ├── CoinFlipSampler.java │ ├── ConsistentAlwaysOffSamplerTest.java │ ├── ConsistentAlwaysOnSamplerTest.java │ ├── ConsistentAnyOfTest.java │ ├── ConsistentFixedThresholdSamplerTest.java │ ├── ConsistentRateLimitingSamplerTest.java │ ├── ConsistentRuleBasedSamplerTest.java │ ├── ConsistentSamplerTest.java │ ├── ConsistentSamplingUtilTest.java │ ├── MarkingSampler.java │ ├── OtelTraceStateTest.java │ ├── RandomValueGeneratorsTest.java │ ├── TestUtil.java │ └── UseCaseTest.java ├── dependencyManagement └── build.gradle.kts ├── disk-buffering ├── DESIGN.md ├── README.md ├── assets │ ├── reading-flow.png │ └── writing-flow.png ├── build.gradle.kts └── src │ ├── jmh │ └── java │ │ └── io │ │ └── opentelemetry │ │ └── contrib │ │ └── disk │ │ └── buffering │ │ └── internal │ │ └── files │ │ └── utils │ │ └── FileTransferUtilBenchmark.java │ ├── main │ └── java │ │ └── io │ │ └── opentelemetry │ │ └── contrib │ │ └── disk │ │ └── buffering │ │ ├── LogRecordFromDiskExporter.java │ │ ├── LogRecordToDiskExporter.java │ │ ├── MetricFromDiskExporter.java │ │ ├── MetricToDiskExporter.java │ │ ├── SpanFromDiskExporter.java │ │ ├── SpanToDiskExporter.java │ │ ├── config │ │ └── StorageConfiguration.java │ │ └── internal │ │ ├── exporter │ │ ├── FromDiskExporter.java │ │ ├── FromDiskExporterBuilder.java │ │ ├── FromDiskExporterImpl.java │ │ ├── ToDiskExporter.java │ │ └── ToDiskExporterBuilder.java │ │ ├── serialization │ │ ├── deserializers │ │ │ ├── DeserializationException.java │ │ │ ├── LogRecordDataDeserializer.java │ │ │ ├── MetricDataDeserializer.java │ │ │ ├── SignalDeserializer.java │ │ │ └── SpanDataDeserializer.java │ │ ├── mapping │ │ │ ├── common │ │ │ │ ├── AttributesMapper.java │ │ │ │ ├── BaseProtoSignalsDataMapper.java │ │ │ │ ├── ByteStringMapper.java │ │ │ │ └── ResourceMapper.java │ │ │ ├── logs │ │ │ │ ├── LogRecordDataMapper.java │ │ │ │ ├── ProtoLogsDataMapper.java │ │ │ │ └── models │ │ │ │ │ └── LogRecordDataImpl.java │ │ │ ├── metrics │ │ │ │ ├── MetricDataMapper.java │ │ │ │ └── ProtoMetricsDataMapper.java │ │ │ └── spans │ │ │ │ ├── ProtoSpansDataMapper.java │ │ │ │ ├── SpanDataMapper.java │ │ │ │ └── models │ │ │ │ └── SpanDataImpl.java │ │ └── serializers │ │ │ ├── LogRecordDataSerializer.java │ │ │ ├── MetricDataSerializer.java │ │ │ ├── SignalSerializer.java │ │ │ └── SpanDataSerializer.java │ │ ├── storage │ │ ├── FolderManager.java │ │ ├── Storage.java │ │ ├── StorageBuilder.java │ │ ├── files │ │ │ ├── FileOperations.java │ │ │ ├── ReadableFile.java │ │ │ ├── WritableFile.java │ │ │ ├── reader │ │ │ │ ├── DelimitedProtoStreamReader.java │ │ │ │ ├── ProcessResult.java │ │ │ │ ├── ReadResult.java │ │ │ │ └── StreamReader.java │ │ │ └── utils │ │ │ │ └── FileStream.java │ │ ├── responses │ │ │ ├── ReadableResult.java │ │ │ └── WritableResult.java │ │ └── util │ │ │ └── ClockBuddy.java │ │ └── utils │ │ ├── DebugLogger.java │ │ ├── ProtobufTools.java │ │ └── SignalTypes.java │ └── test │ └── java │ └── io │ └── opentelemetry │ └── contrib │ └── disk │ └── buffering │ ├── FromDiskExporterImplTest.java │ ├── IntegrationTest.java │ ├── LogRecordToDiskExporterTest.java │ ├── MetricToDiskExporterTest.java │ ├── SpanFromDiskExporterTest.java │ ├── SpanToDiskExporterTest.java │ ├── internal │ ├── exporter │ │ └── ToDiskExporterTest.java │ ├── serialization │ │ ├── mapping │ │ │ ├── common │ │ │ │ ├── AttributesMapperTest.java │ │ │ │ └── ResourceMapperTest.java │ │ │ ├── logs │ │ │ │ ├── LogRecordDataMapperTest.java │ │ │ │ └── ProtoLogsDataMapperTest.java │ │ │ ├── metrics │ │ │ │ ├── MetricDataMapperTest.java │ │ │ │ └── ProtoMetricsDataMapperTest.java │ │ │ └── spans │ │ │ │ ├── ProtoSpansDataMapperTest.java │ │ │ │ └── SpanDataMapperTest.java │ │ └── serializers │ │ │ ├── LogRecordDataSerializerTest.java │ │ │ ├── MetricDataSerializerTest.java │ │ │ └── SpanDataSerializerTest.java │ └── storage │ │ ├── FolderManagerTest.java │ │ ├── StorageTest.java │ │ ├── TestData.java │ │ └── files │ │ ├── ReadableFileTest.java │ │ ├── WritableFileTest.java │ │ └── utils │ │ └── FileStreamTest.java │ └── testutils │ ├── BaseSignalSerializerTest.java │ └── TestData.java ├── example ├── README.md ├── build.gradle.kts └── src │ ├── main │ └── java │ │ └── io │ │ └── opentelemetry │ │ └── contrib │ │ └── example │ │ └── Library.java │ └── test │ └── java │ └── io │ └── opentelemetry │ └── contrib │ └── example │ └── LibraryTest.java ├── gcp-auth-extension ├── README.md ├── build.gradle.kts ├── gradle.properties └── src │ ├── main │ └── java │ │ └── io │ │ └── opentelemetry │ │ └── contrib │ │ └── gcp │ │ └── auth │ │ ├── ConfigurableOption.java │ │ ├── GcpAuthAutoConfigurationCustomizerProvider.java │ │ └── GoogleAuthException.java │ └── test │ ├── java │ └── io │ │ └── opentelemetry │ │ └── contrib │ │ └── gcp │ │ └── auth │ │ ├── GcpAuthAutoConfigurationCustomizerProviderTest.java │ │ ├── GcpAuthExtensionEndToEndTest.java │ │ └── springapp │ │ ├── Application.java │ │ └── Controller.java │ └── resources │ ├── fake_user_creds.json │ └── mockito-extensions │ └── org.mockito.plugins.MockMaker ├── gcp-resources ├── README.md ├── build.gradle.kts ├── gradle.properties └── src │ ├── main │ ├── java │ │ └── io │ │ │ └── opentelemetry │ │ │ └── contrib │ │ │ └── gcp │ │ │ └── resource │ │ │ ├── GCPResourceProvider.java │ │ │ └── IncubatingAttributes.java │ └── resources │ │ └── META-INF │ │ └── services │ │ └── io.opentelemetry.sdk.autoconfigure.spi.ResourceProvider │ └── test │ └── java │ └── io │ └── opentelemetry │ └── contrib │ └── gcp │ └── resource │ └── GCPResourceProviderTest.java ├── gradle.properties ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── inferred-spans ├── README.md ├── build.gradle.kts └── src │ ├── main │ └── java │ │ └── io │ │ └── opentelemetry │ │ └── contrib │ │ └── inferredspans │ │ ├── InferredSpansAutoConfig.java │ │ ├── InferredSpansProcessor.java │ │ ├── InferredSpansProcessorBuilder.java │ │ ├── WildcardMatcher.java │ │ └── internal │ │ ├── CallTree.java │ │ ├── ChildList.java │ │ ├── InferredSpansConfiguration.java │ │ ├── ProfilingActivationListener.java │ │ ├── SamplingProfiler.java │ │ ├── SpanAnchoredClock.java │ │ ├── StackFrame.java │ │ ├── ThreadMatcher.java │ │ ├── TraceContext.java │ │ ├── asyncprofiler │ │ ├── BufferedFile.java │ │ └── JfrParser.java │ │ ├── pooling │ │ ├── AbstractObjectPool.java │ │ ├── Allocator.java │ │ ├── ObjectPool.java │ │ ├── QueueBasedObjectPool.java │ │ ├── Recyclable.java │ │ └── Resetter.java │ │ ├── semconv │ │ └── Attributes.java │ │ └── util │ │ ├── ByteUtils.java │ │ ├── HexUtils.java │ │ └── ThreadUtils.java │ └── test │ ├── java │ └── io │ │ └── opentelemetry │ │ └── contrib │ │ └── inferredspans │ │ ├── InferredSpansAutoConfigTest.java │ │ ├── ProfilerTestSetup.java │ │ ├── SamplingProfilerReplay.java │ │ └── internal │ │ ├── CallTreeSpanifyTest.java │ │ ├── CallTreeTest.java │ │ ├── FixedClock.java │ │ ├── SamplingProfilerQueueTest.java │ │ ├── SamplingProfilerTest.java │ │ ├── ThreadMatcherTest.java │ │ ├── asyncprofiler │ │ └── JfrParserTest.java │ │ ├── semconv │ │ └── AttributesTest.java │ │ └── util │ │ ├── AutoConfigTestProperties.java │ │ ├── AutoConfiguredDataCapture.java │ │ ├── DisabledOnOpenJ9.java │ │ ├── DisabledOnOpenJ9Condition.java │ │ ├── OtelReflectionUtils.java │ │ └── TemporaryProperties.java │ └── resources │ ├── logging.properties │ └── recording.jfr ├── jfr-connection ├── README.md ├── build.gradle.kts └── src │ ├── main │ └── java │ │ └── io │ │ └── opentelemetry │ │ └── contrib │ │ └── jfr │ │ └── connection │ │ ├── FlightRecorderConnection.java │ │ ├── FlightRecorderDiagnosticCommandConnection.java │ │ ├── FlightRecorderMXBeanConnection.java │ │ ├── JfcFileConfiguration.java │ │ ├── JfrConnectionException.java │ │ ├── JfrStream.java │ │ ├── MapConfiguration.java │ │ ├── OpenDataUtils.java │ │ ├── PredefinedConfiguration.java │ │ ├── Recording.java │ │ ├── RecordingConfiguration.java │ │ ├── RecordingOptions.java │ │ └── package-info.java │ └── test │ ├── java │ └── io │ │ └── opentelemetry │ │ └── contrib │ │ └── jfr │ │ └── connection │ │ ├── FlightRecorderDiagnosticCommandConnectionTest.java │ │ ├── OpenDataUtilsTest.java │ │ ├── RecordingConfigurationTest.java │ │ ├── RecordingOptionsTest.java │ │ └── RecordingTest.java │ └── resources │ ├── brokenJfcFile.jfc │ └── sampleJfcFile.jfc ├── jfr-events ├── README.md ├── build.gradle.kts └── src │ ├── main │ └── java │ │ └── io │ │ └── opentelemetry │ │ └── contrib │ │ └── jfrevent │ │ ├── JfrContextStorageWrapper.java │ │ ├── JfrSpanProcessor.java │ │ ├── ScopeEvent.java │ │ ├── SpanEvent.java │ │ └── package-info.java │ └── test │ └── java │ └── io │ └── opentelemetry │ └── contrib │ └── jfrevent │ └── JfrSpanProcessorTest.java ├── jmx-metrics ├── README.md ├── build.gradle.kts ├── docs │ └── target-systems │ │ ├── activemq.md │ │ ├── cassandra.md │ │ ├── hadoop.md │ │ ├── hbase.md │ │ ├── jetty.md │ │ ├── jvm.md │ │ ├── kafka-consumer.md │ │ ├── kafka-producer.md │ │ ├── kafka.md │ │ ├── solr.md │ │ ├── tomcat.md │ │ └── wildfly.md └── src │ ├── integrationTest │ ├── java │ │ └── io │ │ │ └── opentelemetry │ │ │ └── contrib │ │ │ └── jmxmetrics │ │ │ ├── AbstractIntegrationTest.java │ │ │ ├── OtlpIntegrationTest.java │ │ │ └── target_systems │ │ │ ├── ActivemqIntegrationTest.java │ │ │ ├── CassandraIntegrationTest.java │ │ │ ├── HadoopIntegrationTest.java │ │ │ ├── HbaseIntegrationTest.java │ │ │ ├── JettyIntegrationTest.java │ │ │ ├── JvmTargetSystemIntegrationTest.java │ │ │ ├── KafkaIntegrationTest.java │ │ │ ├── SolrIntegrationTest.java │ │ │ ├── TomcatIntegrationTest.java │ │ │ └── WildflyIntegrationTest.java │ └── resources │ │ ├── activemq │ │ ├── Dockerfile │ │ └── config │ │ │ └── env │ │ ├── cassandra │ │ └── jmxremote.password │ │ ├── hadoop │ │ ├── hadoop-env.sh │ │ └── yarn-site.xml │ │ ├── hbase │ │ └── hbase-env.sh │ │ ├── otlp_config.properties │ │ ├── script.groovy │ │ ├── target-systems │ │ ├── activemq.properties │ │ ├── cassandra.properties │ │ ├── hadoop.properties │ │ ├── hbase.properties │ │ ├── jetty.properties │ │ ├── jvm-and-kafka.properties │ │ ├── jvm.properties │ │ ├── kafka-consumer.properties │ │ ├── kafka-producer.properties │ │ ├── kafka-producer.sh │ │ ├── kafka.properties │ │ ├── solr.properties │ │ ├── tomcat.properties │ │ └── wildfly.properties │ │ └── wildfly │ │ └── start.sh │ ├── main │ ├── groovy │ │ └── io │ │ │ └── opentelemetry │ │ │ └── contrib │ │ │ └── jmxmetrics │ │ │ ├── ClientCallbackHandler.java │ │ │ ├── ConfigurationException.java │ │ │ ├── GroovyMetricEnvironment.java │ │ │ ├── GroovyRunner.java │ │ │ ├── InstrumentHelper.groovy │ │ │ ├── JmxClient.java │ │ │ ├── JmxConfig.java │ │ │ ├── JmxConnectorHelper.java │ │ │ ├── JmxMetrics.java │ │ │ ├── MBeanHelper.groovy │ │ │ └── OtelHelper.groovy │ ├── java │ │ └── io │ │ │ └── opentelemetry │ │ │ └── contrib │ │ │ └── jmxmetrics │ │ │ └── InstrumentDescriptor.java │ └── resources │ │ └── target-systems │ │ ├── activemq.groovy │ │ ├── cassandra.groovy │ │ ├── hadoop.groovy │ │ ├── hbase.groovy │ │ ├── jetty.groovy │ │ ├── jvm.groovy │ │ ├── kafka-consumer.groovy │ │ ├── kafka-producer.groovy │ │ ├── kafka.groovy │ │ ├── solr.groovy │ │ ├── tomcat.groovy │ │ └── wildfly.groovy │ └── test │ ├── java │ └── io │ │ └── opentelemetry │ │ └── contrib │ │ └── jmxmetrics │ │ ├── GroovyRunnerTest.java │ │ ├── InstrumenterHelperTest.java │ │ ├── JmxConfigTest.java │ │ ├── MBeanHelperTest.java │ │ ├── OtelHelperAsynchronousMetricTest.java │ │ ├── OtelHelperJmxTest.java │ │ └── OtelHelperSynchronousMetricTest.java │ └── resources │ ├── all.properties │ └── jmxremote.password ├── jmx-scraper ├── README.md ├── build.gradle.kts ├── src │ ├── integrationTest │ │ ├── java │ │ │ └── io │ │ │ │ └── opentelemetry │ │ │ │ └── contrib │ │ │ │ └── jmxscraper │ │ │ │ ├── JmxConnectionTest.java │ │ │ │ ├── JmxScraperContainer.java │ │ │ │ ├── TestAppContainer.java │ │ │ │ ├── TestKeyStore.java │ │ │ │ ├── assertions │ │ │ │ ├── Assertions.java │ │ │ │ ├── AttributeMatcher.java │ │ │ │ ├── AttributeMatcherGroup.java │ │ │ │ ├── DataPointAttributes.java │ │ │ │ └── MetricAssert.java │ │ │ │ └── target_systems │ │ │ │ ├── ActiveMqIntegrationTest.java │ │ │ │ ├── CassandraIntegrationTest.java │ │ │ │ ├── CustomIntegrationTest.java │ │ │ │ ├── HBaseIntegrationTest.java │ │ │ │ ├── HadoopIntegrationTest.java │ │ │ │ ├── JettyIntegrationTest.java │ │ │ │ ├── JvmIntegrationTest.java │ │ │ │ ├── MetricAssertions.java │ │ │ │ ├── MetricsVerifier.java │ │ │ │ ├── SolrIntegrationTest.java │ │ │ │ ├── TargetSystemIntegrationTest.java │ │ │ │ ├── TomcatIntegrationTest.java │ │ │ │ ├── WildflyIntegrationTest.java │ │ │ │ └── kafka │ │ │ │ ├── KafkaConsumerIntegrationTest.java │ │ │ │ ├── KafkaContainerFactory.java │ │ │ │ ├── KafkaIntegrationTest.java │ │ │ │ └── KafkaProducerIntegrationTest.java │ │ └── resources │ │ │ ├── custom-metrics.yaml │ │ │ └── hadoop-env.sh │ ├── main │ │ ├── java │ │ │ └── io │ │ │ │ └── opentelemetry │ │ │ │ └── contrib │ │ │ │ └── jmxscraper │ │ │ │ ├── InvalidArgumentException.java │ │ │ │ ├── JmxConnectorBuilder.java │ │ │ │ ├── JmxScraper.java │ │ │ │ └── config │ │ │ │ ├── JmxScraperConfig.java │ │ │ │ ├── PropertiesCustomizer.java │ │ │ │ └── PropertiesSupplier.java │ │ └── resources │ │ │ ├── activemq.yaml │ │ │ ├── cassandra.yaml │ │ │ ├── hadoop.yaml │ │ │ ├── hbase.yaml │ │ │ ├── jetty.yaml │ │ │ ├── jvm.yaml │ │ │ ├── kafka-consumer.yaml │ │ │ ├── kafka-producer.yaml │ │ │ ├── kafka.yaml │ │ │ ├── solr.yaml │ │ │ ├── tomcat.yaml │ │ │ └── wildfly.yaml │ └── test │ │ ├── java │ │ └── io │ │ │ └── opentelemetry │ │ │ └── contrib │ │ │ └── jmxscraper │ │ │ ├── JmxScraperTest.java │ │ │ └── config │ │ │ ├── JmxScraperConfigTest.java │ │ │ ├── PropertiesCustomizerTest.java │ │ │ ├── PropertiesSupplierTest.java │ │ │ └── TestUtil.java │ │ └── resources │ │ ├── fake-test-system-both.yaml │ │ ├── fake-test-system-legacy-only.yaml │ │ ├── jmx │ │ └── rules │ │ │ ├── fake-test-system-both.yaml │ │ │ └── fake-test-system-instrumentation-only.yaml │ │ └── validConfig.properties ├── test-app │ ├── README.md │ ├── build.gradle.kts │ └── src │ │ └── main │ │ └── java │ │ └── io │ │ └── opentelemetry │ │ └── contrib │ │ └── jmxscraper │ │ └── testapp │ │ ├── TestApp.java │ │ └── TestAppMxBean.java └── test-webapp │ ├── README.md │ ├── build.gradle.kts │ └── src │ └── main │ ├── java │ └── io │ │ └── opentelemetry │ │ └── contrib │ │ └── jmxscraper │ │ └── testwebapp │ │ └── SimpleServlet.java │ └── webapp │ └── WEB-INF │ └── web.xml ├── kafka-exporter ├── README.md ├── build.gradle.kts └── src │ ├── main │ └── java │ │ └── io │ │ └── opentelemetry │ │ └── contrib │ │ └── kafka │ │ ├── KafkaSpanExporter.java │ │ ├── KafkaSpanExporterBuilder.java │ │ ├── SpanDataDeserializer.java │ │ └── SpanDataSerializer.java │ └── test │ └── java │ └── io │ └── opentelemetry │ └── contrib │ └── kafka │ ├── KafkaSpanExporterBuilderTest.java │ ├── KafkaSpanExporterIntegrationTest.java │ ├── SpanDataDeserializerTest.java │ ├── SpanDataSerializerTest.java │ └── TestUtil.java ├── maven-extension ├── README.md ├── build.gradle.kts ├── docs │ └── images │ │ ├── jenkins-maven-execution-trace-jaeger.png │ │ └── maven-execution-trace-jaeger.png └── src │ ├── main │ ├── java │ │ └── io │ │ │ └── opentelemetry │ │ │ └── maven │ │ │ ├── AutoConfigureUtil2.java │ │ │ ├── ChainedExecutionListener.java │ │ │ ├── ChainedTransferListener.java │ │ │ ├── MavenGoal.java │ │ │ ├── MavenUtils.java │ │ │ ├── OpenTelemetrySdkService.java │ │ │ ├── OtelExecutionListener.java │ │ │ ├── OtelLifecycleParticipant.java │ │ │ ├── OtelTransferListener.java │ │ │ ├── SpanRegistry.java │ │ │ ├── StringUtils.java │ │ │ ├── ToUpperCaseTextMapGetter.java │ │ │ ├── handler │ │ │ ├── GoogleJibBuildHandler.java │ │ │ ├── MavenDeployHandler.java │ │ │ ├── MojoGoalExecutionHandler.java │ │ │ ├── MojoGoalExecutionHandlerConfiguration.java │ │ │ ├── SnykMonitorHandler.java │ │ │ ├── SnykTestHandler.java │ │ │ ├── SpringBootBuildImageHandler.java │ │ │ └── package-info.java │ │ │ ├── package-info.java │ │ │ ├── resources │ │ │ ├── MavenResourceProvider.java │ │ │ └── package-info.java │ │ │ └── semconv │ │ │ └── MavenOtelSemanticAttributes.java │ └── resources │ │ └── META-INF │ │ ├── maven │ │ └── extension.xml │ │ ├── services │ │ ├── io.opentelemetry.maven.handler.MojoGoalExecutionHandler │ │ └── io.opentelemetry.sdk.autoconfigure.spi.ResourceProvider │ │ └── sisu │ │ └── javax.inject.Named │ └── test │ ├── java │ └── io │ │ └── opentelemetry │ │ └── maven │ │ ├── AutoConfigureUtil2Test.java │ │ ├── MavenUtilsTests.java │ │ ├── OpenTelemetrySdkServiceTest.java │ │ ├── SpanRegistryTest.java │ │ ├── handler │ │ ├── MojoGoalExecutionHandlerConfigurationTest.java │ │ └── MojoGoalExecutionHandlerTest.java │ │ └── resources │ │ └── MavenResourceProviderTest.java │ └── resources │ └── projects │ ├── jar │ └── pom.xml │ ├── jib_1 │ └── pom.xml │ ├── jib_2 │ └── pom.xml │ ├── snyk_1 │ └── pom.xml │ ├── springboot_1 │ ├── pom.xml │ └── src │ │ ├── main │ │ ├── java │ │ │ └── io │ │ │ │ └── opentelemetry │ │ │ │ └── contrib │ │ │ │ └── maven │ │ │ │ └── test │ │ │ │ └── springboot │ │ │ │ └── SpringbootTestApplication.java │ │ └── resources │ │ │ └── application.properties │ │ └── test │ │ └── java │ │ └── io │ │ └── opentelemetry │ │ └── contrib │ │ └── maven │ │ └── test │ │ └── springboot │ │ └── SpringbootTestApplicationTests.java │ └── springboot_2 │ ├── pom.xml │ └── src │ ├── main │ ├── java │ │ └── io │ │ │ └── opentelemetry │ │ │ └── contrib │ │ │ └── maven │ │ │ └── test │ │ │ └── springboot │ │ │ └── SpringbootTestApplication.java │ └── resources │ │ └── application.properties │ └── test │ └── java │ └── io │ └── opentelemetry │ └── contrib │ └── maven │ └── test │ └── springboot │ └── SpringbootTestApplicationTests.java ├── micrometer-meter-provider ├── README.md ├── build.gradle.kts └── src │ ├── integrationTest │ └── java │ │ └── io │ │ └── opentelemetry │ │ └── contrib │ │ └── metrics │ │ └── micrometer │ │ └── PrometheusIntegrationTest.java │ ├── main │ └── java │ │ └── io │ │ └── opentelemetry │ │ └── contrib │ │ └── metrics │ │ └── micrometer │ │ ├── CallbackRegistrar.java │ │ ├── CallbackRegistration.java │ │ ├── MicrometerMeter.java │ │ ├── MicrometerMeterBuilder.java │ │ ├── MicrometerMeterProvider.java │ │ ├── MicrometerMeterProviderBuilder.java │ │ ├── ScheduledCallbackRegistrar.java │ │ ├── ScheduledCallbackRegistrarBuilder.java │ │ ├── internal │ │ ├── Constants.java │ │ ├── MemoizingSupplier.java │ │ ├── PollingMeterCallbackRegistrar.java │ │ ├── instruments │ │ │ ├── AbstractCounter.java │ │ │ ├── AbstractGauge.java │ │ │ ├── AbstractHistogram.java │ │ │ ├── AbstractInstrument.java │ │ │ ├── AbstractInstrumentBuilder.java │ │ │ ├── AbstractUpDownCounter.java │ │ │ ├── AtomicDoubleCounter.java │ │ │ ├── MicrometerDoubleCounter.java │ │ │ ├── MicrometerDoubleGauge.java │ │ │ ├── MicrometerDoubleHistogram.java │ │ │ ├── MicrometerDoubleUpDownCounter.java │ │ │ ├── MicrometerLongCounter.java │ │ │ ├── MicrometerLongGauge.java │ │ │ ├── MicrometerLongHistogram.java │ │ │ ├── MicrometerLongUpDownCounter.java │ │ │ └── package-info.java │ │ └── state │ │ │ ├── InstrumentState.java │ │ │ ├── MeterProviderSharedState.java │ │ │ ├── MeterSharedState.java │ │ │ └── package-info.java │ │ └── package-info.java │ └── test │ └── java │ └── io │ └── opentelemetry │ └── contrib │ └── metrics │ └── micrometer │ ├── MicrometerMeterProviderTest.java │ ├── MicrometerMeterTest.java │ ├── ScheduledCallbackRegistrarTest.java │ ├── TestCallbackRegistrar.java │ └── internal │ ├── MemoizingSupplierTest.java │ ├── PollingMeterCallbackRegistrarTest.java │ └── instruments │ ├── MicrometerDoubleCounterTest.java │ ├── MicrometerDoubleGaugeTest.java │ ├── MicrometerDoubleHistogramTest.java │ ├── MicrometerDoubleUpDownCounterTest.java │ ├── MicrometerLongCounterTest.java │ ├── MicrometerLongGaugeTest.java │ ├── MicrometerLongHistogramTest.java │ ├── MicrometerLongUpDownCounterTest.java │ └── RandomUtils.java ├── noop-api ├── README.md ├── build.gradle.kts └── src │ ├── main │ ├── java │ │ └── io │ │ │ └── opentelemetry │ │ │ └── contrib │ │ │ └── noopapi │ │ │ ├── NoopContextStorageProvider.java │ │ │ ├── NoopOpenTelemetry.java │ │ │ └── NoopTracerProvider.java │ └── resources │ │ └── META-INF │ │ └── services │ │ └── io.opentelemetry.context.ContextStorageProvider │ └── test │ └── java │ └── io │ └── opentelemetry │ └── contrib │ └── noopapi │ └── NoopOpenTelemetryTest.java ├── opamp-client ├── README.md ├── build.gradle.kts └── src │ └── main │ └── java │ └── io │ └── opentelemetry │ └── opamp │ └── client │ └── internal │ ├── OpampClient.java │ └── response │ └── MessageData.java ├── processors ├── README.md ├── build.gradle.kts └── src │ ├── main │ ├── java │ │ └── io │ │ │ └── opentelemetry │ │ │ └── contrib │ │ │ ├── eventbridge │ │ │ ├── EventToSpanEventBridge.java │ │ │ └── internal │ │ │ │ └── EventToSpanEventBridgeComponentProvider.java │ │ │ ├── filter │ │ │ └── FilteringLogRecordProcessor.java │ │ │ └── interceptor │ │ │ ├── InterceptableLogRecordExporter.java │ │ │ ├── InterceptableMetricExporter.java │ │ │ ├── InterceptableSpanExporter.java │ │ │ ├── api │ │ │ └── Interceptor.java │ │ │ └── common │ │ │ └── ComposableInterceptor.java │ └── resources │ │ └── META-INF │ │ └── services │ │ └── io.opentelemetry.sdk.autoconfigure.spi.internal.ComponentProvider │ └── test │ └── java │ └── io │ └── opentelemetry │ └── contrib │ ├── eventbridge │ ├── EventToSpanEventBridgeTest.java │ └── internal │ │ └── EventToSpanBridgeComponentProviderTest.java │ ├── filter │ └── FilteringLogRecordProcessorTest.java │ └── interceptor │ ├── InterceptableLogRecordExporterTest.java │ ├── InterceptableMetricExporterTest.java │ └── InterceptableSpanExporterTest.java ├── prometheus-client-bridge ├── README.md ├── build.gradle.kts └── src │ ├── main │ └── java │ │ └── io │ │ └── opentelemetry │ │ └── contrib │ │ └── metrics │ │ └── prometheus │ │ └── clientbridge │ │ ├── MetricAdapter.java │ │ ├── NameSanitizer.java │ │ ├── PrometheusCollector.java │ │ └── Serializer.java │ └── test │ └── java │ └── io │ └── opentelemetry │ └── contrib │ └── metrics │ └── prometheus │ └── clientbridge │ ├── MetricAdapterTest.java │ └── PrometheusCollectorTest.java ├── resource-providers ├── README.md ├── build.gradle.kts └── src │ ├── main │ └── java │ │ └── io │ │ └── opentelemetry │ │ └── contrib │ │ └── resourceproviders │ │ ├── AppServer.java │ │ ├── AppServerServiceNameDetector.java │ │ ├── AppServerServiceNameProvider.java │ │ ├── CommonAppServersServiceNameDetector.java │ │ ├── DelegatingServiceNameDetector.java │ │ ├── GlassfishAppServer.java │ │ ├── JettyAppServer.java │ │ ├── LibertyAppService.java │ │ ├── ParseBuddy.java │ │ ├── ResourceLocator.java │ │ ├── ServiceNameDetector.java │ │ ├── TomcatAppServer.java │ │ ├── TomeeAppServer.java │ │ ├── WebSphereAppServer.java │ │ ├── WebSphereServiceNameDetector.java │ │ └── WildflyAppServer.java │ └── test │ └── java │ └── io │ └── opentelemetry │ └── contrib │ └── resourceproviders │ ├── AppServerServiceNameDetectorTest.java │ ├── AppServerServiceNameProviderTest.java │ ├── DelegatingServiceNameDetectorTest.java │ ├── JettyServiceNameDetectorTest.java │ └── ParseBuddyTest.java ├── runtime-attach ├── README.md ├── runtime-attach-core │ ├── README.md │ ├── build.gradle.kts │ └── src │ │ └── main │ │ └── java │ │ └── io │ │ └── opentelemetry │ │ └── contrib │ │ └── attach │ │ └── core │ │ ├── AgentFileProvider.java │ │ ├── CoreRuntimeAttach.java │ │ └── RuntimeAttachException.java └── runtime-attach │ ├── build.gradle.kts │ └── src │ ├── main │ └── java │ │ └── io │ │ └── opentelemetry │ │ └── contrib │ │ └── attach │ │ └── RuntimeAttach.java │ └── test │ └── java │ └── io │ └── opentelemetry │ └── contrib │ └── attach │ ├── AbstractAttachmentTest.java │ ├── AgentDisabledByEnvironmentVariableTest.java │ ├── AgentDisabledBySystemPropertyTest.java │ └── RunTimeAttachBasicTest.java ├── samplers ├── README.md ├── build.gradle.kts └── src │ ├── main │ ├── java │ │ └── io │ │ │ └── opentelemetry │ │ │ └── contrib │ │ │ └── sampler │ │ │ ├── LinksBasedSampler.java │ │ │ ├── LinksParentAlwaysOnSamplerProvider.java │ │ │ ├── RuleBasedRoutingSampler.java │ │ │ ├── RuleBasedRoutingSamplerBuilder.java │ │ │ ├── SamplingRule.java │ │ │ └── internal │ │ │ └── RuleBasedRoutingSamplerComponentProvider.java │ └── resources │ │ └── META-INF │ │ └── services │ │ ├── io.opentelemetry.sdk.autoconfigure.spi.internal.ComponentProvider │ │ └── io.opentelemetry.sdk.autoconfigure.spi.traces.ConfigurableSamplerProvider │ └── test │ └── java │ ├── internal │ └── RuleBasedRoutingSamplerComponentProviderTest.java │ └── io │ └── opentelemetry │ └── contrib │ └── sampler │ ├── LinksBasedSamplerTest.java │ └── RuleBasedRoutingSamplerTest.java ├── settings.gradle.kts ├── span-stacktrace ├── README.md ├── build.gradle.kts └── src │ ├── main │ └── java │ │ └── io │ │ └── opentelemetry │ │ └── contrib │ │ └── stacktrace │ │ ├── StackTraceAutoConfig.java │ │ └── StackTraceSpanProcessor.java │ └── test │ └── java │ └── io │ └── opentelemetry │ └── contrib │ └── stacktrace │ ├── StackTraceAutoConfigTest.java │ └── StackTraceSpanProcessorTest.java └── version.gradle.kts /.clomonitor.yml: -------------------------------------------------------------------------------- 1 | # see https://github.com/cncf/clomonitor/blob/main/docs/checks.md#exemptions 2 | exemptions: 3 | - check: artifacthub_badge 4 | reason: "Artifact Hub doesn't support Java packages" 5 | - check: openssf_badge 6 | reason: "ETOOMANYBADGES, but the work has been done: https://www.bestpractices.dev/projects/9992" 7 | -------------------------------------------------------------------------------- /.fossa.yml: -------------------------------------------------------------------------------- 1 | version: 3 2 | 3 | targets: 4 | only: 5 | - type: gradle 6 | 7 | experimental: 8 | gradle: 9 | configurations-only: 10 | # consumer will only be exposed to these dependencies 11 | - runtimeClasspath 12 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | * text=auto eol=lf 2 | 3 | *.bat text eol=crlf 4 | *.cmd text eol=crlf 5 | -------------------------------------------------------------------------------- /.github/CODEOWNERS: -------------------------------------------------------------------------------- 1 | # 2 | # Learn about membership in OpenTelemetry community: 3 | # https://github.com/open-telemetry/community/blob/main/guides/contributor/membership.md 4 | # 5 | # 6 | # Learn about CODEOWNERS file format: 7 | # https://help.github.com/en/articles/about-code-owners 8 | # 9 | 10 | * @open-telemetry/java-contrib-approvers 11 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/config.yml: -------------------------------------------------------------------------------- 1 | contact_links: 2 | - name: StackOverflow 3 | url: https://stackoverflow.com/questions/ask?tags=open-telemetry+java 4 | about: Please ask questions here. 5 | - name: Slack 6 | url: https://cloud-native.slack.com/archives/C014L2KCTE3 7 | about: Or here. 8 | -------------------------------------------------------------------------------- /.github/config/markdownlint.yml: -------------------------------------------------------------------------------- 1 | # See https://github.com/DavidAnson/markdownlint/blob/main/doc/Rules.md 2 | # and https://github.com/DavidAnson/markdownlint/blob/main/README.md 3 | 4 | # Default state for all rules 5 | default: true 6 | 7 | ul-style: false 8 | line-length: false 9 | no-duplicate-header: 10 | siblings_only: true 11 | ol-prefix: 12 | style: ordered 13 | no-inline-html: false 14 | fenced-code-language: false 15 | -------------------------------------------------------------------------------- /.github/pull_request_template.md: -------------------------------------------------------------------------------- 1 | **Description:** 2 | 3 | < Describe what is being changed or added. 4 | Ex. Bug fix - Describe the bug and how this fixes it. 5 | Ex. Feature addition - Describe what this provides and why. > 6 | 7 | **Existing Issue(s):** 8 | 9 | < Link any applicable issues. > 10 | 11 | **Testing:** 12 | 13 | < Describe what testing was performed and any tests were added. > 14 | 15 | **Documentation:** 16 | 17 | < Describe the documentation added. 18 | Please be sure to modify relevant existing documentation if needed. > 19 | 20 | **Outstanding items:** 21 | 22 | < Anything that these changes are intentionally missing 23 | that will be needed or can be helpful in the future. > 24 | -------------------------------------------------------------------------------- /.github/repository-settings.md: -------------------------------------------------------------------------------- 1 | # Repository settings 2 | 3 | This document describes any changes that have been made to the 4 | settings in this repository outside the settings tracked in the 5 | private admin repo. 6 | 7 | ## Merge queue for `main` 8 | 9 | [The admin repo doesn't currently support tracking merge queue settings.] 10 | 11 | - Require merge queue: CHECKED 12 | - Build concurrency: 5 13 | - Maximum pull requests to build: 5 14 | - Minimum pull requests to merge: 1, or after 5 minutes 15 | - Maximum pull requests to merge: 5 16 | - Only merge non-failing pull requests: CHECKED 17 | - Status check timeout: 60 minutes 18 | -------------------------------------------------------------------------------- /.github/scripts/get-version.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash -e 2 | 3 | grep "val stableVersion = " version.gradle.kts | grep -Eo "[0-9]+.[0-9]+.[0-9]+" 4 | -------------------------------------------------------------------------------- /.github/scripts/update-version.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash -e 2 | 3 | version=$1 4 | 5 | if [[ $version == *-SNAPSHOT ]]; then 6 | alpha_version=${version//-SNAPSHOT/-alpha-SNAPSHOT} 7 | else 8 | alpha_version=${version}-alpha 9 | fi 10 | 11 | sed -Ei "s/val stableVersion = \"[^\"]*\"/val stableVersion = \"$version\"/" version.gradle.kts 12 | sed -Ei "s/val alphaVersion = \"[^\"]*\"/val alphaVersion = \"$alpha_version\"/" version.gradle.kts 13 | -------------------------------------------------------------------------------- /.github/scripts/use-cla-approved-bot.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash -e 2 | 3 | git config user.name otelbot 4 | git config user.email 197425009+otelbot@users.noreply.github.com 5 | -------------------------------------------------------------------------------- /.github/workflows/assign-reviewers.yml: -------------------------------------------------------------------------------- 1 | # assigns reviewers to pull requests in a similar way as CODEOWNERS, but doesn't require reviewers 2 | # to have write access to the repository 3 | # see .github/component_owners.yaml for the list of components and their owners 4 | name: Assign reviewers 5 | 6 | on: 7 | # pull_request_target is needed instead of just pull_request 8 | # because repository write permission is needed to assign reviewers 9 | pull_request_target: 10 | 11 | permissions: 12 | contents: read 13 | 14 | jobs: 15 | assign-reviewers: 16 | permissions: 17 | contents: read 18 | pull-requests: write # for assigning reviewers 19 | runs-on: ubuntu-latest 20 | steps: 21 | - uses: open-telemetry/assign-reviewers-action@cb42e3ee14a59c01abccd401f126a0f4c3991cb3 # main 22 | with: 23 | config-file: .github/component_owners.yml 24 | -------------------------------------------------------------------------------- /.github/workflows/fossa.yml: -------------------------------------------------------------------------------- 1 | name: FOSSA 2 | 3 | on: 4 | push: 5 | branches: 6 | - main 7 | 8 | permissions: 9 | contents: read 10 | 11 | jobs: 12 | fossa: 13 | runs-on: ubuntu-latest 14 | steps: 15 | - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 16 | 17 | - uses: fossas/fossa-action@3ebcea1862c6ffbd5cf1b4d0bd6b3fe7bd6f2cac # v1.7.0 18 | with: 19 | api-key: ${{secrets.FOSSA_API_KEY}} 20 | team: OpenTelemetry 21 | -------------------------------------------------------------------------------- /.github/workflows/gradle-wrapper-validation.yml: -------------------------------------------------------------------------------- 1 | name: Gradle wrapper validation 2 | 3 | on: 4 | push: 5 | branches: 6 | - main 7 | - release/* 8 | pull_request: 9 | merge_group: 10 | 11 | permissions: 12 | contents: read 13 | 14 | jobs: 15 | gradle-wrapper-validation: 16 | runs-on: ubuntu-latest 17 | steps: 18 | - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 19 | 20 | - uses: gradle/actions/wrapper-validation@8379f6a1328ee0e06e2bb424dadb7b159856a326 # v4.4.0 21 | -------------------------------------------------------------------------------- /.github/workflows/issue-management-feedback-label.yml: -------------------------------------------------------------------------------- 1 | name: Issue management - remove labels as needed 2 | 3 | on: 4 | issue_comment: 5 | types: [created] 6 | 7 | permissions: 8 | contents: read 9 | 10 | jobs: 11 | issue_comment: 12 | permissions: 13 | contents: read 14 | issues: write 15 | pull-requests: write 16 | if: > 17 | contains(github.event.issue.labels.*.name, 'needs author feedback') && 18 | github.event.comment.user.login == github.event.issue.user.login 19 | runs-on: ubuntu-latest 20 | steps: 21 | - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 22 | 23 | - name: Remove labels 24 | env: 25 | ISSUE_NUMBER: ${{ github.event.issue.number }} 26 | GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} 27 | run: | 28 | gh issue edit --remove-label "needs author feedback" $ISSUE_NUMBER 29 | gh issue edit --remove-label "stale" $ISSUE_NUMBER 30 | -------------------------------------------------------------------------------- /.github/workflows/reusable-markdown-link-check.yml: -------------------------------------------------------------------------------- 1 | name: Reusable - Markdown link check 2 | 3 | on: 4 | workflow_call: 5 | 6 | permissions: 7 | contents: read 8 | 9 | jobs: 10 | markdown-link-check: 11 | runs-on: ubuntu-latest 12 | steps: 13 | - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 14 | 15 | - uses: lycheeverse/lychee-action@82202e5e9c2f4ef1a55a3d02563e1cb6041e5332 # v2.4.1 16 | with: 17 | # excluding links to pull requests and issues is done for performance 18 | args: > 19 | --include-fragments 20 | --exclude "^https://github.com/open-telemetry/opentelemetry-java-contrib/(issues|pull)/\\d+$" 21 | --max-retries 6 22 | --max-concurrency 1 23 | . 24 | -------------------------------------------------------------------------------- /.github/workflows/reusable-markdown-lint.yml: -------------------------------------------------------------------------------- 1 | name: Reusable - Markdown lint check 2 | 3 | on: 4 | workflow_call: 5 | 6 | permissions: 7 | contents: read 8 | 9 | jobs: 10 | markdown-lint-check: 11 | runs-on: ubuntu-latest 12 | steps: 13 | - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 14 | 15 | - name: Run markdownlint 16 | run: | 17 | npx markdownlint-cli@0.45.0 -c .github/config/markdownlint.yml **/*.md 18 | -------------------------------------------------------------------------------- /.github/workflows/reusable-misspell-check.yml: -------------------------------------------------------------------------------- 1 | name: Reusable - Misspell check 2 | 3 | on: 4 | workflow_call: 5 | 6 | permissions: 7 | contents: read 8 | 9 | jobs: 10 | misspell-check: 11 | runs-on: ubuntu-latest 12 | steps: 13 | - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 14 | 15 | - name: Install misspell 16 | run: | 17 | curl -L -o install-misspell.sh \ 18 | https://raw.githubusercontent.com/client9/misspell/master/install-misspell.sh 19 | sh ./install-misspell.sh 20 | 21 | - name: Run misspell 22 | run: bin/misspell -error . 23 | -------------------------------------------------------------------------------- /.github/workflows/reusable-shell-script-check.yml: -------------------------------------------------------------------------------- 1 | name: Reusable - Shell script check 2 | 3 | on: 4 | workflow_call: 5 | 6 | permissions: 7 | contents: read 8 | 9 | jobs: 10 | shell-script-check: 11 | runs-on: ubuntu-latest 12 | steps: 13 | - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 14 | 15 | - name: Install shell check 16 | run: wget -qO- "https://github.com/koalaman/shellcheck/releases/download/stable/shellcheck-stable.linux.x86_64.tar.xz" | tar -xJv 17 | 18 | - name: Run shellcheck 19 | run: find -name '*.sh' | xargs shellcheck-stable/shellcheck --format=gcc 20 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Compiled class file 2 | *.class 3 | 4 | # No jars 5 | *.jar 6 | 7 | # Log file 8 | *.log 9 | 10 | # BlueJ files 11 | *.ctxt 12 | 13 | # Mobile Tools for Java (J2ME) 14 | .mtj.tmp/ 15 | 16 | # virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml 17 | hs_err_pid* 18 | 19 | # IntelliJ 20 | *.idea 21 | *.iml 22 | 23 | # Gradle 24 | build 25 | .gradle 26 | local.properties 27 | out/ 28 | 29 | # Maven (proto) 30 | target 31 | 32 | # Eclipse 33 | .classpath 34 | .project 35 | .settings 36 | bin 37 | 38 | # NetBeans 39 | /.nb-gradle 40 | /.nb-gradle-properties 41 | 42 | # VS Code 43 | .vscode 44 | 45 | # etc 46 | .DS_Store 47 | 48 | # Emacs 49 | *~ 50 | \#*\# 51 | 52 | # Vim 53 | .swp 54 | 55 | .gitpod.yml 56 | -------------------------------------------------------------------------------- /all/README.md: -------------------------------------------------------------------------------- 1 | # opentelemetry-contrib-all (utility project) 2 | 3 | This is a utility project which depends on all other projects in this repository. 4 | We use it for collecting all coverage reports from all modules for uploading to codecov. 5 | -------------------------------------------------------------------------------- /aws-resources/README.md: -------------------------------------------------------------------------------- 1 | # OpenTelemetry AWS Resource Support 2 | 3 | This module contains AWS resource detectors including Beanstalk, EC2, ECS, EKS, and Lambda. 4 | 5 | ## Component owners 6 | 7 | - [Lei Wang](https://github.com/wangzlei), AWS 8 | - [Prashant Srivastava](https://github.com/srprash), AWS 9 | 10 | Learn more about component owners in [component_owners.yml](../.github/component_owners.yml). 11 | -------------------------------------------------------------------------------- /aws-resources/build.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | id("otel.java-conventions") 3 | 4 | id("otel.publish-conventions") 5 | } 6 | 7 | description = "OpenTelemetry AWS Resources Support" 8 | otelJava.moduleName.set("io.opentelemetry.contrib.aws.resource") 9 | 10 | dependencies { 11 | api("io.opentelemetry:opentelemetry-api") 12 | api("io.opentelemetry:opentelemetry-sdk") 13 | 14 | implementation("io.opentelemetry.semconv:opentelemetry-semconv") 15 | testImplementation("io.opentelemetry.semconv:opentelemetry-semconv-incubating") 16 | 17 | compileOnly("io.opentelemetry:opentelemetry-sdk-extension-autoconfigure") 18 | 19 | implementation("com.fasterxml.jackson.core:jackson-core") 20 | implementation("com.squareup.okhttp3:okhttp") 21 | 22 | testImplementation("io.opentelemetry:opentelemetry-sdk-extension-autoconfigure") 23 | testImplementation("io.opentelemetry:opentelemetry-sdk-testing") 24 | 25 | testImplementation("com.linecorp.armeria:armeria-junit5") 26 | testRuntimeOnly("org.bouncycastle:bcpkix-jdk15on") 27 | testImplementation("com.google.guava:guava") 28 | testImplementation("org.skyscreamer:jsonassert") 29 | } 30 | -------------------------------------------------------------------------------- /aws-resources/gradle.properties: -------------------------------------------------------------------------------- 1 | # TODO: uncomment when ready to mark as stable 2 | # otel.stable=true 3 | -------------------------------------------------------------------------------- /aws-resources/src/main/java/io/opentelemetry/contrib/aws/resource/BeanstalkResourceProvider.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright The OpenTelemetry Authors 3 | * SPDX-License-Identifier: Apache-2.0 4 | */ 5 | 6 | package io.opentelemetry.contrib.aws.resource; 7 | 8 | import io.opentelemetry.sdk.autoconfigure.spi.ConfigProperties; 9 | import io.opentelemetry.sdk.autoconfigure.spi.ResourceProvider; 10 | import io.opentelemetry.sdk.resources.Resource; 11 | 12 | /** {@link ResourceProvider} for automatically configuring {@link BeanstalkResource}. */ 13 | public final class BeanstalkResourceProvider extends CloudResourceProvider { 14 | @Override 15 | public Resource createResource(ConfigProperties config) { 16 | return BeanstalkResource.get(); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /aws-resources/src/main/java/io/opentelemetry/contrib/aws/resource/CloudResourceProvider.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright The OpenTelemetry Authors 3 | * SPDX-License-Identifier: Apache-2.0 4 | */ 5 | 6 | package io.opentelemetry.contrib.aws.resource; 7 | 8 | import static io.opentelemetry.contrib.aws.resource.IncubatingAttributes.CLOUD_PROVIDER; 9 | 10 | import io.opentelemetry.sdk.autoconfigure.spi.ConfigProperties; 11 | import io.opentelemetry.sdk.autoconfigure.spi.internal.ConditionalResourceProvider; 12 | import io.opentelemetry.sdk.resources.Resource; 13 | 14 | abstract class CloudResourceProvider implements ConditionalResourceProvider { 15 | @Override 16 | public final boolean shouldApply(ConfigProperties config, Resource existing) { 17 | return existing.getAttribute(CLOUD_PROVIDER) == null; 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /aws-resources/src/main/java/io/opentelemetry/contrib/aws/resource/Ec2ResourceProvider.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright The OpenTelemetry Authors 3 | * SPDX-License-Identifier: Apache-2.0 4 | */ 5 | 6 | package io.opentelemetry.contrib.aws.resource; 7 | 8 | import io.opentelemetry.sdk.autoconfigure.spi.ConfigProperties; 9 | import io.opentelemetry.sdk.autoconfigure.spi.ResourceProvider; 10 | import io.opentelemetry.sdk.resources.Resource; 11 | 12 | /** {@link ResourceProvider} for automatically configuring {@link Ec2Resource}. */ 13 | public final class Ec2ResourceProvider extends CloudResourceProvider { 14 | @Override 15 | public Resource createResource(ConfigProperties config) { 16 | return Ec2Resource.get(); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /aws-resources/src/main/java/io/opentelemetry/contrib/aws/resource/EcsResourceProvider.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright The OpenTelemetry Authors 3 | * SPDX-License-Identifier: Apache-2.0 4 | */ 5 | 6 | package io.opentelemetry.contrib.aws.resource; 7 | 8 | import io.opentelemetry.sdk.autoconfigure.spi.ConfigProperties; 9 | import io.opentelemetry.sdk.autoconfigure.spi.ResourceProvider; 10 | import io.opentelemetry.sdk.resources.Resource; 11 | 12 | /** {@link ResourceProvider} for automatically configuring {@link EcsResource}. */ 13 | public final class EcsResourceProvider extends CloudResourceProvider { 14 | @Override 15 | public Resource createResource(ConfigProperties config) { 16 | return EcsResource.get(); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /aws-resources/src/main/java/io/opentelemetry/contrib/aws/resource/EksResourceProvider.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright The OpenTelemetry Authors 3 | * SPDX-License-Identifier: Apache-2.0 4 | */ 5 | 6 | package io.opentelemetry.contrib.aws.resource; 7 | 8 | import io.opentelemetry.sdk.autoconfigure.spi.ConfigProperties; 9 | import io.opentelemetry.sdk.autoconfigure.spi.ResourceProvider; 10 | import io.opentelemetry.sdk.resources.Resource; 11 | 12 | /** {@link ResourceProvider} for automatically configuring {@link EksResource}. */ 13 | public final class EksResourceProvider extends CloudResourceProvider { 14 | @Override 15 | public Resource createResource(ConfigProperties config) { 16 | return EksResource.get(); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /aws-resources/src/main/java/io/opentelemetry/contrib/aws/resource/LambdaResourceProvider.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright The OpenTelemetry Authors 3 | * SPDX-License-Identifier: Apache-2.0 4 | */ 5 | 6 | package io.opentelemetry.contrib.aws.resource; 7 | 8 | import io.opentelemetry.sdk.autoconfigure.spi.ConfigProperties; 9 | import io.opentelemetry.sdk.autoconfigure.spi.ResourceProvider; 10 | import io.opentelemetry.sdk.resources.Resource; 11 | 12 | /** {@link ResourceProvider} for automatically configuring {@link LambdaResource}. */ 13 | public final class LambdaResourceProvider extends CloudResourceProvider { 14 | @Override 15 | public Resource createResource(ConfigProperties config) { 16 | return LambdaResource.get(); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /aws-resources/src/main/java/io/opentelemetry/contrib/aws/resource/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright The OpenTelemetry Authors 3 | * SPDX-License-Identifier: Apache-2.0 4 | */ 5 | 6 | /** 7 | * {@link io.opentelemetry.sdk.autoconfigure.spi.ResourceProvider} implementations for inferring 8 | * resource information for AWS services. 9 | */ 10 | @ParametersAreNonnullByDefault 11 | package io.opentelemetry.contrib.aws.resource; 12 | 13 | import javax.annotation.ParametersAreNonnullByDefault; 14 | -------------------------------------------------------------------------------- /aws-resources/src/main/resources/META-INF/services/io.opentelemetry.sdk.autoconfigure.spi.ResourceProvider: -------------------------------------------------------------------------------- 1 | io.opentelemetry.contrib.aws.resource.BeanstalkResourceProvider 2 | io.opentelemetry.contrib.aws.resource.Ec2ResourceProvider 3 | io.opentelemetry.contrib.aws.resource.EcsResourceProvider 4 | io.opentelemetry.contrib.aws.resource.EksResourceProvider 5 | io.opentelemetry.contrib.aws.resource.LambdaResourceProvider 6 | -------------------------------------------------------------------------------- /aws-resources/src/test/resources/ecs-container-metadata-v3.json: -------------------------------------------------------------------------------- 1 | { 2 | "DockerId": "43481a6ce4842eec8fe72fc28500c6b52edcc0917f105b83379f88cac1ff3946", 3 | "Name": "nginx-curl", 4 | "DockerName": "ecs-nginx-5-nginx-curl-ccccb9f49db0dfe0d901", 5 | "Image": "nrdlngr/nginx-curl", 6 | "ImageID": "sha256:2e00ae64383cfc865ba0a2ba37f61b50a120d2d9378559dcd458dc0de47bc165", 7 | "Labels": { 8 | "com.amazonaws.ecs.cluster": "default", 9 | "com.amazonaws.ecs.container-name": "nginx-curl", 10 | "com.amazonaws.ecs.task-arn": "arn:aws:ecs:us-east-2:012345678910:task/9781c248-0edd-4cdb-9a93-f63cb662a5d3", 11 | "com.amazonaws.ecs.task-definition-family": "nginx", 12 | "com.amazonaws.ecs.task-definition-version": "5" 13 | }, 14 | "DesiredStatus": "RUNNING", 15 | "KnownStatus": "RUNNING", 16 | "Limits": { 17 | "CPU": 512, 18 | "Memory": 512 19 | }, 20 | "CreatedAt": "2018-02-01T20:55:10.554941919Z", 21 | "StartedAt": "2018-02-01T20:55:11.064236631Z", 22 | "Type": "NORMAL", 23 | "Networks": [ 24 | { 25 | "NetworkMode": "awsvpc", 26 | "IPv4Addresses": [ 27 | "10.0.2.106" 28 | ] 29 | } 30 | ] 31 | } -------------------------------------------------------------------------------- /aws-resources/src/test/resources/mockito-extensions/org.mockito.plugins.MockMaker: -------------------------------------------------------------------------------- 1 | mock-maker-inline 2 | -------------------------------------------------------------------------------- /aws-xray-propagator/README.md: -------------------------------------------------------------------------------- 1 | # OpenTelemetry AWS X-Ray Propagator 2 | 3 | This module contains a `TextMapPropagator` implementation compatible with 4 | the [AWS X-Ray Trace Header propagation protocol](https://docs.aws.amazon.com/xray/latest/devguide/xray-concepts.html#xray-concepts-tracingheader). 5 | 6 | ## Component owners 7 | 8 | - [Lei Wang](https://github.com/wangzlei), AWS 9 | - [Prashant Srivastava](https://github.com/srprash), AWS 10 | 11 | Learn more about component owners in [component_owners.yml](../.github/component_owners.yml). 12 | -------------------------------------------------------------------------------- /aws-xray-propagator/build.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | id("otel.java-conventions") 3 | 4 | id("otel.publish-conventions") 5 | } 6 | 7 | description = "OpenTelemetry AWS X-Ray Propagator" 8 | otelJava.moduleName.set("io.opentelemetry.contrib.awsxray.propagator") 9 | 10 | dependencies { 11 | api("io.opentelemetry:opentelemetry-api") 12 | compileOnly("io.opentelemetry:opentelemetry-sdk-extension-autoconfigure-spi") 13 | compileOnly("io.opentelemetry:opentelemetry-api-incubator") 14 | testImplementation("io.opentelemetry:opentelemetry-sdk-extension-autoconfigure") 15 | testImplementation("io.opentelemetry:opentelemetry-sdk-trace") 16 | testImplementation("io.opentelemetry:opentelemetry-sdk-testing") 17 | 18 | testImplementation("io.opentelemetry:opentelemetry-sdk-extension-incubator") 19 | testImplementation("uk.org.webcompere:system-stubs-jupiter:2.0.3") 20 | } 21 | -------------------------------------------------------------------------------- /aws-xray-propagator/gradle.properties: -------------------------------------------------------------------------------- 1 | # TODO: uncomment when ready to mark as stable 2 | # otel.stable=true 3 | -------------------------------------------------------------------------------- /aws-xray-propagator/src/main/java/io/opentelemetry/contrib/awsxray/propagator/internal/AwsConfigurablePropagator.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright The OpenTelemetry Authors 3 | * SPDX-License-Identifier: Apache-2.0 4 | */ 5 | 6 | package io.opentelemetry.contrib.awsxray.propagator.internal; 7 | 8 | import io.opentelemetry.context.propagation.TextMapPropagator; 9 | import io.opentelemetry.contrib.awsxray.propagator.AwsXrayPropagator; 10 | import io.opentelemetry.sdk.autoconfigure.spi.ConfigProperties; 11 | import io.opentelemetry.sdk.autoconfigure.spi.ConfigurablePropagatorProvider; 12 | 13 | /** 14 | * A {@link ConfigurablePropagatorProvider} which allows enabling the {@link AwsXrayPropagator} with 15 | * the propagator name {@code xray}. 16 | */ 17 | public final class AwsConfigurablePropagator implements ConfigurablePropagatorProvider { 18 | @Override 19 | public TextMapPropagator getPropagator(ConfigProperties config) { 20 | return AwsXrayPropagator.getInstance(); 21 | } 22 | 23 | @Override 24 | public String getName() { 25 | return "xray"; 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /aws-xray-propagator/src/main/java/io/opentelemetry/contrib/awsxray/propagator/internal/AwsXrayComponentProvider.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright The OpenTelemetry Authors 3 | * SPDX-License-Identifier: Apache-2.0 4 | */ 5 | 6 | package io.opentelemetry.contrib.awsxray.propagator.internal; 7 | 8 | import io.opentelemetry.api.incubator.config.DeclarativeConfigProperties; 9 | import io.opentelemetry.context.propagation.TextMapPropagator; 10 | import io.opentelemetry.contrib.awsxray.propagator.AwsXrayPropagator; 11 | import io.opentelemetry.sdk.autoconfigure.spi.internal.ComponentProvider; 12 | 13 | public class AwsXrayComponentProvider implements ComponentProvider { 14 | @Override 15 | public Class getType() { 16 | return TextMapPropagator.class; 17 | } 18 | 19 | @Override 20 | public String getName() { 21 | return "xray"; 22 | } 23 | 24 | @Override 25 | public TextMapPropagator create(DeclarativeConfigProperties config) { 26 | return AwsXrayPropagator.getInstance(); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /aws-xray-propagator/src/main/java/io/opentelemetry/contrib/awsxray/propagator/internal/AwsXrayLambdaComponentProvider.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright The OpenTelemetry Authors 3 | * SPDX-License-Identifier: Apache-2.0 4 | */ 5 | 6 | package io.opentelemetry.contrib.awsxray.propagator.internal; 7 | 8 | import io.opentelemetry.api.incubator.config.DeclarativeConfigProperties; 9 | import io.opentelemetry.context.propagation.TextMapPropagator; 10 | import io.opentelemetry.contrib.awsxray.propagator.AwsXrayLambdaPropagator; 11 | import io.opentelemetry.sdk.autoconfigure.spi.internal.ComponentProvider; 12 | 13 | public class AwsXrayLambdaComponentProvider implements ComponentProvider { 14 | @Override 15 | public Class getType() { 16 | return TextMapPropagator.class; 17 | } 18 | 19 | @Override 20 | public String getName() { 21 | return "xray-lambda"; 22 | } 23 | 24 | @Override 25 | public TextMapPropagator create(DeclarativeConfigProperties config) { 26 | return AwsXrayLambdaPropagator.getInstance(); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /aws-xray-propagator/src/main/java/io/opentelemetry/contrib/awsxray/propagator/internal/AwsXrayLambdaConfigurablePropagator.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright The OpenTelemetry Authors 3 | * SPDX-License-Identifier: Apache-2.0 4 | */ 5 | 6 | package io.opentelemetry.contrib.awsxray.propagator.internal; 7 | 8 | import io.opentelemetry.context.propagation.TextMapPropagator; 9 | import io.opentelemetry.contrib.awsxray.propagator.AwsXrayLambdaPropagator; 10 | import io.opentelemetry.sdk.autoconfigure.spi.ConfigProperties; 11 | import io.opentelemetry.sdk.autoconfigure.spi.ConfigurablePropagatorProvider; 12 | 13 | /** 14 | * A {@link ConfigurablePropagatorProvider} which allows enabling the {@link 15 | * AwsXrayLambdaPropagator} with the propagator name {@code xray-lambda}. 16 | */ 17 | public final class AwsXrayLambdaConfigurablePropagator implements ConfigurablePropagatorProvider { 18 | @Override 19 | public TextMapPropagator getPropagator(ConfigProperties config) { 20 | return AwsXrayLambdaPropagator.getInstance(); 21 | } 22 | 23 | @Override 24 | public String getName() { 25 | return "xray-lambda"; 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /aws-xray-propagator/src/main/java/io/opentelemetry/contrib/awsxray/propagator/package-info.java: -------------------------------------------------------------------------------- 1 | /** OpenTelemetry AWS X-Ray propagator extension. */ 2 | @ParametersAreNonnullByDefault 3 | package io.opentelemetry.contrib.awsxray.propagator; 4 | 5 | import javax.annotation.ParametersAreNonnullByDefault; 6 | -------------------------------------------------------------------------------- /aws-xray-propagator/src/main/resources/META-INF/services/io.opentelemetry.sdk.autoconfigure.spi.ConfigurablePropagatorProvider: -------------------------------------------------------------------------------- 1 | io.opentelemetry.contrib.awsxray.propagator.internal.AwsConfigurablePropagator 2 | io.opentelemetry.contrib.awsxray.propagator.internal.AwsXrayLambdaConfigurablePropagator 3 | -------------------------------------------------------------------------------- /aws-xray-propagator/src/main/resources/META-INF/services/io.opentelemetry.sdk.autoconfigure.spi.internal.ComponentProvider: -------------------------------------------------------------------------------- 1 | io.opentelemetry.contrib.awsxray.propagator.internal.AwsXrayComponentProvider 2 | io.opentelemetry.contrib.awsxray.propagator.internal.AwsXrayLambdaComponentProvider 3 | -------------------------------------------------------------------------------- /aws-xray/README.md: -------------------------------------------------------------------------------- 1 | # AWS X-Ray Support 2 | 3 | This module contains a custom `IdGenerator` and `Sampler` for use with AWS X-Ray. 4 | 5 | ## Component owners 6 | 7 | - [Lei Wang](https://github.com/wangzlei), AWS 8 | - [Prashant Srivastava](https://github.com/srprash), AWS 9 | 10 | Learn more about component owners in [component_owners.yml](../.github/component_owners.yml). 11 | -------------------------------------------------------------------------------- /aws-xray/gradle.properties: -------------------------------------------------------------------------------- 1 | otel.stable=true 2 | -------------------------------------------------------------------------------- /aws-xray/src/awsTest/resources/otel-collector.yml: -------------------------------------------------------------------------------- 1 | receivers: 2 | awsxray: 3 | 4 | extensions: 5 | health_check: 6 | 7 | exporters: 8 | debug: 9 | 10 | service: 11 | extensions: [health_check] 12 | pipelines: 13 | traces: 14 | receivers: [awsxray] 15 | exporters: [debug] 16 | -------------------------------------------------------------------------------- /aws-xray/src/main/java/io/opentelemetry/contrib/awsxray/GetSamplingRulesRequest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright The OpenTelemetry Authors 3 | * SPDX-License-Identifier: Apache-2.0 4 | */ 5 | 6 | package io.opentelemetry.contrib.awsxray; 7 | 8 | import com.fasterxml.jackson.annotation.JsonProperty; 9 | import com.fasterxml.jackson.databind.annotation.JsonSerialize; 10 | import com.google.auto.value.AutoValue; 11 | import javax.annotation.Nullable; 12 | 13 | @AutoValue 14 | @JsonSerialize(as = GetSamplingRulesRequest.class) 15 | abstract class GetSamplingRulesRequest { 16 | 17 | static GetSamplingRulesRequest create(@Nullable String nextToken) { 18 | return new AutoValue_GetSamplingRulesRequest(nextToken); 19 | } 20 | 21 | @JsonProperty("NextToken") 22 | @Nullable 23 | abstract String getNextToken(); 24 | } 25 | -------------------------------------------------------------------------------- /aws-xray/src/main/java/io/opentelemetry/contrib/awsxray/MetricAttributeGenerator.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright The OpenTelemetry Authors 3 | * SPDX-License-Identifier: Apache-2.0 4 | */ 5 | 6 | package io.opentelemetry.contrib.awsxray; 7 | 8 | import io.opentelemetry.api.common.Attributes; 9 | import io.opentelemetry.sdk.resources.Resource; 10 | import io.opentelemetry.sdk.trace.data.SpanData; 11 | 12 | /** 13 | * Metric attribute generator defines an interface for classes that can generate specific attributes 14 | * to be used by an {@link AwsSpanMetricsProcessor} to produce metrics and by {@link 15 | * AwsMetricAttributesSpanExporter} to wrap the original span. 16 | */ 17 | public interface MetricAttributeGenerator { 18 | 19 | /** 20 | * Given a span and associated resource, produce meaningful metric attributes for metrics produced 21 | * from the span. If no metrics should be generated from this span, return {@link 22 | * Attributes#empty()}. 23 | * 24 | * @param span - SpanData to be used to generate metric attributes. 25 | * @param resource - Resource associated with Span to be used to generate metric attributes. 26 | * @return A set of zero or more attributes. Must not return null. 27 | */ 28 | Attributes generateMetricAttributesFromSpan(SpanData span, Resource resource); 29 | } 30 | -------------------------------------------------------------------------------- /aws-xray/src/main/java/io/opentelemetry/contrib/awsxray/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright The OpenTelemetry Authors 3 | * SPDX-License-Identifier: Apache-2.0 4 | */ 5 | 6 | /** Provides implementations of SDK interfaces for AWS X-Ray users. */ 7 | @ParametersAreNonnullByDefault 8 | package io.opentelemetry.contrib.awsxray; 9 | 10 | import javax.annotation.ParametersAreNonnullByDefault; 11 | -------------------------------------------------------------------------------- /aws-xray/src/test/resources/get-sampling-rules-response.json: -------------------------------------------------------------------------------- 1 | { 2 | "SamplingRuleRecords": [ 3 | { 4 | "SamplingRule": { 5 | "RuleName": "Test", 6 | "RuleARN": "arn:aws:xray:us-east-1:595986152929:sampling-rule/Test", 7 | "ResourceARN": "*", 8 | "Priority": 1, 9 | "FixedRate": 0.9, 10 | "ReservoirSize": 1000, 11 | "ServiceName": "test-service-foo-bar", 12 | "ServiceType": "*", 13 | "Host": "*", 14 | "HTTPMethod": "*", 15 | "URLPath": "*", 16 | "Version": 1, 17 | "Attributes": { 18 | "animal": "cat", 19 | "speed": "10" 20 | } 21 | }, 22 | "CreatedAt": "2021-06-18T17:28:15+09:00", 23 | "ModifiedAt": "2021-06-18T17:28:15+09:00" 24 | }, 25 | { 26 | "SamplingRule": { 27 | "RuleName": "Default", 28 | "RuleARN": "arn:aws:xray:us-east-1:595986152929:sampling-rule/Default", 29 | "ResourceARN": "*", 30 | "Priority": 10000, 31 | "FixedRate": 0.05, 32 | "ReservoirSize": 1, 33 | "ServiceName": "*", 34 | "ServiceType": "*", 35 | "Host": "*", 36 | "HTTPMethod": "*", 37 | "URLPath": "*", 38 | "Version": 1, 39 | "Attributes": {} 40 | }, 41 | "CreatedAt": "1970-01-01T09:00:00+09:00", 42 | "ModifiedAt": "1970-01-01T09:00:00+09:00" 43 | } 44 | ] 45 | } -------------------------------------------------------------------------------- /aws-xray/src/test/resources/get-sampling-targets-request.json: -------------------------------------------------------------------------------- 1 | { 2 | "SamplingStatisticsDocuments":[ 3 | { 4 | "RuleName":"Test", 5 | "ClientID":"ABCDEF1234567890ABCDEF10", 6 | "Timestamp":1624257967000, 7 | "RequestCount":110, 8 | "SampledCount":30, 9 | "BorrowCount":20 10 | }, 11 | { 12 | "RuleName":"polling-scorekeep", 13 | "ClientID":"ABCDEF1234567890ABCDEF11", 14 | "Timestamp":1530922806000, 15 | "RequestCount":10500, 16 | "SampledCount":31, 17 | "BorrowCount":0 18 | } 19 | ] 20 | } 21 | -------------------------------------------------------------------------------- /aws-xray/src/test/resources/get-sampling-targets-response.json: -------------------------------------------------------------------------------- 1 | { 2 | "SamplingTargetDocuments": [ 3 | { 4 | "RuleName": "base-scorekeep", 5 | "FixedRate": 0.1, 6 | "ReservoirQuota": 2, 7 | "ReservoirQuotaTTL": 1530923107.0, 8 | "Interval": 10 9 | }, 10 | { 11 | "RuleName": "polling-scorekeep", 12 | "FixedRate": 0.003 13 | } 14 | ], 15 | "LastRuleModification": 1530920505.0, 16 | "UnprocessedStatistics": [ 17 | { 18 | "RuleName": "cats-rule", 19 | "ErrorCode": "400", 20 | "Message": "Unknown rule" 21 | } 22 | ] 23 | } -------------------------------------------------------------------------------- /aws-xray/src/test/resources/mockito-extensions/org.mockito.plugins.MockMaker: -------------------------------------------------------------------------------- 1 | mock-maker-inline 2 | -------------------------------------------------------------------------------- /aws-xray/src/test/resources/sampling-rule-awslambda.json: -------------------------------------------------------------------------------- 1 | { 2 | "RuleName": "Test", 3 | "RuleARN": "arn:aws:xray:us-east-1:595986152929:sampling-rule/Test", 4 | "ResourceARN": "arn:aws:xray:us-east-1:595986152929:my-service", 5 | "Priority": 1, 6 | "FixedRate": 1.0, 7 | "ReservoirSize": 1000, 8 | "ServiceName": "*", 9 | "ServiceType": "AWS::Lambda::Function", 10 | "Host": "opentelemetry.io", 11 | "HTTPMethod": "GET", 12 | "URLPath": "/instrument-me", 13 | "Version": 1, 14 | "Attributes": { 15 | "animal": "cat", 16 | "speed": "10" 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /aws-xray/src/test/resources/sampling-rule-exactmatch.json: -------------------------------------------------------------------------------- 1 | { 2 | "RuleName": "Test", 3 | "RuleARN": "arn:aws:xray:us-east-1:595986152929:sampling-rule/Test", 4 | "ResourceARN": "arn:aws:xray:us-east-1:595986152929:my-service", 5 | "Priority": 1, 6 | "FixedRate": 1.0, 7 | "ReservoirSize": 0, 8 | "ServiceName": "test-service-foo-bar", 9 | "ServiceType": "AWS::EKS::Container", 10 | "Host": "opentelemetry.io", 11 | "HTTPMethod": "GET", 12 | "URLPath": "/instrument-me", 13 | "Version": 1, 14 | "Attributes": { 15 | "animal": "cat", 16 | "speed": "10" 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /aws-xray/src/test/resources/sampling-rule-reservoir.json: -------------------------------------------------------------------------------- 1 | { 2 | "RuleName": "Test", 3 | "RuleARN": "arn:aws:xray:us-east-1:595986152929:sampling-rule/Test", 4 | "ResourceARN": "arn:aws:xray:us-east-1:595986152929:my-service", 5 | "Priority": 1, 6 | "FixedRate": 0.0, 7 | "ReservoirSize": 1000, 8 | "ServiceName": "test-service-foo-bar", 9 | "ServiceType": "AWS::EKS::Container", 10 | "Host": "opentelemetry.io", 11 | "HTTPMethod": "GET", 12 | "URLPath": "/instrument-me", 13 | "Version": 1, 14 | "Attributes": { 15 | "animal": "cat", 16 | "speed": "10" 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /aws-xray/src/test/resources/sampling-rule-wildcards.json: -------------------------------------------------------------------------------- 1 | { 2 | "RuleName": "Test", 3 | "RuleARN": "arn:aws:xray:us-east-1:595986152929:sampling-rule/Test", 4 | "ResourceARN": "arn:aws:*:us-east-?:*:my-service", 5 | "Priority": 1, 6 | "FixedRate": 0.0, 7 | "ReservoirSize": 0, 8 | "ServiceName": "test-service-foo-*", 9 | "ServiceType": "*", 10 | "Host": "*op*t?lem*r?.io*", 11 | "HTTPMethod": "**GET**", 12 | "URLPath": "/instrument-me?foo=bar&cat=*", 13 | "Version": 1, 14 | "Attributes": { 15 | "animal": "cat*", 16 | "speed": "?0" 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /aws-xray/src/test/resources/test-sampling-rules-response-1.json: -------------------------------------------------------------------------------- 1 | { 2 | "SamplingRuleRecords": [ 3 | { 4 | "SamplingRule": { 5 | "RuleName": "Test", 6 | "RuleARN": "arn:aws:xray:us-east-1:595986152929:sampling-rule/Test", 7 | "ResourceARN": "*", 8 | "Priority": 1, 9 | "FixedRate": 1.0, 10 | "ReservoirSize": 1, 11 | "ServiceName": "*", 12 | "ServiceType": "*", 13 | "Host": "*", 14 | "HTTPMethod": "*", 15 | "URLPath": "*", 16 | "Version": 1, 17 | "Attributes": { "test": "cat-service" } 18 | }, 19 | "CreatedAt": "2021-06-18T17:28:15+09:00", 20 | "ModifiedAt": "2021-06-18T17:28:15+09:00" 21 | }, 22 | { 23 | "SamplingRule": { 24 | "RuleName": "Default", 25 | "RuleARN": "arn:aws:xray:us-east-1:595986152929:sampling-rule/Default", 26 | "ResourceARN": "*", 27 | "Priority": 10000, 28 | "FixedRate": 0.0, 29 | "ReservoirSize": 1, 30 | "ServiceName": "*", 31 | "ServiceType": "*", 32 | "Host": "*", 33 | "HTTPMethod": "*", 34 | "URLPath": "*", 35 | "Version": 1, 36 | "Attributes": {} 37 | }, 38 | "CreatedAt": "1970-01-01T09:00:00+09:00", 39 | "ModifiedAt": "1970-01-01T09:00:00+09:00" 40 | } 41 | ] 42 | } -------------------------------------------------------------------------------- /aws-xray/src/test/resources/test-sampling-rules-response-2.json: -------------------------------------------------------------------------------- 1 | { 2 | "SamplingRuleRecords": [ 3 | { 4 | "SamplingRule": { 5 | "RuleName": "Test", 6 | "RuleARN": "arn:aws:xray:us-east-1:595986152929:sampling-rule/Test", 7 | "ResourceARN": "*", 8 | "Priority": 1, 9 | "FixedRate": 0.0, 10 | "ReservoirSize": 1, 11 | "ServiceName": "*", 12 | "ServiceType": "*", 13 | "Host": "*", 14 | "HTTPMethod": "*", 15 | "URLPath": "*", 16 | "Version": 1, 17 | "Attributes": { "test": "cat-service" } 18 | }, 19 | "CreatedAt": "2021-06-18T17:28:15+09:00", 20 | "ModifiedAt": "2021-06-18T17:28:15+09:00" 21 | }, 22 | { 23 | "SamplingRule": { 24 | "RuleName": "Default", 25 | "RuleARN": "arn:aws:xray:us-east-1:595986152929:sampling-rule/Default", 26 | "ResourceARN": "*", 27 | "Priority": 10000, 28 | "FixedRate": 1.0, 29 | "ReservoirSize": 1, 30 | "ServiceName": "*", 31 | "ServiceType": "*", 32 | "Host": "*", 33 | "HTTPMethod": "*", 34 | "URLPath": "*", 35 | "Version": 1, 36 | "Attributes": {} 37 | }, 38 | "CreatedAt": "1970-01-01T09:00:00+09:00", 39 | "ModifiedAt": "1970-01-01T09:00:00+09:00" 40 | } 41 | ] 42 | } -------------------------------------------------------------------------------- /aws-xray/src/test/resources/test-sampling-targets-response.json: -------------------------------------------------------------------------------- 1 | { 2 | "SamplingTargetDocuments": [ 3 | { 4 | "RuleName": "Test", 5 | "FixedRate": 1.0 6 | } 7 | ], 8 | "LastRuleModification": 1530920505.0, 9 | "UnprocessedStatistics": [ 10 | { 11 | "RuleName": "cats-rule", 12 | "ErrorCode": "400", 13 | "Message": "Unknown rule" 14 | } 15 | ] 16 | } 17 | -------------------------------------------------------------------------------- /azure-resources/build.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | id("otel.java-conventions") 3 | 4 | id("otel.publish-conventions") 5 | id("maven-publish") 6 | } 7 | 8 | description = "OpenTelemetry GCP Resources Support" 9 | otelJava.moduleName.set("io.opentelemetry.contrib.gcp.resource") 10 | 11 | // enable publishing to maven local 12 | java { 13 | withSourcesJar() 14 | } 15 | 16 | dependencies { 17 | api("io.opentelemetry:opentelemetry-api") 18 | api("io.opentelemetry:opentelemetry-sdk") 19 | 20 | implementation("io.opentelemetry.semconv:opentelemetry-semconv") 21 | 22 | compileOnly("io.opentelemetry:opentelemetry-sdk-extension-autoconfigure") 23 | 24 | implementation("com.fasterxml.jackson.core:jackson-core") 25 | implementation("com.squareup.okhttp3:okhttp") 26 | 27 | testImplementation("io.opentelemetry.semconv:opentelemetry-semconv-incubating") 28 | testImplementation("io.opentelemetry:opentelemetry-sdk-extension-autoconfigure") 29 | testImplementation("io.opentelemetry:opentelemetry-sdk-testing") 30 | 31 | // testImplementation("org.mockito:mockito-core") 32 | testImplementation("com.google.guava:guava") 33 | 34 | testImplementation("org.junit.jupiter:junit-jupiter-api") 35 | testImplementation("org.assertj:assertj-core") 36 | testImplementation("com.linecorp.armeria:armeria-junit5") 37 | } 38 | -------------------------------------------------------------------------------- /azure-resources/src/main/java/io/opentelemetry/contrib/azure/resource/AzureEnvVarPlatform.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright The OpenTelemetry Authors 3 | * SPDX-License-Identifier: Apache-2.0 4 | */ 5 | 6 | package io.opentelemetry.contrib.azure.resource; 7 | 8 | import io.opentelemetry.api.common.AttributeKey; 9 | import io.opentelemetry.api.common.AttributesBuilder; 10 | import java.util.Map; 11 | 12 | public enum AzureEnvVarPlatform { 13 | APP_SERVICE, 14 | FUNCTIONS, 15 | CONTAINER_APP, 16 | NONE; 17 | 18 | public static AzureEnvVarPlatform detect(Map env) { 19 | String appName = env.get(AzureContainersResourceProvider.CONTAINER_APP_NAME); 20 | if (appName != null) { 21 | return CONTAINER_APP; 22 | } 23 | String name = env.get(AzureAppServiceResourceProvider.WEBSITE_SITE_NAME); 24 | if (name == null) { 25 | return NONE; 26 | } 27 | if (env.get(AzureFunctionsResourceProvider.FUNCTIONS_VERSION) != null) { 28 | return FUNCTIONS; 29 | } 30 | return APP_SERVICE; 31 | } 32 | 33 | static void addAttributesFromEnv( 34 | Map, String> mapping, 35 | Map env, 36 | AttributesBuilder builder) { 37 | mapping.forEach( 38 | (key, value) -> { 39 | String envValue = env.get(value); 40 | if (envValue != null) { 41 | builder.put(key, envValue); 42 | } 43 | }); 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /azure-resources/src/main/java/io/opentelemetry/contrib/azure/resource/CloudResourceProvider.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright The OpenTelemetry Authors 3 | * SPDX-License-Identifier: Apache-2.0 4 | */ 5 | 6 | package io.opentelemetry.contrib.azure.resource; 7 | 8 | import static io.opentelemetry.contrib.azure.resource.IncubatingAttributes.CLOUD_PROVIDER; 9 | 10 | import io.opentelemetry.sdk.autoconfigure.spi.ConfigProperties; 11 | import io.opentelemetry.sdk.autoconfigure.spi.internal.ConditionalResourceProvider; 12 | import io.opentelemetry.sdk.resources.Resource; 13 | 14 | public abstract class CloudResourceProvider implements ConditionalResourceProvider { 15 | 16 | @Override 17 | public final boolean shouldApply(ConfigProperties config, Resource existing) { 18 | return existing.getAttribute(CLOUD_PROVIDER) == null; 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /azure-resources/src/main/resources/META-INF/services/io.opentelemetry.sdk.autoconfigure.spi.ResourceProvider: -------------------------------------------------------------------------------- 1 | io.opentelemetry.contrib.azure.resource.AzureAppServiceResourceProvider 2 | io.opentelemetry.contrib.azure.resource.AzureFunctionsResourceProvider 3 | io.opentelemetry.contrib.azure.resource.AzureVmResourceProvider 4 | -------------------------------------------------------------------------------- /baggage-processor/build.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | id("otel.java-conventions") 3 | 4 | id("otel.publish-conventions") 5 | } 6 | 7 | description = "OpenTelemetry Baggage Span Processor" 8 | otelJava.moduleName.set("io.opentelemetry.contrib.baggage.processor") 9 | 10 | dependencies { 11 | api("io.opentelemetry:opentelemetry-api") 12 | api("io.opentelemetry:opentelemetry-sdk") 13 | implementation("io.opentelemetry:opentelemetry-sdk-extension-autoconfigure-spi") 14 | 15 | testImplementation("io.opentelemetry:opentelemetry-sdk-extension-autoconfigure") 16 | testImplementation("io.opentelemetry:opentelemetry-sdk-testing") 17 | testImplementation("org.mockito:mockito-inline") 18 | testImplementation("com.google.guava:guava") 19 | testImplementation("org.awaitility:awaitility") 20 | } 21 | -------------------------------------------------------------------------------- /baggage-processor/gradle.properties: -------------------------------------------------------------------------------- 1 | # TODO: uncomment when ready to mark as stable 2 | # otel.stable=true 3 | -------------------------------------------------------------------------------- /baggage-processor/src/main/resources/META-INF/services/io.opentelemetry.sdk.autoconfigure.spi.AutoConfigurationCustomizerProvider: -------------------------------------------------------------------------------- 1 | io.opentelemetry.contrib.baggage.processor.BaggageProcessorCustomizer 2 | -------------------------------------------------------------------------------- /build.gradle.kts: -------------------------------------------------------------------------------- 1 | import java.time.Duration 2 | 3 | plugins { 4 | id("otel.spotless-conventions") 5 | 6 | id("idea") 7 | 8 | id("io.github.gradle-nexus.publish-plugin") 9 | } 10 | 11 | apply(from = "version.gradle.kts") 12 | 13 | nexusPublishing { 14 | packageGroup.set("io.opentelemetry") 15 | 16 | repositories { 17 | // see https://central.sonatype.org/publish/publish-portal-ossrh-staging-api/#configuration 18 | sonatype { 19 | nexusUrl.set(uri("https://ossrh-staging-api.central.sonatype.com/service/local/")) 20 | snapshotRepositoryUrl.set(uri("https://central.sonatype.com/repository/maven-snapshots/")) 21 | username.set(System.getenv("SONATYPE_USER")) 22 | password.set(System.getenv("SONATYPE_KEY")) 23 | } 24 | } 25 | 26 | connectTimeout.set(Duration.ofMinutes(5)) 27 | clientTimeout.set(Duration.ofMinutes(5)) 28 | 29 | transitionCheckOptions { 30 | // We have many artifacts so Maven Central takes a long time on its compliance checks. This sets 31 | // the timeout for waiting for the repository to close to a comfortable 50 minutes. 32 | maxRetries.set(300) 33 | delayBetween.set(Duration.ofSeconds(10)) 34 | } 35 | } 36 | 37 | description = "OpenTelemetry Contrib libraries and utilities for the JVM" 38 | -------------------------------------------------------------------------------- /buildSrc/src/main/kotlin/io/opentelemetry/gradle/OtelJavaExtension.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright The OpenTelemetry Authors 3 | * SPDX-License-Identifier: Apache-2.0 4 | */ 5 | 6 | package io.opentelemetry.gradle 7 | 8 | import org.gradle.api.JavaVersion 9 | import org.gradle.api.provider.Property 10 | 11 | abstract class OtelJavaExtension { 12 | abstract val moduleName: Property 13 | 14 | abstract val minJavaVersionSupported: Property 15 | 16 | abstract val maxJavaVersionForTests: Property 17 | 18 | init { 19 | minJavaVersionSupported.convention(JavaVersion.VERSION_1_8) 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /buildSrc/src/main/kotlin/otel.groovy-conventions.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | groovy 3 | 4 | id("otel.java-conventions") 5 | id("otel.spotless-conventions") 6 | } 7 | 8 | tasks { 9 | withType { 10 | sourceCompatibility = "8" 11 | targetCompatibility = "8" 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /buildscripts/dependency-check-suppressions.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | ^pkg:maven/com\.squareup\.wire/wire-runtime-jvm@.*$ 6 | cpe:/a:wire:wire 7 | 8 | 9 | 10 | ^pkg:maven/io\.opentelemetry/opentelemetry-exporter-prometheus@.*$ 11 | cpe:/a:prometheus:prometheus 12 | 13 | 14 | -------------------------------------------------------------------------------- /buildscripts/spotless.license.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright The OpenTelemetry Authors 3 | * SPDX-License-Identifier: Apache-2.0 4 | */ 5 | 6 | -------------------------------------------------------------------------------- /cloudfoundry-resources/build.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | id("otel.java-conventions") 3 | 4 | id("otel.publish-conventions") 5 | } 6 | 7 | description = "OpenTelemetry CloudFoundry Resources" 8 | otelJava.moduleName.set("io.opentelemetry.contrib.cloudfoundry.resources") 9 | 10 | dependencies { 11 | api("io.opentelemetry:opentelemetry-api") 12 | api("io.opentelemetry:opentelemetry-sdk") 13 | compileOnly("io.opentelemetry:opentelemetry-sdk-extension-autoconfigure-spi") 14 | 15 | compileOnly("io.opentelemetry:opentelemetry-sdk-extension-autoconfigure") 16 | 17 | implementation("com.fasterxml.jackson.core:jackson-core") 18 | implementation("io.opentelemetry.semconv:opentelemetry-semconv") 19 | testImplementation("io.opentelemetry.semconv:opentelemetry-semconv-incubating") 20 | 21 | testImplementation("io.opentelemetry:opentelemetry-sdk-extension-autoconfigure") 22 | testImplementation("io.opentelemetry:opentelemetry-sdk-testing") 23 | testImplementation("io.opentelemetry:opentelemetry-sdk-extension-autoconfigure-spi") 24 | } 25 | -------------------------------------------------------------------------------- /cloudfoundry-resources/src/main/java/io/opentelemetry/contrib/cloudfoundry/resources/CloudFoundryResourceProvider.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright The OpenTelemetry Authors 3 | * SPDX-License-Identifier: Apache-2.0 4 | */ 5 | 6 | package io.opentelemetry.contrib.cloudfoundry.resources; 7 | 8 | import io.opentelemetry.sdk.autoconfigure.spi.ConfigProperties; 9 | import io.opentelemetry.sdk.autoconfigure.spi.ResourceProvider; 10 | import io.opentelemetry.sdk.resources.Resource; 11 | 12 | public class CloudFoundryResourceProvider implements ResourceProvider { 13 | 14 | @Override 15 | public Resource createResource(ConfigProperties configProperties) { 16 | return CloudFoundryResource.get(); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /cloudfoundry-resources/src/main/resources/META-INF/services/io.opentelemetry.sdk.autoconfigure.spi.ResourceProvider: -------------------------------------------------------------------------------- 1 | io.opentelemetry.contrib.cloudfoundry.resources.CloudFoundryResourceProvider 2 | -------------------------------------------------------------------------------- /cloudfoundry-resources/src/test/resources/vcap_application.json: -------------------------------------------------------------------------------- 1 | { 2 | "application_id": "0193a038-e615-7e5e-92ca-f4bcd7ba0a25", 3 | "application_name": "cf-app-name", 4 | "application_uris": [ 5 | "testapp.example.com" 6 | ], 7 | "cf_api": "https://api.cf.example.com", 8 | "limits": { 9 | "fds": 256 10 | }, 11 | "instance_index": 1, 12 | "organization_id": "0193a375-8d8e-7e0c-a832-01ce9ded40dc", 13 | "organization_name": "cf-org-name", 14 | "process_id": "0193a4e3-8fd3-71b9-9fe3-5640c53bf1e2", 15 | "process_type": "web", 16 | "space_id": "0193a7e7-da17-7ea4-8940-b1e07b401b16", 17 | "space_name": "cf-space-name", 18 | "users": null 19 | } 20 | -------------------------------------------------------------------------------- /compressors/compressor-zstd/build.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | id("otel.java-conventions") 3 | id("otel.publish-conventions") 4 | } 5 | 6 | description = "zstd compressor implementation for use with OTLP exporters" 7 | otelJava.moduleName.set("io.opentelemetry.contrib.compressor.zstd") 8 | 9 | dependencies { 10 | api("io.opentelemetry:opentelemetry-exporter-common") 11 | 12 | implementation("com.github.luben:zstd-jni:1.5.7-3") 13 | 14 | testImplementation("io.opentelemetry:opentelemetry-sdk-testing") 15 | testImplementation("io.opentelemetry:opentelemetry-exporter-otlp") 16 | 17 | testImplementation("io.opentelemetry.proto:opentelemetry-proto") 18 | testImplementation("com.linecorp.armeria:armeria-junit5") 19 | } 20 | -------------------------------------------------------------------------------- /compressors/compressor-zstd/src/main/java/io/opentelemetry/contrib/compressor/zstd/ZstdCompressor.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright The OpenTelemetry Authors 3 | * SPDX-License-Identifier: Apache-2.0 4 | */ 5 | 6 | package io.opentelemetry.contrib.compressor.zstd; 7 | 8 | import com.github.luben.zstd.ZstdOutputStream; 9 | import io.opentelemetry.exporter.internal.compression.Compressor; 10 | import java.io.IOException; 11 | import java.io.OutputStream; 12 | 13 | public final class ZstdCompressor implements Compressor { 14 | 15 | private static final ZstdCompressor INSTANCE = new ZstdCompressor(); 16 | 17 | private ZstdCompressor() {} 18 | 19 | public static ZstdCompressor getInstance() { 20 | return INSTANCE; 21 | } 22 | 23 | @Override 24 | public String getEncoding() { 25 | return "zstd"; 26 | } 27 | 28 | @Override 29 | public OutputStream compress(OutputStream outputStream) throws IOException { 30 | return new ZstdOutputStream(outputStream); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /compressors/compressor-zstd/src/main/java/io/opentelemetry/contrib/compressor/zstd/ZstdCompressorProvider.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright The OpenTelemetry Authors 3 | * SPDX-License-Identifier: Apache-2.0 4 | */ 5 | 6 | package io.opentelemetry.contrib.compressor.zstd; 7 | 8 | import io.opentelemetry.exporter.internal.compression.Compressor; 9 | import io.opentelemetry.exporter.internal.compression.CompressorProvider; 10 | 11 | public final class ZstdCompressorProvider implements CompressorProvider { 12 | @Override 13 | public Compressor getInstance() { 14 | return ZstdCompressor.getInstance(); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /compressors/compressor-zstd/src/main/resources/META-INF/services/io.opentelemetry.exporter.internal.compression.CompressorProvider: -------------------------------------------------------------------------------- 1 | io.opentelemetry.contrib.compressor.zstd.ZstdCompressorProvider 2 | -------------------------------------------------------------------------------- /compressors/compressor-zstd/src/test/java/io/opentelemetry/contrib/compressor/zstd/ZstdCompressorTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright The OpenTelemetry Authors 3 | * SPDX-License-Identifier: Apache-2.0 4 | */ 5 | 6 | package io.opentelemetry.contrib.compressor.zstd; 7 | 8 | import static org.assertj.core.api.Assertions.assertThat; 9 | 10 | import com.github.luben.zstd.ZstdInputStream; 11 | import java.io.ByteArrayInputStream; 12 | import java.io.ByteArrayOutputStream; 13 | import java.io.IOException; 14 | import java.io.InputStream; 15 | import java.io.OutputStream; 16 | import java.nio.charset.StandardCharsets; 17 | import org.junit.jupiter.api.Test; 18 | 19 | class ZstdCompressorTest { 20 | 21 | @Test 22 | void roundTrip() throws IOException { 23 | String content = "hello world"; 24 | 25 | ByteArrayOutputStream baos = new ByteArrayOutputStream(); 26 | OutputStream os = ZstdCompressor.getInstance().compress(baos); 27 | os.write(content.getBytes(StandardCharsets.UTF_8)); 28 | os.close(); 29 | 30 | byte[] decompressed = new byte[content.length()]; 31 | InputStream is = new ZstdInputStream(new ByteArrayInputStream(baos.toByteArray())); 32 | is.read(decompressed); 33 | is.close(); 34 | 35 | assertThat(new String(decompressed, StandardCharsets.UTF_8)).isEqualTo(content); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /config/license/spotless.license.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright The OpenTelemetry Authors 3 | * SPDX-License-Identifier: Apache-2.0 4 | */ 5 | -------------------------------------------------------------------------------- /consistent-sampling/build.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | id("otel.java-conventions") 3 | id("otel.publish-conventions") 4 | } 5 | 6 | description = "Sampler and exporter implementations for consistent sampling" 7 | otelJava.moduleName.set("io.opentelemetry.contrib.sampler") 8 | 9 | dependencies { 10 | api("io.opentelemetry:opentelemetry-sdk-trace") 11 | api("io.opentelemetry:opentelemetry-sdk-extension-autoconfigure-spi") 12 | testImplementation("org.hipparchus:hipparchus-core:4.0.1") 13 | testImplementation("org.hipparchus:hipparchus-stat:4.0.1") 14 | } 15 | -------------------------------------------------------------------------------- /consistent-sampling/src/main/java/io/opentelemetry/contrib/sampler/consistent/ConsistentAlwaysOffSampler.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright The OpenTelemetry Authors 3 | * SPDX-License-Identifier: Apache-2.0 4 | */ 5 | 6 | package io.opentelemetry.contrib.sampler.consistent; 7 | 8 | import javax.annotation.concurrent.Immutable; 9 | 10 | @Immutable 11 | final class ConsistentAlwaysOffSampler extends ConsistentSampler { 12 | 13 | ConsistentAlwaysOffSampler(RValueGenerator rValueGenerator) { 14 | super(rValueGenerator); 15 | } 16 | 17 | @Override 18 | protected int getP(int parentP, boolean isRoot) { 19 | return OtelTraceState.getMaxP(); 20 | } 21 | 22 | @Override 23 | public String getDescription() { 24 | return "ConsistentAlwaysOffSampler"; 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /consistent-sampling/src/main/java/io/opentelemetry/contrib/sampler/consistent/ConsistentAlwaysOnSampler.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright The OpenTelemetry Authors 3 | * SPDX-License-Identifier: Apache-2.0 4 | */ 5 | 6 | package io.opentelemetry.contrib.sampler.consistent; 7 | 8 | import javax.annotation.concurrent.Immutable; 9 | 10 | @Immutable 11 | final class ConsistentAlwaysOnSampler extends ConsistentSampler { 12 | 13 | ConsistentAlwaysOnSampler(RValueGenerator rValueGenerator) { 14 | super(rValueGenerator); 15 | } 16 | 17 | @Override 18 | protected int getP(int parentP, boolean isRoot) { 19 | return 0; 20 | } 21 | 22 | @Override 23 | public String getDescription() { 24 | return "ConsistentAlwaysOnSampler"; 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /consistent-sampling/src/main/java/io/opentelemetry/contrib/sampler/consistent/ParentBasedConsistentProbabilitySamplerProvider.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright The OpenTelemetry Authors 3 | * SPDX-License-Identifier: Apache-2.0 4 | */ 5 | 6 | package io.opentelemetry.contrib.sampler.consistent; 7 | 8 | import io.opentelemetry.sdk.autoconfigure.spi.ConfigProperties; 9 | import io.opentelemetry.sdk.autoconfigure.spi.traces.ConfigurableSamplerProvider; 10 | import io.opentelemetry.sdk.trace.samplers.Sampler; 11 | 12 | public final class ParentBasedConsistentProbabilitySamplerProvider 13 | implements ConfigurableSamplerProvider { 14 | 15 | @Override 16 | public Sampler createSampler(ConfigProperties config) { 17 | double samplingProbability = config.getDouble("otel.traces.sampler.arg", 1.0d); 18 | return ConsistentSampler.parentBased(ConsistentSampler.probabilityBased(samplingProbability)); 19 | } 20 | 21 | @Override 22 | public String getName() { 23 | return "parentbased_consistent_probability"; 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /consistent-sampling/src/main/java/io/opentelemetry/contrib/sampler/consistent/RValueGenerators.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright The OpenTelemetry Authors 3 | * SPDX-License-Identifier: Apache-2.0 4 | */ 5 | 6 | package io.opentelemetry.contrib.sampler.consistent; 7 | 8 | final class RValueGenerators { 9 | 10 | private static final RValueGenerator DEFAULT = createDefault(); 11 | 12 | static RValueGenerator getDefault() { 13 | return DEFAULT; 14 | } 15 | 16 | private static RValueGenerator createDefault() { 17 | RandomGenerator randomGenerator = RandomGenerator.getDefault(); 18 | return s -> randomGenerator.numberOfLeadingZerosOfRandomLong(); 19 | } 20 | 21 | private RValueGenerators() {} 22 | } 23 | -------------------------------------------------------------------------------- /consistent-sampling/src/main/java/io/opentelemetry/contrib/sampler/consistent56/ConsistentAlwaysOnSampler.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright The OpenTelemetry Authors 3 | * SPDX-License-Identifier: Apache-2.0 4 | */ 5 | 6 | package io.opentelemetry.contrib.sampler.consistent56; 7 | 8 | import static io.opentelemetry.contrib.sampler.consistent56.ConsistentSamplingUtil.getMinThreshold; 9 | 10 | import io.opentelemetry.api.common.Attributes; 11 | import io.opentelemetry.api.trace.SpanKind; 12 | import io.opentelemetry.context.Context; 13 | import io.opentelemetry.sdk.trace.data.LinkData; 14 | import java.util.List; 15 | import javax.annotation.concurrent.Immutable; 16 | 17 | @Immutable 18 | final class ConsistentAlwaysOnSampler extends ConsistentSampler { 19 | 20 | private static final ConsistentAlwaysOnSampler INSTANCE = new ConsistentAlwaysOnSampler(); 21 | 22 | private ConsistentAlwaysOnSampler() {} 23 | 24 | static ConsistentAlwaysOnSampler getInstance() { 25 | return INSTANCE; 26 | } 27 | 28 | @Override 29 | public SamplingIntent getSamplingIntent( 30 | Context parentContext, 31 | String name, 32 | SpanKind spanKind, 33 | Attributes attributes, 34 | List parentLinks) { 35 | 36 | return () -> getMinThreshold(); 37 | } 38 | 39 | @Override 40 | public String getDescription() { 41 | return "ConsistentAlwaysOnSampler"; 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /consistent-sampling/src/main/java/io/opentelemetry/contrib/sampler/consistent56/PredicatedSampler.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright The OpenTelemetry Authors 3 | * SPDX-License-Identifier: Apache-2.0 4 | */ 5 | 6 | package io.opentelemetry.contrib.sampler.consistent56; 7 | 8 | import static java.util.Objects.requireNonNull; 9 | 10 | /** A class for holding a pair (Predicate, Composable) */ 11 | public final class PredicatedSampler { 12 | 13 | public static PredicatedSampler onMatch(Predicate predicate, Composable sampler) { 14 | return new PredicatedSampler(predicate, sampler); 15 | } 16 | 17 | private final Predicate predicate; 18 | private final Composable sampler; 19 | 20 | private PredicatedSampler(Predicate predicate, Composable sampler) { 21 | this.predicate = requireNonNull(predicate); 22 | this.sampler = requireNonNull(sampler); 23 | } 24 | 25 | public Predicate getPredicate() { 26 | return predicate; 27 | } 28 | 29 | public Composable getSampler() { 30 | return sampler; 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /consistent-sampling/src/main/java/io/opentelemetry/contrib/sampler/consistent56/RandomValueGenerator.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright The OpenTelemetry Authors 3 | * SPDX-License-Identifier: Apache-2.0 4 | */ 5 | 6 | package io.opentelemetry.contrib.sampler.consistent56; 7 | 8 | /** 9 | * A function for generating random values. 10 | * 11 | *

The distribution of random values generated by this function must be uniform over the range 12 | * [0,2^56-1] 13 | */ 14 | @FunctionalInterface 15 | public interface RandomValueGenerator { 16 | 17 | /** 18 | * Returns a 56-bit uniformly distributed random value. 19 | * 20 | * @param traceId the trace ID 21 | * @return the random value 22 | */ 23 | long generate(String traceId); 24 | } 25 | -------------------------------------------------------------------------------- /consistent-sampling/src/main/java/io/opentelemetry/contrib/sampler/consistent56/RandomValueGenerators.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright The OpenTelemetry Authors 3 | * SPDX-License-Identifier: Apache-2.0 4 | */ 5 | 6 | package io.opentelemetry.contrib.sampler.consistent56; 7 | 8 | import static io.opentelemetry.contrib.sampler.consistent56.ConsistentSamplingUtil.getMaxRandomValue; 9 | 10 | import java.util.concurrent.ThreadLocalRandom; 11 | 12 | final class RandomValueGenerators { 13 | 14 | private static final RandomValueGenerator DEFAULT = createDefault(); 15 | 16 | static RandomValueGenerator getDefault() { 17 | return DEFAULT; 18 | } 19 | 20 | private static RandomValueGenerator createDefault() { 21 | return s -> ThreadLocalRandom.current().nextLong() & getMaxRandomValue(); 22 | } 23 | 24 | private RandomValueGenerators() {} 25 | } 26 | -------------------------------------------------------------------------------- /consistent-sampling/src/main/resources/META-INF/services/io.opentelemetry.sdk.autoconfigure.spi.traces.ConfigurableSamplerProvider: -------------------------------------------------------------------------------- 1 | io.opentelemetry.contrib.sampler.consistent.ParentBasedConsistentProbabilitySamplerProvider 2 | -------------------------------------------------------------------------------- /consistent-sampling/src/test/java/io/opentelemetry/contrib/sampler/consistent56/ConsistentAlwaysOffSamplerTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright The OpenTelemetry Authors 3 | * SPDX-License-Identifier: Apache-2.0 4 | */ 5 | 6 | package io.opentelemetry.contrib.sampler.consistent56; 7 | 8 | import static io.opentelemetry.contrib.sampler.consistent56.ConsistentSamplingUtil.getInvalidThreshold; 9 | import static org.assertj.core.api.Assertions.assertThat; 10 | 11 | import org.junit.jupiter.api.Test; 12 | 13 | public class ConsistentAlwaysOffSamplerTest { 14 | 15 | @Test 16 | void testDescription() { 17 | assertThat(ConsistentSampler.alwaysOff().getDescription()) 18 | .isEqualTo("ConsistentAlwaysOffSampler"); 19 | } 20 | 21 | @Test 22 | void testThreshold() { 23 | assertThat( 24 | ConsistentSampler.alwaysOff() 25 | .getSamplingIntent(null, "span_name", null, null, null) 26 | .getThreshold()) 27 | .isEqualTo(getInvalidThreshold()); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /consistent-sampling/src/test/java/io/opentelemetry/contrib/sampler/consistent56/ConsistentAlwaysOnSamplerTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright The OpenTelemetry Authors 3 | * SPDX-License-Identifier: Apache-2.0 4 | */ 5 | 6 | package io.opentelemetry.contrib.sampler.consistent56; 7 | 8 | import static io.opentelemetry.contrib.sampler.consistent56.ConsistentSamplingUtil.getMinThreshold; 9 | import static org.assertj.core.api.Assertions.assertThat; 10 | 11 | import org.junit.jupiter.api.Test; 12 | 13 | public class ConsistentAlwaysOnSamplerTest { 14 | 15 | @Test 16 | void testDescription() { 17 | assertThat(ConsistentSampler.alwaysOn().getDescription()) 18 | .isEqualTo("ConsistentAlwaysOnSampler"); 19 | } 20 | 21 | @Test 22 | void testThreshold() { 23 | assertThat( 24 | ConsistentSampler.alwaysOn() 25 | .getSamplingIntent(null, "span_name", null, null, null) 26 | .getThreshold()) 27 | .isEqualTo(getMinThreshold()); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /consistent-sampling/src/test/java/io/opentelemetry/contrib/sampler/consistent56/RandomValueGeneratorsTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright The OpenTelemetry Authors 3 | * SPDX-License-Identifier: Apache-2.0 4 | */ 5 | 6 | package io.opentelemetry.contrib.sampler.consistent56; 7 | 8 | import static io.opentelemetry.contrib.sampler.consistent56.ConsistentSamplingUtil.getMaxRandomValue; 9 | import static org.assertj.core.api.Assertions.assertThat; 10 | 11 | import org.junit.jupiter.api.Test; 12 | 13 | public class RandomValueGeneratorsTest { 14 | @Test 15 | void testRandomRange() { 16 | int attempts = 10000; 17 | for (int i = 0; i < attempts; ++i) { 18 | assertThat(RandomValueGenerators.getDefault().generate("")) 19 | .isBetween(0L, getMaxRandomValue()); 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /consistent-sampling/src/test/java/io/opentelemetry/contrib/sampler/consistent56/TestUtil.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright The OpenTelemetry Authors 3 | * SPDX-License-Identifier: Apache-2.0 4 | */ 5 | 6 | package io.opentelemetry.contrib.sampler.consistent56; 7 | 8 | import static io.opentelemetry.contrib.sampler.consistent56.ConsistentSamplingUtil.HEX_DIGITS; 9 | 10 | import java.util.SplittableRandom; 11 | 12 | public final class TestUtil { 13 | 14 | private TestUtil() {} 15 | 16 | static String generateRandomTraceId(SplittableRandom random) { 17 | StringBuilder sb = new StringBuilder(16); 18 | long hi = random.nextLong(); 19 | long lo = random.nextLong(); 20 | for (int i = 0; i < 64; i += 4) { 21 | sb.append(HEX_DIGITS[(int) (hi >>> i) & 0xF]); 22 | } 23 | for (int i = 0; i < 64; i += 4) { 24 | sb.append(HEX_DIGITS[(int) (lo >>> i) & 0xF]); 25 | } 26 | return sb.toString(); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /disk-buffering/assets/reading-flow.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/open-telemetry/opentelemetry-java-contrib/0a37bb9ed29bf9d8fea2d64114ddb2566b7aae80/disk-buffering/assets/reading-flow.png -------------------------------------------------------------------------------- /disk-buffering/assets/writing-flow.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/open-telemetry/opentelemetry-java-contrib/0a37bb9ed29bf9d8fea2d64114ddb2566b7aae80/disk-buffering/assets/writing-flow.png -------------------------------------------------------------------------------- /disk-buffering/src/main/java/io/opentelemetry/contrib/disk/buffering/internal/exporter/FromDiskExporter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright The OpenTelemetry Authors 3 | * SPDX-License-Identifier: Apache-2.0 4 | */ 5 | 6 | package io.opentelemetry.contrib.disk.buffering.internal.exporter; 7 | 8 | import java.io.IOException; 9 | import java.util.concurrent.TimeUnit; 10 | 11 | public interface FromDiskExporter { 12 | boolean exportStoredBatch(long timeout, TimeUnit unit) throws IOException; 13 | 14 | void shutdown() throws IOException; 15 | } 16 | -------------------------------------------------------------------------------- /disk-buffering/src/main/java/io/opentelemetry/contrib/disk/buffering/internal/serialization/deserializers/DeserializationException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright The OpenTelemetry Authors 3 | * SPDX-License-Identifier: Apache-2.0 4 | */ 5 | 6 | package io.opentelemetry.contrib.disk.buffering.internal.serialization.deserializers; 7 | 8 | import java.io.IOException; 9 | 10 | @SuppressWarnings("serial") 11 | public class DeserializationException extends IOException { 12 | public DeserializationException(Throwable cause) { 13 | super(cause); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /disk-buffering/src/main/java/io/opentelemetry/contrib/disk/buffering/internal/serialization/deserializers/MetricDataDeserializer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright The OpenTelemetry Authors 3 | * SPDX-License-Identifier: Apache-2.0 4 | */ 5 | 6 | package io.opentelemetry.contrib.disk.buffering.internal.serialization.deserializers; 7 | 8 | import io.opentelemetry.contrib.disk.buffering.internal.serialization.mapping.metrics.ProtoMetricsDataMapper; 9 | import io.opentelemetry.contrib.disk.buffering.internal.utils.SignalTypes; 10 | import io.opentelemetry.proto.metrics.v1.MetricsData; 11 | import io.opentelemetry.sdk.metrics.data.MetricData; 12 | import java.io.IOException; 13 | import java.util.List; 14 | 15 | public final class MetricDataDeserializer implements SignalDeserializer { 16 | private static final MetricDataDeserializer INSTANCE = new MetricDataDeserializer(); 17 | 18 | private MetricDataDeserializer() {} 19 | 20 | static MetricDataDeserializer getInstance() { 21 | return INSTANCE; 22 | } 23 | 24 | @Override 25 | public List deserialize(byte[] source) throws DeserializationException { 26 | try { 27 | return ProtoMetricsDataMapper.getInstance().fromProto(MetricsData.ADAPTER.decode(source)); 28 | } catch (IOException e) { 29 | throw new DeserializationException(e); 30 | } 31 | } 32 | 33 | @Override 34 | public String signalType() { 35 | return SignalTypes.metrics.name(); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /disk-buffering/src/main/java/io/opentelemetry/contrib/disk/buffering/internal/serialization/deserializers/SignalDeserializer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright The OpenTelemetry Authors 3 | * SPDX-License-Identifier: Apache-2.0 4 | */ 5 | 6 | package io.opentelemetry.contrib.disk.buffering.internal.serialization.deserializers; 7 | 8 | import io.opentelemetry.sdk.logs.data.LogRecordData; 9 | import io.opentelemetry.sdk.metrics.data.MetricData; 10 | import io.opentelemetry.sdk.trace.data.SpanData; 11 | import java.util.List; 12 | 13 | public interface SignalDeserializer { 14 | 15 | static SignalDeserializer ofSpans() { 16 | return SpanDataDeserializer.getInstance(); 17 | } 18 | 19 | static SignalDeserializer ofMetrics() { 20 | return MetricDataDeserializer.getInstance(); 21 | } 22 | 23 | static SignalDeserializer ofLogs() { 24 | return LogRecordDataDeserializer.getInstance(); 25 | } 26 | 27 | /** Deserializes the given byte array into a list of telemetry items. */ 28 | List deserialize(byte[] source) throws DeserializationException; 29 | 30 | /** Returns the name of the stored type of signal -- one of "metrics", "spans", or "logs". */ 31 | default String signalType() { 32 | return "unknown"; 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /disk-buffering/src/main/java/io/opentelemetry/contrib/disk/buffering/internal/serialization/deserializers/SpanDataDeserializer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright The OpenTelemetry Authors 3 | * SPDX-License-Identifier: Apache-2.0 4 | */ 5 | 6 | package io.opentelemetry.contrib.disk.buffering.internal.serialization.deserializers; 7 | 8 | import io.opentelemetry.contrib.disk.buffering.internal.serialization.mapping.spans.ProtoSpansDataMapper; 9 | import io.opentelemetry.contrib.disk.buffering.internal.utils.SignalTypes; 10 | import io.opentelemetry.proto.trace.v1.TracesData; 11 | import io.opentelemetry.sdk.trace.data.SpanData; 12 | import java.io.IOException; 13 | import java.util.List; 14 | 15 | public final class SpanDataDeserializer implements SignalDeserializer { 16 | private static final SpanDataDeserializer INSTANCE = new SpanDataDeserializer(); 17 | 18 | private SpanDataDeserializer() {} 19 | 20 | static SpanDataDeserializer getInstance() { 21 | return INSTANCE; 22 | } 23 | 24 | @Override 25 | public List deserialize(byte[] source) throws DeserializationException { 26 | try { 27 | return ProtoSpansDataMapper.getInstance().fromProto(TracesData.ADAPTER.decode(source)); 28 | } catch (IOException e) { 29 | throw new DeserializationException(e); 30 | } 31 | } 32 | 33 | @Override 34 | public String signalType() { 35 | return SignalTypes.spans.name(); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /disk-buffering/src/main/java/io/opentelemetry/contrib/disk/buffering/internal/serialization/mapping/common/ByteStringMapper.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright The OpenTelemetry Authors 3 | * SPDX-License-Identifier: Apache-2.0 4 | */ 5 | 6 | package io.opentelemetry.contrib.disk.buffering.internal.serialization.mapping.common; 7 | 8 | import okio.ByteString; 9 | 10 | public final class ByteStringMapper { 11 | 12 | private static final ByteStringMapper INSTANCE = new ByteStringMapper(); 13 | 14 | public static ByteStringMapper getInstance() { 15 | return INSTANCE; 16 | } 17 | 18 | public ByteString stringToProto(String source) { 19 | return ByteString.encodeUtf8(source); 20 | } 21 | 22 | public String protoToString(ByteString source) { 23 | return source.utf8(); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /disk-buffering/src/main/java/io/opentelemetry/contrib/disk/buffering/internal/serialization/mapping/common/ResourceMapper.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright The OpenTelemetry Authors 3 | * SPDX-License-Identifier: Apache-2.0 4 | */ 5 | 6 | package io.opentelemetry.contrib.disk.buffering.internal.serialization.mapping.common; 7 | 8 | import io.opentelemetry.proto.resource.v1.Resource; 9 | import io.opentelemetry.sdk.resources.ResourceBuilder; 10 | import javax.annotation.Nullable; 11 | 12 | public final class ResourceMapper { 13 | 14 | private static final ResourceMapper INSTANCE = new ResourceMapper(); 15 | 16 | public static ResourceMapper getInstance() { 17 | return INSTANCE; 18 | } 19 | 20 | public Resource mapToProto(io.opentelemetry.sdk.resources.Resource sdkResource) { 21 | return new Resource.Builder() 22 | .attributes(AttributesMapper.getInstance().attributesToProto(sdkResource.getAttributes())) 23 | .build(); 24 | } 25 | 26 | public io.opentelemetry.sdk.resources.Resource mapToSdk( 27 | Resource protoResource, @Nullable String schemaUrl) { 28 | ResourceBuilder resource = io.opentelemetry.sdk.resources.Resource.builder(); 29 | 30 | if (schemaUrl != null) { 31 | resource.setSchemaUrl(schemaUrl); 32 | } 33 | resource.putAll(AttributesMapper.getInstance().protoToAttributes(protoResource.attributes)); 34 | return resource.build(); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /disk-buffering/src/main/java/io/opentelemetry/contrib/disk/buffering/internal/serialization/serializers/SignalSerializer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright The OpenTelemetry Authors 3 | * SPDX-License-Identifier: Apache-2.0 4 | */ 5 | 6 | package io.opentelemetry.contrib.disk.buffering.internal.serialization.serializers; 7 | 8 | import io.opentelemetry.sdk.logs.data.LogRecordData; 9 | import io.opentelemetry.sdk.metrics.data.MetricData; 10 | import io.opentelemetry.sdk.trace.data.SpanData; 11 | import java.util.Collection; 12 | 13 | public interface SignalSerializer { 14 | 15 | static SignalSerializer ofSpans() { 16 | return SpanDataSerializer.getInstance(); 17 | } 18 | 19 | static SignalSerializer ofMetrics() { 20 | return MetricDataSerializer.getInstance(); 21 | } 22 | 23 | static SignalSerializer ofLogs() { 24 | return LogRecordDataSerializer.getInstance(); 25 | } 26 | 27 | byte[] serialize(Collection items); 28 | } 29 | -------------------------------------------------------------------------------- /disk-buffering/src/main/java/io/opentelemetry/contrib/disk/buffering/internal/storage/files/FileOperations.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright The OpenTelemetry Authors 3 | * SPDX-License-Identifier: Apache-2.0 4 | */ 5 | 6 | package io.opentelemetry.contrib.disk.buffering.internal.storage.files; 7 | 8 | import java.io.Closeable; 9 | import java.io.File; 10 | 11 | public interface FileOperations extends Closeable { 12 | boolean hasExpired(); 13 | 14 | boolean isClosed(); 15 | 16 | File getFile(); 17 | } 18 | -------------------------------------------------------------------------------- /disk-buffering/src/main/java/io/opentelemetry/contrib/disk/buffering/internal/storage/files/reader/ProcessResult.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright The OpenTelemetry Authors 3 | * SPDX-License-Identifier: Apache-2.0 4 | */ 5 | 6 | package io.opentelemetry.contrib.disk.buffering.internal.storage.files.reader; 7 | 8 | /** Result of processing the contents of a file. */ 9 | public enum ProcessResult { 10 | SUCCEEDED, 11 | TRY_LATER, 12 | CONTENT_INVALID 13 | } 14 | -------------------------------------------------------------------------------- /disk-buffering/src/main/java/io/opentelemetry/contrib/disk/buffering/internal/storage/files/reader/ReadResult.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright The OpenTelemetry Authors 3 | * SPDX-License-Identifier: Apache-2.0 4 | */ 5 | 6 | package io.opentelemetry.contrib.disk.buffering.internal.storage.files.reader; 7 | 8 | public final class ReadResult { 9 | /** The consumable data. */ 10 | public final byte[] content; 11 | 12 | public ReadResult(byte[] content) { 13 | this.content = content; 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /disk-buffering/src/main/java/io/opentelemetry/contrib/disk/buffering/internal/storage/files/reader/StreamReader.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright The OpenTelemetry Authors 3 | * SPDX-License-Identifier: Apache-2.0 4 | */ 5 | 6 | package io.opentelemetry.contrib.disk.buffering.internal.storage.files.reader; 7 | 8 | import java.io.Closeable; 9 | import java.io.IOException; 10 | import java.io.InputStream; 11 | import javax.annotation.Nullable; 12 | 13 | public interface StreamReader extends Closeable { 14 | @Nullable 15 | ReadResult readNext() throws IOException; 16 | 17 | interface Factory { 18 | StreamReader create(InputStream stream); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /disk-buffering/src/main/java/io/opentelemetry/contrib/disk/buffering/internal/storage/responses/ReadableResult.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright The OpenTelemetry Authors 3 | * SPDX-License-Identifier: Apache-2.0 4 | */ 5 | 6 | package io.opentelemetry.contrib.disk.buffering.internal.storage.responses; 7 | 8 | public enum ReadableResult { 9 | SUCCEEDED, 10 | FAILED, 11 | TRY_LATER 12 | } 13 | -------------------------------------------------------------------------------- /disk-buffering/src/main/java/io/opentelemetry/contrib/disk/buffering/internal/storage/responses/WritableResult.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright The OpenTelemetry Authors 3 | * SPDX-License-Identifier: Apache-2.0 4 | */ 5 | 6 | package io.opentelemetry.contrib.disk.buffering.internal.storage.responses; 7 | 8 | public enum WritableResult { 9 | SUCCEEDED, 10 | FAILED 11 | } 12 | -------------------------------------------------------------------------------- /disk-buffering/src/main/java/io/opentelemetry/contrib/disk/buffering/internal/storage/util/ClockBuddy.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright The OpenTelemetry Authors 3 | * SPDX-License-Identifier: Apache-2.0 4 | */ 5 | 6 | package io.opentelemetry.contrib.disk.buffering.internal.storage.util; 7 | 8 | import static java.util.concurrent.TimeUnit.NANOSECONDS; 9 | 10 | import io.opentelemetry.sdk.common.Clock; 11 | 12 | public class ClockBuddy { 13 | 14 | private ClockBuddy() {} 15 | 16 | /** Returns the current time in millis from the given clock */ 17 | public static final long nowMillis(Clock clock) { 18 | return NANOSECONDS.toMillis(clock.now()); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /disk-buffering/src/main/java/io/opentelemetry/contrib/disk/buffering/internal/utils/DebugLogger.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright The OpenTelemetry Authors 3 | * SPDX-License-Identifier: Apache-2.0 4 | */ 5 | 6 | package io.opentelemetry.contrib.disk.buffering.internal.utils; 7 | 8 | import java.util.logging.Level; 9 | import java.util.logging.Logger; 10 | 11 | public class DebugLogger { 12 | private final Logger logger; 13 | private final boolean debugEnabled; 14 | 15 | private DebugLogger(Logger logger, boolean debugEnabled) { 16 | this.logger = logger; 17 | this.debugEnabled = debugEnabled; 18 | } 19 | 20 | public static DebugLogger wrap(Logger logger, boolean debugEnabled) { 21 | return new DebugLogger(logger, debugEnabled); 22 | } 23 | 24 | public void log(String msg) { 25 | log(msg, Level.INFO); 26 | } 27 | 28 | public void log(String msg, Level level) { 29 | if (debugEnabled) { 30 | logger.log(level, msg); 31 | } 32 | } 33 | 34 | public void log(String msg, Level level, Throwable e) { 35 | if (debugEnabled) { 36 | logger.log(level, msg, e); 37 | } 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /disk-buffering/src/main/java/io/opentelemetry/contrib/disk/buffering/internal/utils/SignalTypes.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright The OpenTelemetry Authors 3 | * SPDX-License-Identifier: Apache-2.0 4 | */ 5 | 6 | package io.opentelemetry.contrib.disk.buffering.internal.utils; 7 | 8 | public enum SignalTypes { 9 | metrics, 10 | spans, 11 | logs 12 | } 13 | -------------------------------------------------------------------------------- /disk-buffering/src/test/java/io/opentelemetry/contrib/disk/buffering/internal/serialization/mapping/common/ResourceMapperTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright The OpenTelemetry Authors 3 | * SPDX-License-Identifier: Apache-2.0 4 | */ 5 | 6 | package io.opentelemetry.contrib.disk.buffering.internal.serialization.mapping.common; 7 | 8 | import static org.junit.jupiter.api.Assertions.assertEquals; 9 | 10 | import io.opentelemetry.contrib.disk.buffering.testutils.TestData; 11 | import io.opentelemetry.proto.resource.v1.Resource; 12 | import org.junit.jupiter.api.Test; 13 | 14 | class ResourceMapperTest { 15 | 16 | @Test 17 | void verifyMapping() { 18 | Resource proto = mapToProto(TestData.RESOURCE_FULL); 19 | 20 | assertEquals(TestData.RESOURCE_FULL, mapToSdk(proto, TestData.RESOURCE_FULL.getSchemaUrl())); 21 | } 22 | 23 | private static Resource mapToProto(io.opentelemetry.sdk.resources.Resource sdkResource) { 24 | return ResourceMapper.getInstance().mapToProto(sdkResource); 25 | } 26 | 27 | private static io.opentelemetry.sdk.resources.Resource mapToSdk( 28 | Resource protoResource, String schemaUrl) { 29 | return ResourceMapper.getInstance().mapToSdk(protoResource, schemaUrl); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /example/README.md: -------------------------------------------------------------------------------- 1 | # Example Library 2 | 3 | This is an example library intended to be used as a template for easy additions to the OpenTelemetry Java Contrib project. 4 | -------------------------------------------------------------------------------- /example/build.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | id("otel.java-conventions") 3 | } 4 | 5 | description = "An example OpenTelemetry Java Contrib library" 6 | 7 | tasks { 8 | jar { 9 | manifest { 10 | attributes["Main-Class"] = "io.opentelemetry.contrib.example.Library" 11 | } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /example/src/main/java/io/opentelemetry/contrib/example/Library.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright The OpenTelemetry Authors 3 | * SPDX-License-Identifier: Apache-2.0 4 | */ 5 | 6 | package io.opentelemetry.contrib.example; 7 | 8 | public class Library { 9 | 10 | public boolean myMethod() { 11 | return true; 12 | } 13 | 14 | @SuppressWarnings("SystemOut") 15 | public static void main(String... args) { 16 | System.out.println("ExampleLibrary.main"); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /example/src/test/java/io/opentelemetry/contrib/example/LibraryTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright The OpenTelemetry Authors 3 | * SPDX-License-Identifier: Apache-2.0 4 | */ 5 | 6 | package io.opentelemetry.contrib.example; 7 | 8 | import static org.assertj.core.api.Assertions.assertThat; 9 | 10 | import org.junit.jupiter.api.Test; 11 | 12 | class LibraryTest { 13 | 14 | @Test 15 | void myMethod() { 16 | Library library = new Library(); 17 | assertThat(library.myMethod()).isTrue(); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /gcp-auth-extension/gradle.properties: -------------------------------------------------------------------------------- 1 | # TODO: uncomment when ready to mark as stable 2 | # otel.stable=true 3 | -------------------------------------------------------------------------------- /gcp-auth-extension/src/test/java/io/opentelemetry/contrib/gcp/auth/springapp/Application.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright The OpenTelemetry Authors 3 | * SPDX-License-Identifier: Apache-2.0 4 | */ 5 | 6 | package io.opentelemetry.contrib.gcp.auth.springapp; 7 | 8 | import org.springframework.boot.SpringApplication; 9 | import org.springframework.boot.autoconfigure.SpringBootApplication; 10 | 11 | @SpringBootApplication 12 | @SuppressWarnings("PrivateConstructorForUtilityClass") 13 | public class Application { 14 | public static void main(String[] args) { 15 | SpringApplication.run(Application.class, args); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /gcp-auth-extension/src/test/java/io/opentelemetry/contrib/gcp/auth/springapp/Controller.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright The OpenTelemetry Authors 3 | * SPDX-License-Identifier: Apache-2.0 4 | */ 5 | 6 | package io.opentelemetry.contrib.gcp.auth.springapp; 7 | 8 | import io.opentelemetry.instrumentation.annotations.WithSpan; 9 | import java.time.Duration; 10 | import java.time.Instant; 11 | import java.util.Random; 12 | import org.springframework.web.bind.annotation.GetMapping; 13 | import org.springframework.web.bind.annotation.RestController; 14 | 15 | @RestController 16 | public class Controller { 17 | 18 | private final Random random = new Random(); 19 | 20 | @GetMapping("/ping") 21 | public String ping() { 22 | int busyTime = random.nextInt(200); 23 | busyloop(busyTime); 24 | return "pong"; 25 | } 26 | 27 | @WithSpan 28 | private static long busyloop(int busyMillis) { 29 | Instant start = Instant.now(); 30 | Instant end; 31 | long counter = 0; 32 | do { 33 | counter++; 34 | end = Instant.now(); 35 | } while (Duration.between(start, end).toMillis() < busyMillis); 36 | return counter; 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /gcp-auth-extension/src/test/resources/fake_user_creds.json: -------------------------------------------------------------------------------- 1 | { 2 | "client_id": "....apps.googleusercontent.com", 3 | "client_secret": "...", 4 | "refresh_token": "1//...", 5 | "quota_project_id": "your-configured-quota-project", 6 | "type": "authorized_user" 7 | } 8 | -------------------------------------------------------------------------------- /gcp-auth-extension/src/test/resources/mockito-extensions/org.mockito.plugins.MockMaker: -------------------------------------------------------------------------------- 1 | mock-maker-inline 2 | -------------------------------------------------------------------------------- /gcp-resources/build.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | id("otel.java-conventions") 3 | 4 | id("otel.publish-conventions") 5 | } 6 | 7 | description = "OpenTelemetry GCP Resources Support" 8 | otelJava.moduleName.set("io.opentelemetry.contrib.gcp.resource") 9 | 10 | dependencies { 11 | api("io.opentelemetry:opentelemetry-api") 12 | api("io.opentelemetry:opentelemetry-sdk") 13 | 14 | // Provides GCP resource detection support 15 | implementation("com.google.cloud.opentelemetry:detector-resources-support:0.35.0") 16 | 17 | testImplementation("io.opentelemetry.semconv:opentelemetry-semconv-incubating") 18 | 19 | compileOnly("io.opentelemetry:opentelemetry-sdk-extension-autoconfigure") 20 | 21 | implementation("com.fasterxml.jackson.core:jackson-core") 22 | 23 | testImplementation("io.opentelemetry:opentelemetry-sdk-extension-autoconfigure") 24 | testImplementation("io.opentelemetry:opentelemetry-sdk-testing") 25 | 26 | testImplementation("org.mockito:mockito-core") 27 | testImplementation("com.google.guava:guava") 28 | 29 | testImplementation("org.junit.jupiter:junit-jupiter-api") 30 | } 31 | -------------------------------------------------------------------------------- /gcp-resources/gradle.properties: -------------------------------------------------------------------------------- 1 | # TODO: uncomment when ready to mark as stable 2 | # otel.stable=true 3 | -------------------------------------------------------------------------------- /gcp-resources/src/main/resources/META-INF/services/io.opentelemetry.sdk.autoconfigure.spi.ResourceProvider: -------------------------------------------------------------------------------- 1 | io.opentelemetry.contrib.gcp.resource.GCPResourceProvider 2 | -------------------------------------------------------------------------------- /gradle.properties: -------------------------------------------------------------------------------- 1 | org.gradle.parallel=true 2 | org.gradle.caching=true 3 | 4 | org.gradle.priority=low 5 | 6 | # Gradle default is 256m which causes issues with our build - https://docs.gradle.org/current/userguide/build_environment.html#sec:configuring_jvm_memory 7 | org.gradle.jvmargs=-XX:MaxMetaspaceSize=512m 8 | 9 | # Workaround https://youtrack.jetbrains.com/issue/KT-47152 10 | # We don't have enough kotlin code to care about incremental compilation anyways. 11 | kotlin.incremental=false 12 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/open-telemetry/opentelemetry-java-contrib/0a37bb9ed29bf9d8fea2d64114ddb2566b7aae80/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | distributionSha256Sum=845952a9d6afa783db70bb3b0effaae45ae5542ca2bb7929619e8af49cb634cf 4 | distributionUrl=https\://services.gradle.org/distributions/gradle-8.14.1-bin.zip 5 | networkTimeout=10000 6 | validateDistributionUrl=true 7 | zipStoreBase=GRADLE_USER_HOME 8 | zipStorePath=wrapper/dists 9 | -------------------------------------------------------------------------------- /inferred-spans/src/main/java/io/opentelemetry/contrib/inferredspans/internal/pooling/Allocator.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright The OpenTelemetry Authors 3 | * SPDX-License-Identifier: Apache-2.0 4 | */ 5 | 6 | package io.opentelemetry.contrib.inferredspans.internal.pooling; 7 | 8 | /** 9 | * Defines a pooled object factory 10 | * 11 | * @param pooled object type 12 | */ 13 | public interface Allocator { 14 | 15 | /** Creates a new instance of pooled object type. */ 16 | T createInstance(); 17 | } 18 | -------------------------------------------------------------------------------- /inferred-spans/src/main/java/io/opentelemetry/contrib/inferredspans/internal/pooling/ObjectPool.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright The OpenTelemetry Authors 3 | * SPDX-License-Identifier: Apache-2.0 4 | */ 5 | 6 | package io.opentelemetry.contrib.inferredspans.internal.pooling; 7 | 8 | import org.jctools.queues.MpmcArrayQueue; 9 | 10 | /** 11 | * Object pool 12 | * 13 | * @param pooled object type. Does not have to implement {@link Recyclable} in order to allow 14 | * for dealing with external objects (like standard JDK or third party library classes). 15 | */ 16 | public interface ObjectPool { 17 | 18 | /** 19 | * Tries to reuse any existing instance if pool has any, otherwise creates a new un-pooled 20 | * instance 21 | * 22 | * @return object instance, either from pool or freshly allocated 23 | */ 24 | T createInstance(); 25 | 26 | /** 27 | * Recycles an object 28 | * 29 | * @param obj object to recycle 30 | */ 31 | void recycle(T obj); 32 | 33 | void clear(); 34 | 35 | public static ObjectPool createRecyclable( 36 | int capacity, Allocator allocator) { 37 | return QueueBasedObjectPool.ofRecyclable( 38 | new MpmcArrayQueue<>(capacity), /* preAllocate= */ false, allocator); 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /inferred-spans/src/main/java/io/opentelemetry/contrib/inferredspans/internal/pooling/Recyclable.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright The OpenTelemetry Authors 3 | * SPDX-License-Identifier: Apache-2.0 4 | */ 5 | 6 | package io.opentelemetry.contrib.inferredspans.internal.pooling; 7 | 8 | public interface Recyclable { 9 | 10 | /** resets pooled object state so it can be reused */ 11 | void resetState(); 12 | } 13 | -------------------------------------------------------------------------------- /inferred-spans/src/main/java/io/opentelemetry/contrib/inferredspans/internal/pooling/Resetter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright The OpenTelemetry Authors 3 | * SPDX-License-Identifier: Apache-2.0 4 | */ 5 | 6 | package io.opentelemetry.contrib.inferredspans.internal.pooling; 7 | 8 | /** 9 | * Defines reset strategy to use for a given pooled object type when they are returned to pool 10 | * 11 | * @param pooled object type 12 | */ 13 | public interface Resetter { 14 | 15 | /** 16 | * Recycles a pooled object state 17 | * 18 | * @param object object to recycle 19 | */ 20 | void recycle(T object); 21 | 22 | /** 23 | * Resetter for objects that implement {@link Recyclable} 24 | * 25 | * @param recyclable object type 26 | */ 27 | @SuppressWarnings({"unchecked", "rawtypes"}) 28 | class ForRecyclable implements Resetter { 29 | private static final ForRecyclable INSTANCE = new ForRecyclable(); 30 | 31 | public static Resetter get() { 32 | return INSTANCE; 33 | } 34 | 35 | @Override 36 | public void recycle(Recyclable object) { 37 | object.resetState(); 38 | } 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /inferred-spans/src/main/java/io/opentelemetry/contrib/inferredspans/internal/semconv/Attributes.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright The OpenTelemetry Authors 3 | * SPDX-License-Identifier: Apache-2.0 4 | */ 5 | 6 | package io.opentelemetry.contrib.inferredspans.internal.semconv; 7 | 8 | import io.opentelemetry.api.common.AttributeKey; 9 | 10 | public class Attributes { 11 | 12 | private Attributes() {} 13 | 14 | public static final AttributeKey CODE_STACKTRACE = 15 | AttributeKey.stringKey("code.stacktrace"); 16 | public static final AttributeKey LINK_IS_CHILD = AttributeKey.booleanKey("is_child"); 17 | public static final AttributeKey SPAN_IS_INFERRED = 18 | AttributeKey.booleanKey("is_inferred"); 19 | } 20 | -------------------------------------------------------------------------------- /inferred-spans/src/main/java/io/opentelemetry/contrib/inferredspans/internal/util/ByteUtils.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright The OpenTelemetry Authors 3 | * SPDX-License-Identifier: Apache-2.0 4 | */ 5 | 6 | package io.opentelemetry.contrib.inferredspans.internal.util; 7 | 8 | public class ByteUtils { 9 | 10 | private ByteUtils() {} 11 | 12 | public static void putLong(byte[] buffer, int offset, long l) { 13 | buffer[offset++] = (byte) (l >> 56); 14 | buffer[offset++] = (byte) (l >> 48); 15 | buffer[offset++] = (byte) (l >> 40); 16 | buffer[offset++] = (byte) (l >> 32); 17 | buffer[offset++] = (byte) (l >> 24); 18 | buffer[offset++] = (byte) (l >> 16); 19 | buffer[offset++] = (byte) (l >> 8); 20 | buffer[offset] = (byte) l; 21 | } 22 | 23 | public static long getLong(byte[] buffer, int offset) { 24 | return ((long) buffer[offset] << 56) 25 | | ((long) buffer[offset + 1] & 0xff) << 48 26 | | ((long) buffer[offset + 2] & 0xff) << 40 27 | | ((long) buffer[offset + 3] & 0xff) << 32 28 | | ((long) buffer[offset + 4] & 0xff) << 24 29 | | ((long) buffer[offset + 5] & 0xff) << 16 30 | | ((long) buffer[offset + 6] & 0xff) << 8 31 | | ((long) buffer[offset + 7] & 0xff); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /inferred-spans/src/test/java/io/opentelemetry/contrib/inferredspans/internal/FixedClock.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright The OpenTelemetry Authors 3 | * SPDX-License-Identifier: Apache-2.0 4 | */ 5 | 6 | package io.opentelemetry.contrib.inferredspans.internal; 7 | 8 | import io.opentelemetry.api.trace.Span; 9 | import io.opentelemetry.context.Context; 10 | import io.opentelemetry.sdk.trace.ReadWriteSpan; 11 | 12 | public class FixedClock extends SpanAnchoredClock { 13 | 14 | private long nanoTime = -1L; 15 | 16 | @Override 17 | public void onSpanStart(ReadWriteSpan started, Context parentContext) {} 18 | 19 | @Override 20 | public long nanoTime() { 21 | if (nanoTime == -1L) { 22 | return System.nanoTime(); 23 | } 24 | return nanoTime; 25 | } 26 | 27 | @Override 28 | public long getAnchor(Span parent) { 29 | return 0; 30 | } 31 | 32 | @Override 33 | @SuppressWarnings("CanIgnoreReturnValueSuggester") 34 | public long toEpochNanos(long anchor, long recordedNanoTime) { 35 | return recordedNanoTime; 36 | } 37 | 38 | public void setNanoTime(long nanoTime) { 39 | this.nanoTime = nanoTime; 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /inferred-spans/src/test/java/io/opentelemetry/contrib/inferredspans/internal/ThreadMatcherTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright The OpenTelemetry Authors 3 | * SPDX-License-Identifier: Apache-2.0 4 | */ 5 | 6 | package io.opentelemetry.contrib.inferredspans.internal; 7 | 8 | import static org.assertj.core.api.Assertions.assertThat; 9 | 10 | import java.util.ArrayList; 11 | import java.util.Arrays; 12 | import java.util.List; 13 | import org.junit.jupiter.api.Test; 14 | 15 | class ThreadMatcherTest { 16 | 17 | private final ThreadMatcher threadMatcher = new ThreadMatcher(); 18 | 19 | @Test 20 | void testLookup() { 21 | ArrayList threads = new ArrayList<>(); 22 | threadMatcher.forEachThread( 23 | new ThreadMatcher.NonCapturingPredicate() { 24 | @Override 25 | public boolean test(Thread thread, Void state) { 26 | return thread.getId() == Thread.currentThread().getId(); 27 | } 28 | }, 29 | null, 30 | new ThreadMatcher.NonCapturingConsumer>() { 31 | @Override 32 | public void accept(Thread thread, List state) { 33 | state.add(thread); 34 | } 35 | }, 36 | threads); 37 | assertThat(threads).isEqualTo(Arrays.asList(Thread.currentThread())); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /inferred-spans/src/test/java/io/opentelemetry/contrib/inferredspans/internal/semconv/AttributesTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright The OpenTelemetry Authors 3 | * SPDX-License-Identifier: Apache-2.0 4 | */ 5 | 6 | package io.opentelemetry.contrib.inferredspans.internal.semconv; 7 | 8 | import static org.assertj.core.api.Assertions.assertThat; 9 | 10 | import io.opentelemetry.semconv.incubating.CodeIncubatingAttributes; 11 | import org.junit.jupiter.api.Test; 12 | 13 | public class AttributesTest { 14 | 15 | @Test 16 | public void checkCodeStacktraceUpToDate() { 17 | assertThat(Attributes.CODE_STACKTRACE).isEqualTo(CodeIncubatingAttributes.CODE_STACKTRACE); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /inferred-spans/src/test/java/io/opentelemetry/contrib/inferredspans/internal/util/AutoConfigTestProperties.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright The OpenTelemetry Authors 3 | * SPDX-License-Identifier: Apache-2.0 4 | */ 5 | 6 | package io.opentelemetry.contrib.inferredspans.internal.util; 7 | 8 | import com.google.errorprone.annotations.CanIgnoreReturnValue; 9 | import javax.annotation.Nullable; 10 | 11 | public class AutoConfigTestProperties extends TemporaryProperties { 12 | 13 | public AutoConfigTestProperties() { 14 | put("otel.java.global-autoconfigure.enabled", "true"); 15 | put("otel.traces.exporter", "logging"); 16 | put("otel.metrics.exporter", "logging"); 17 | put("otel.logs.exporter", "logging"); 18 | } 19 | 20 | @Override 21 | @CanIgnoreReturnValue 22 | public AutoConfigTestProperties put(String key, @Nullable String value) { 23 | super.put(key, value); 24 | return this; 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /inferred-spans/src/test/java/io/opentelemetry/contrib/inferredspans/internal/util/DisabledOnOpenJ9.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright The OpenTelemetry Authors 3 | * SPDX-License-Identifier: Apache-2.0 4 | */ 5 | 6 | package io.opentelemetry.contrib.inferredspans.internal.util; 7 | 8 | import java.lang.annotation.Documented; 9 | import java.lang.annotation.ElementType; 10 | import java.lang.annotation.Retention; 11 | import java.lang.annotation.RetentionPolicy; 12 | import java.lang.annotation.Target; 13 | import org.junit.jupiter.api.extension.ExtendWith; 14 | 15 | @Target({ElementType.TYPE, ElementType.METHOD}) 16 | @Retention(RetentionPolicy.RUNTIME) 17 | @Documented 18 | @ExtendWith(DisabledOnOpenJ9Condition.class) 19 | public @interface DisabledOnOpenJ9 { 20 | 21 | /** The reason this annotated test class or test method is disabled. */ 22 | String value() default ""; 23 | } 24 | -------------------------------------------------------------------------------- /inferred-spans/src/test/java/io/opentelemetry/contrib/inferredspans/internal/util/TemporaryProperties.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright The OpenTelemetry Authors 3 | * SPDX-License-Identifier: Apache-2.0 4 | */ 5 | 6 | package io.opentelemetry.contrib.inferredspans.internal.util; 7 | 8 | import com.google.errorprone.annotations.CanIgnoreReturnValue; 9 | import java.util.HashMap; 10 | import java.util.Map; 11 | import javax.annotation.Nullable; 12 | 13 | public class TemporaryProperties implements AutoCloseable { 14 | 15 | private final Map originalValues = new HashMap<>(); 16 | 17 | @CanIgnoreReturnValue 18 | public TemporaryProperties put(String key, @Nullable String value) { 19 | if (!originalValues.containsKey(key)) { 20 | originalValues.put(key, System.getProperty(key)); 21 | } 22 | if (value == null) { 23 | System.clearProperty(key); 24 | } else { 25 | System.setProperty(key, value); 26 | } 27 | return this; 28 | } 29 | 30 | @Override 31 | public void close() { 32 | for (String key : originalValues.keySet()) { 33 | String value = originalValues.get(key); 34 | if (value == null) { 35 | System.clearProperty(key); 36 | } else { 37 | System.setProperty(key, value); 38 | } 39 | } 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /inferred-spans/src/test/resources/logging.properties: -------------------------------------------------------------------------------- 1 | handlers=java.util.logging.ConsoleHandler 2 | .level=ALL 3 | java.util.logging.ConsoleHandler.level=ALL 4 | java.util.logging.ConsoleHandler.formatter=java.util.logging.SimpleFormatter 5 | -------------------------------------------------------------------------------- /inferred-spans/src/test/resources/recording.jfr: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/open-telemetry/opentelemetry-java-contrib/0a37bb9ed29bf9d8fea2d64114ddb2566b7aae80/inferred-spans/src/test/resources/recording.jfr -------------------------------------------------------------------------------- /jfr-connection/build.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | id("otel.java-conventions") 3 | id("otel.publish-conventions") 4 | } 5 | 6 | description = "OpenTelemetry JFR Connection" 7 | otelJava.moduleName.set("io.opentelemetry.contrib.jfr.connection") 8 | 9 | dependencies { 10 | testImplementation("org.openjdk.jmc:common:8.3.1") 11 | testImplementation("org.openjdk.jmc:flightrecorder:8.3.1") 12 | testImplementation("org.mockito:mockito-inline") 13 | } 14 | -------------------------------------------------------------------------------- /jfr-connection/src/main/java/io/opentelemetry/contrib/jfr/connection/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright The OpenTelemetry Authors 3 | * SPDX-License-Identifier: Apache-2.0 4 | */ 5 | 6 | /** 7 | * This package provides API for controlling Java Flight Recordings (JFR) through Java Management 8 | * Extensions (JMX). The main entry point is {@link 9 | * io.opentelemetry.contrib.jfr.connection.FlightRecorderConnection}. 10 | * 11 | *

JDK 9 introduced the {@code jdk.jfr} API which is not available in JDK 8. The {@code 12 | * jdk.management.jfr.FlightRecorderMXBean} is available in OpenJDK 8u262 and higher. By relying on 13 | * JMX and the {@code jdk.management.jfr.FlightRecorderMXBean}, the {@code 14 | * io.opentelemetry.contrib.jfr.connection} package provides access to JFR on local or remote JVMs. 15 | */ 16 | package io.opentelemetry.contrib.jfr.connection; 17 | -------------------------------------------------------------------------------- /jfr-connection/src/test/resources/brokenJfcFile.jfc: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | true 5 | everyChunk 6 | 7 | -------------------------------------------------------------------------------- /jfr-connection/src/test/resources/sampleJfcFile.jfc: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | true 5 | everyChunk 6 | 7 | 8 | -------------------------------------------------------------------------------- /jfr-events/README.md: -------------------------------------------------------------------------------- 1 | # OpenTelemetry Java Flight Recorder (JFR) Events 2 | 3 | Create JFR events that can be recorded and viewed in Java Mission Control (JMC). 4 | 5 | * Creates Open Telemetry Tracing/Span events for spans 6 | * The thread and stacktrace will be of the thead ending the span which might be different from the thread creating the span. 7 | * Has the fields 8 | * Operation Name 9 | * Trace ID 10 | * Parent Span ID 11 | * Span ID 12 | * Creates Open Telemetry Tracing/Scope events for scopes 13 | * Thread will match the thread the scope was active in and the stacktrace will be when scope was closed 14 | * Multiple scopes might be collected for a single span 15 | * Has the fields 16 | * Trace ID 17 | * Span ID 18 | * Supports the Open Source version of JFR in Java 11. 19 | * Might support back port to OpenJDK 8, but not tested and classes are built with JDK 11 bytecode. 20 | 21 | ## Component owners 22 | 23 | - [Staffan Friberg](https://github.com/sfriberg) 24 | 25 | Learn more about component owners in [component_owners.yml](../.github/component_owners.yml). 26 | -------------------------------------------------------------------------------- /jfr-events/build.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | id("otel.java-conventions") 3 | id("otel.publish-conventions") 4 | } 5 | 6 | description = "OpenTelemetry JFR Events" 7 | otelJava.moduleName.set("io.opentelemetry.contrib.jfrevent") 8 | 9 | dependencies { 10 | implementation("io.opentelemetry:opentelemetry-sdk") 11 | } 12 | 13 | tasks { 14 | withType(JavaCompile::class) { 15 | options.release.set(11) 16 | } 17 | 18 | test { 19 | val testJavaVersion: String? by project 20 | if (testJavaVersion == "8") { 21 | enabled = false 22 | } 23 | 24 | // Disabled due to https://bugs.openjdk.java.net/browse/JDK-8245283 25 | configure { 26 | enabled = false 27 | } 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /jfr-events/src/main/java/io/opentelemetry/contrib/jfrevent/JfrContextStorageWrapper.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright The OpenTelemetry Authors 3 | * SPDX-License-Identifier: Apache-2.0 4 | */ 5 | 6 | package io.opentelemetry.contrib.jfrevent; 7 | 8 | import io.opentelemetry.api.trace.Span; 9 | import io.opentelemetry.context.Context; 10 | import io.opentelemetry.context.ContextStorage; 11 | import io.opentelemetry.context.Scope; 12 | import javax.annotation.Nullable; 13 | 14 | public final class JfrContextStorageWrapper implements ContextStorage { 15 | 16 | private final ContextStorage wrapped; 17 | 18 | public JfrContextStorageWrapper(ContextStorage wrapped) { 19 | this.wrapped = wrapped; 20 | } 21 | 22 | @Override 23 | public Scope attach(Context toAttach) { 24 | Scope scope = wrapped.attach(toAttach); 25 | ScopeEvent event = new ScopeEvent(Span.fromContext(toAttach).getSpanContext()); 26 | event.begin(); 27 | return () -> { 28 | if (event.shouldCommit()) { 29 | event.commit(); 30 | } 31 | scope.close(); 32 | }; 33 | } 34 | 35 | @Override 36 | @Nullable 37 | public Context current() { 38 | return wrapped.current(); 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /jfr-events/src/main/java/io/opentelemetry/contrib/jfrevent/ScopeEvent.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright The OpenTelemetry Authors 3 | * SPDX-License-Identifier: Apache-2.0 4 | */ 5 | 6 | package io.opentelemetry.contrib.jfrevent; 7 | 8 | import io.opentelemetry.api.trace.SpanContext; 9 | import jdk.jfr.Category; 10 | import jdk.jfr.Description; 11 | import jdk.jfr.Event; 12 | import jdk.jfr.Label; 13 | import jdk.jfr.Name; 14 | 15 | @Name("io.opentelemetry.context.Scope") 16 | @Label("Scope") 17 | @Category("Open Telemetry Tracing") 18 | @Description( 19 | "Open Telemetry trace event corresponding to the span currently " 20 | + "in scope/active on this thread.") 21 | class ScopeEvent extends Event { 22 | 23 | private final String traceId; 24 | private final String spanId; 25 | 26 | ScopeEvent(SpanContext spanContext) { 27 | this.traceId = spanContext.getTraceId(); 28 | this.spanId = spanContext.getSpanId(); 29 | } 30 | 31 | @Label("Trace Id") 32 | public String getTraceId() { 33 | return traceId; 34 | } 35 | 36 | @Label("Span Id") 37 | public String getSpanId() { 38 | return spanId; 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /jfr-events/src/main/java/io/opentelemetry/contrib/jfrevent/SpanEvent.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright The OpenTelemetry Authors 3 | * SPDX-License-Identifier: Apache-2.0 4 | */ 5 | 6 | package io.opentelemetry.contrib.jfrevent; 7 | 8 | import io.opentelemetry.sdk.trace.data.SpanData; 9 | import jdk.jfr.Category; 10 | import jdk.jfr.Description; 11 | import jdk.jfr.Event; 12 | import jdk.jfr.Label; 13 | import jdk.jfr.Name; 14 | 15 | @Label("Span") 16 | @Name("io.opentelemetry.trace.Span") 17 | @Category("Open Telemetry Tracing") 18 | @Description("Open Telemetry trace event corresponding to a span.") 19 | class SpanEvent extends Event { 20 | 21 | private final String operationName; 22 | private final String traceId; 23 | private final String spanId; 24 | private final String parentId; 25 | 26 | SpanEvent(SpanData spanData) { 27 | this.operationName = spanData.getName(); 28 | this.traceId = spanData.getTraceId(); 29 | this.spanId = spanData.getSpanId(); 30 | this.parentId = spanData.getParentSpanId(); 31 | } 32 | 33 | @Label("Operation Name") 34 | public String getOperationName() { 35 | return operationName; 36 | } 37 | 38 | @Label("Trace Id") 39 | public String getTraceId() { 40 | return traceId; 41 | } 42 | 43 | @Label("Span Id") 44 | public String getSpanId() { 45 | return spanId; 46 | } 47 | 48 | @Label("Parent Id") 49 | public String getParentId() { 50 | return parentId; 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /jfr-events/src/main/java/io/opentelemetry/contrib/jfrevent/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright The OpenTelemetry Authors 3 | * SPDX-License-Identifier: Apache-2.0 4 | */ 5 | 6 | /** 7 | * Capture Spans and Scopes as events in JFR recordings. 8 | * 9 | * @see io.opentelemetry.contrib.jfrevent.JfrSpanProcessor 10 | */ 11 | @ParametersAreNonnullByDefault 12 | package io.opentelemetry.contrib.jfrevent; 13 | 14 | import javax.annotation.ParametersAreNonnullByDefault; 15 | -------------------------------------------------------------------------------- /jmx-metrics/docs/target-systems/jetty.md: -------------------------------------------------------------------------------- 1 | # Jetty Metrics 2 | 3 | The JMX Metric Gatherer provides built in Jetty metric gathering capabilities. 4 | Details about using JMX with WildFly can be found here: https://www.eclipse.org/jetty/documentation/jetty-11/operations-guide/index.html#og-jmx 5 | 6 | ### Metrics 7 | * Name: `jetty.select.count` 8 | * Description: The number of select calls. 9 | * Unit: `{operations}` 10 | * Instrument Type: longCounterCallback 11 | 12 | 13 | * Name: `jetty.session.count` 14 | * Description: The number of sessions created. 15 | * Unit: `{sessions}` 16 | * Instrument Type: LongCounterCallback 17 | 18 | 19 | * Name: `jetty.session.time.total` 20 | * Description: The total time sessions have been active. 21 | * Unit: `s` 22 | * Instrument Type: longUpDownCounterCallback 23 | 24 | 25 | * Name: `jetty.session.time.max` 26 | * Description: The maximum amount of time a session has been active. 27 | * Unit: `s` 28 | * Instrument Type: longValueCallback 29 | 30 | 31 | * Name: `jetty.thread.count` 32 | * Description: The current number of threads. 33 | * Unit: `{threads}` 34 | * Labels: `state` 35 | * Instrument Type: longValueCallback 36 | 37 | 38 | * Name: `jetty.thread.queue.count` 39 | * Description: The current number of threads in the queue. 40 | * Unit: `{threads}` 41 | * Instrument Type: longValueCallback 42 | -------------------------------------------------------------------------------- /jmx-metrics/src/integrationTest/resources/activemq/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM rmohr/activemq:5.15.9@sha256:b5669f141ac5c455b1010b90d348fe78289bba7e2db5659484d99736b696593c 2 | 3 | 4 | COPY --chown=activemq config/env /opt/activemq/bin/env 5 | ENV ACTIVEMQ_JMX=10991 6 | EXPOSE $ACTIVEMQ_JMX 7 | 8 | ENV ACTIVEMQ_JMX_OPTS="-Dcom.sun.management.jmxremote.port=10991 -Dcom.sun.management.jmxremote.rmi.port=10991 -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.authenticate=false" 9 | -------------------------------------------------------------------------------- /jmx-metrics/src/integrationTest/resources/cassandra/jmxremote.password: -------------------------------------------------------------------------------- 1 | cassandra cassandra -------------------------------------------------------------------------------- /jmx-metrics/src/integrationTest/resources/hadoop/yarn-site.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | yarn.nodemanager.aux-services 5 | mapreduce_shuffle 6 | 7 | 8 | yarn.nodemanager.disk-health-checker.max-disk-utilization-per-disk-percentage 9 | 100 10 | 11 | 12 | yarn.nodemanager.resource.cpu-vcores 13 | 2 14 | 15 | 16 | yarn.nodemanager.resource.memory-mb 17 | 4096 18 | 19 | 20 | -------------------------------------------------------------------------------- /jmx-metrics/src/integrationTest/resources/hbase/hbase-env.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Set environment variables here. 4 | 5 | # This script sets variables multiple times over the course of starting an hbase process, 6 | # so try to keep things idempotent unless you want to take an even deeper look 7 | # into the startup scripts (bin/hbase, etc.) 8 | 9 | # The java implementation to use. Java 1.8+ required. 10 | export JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64 11 | export HBASE_OPTS="$HBASE_OPTS -XX:+UseConcMarkSweepGC" 12 | export HBASE_JMX_BASE="-Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.authenticate=false" 13 | export HBASE_MASTER_OPTS="$HBASE_MASTER_OPTS $HBASE_JMX_BASE -Dcom.sun.management.jmxremote.rmi.port=9900 -Dcom.sun.management.jmxremote.port=9900" 14 | -------------------------------------------------------------------------------- /jmx-metrics/src/integrationTest/resources/otlp_config.properties: -------------------------------------------------------------------------------- 1 | otel.jmx.interval.milliseconds = 3000 2 | otel.metrics.exporter = otlp 3 | otel.jmx.service.url = service:jmx:rmi:///jndi/rmi://cassandra:7199/jmxrmi 4 | otel.jmx.groovy.script = /app/script.groovy 5 | 6 | # these will be overridden by cmd line 7 | otel.jmx.username = wrong_username 8 | otel.jmx.password = wrong_password 9 | otel.exporter.otlp.endpoint = http://host.testcontainers.internal 10 | -------------------------------------------------------------------------------- /jmx-metrics/src/integrationTest/resources/script.groovy: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright The OpenTelemetry Authors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | import io.opentelemetry.api.common.Attributes 18 | 19 | def loadMatches = otel.queryJmx("org.apache.cassandra.metrics:type=Storage,name=Load") 20 | if (!loadMatches.isEmpty()) { 21 | def load = loadMatches.first() 22 | 23 | def lvr = otel.longHistogram( 24 | "cassandra.storage.load", 25 | "Size, in bytes, of the on disk data size this node manages", 26 | "By" 27 | ) 28 | lvr.record(load.Count, Attributes.builder().put("myKey", "myVal").build()) 29 | } 30 | -------------------------------------------------------------------------------- /jmx-metrics/src/integrationTest/resources/target-systems/activemq.properties: -------------------------------------------------------------------------------- 1 | otel.jmx.interval.milliseconds = 3000 2 | otel.metrics.exporter = otlp 3 | otel.jmx.service.url = service:jmx:rmi:///jndi/rmi://activemq:10991/jmxrmi 4 | otel.jmx.target.system = activemq 5 | 6 | # these will be overridden by cmd line 7 | otel.exporter.otlp.endpoint = http://host.testcontainers.internal 8 | -------------------------------------------------------------------------------- /jmx-metrics/src/integrationTest/resources/target-systems/cassandra.properties: -------------------------------------------------------------------------------- 1 | otel.jmx.interval.milliseconds = 3000 2 | otel.metrics.exporter = otlp 3 | otel.jmx.service.url = service:jmx:rmi:///jndi/rmi://cassandra:7199/jmxrmi 4 | otel.jmx.target.system = cassandra 5 | 6 | # these will be overridden by cmd line 7 | otel.jmx.username = wrong_username 8 | otel.jmx.password = wrong_password 9 | otel.exporter.otlp.endpoint = http://host.testcontainers.internal 10 | -------------------------------------------------------------------------------- /jmx-metrics/src/integrationTest/resources/target-systems/hadoop.properties: -------------------------------------------------------------------------------- 1 | otel.jmx.interval.milliseconds = 3000 2 | otel.metrics.exporter = otlp 3 | otel.jmx.service.url = service:jmx:rmi:///jndi/rmi://hadoop:8004/jmxrmi 4 | otel.jmx.target.system = hadoop 5 | 6 | # these will be overridden by cmd line 7 | otel.exporter.otlp.endpoint = http://host.testcontainers.internal 8 | -------------------------------------------------------------------------------- /jmx-metrics/src/integrationTest/resources/target-systems/hbase.properties: -------------------------------------------------------------------------------- 1 | otel.jmx.interval.milliseconds = 3000 2 | otel.metrics.exporter = otlp 3 | otel.jmx.service.url = service:jmx:rmi:///jndi/rmi://hbase:9900/jmxrmi 4 | otel.jmx.target.system = hbase 5 | 6 | # these will be overridden by cmd line 7 | otel.exporter.otlp.endpoint = http://host.testcontainers.internal 8 | -------------------------------------------------------------------------------- /jmx-metrics/src/integrationTest/resources/target-systems/jetty.properties: -------------------------------------------------------------------------------- 1 | otel.jmx.interval.milliseconds = 3000 2 | otel.metrics.exporter = otlp 3 | otel.jmx.service.url = service:jmx:rmi:///jndi/rmi://jetty:1099/jmxrmi 4 | otel.jmx.target.system = jetty 5 | 6 | # these will be overridden by cmd line 7 | otel.exporter.otlp.endpoint = http://host.testcontainers.internal 8 | -------------------------------------------------------------------------------- /jmx-metrics/src/integrationTest/resources/target-systems/jvm-and-kafka.properties: -------------------------------------------------------------------------------- 1 | otel.jmx.interval.milliseconds = 3000 2 | otel.metrics.exporter = otlp 3 | otel.jmx.service.url = service:jmx:rmi:///jndi/rmi://kafka:7199/jmxrmi 4 | otel.jmx.target.system = jvm,kafka 5 | 6 | # these will be overridden by cmd line 7 | otel.jmx.username = wrong_username 8 | otel.jmx.password = wrong_password 9 | otel.exporter.otlp.endpoint = http://host.testcontainers.internal 10 | -------------------------------------------------------------------------------- /jmx-metrics/src/integrationTest/resources/target-systems/jvm.properties: -------------------------------------------------------------------------------- 1 | otel.jmx.interval.milliseconds = 3000 2 | otel.metrics.exporter = otlp 3 | otel.jmx.service.url = service:jmx:rmi:///jndi/rmi://cassandra:7199/jmxrmi 4 | otel.jmx.target.system = jvm 5 | 6 | # these will be overridden by cmd line 7 | otel.jmx.username = wrong_username 8 | otel.jmx.password = wrong_password 9 | otel.exporter.otlp.endpoint = http://host.testcontainers.internal 10 | -------------------------------------------------------------------------------- /jmx-metrics/src/integrationTest/resources/target-systems/kafka-consumer.properties: -------------------------------------------------------------------------------- 1 | otel.jmx.interval.milliseconds = 3000 2 | otel.metrics.exporter = otlp 3 | otel.jmx.service.url = service:jmx:rmi:///jndi/rmi://kafka-consumer:7199/jmxrmi 4 | otel.jmx.target.system = kafka-consumer 5 | 6 | # these will be overridden by cmd line 7 | otel.jmx.username = wrong_username 8 | otel.jmx.password = wrong_password 9 | otel.exporter.otlp.endpoint = http://host.testcontainers.internal 10 | -------------------------------------------------------------------------------- /jmx-metrics/src/integrationTest/resources/target-systems/kafka-producer.properties: -------------------------------------------------------------------------------- 1 | otel.jmx.interval.milliseconds = 3000 2 | otel.metrics.exporter = otlp 3 | otel.jmx.service.url = service:jmx:rmi:///jndi/rmi://kafka-producer:7199/jmxrmi 4 | otel.jmx.target.system = kafka-producer 5 | 6 | # these will be overridden by cmd line 7 | otel.jmx.username = wrong_username 8 | otel.jmx.password = wrong_password 9 | otel.exporter.otlp.endpoint = http://host.testcontainers.internal 10 | -------------------------------------------------------------------------------- /jmx-metrics/src/integrationTest/resources/target-systems/kafka-producer.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | function msg() { 4 | while true; do 5 | echo 'some message' 6 | sleep .25 7 | done 8 | } 9 | 10 | msg | kafka-console-producer.sh --bootstrap-server kafka:9092 --topic test-topic-1 11 | -------------------------------------------------------------------------------- /jmx-metrics/src/integrationTest/resources/target-systems/kafka.properties: -------------------------------------------------------------------------------- 1 | otel.jmx.interval.milliseconds = 3000 2 | otel.metrics.exporter = otlp 3 | otel.jmx.service.url = service:jmx:rmi:///jndi/rmi://kafka:7199/jmxrmi 4 | otel.jmx.target.system = kafka 5 | 6 | # these will be overridden by cmd line 7 | otel.jmx.username = wrong_username 8 | otel.jmx.password = wrong_password 9 | otel.exporter.otlp.endpoint = http://host.testcontainers.internal 10 | -------------------------------------------------------------------------------- /jmx-metrics/src/integrationTest/resources/target-systems/solr.properties: -------------------------------------------------------------------------------- 1 | otel.jmx.interval.milliseconds = 3000 2 | otel.metrics.exporter = otlp 3 | otel.jmx.service.url = service:jmx:rmi:///jndi/rmi://solr:9990/jmxrmi 4 | otel.jmx.target.system = solr 5 | 6 | # these will be overridden by cmd line 7 | otel.exporter.otlp.endpoint = http://host.testcontainers.internal 8 | -------------------------------------------------------------------------------- /jmx-metrics/src/integrationTest/resources/target-systems/tomcat.properties: -------------------------------------------------------------------------------- 1 | otel.jmx.interval.milliseconds = 3000 2 | otel.metrics.exporter = otlp 3 | otel.jmx.service.url = service:jmx:rmi:///jndi/rmi://tomcat:9010/jmxrmi 4 | otel.jmx.target.system = tomcat 5 | 6 | # these will be overridden by cmd line 7 | otel.jmx.username = wrong_username 8 | otel.jmx.password = wrong_password 9 | otel.exporter.otlp.endpoint = http://host.testcontainers.internal 10 | -------------------------------------------------------------------------------- /jmx-metrics/src/integrationTest/resources/target-systems/wildfly.properties: -------------------------------------------------------------------------------- 1 | otel.jmx.interval.milliseconds = 3000 2 | otel.metrics.exporter = otlp 3 | otel.jmx.service.url = service:jmx:remote+http://wildfly:9990 4 | otel.jmx.target.system = wildfly 5 | -------------------------------------------------------------------------------- /jmx-metrics/src/integrationTest/resources/wildfly/start.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | /opt/jboss/wildfly/bin/standalone.sh -b 0.0.0.0 -bmanagement 0.0.0.0 & \ 4 | 5 | /opt/jboss/wildfly/bin/add-user.sh user password --silent & \ 6 | 7 | java -cp /app/OpenTelemetryJMXMetrics.jar:/opt/jboss/wildfly/bin/client/jboss-client.jar \ 8 | -Dotel.jmx.username=user -Dotel.jmx.password=password \ 9 | -Dotel.exporter.otlp.endpoint="$OTLP_ENDPOINT" \ 10 | io.opentelemetry.contrib.jmxmetrics.JmxMetrics -config /app/target-systems/wildfly.properties 11 | -------------------------------------------------------------------------------- /jmx-metrics/src/main/groovy/io/opentelemetry/contrib/jmxmetrics/ConfigurationException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright The OpenTelemetry Authors 3 | * SPDX-License-Identifier: Apache-2.0 4 | */ 5 | 6 | package io.opentelemetry.contrib.jmxmetrics; 7 | 8 | public class ConfigurationException extends RuntimeException { 9 | private static final long serialVersionUID = 0L; 10 | 11 | public ConfigurationException(final String message, final Throwable cause) { 12 | super(message, cause); 13 | } 14 | 15 | public ConfigurationException(final String message) { 16 | super(message); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /jmx-metrics/src/main/java/io/opentelemetry/contrib/jmxmetrics/InstrumentDescriptor.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright The OpenTelemetry Authors 3 | * SPDX-License-Identifier: Apache-2.0 4 | */ 5 | 6 | package io.opentelemetry.contrib.jmxmetrics; 7 | 8 | import com.google.auto.value.AutoValue; 9 | import io.opentelemetry.sdk.metrics.InstrumentType; 10 | import io.opentelemetry.sdk.metrics.InstrumentValueType; 11 | 12 | @AutoValue 13 | abstract class InstrumentDescriptor { 14 | 15 | static InstrumentDescriptor create( 16 | String name, 17 | String description, 18 | String unit, 19 | InstrumentType instrumentType, 20 | InstrumentValueType valueType) { 21 | return new AutoValue_InstrumentDescriptor(name, description, unit, instrumentType, valueType); 22 | } 23 | 24 | abstract String getName(); 25 | 26 | abstract String getDescription(); 27 | 28 | abstract String getUnit(); 29 | 30 | abstract InstrumentType getInstrumentType(); 31 | 32 | abstract InstrumentValueType getValueType(); 33 | } 34 | -------------------------------------------------------------------------------- /jmx-metrics/src/test/resources/all.properties: -------------------------------------------------------------------------------- 1 | otel.jmx.service.url=service:jmx:rmi:///jndi/rmi://myhost:12345/jmxrmi 2 | otel.jmx.groovy.script=/my/groovy/script 3 | otel.jmx.target.system=jvm,cassandra 4 | otel.jmx.interval.milliseconds=20000 5 | otel.metrics.exporter=otlp 6 | otel.metric.export.interval=1000 7 | otel.exporter.otlp.endpoint=https://myotlpendpoint 8 | otel.exporter.prometheus.host=host123.domain.com 9 | otel.exporter.prometheus.port=67890 10 | otel.jmx.username=myUser\n\ 11 | name 12 | otel.jmx.password=myPassw\\ord 13 | otel.jmx.remote.profile=SASL/DIG\EST-MD5 14 | otel.jmx.realm=myRealm 15 | otel.resource.attributes=one=two,three=four 16 | javax.net.ssl.keyStore=/my/key/store 17 | javax.net.ssl.keyStorePassword=abc123 18 | javax.net.ssl.keyStoreType=JKS 19 | javax.net.ssl.trustStore=/my/trust/store 20 | javax.net.ssl.trustStorePassword=def456 21 | javax.net.ssl.trustStoreType=JKS 22 | otel.jmx.aggregate.across.mbeans=true 23 | -------------------------------------------------------------------------------- /jmx-metrics/src/test/resources/jmxremote.password: -------------------------------------------------------------------------------- 1 | correctUsername correctPassword 2 | -------------------------------------------------------------------------------- /jmx-scraper/src/integrationTest/java/io/opentelemetry/contrib/jmxscraper/assertions/Assertions.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright The OpenTelemetry Authors 3 | * SPDX-License-Identifier: Apache-2.0 4 | */ 5 | 6 | package io.opentelemetry.contrib.jmxscraper.assertions; 7 | 8 | import io.opentelemetry.proto.metrics.v1.Metric; 9 | 10 | /** Dedicated Assertj extension to provide convenient fluent API for metrics testing */ 11 | public class Assertions extends org.assertj.core.api.Assertions { 12 | 13 | public static MetricAssert assertThat(Metric metric) { 14 | return new MetricAssert(metric); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /jmx-scraper/src/integrationTest/resources/custom-metrics.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | 3 | rules: 4 | 5 | - bean: java.lang:type=Runtime 6 | mapping: 7 | Uptime: 8 | metric: custom.jvm.uptime 9 | type: counter 10 | unit: ms 11 | desc: JVM uptime in milliseconds 12 | -------------------------------------------------------------------------------- /jmx-scraper/src/main/java/io/opentelemetry/contrib/jmxscraper/InvalidArgumentException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright The OpenTelemetry Authors 3 | * SPDX-License-Identifier: Apache-2.0 4 | */ 5 | 6 | package io.opentelemetry.contrib.jmxscraper; 7 | 8 | /** 9 | * Exception indicating something is wrong with the provided arguments or reading the configuration 10 | * from them 11 | */ 12 | public class InvalidArgumentException extends Exception { 13 | 14 | private static final long serialVersionUID = 0L; 15 | 16 | public InvalidArgumentException(String msg) { 17 | super(msg); 18 | } 19 | 20 | public InvalidArgumentException(String msg, Throwable cause) { 21 | super(msg, cause); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /jmx-scraper/src/main/java/io/opentelemetry/contrib/jmxscraper/config/PropertiesSupplier.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright The OpenTelemetry Authors 3 | * SPDX-License-Identifier: Apache-2.0 4 | */ 5 | 6 | package io.opentelemetry.contrib.jmxscraper.config; 7 | 8 | import java.util.HashMap; 9 | import java.util.Map; 10 | import java.util.Properties; 11 | import java.util.function.Supplier; 12 | 13 | /** Configuration supplier for java properties */ 14 | public class PropertiesSupplier implements Supplier> { 15 | 16 | private final Properties properties; 17 | 18 | public PropertiesSupplier(Properties properties) { 19 | this.properties = properties; 20 | } 21 | 22 | @Override 23 | public Map get() { 24 | Map map = new HashMap<>(); 25 | properties.forEach((k, v) -> map.put((String) k, (String) v)); 26 | return map; 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /jmx-scraper/src/test/java/io/opentelemetry/contrib/jmxscraper/config/PropertiesSupplierTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright The OpenTelemetry Authors 3 | * SPDX-License-Identifier: Apache-2.0 4 | */ 5 | 6 | package io.opentelemetry.contrib.jmxscraper.config; 7 | 8 | import static org.assertj.core.api.Assertions.assertThat; 9 | 10 | import java.util.Properties; 11 | import org.junit.jupiter.api.Test; 12 | 13 | class PropertiesSupplierTest { 14 | 15 | @Test 16 | void empty() { 17 | PropertiesSupplier supplier = new PropertiesSupplier(new Properties()); 18 | assertThat(supplier.get()).isEmpty(); 19 | } 20 | 21 | @Test 22 | void someValues() { 23 | Properties properties = new Properties(); 24 | properties.setProperty("foo", "bar"); 25 | properties.setProperty("hello", "world"); 26 | PropertiesSupplier supplier = new PropertiesSupplier(properties); 27 | assertThat(supplier.get()) 28 | .hasSize(2) 29 | .containsEntry("foo", "bar") 30 | .containsEntry("hello", "world"); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /jmx-scraper/src/test/java/io/opentelemetry/contrib/jmxscraper/config/TestUtil.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright The OpenTelemetry Authors 3 | * SPDX-License-Identifier: Apache-2.0 4 | */ 5 | 6 | package io.opentelemetry.contrib.jmxscraper.config; 7 | 8 | import io.opentelemetry.sdk.autoconfigure.spi.ConfigProperties; 9 | import io.opentelemetry.sdk.autoconfigure.spi.internal.DefaultConfigProperties; 10 | import java.util.HashMap; 11 | import java.util.Map; 12 | import java.util.Properties; 13 | 14 | public class TestUtil { 15 | 16 | private TestUtil() {} 17 | 18 | public static ConfigProperties configProperties(Properties properties) { 19 | Map map = new HashMap<>(); 20 | properties.forEach((k, v) -> map.put((String) k, (String) v)); 21 | return DefaultConfigProperties.createFromMap(map); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /jmx-scraper/src/test/resources/fake-test-system-both.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | # test system 1 that is in the same location as legacy yaml files 3 | rules: 4 | 5 | - bean: java.lang:type=Runtime 6 | mapping: 7 | Uptime: 8 | metric: custom.jvm.uptime 9 | type: counter 10 | unit: ms 11 | desc: JVM uptime in milliseconds 12 | -------------------------------------------------------------------------------- /jmx-scraper/src/test/resources/fake-test-system-legacy-only.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | # test system 2 that is in the same location as legacy yaml files and is not suppored in instrumentation 3 | rules: 4 | 5 | - bean: java.lang:type=Runtime 6 | mapping: 7 | Uptime: 8 | metric: custom.jvm.uptime 9 | type: counter 10 | unit: ms 11 | desc: JVM uptime in milliseconds 12 | -------------------------------------------------------------------------------- /jmx-scraper/src/test/resources/jmx/rules/fake-test-system-both.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | # test system 1 that is in the same location as instrumentation yaml files 3 | rules: 4 | 5 | - bean: java.lang:type=Runtime 6 | mapping: 7 | Uptime: 8 | metric: custom.jvm.uptime 9 | type: counter 10 | unit: ms 11 | desc: JVM uptime in milliseconds 12 | -------------------------------------------------------------------------------- /jmx-scraper/src/test/resources/jmx/rules/fake-test-system-instrumentation-only.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | # test system 3 that is in the same location as instrumentation yaml files and is NOT defined in legacy 3 | rules: 4 | 5 | - bean: java.lang:type=Runtime 6 | mapping: 7 | Uptime: 8 | metric: custom.jvm.uptime 9 | type: counter 10 | unit: ms 11 | desc: JVM uptime in milliseconds 12 | -------------------------------------------------------------------------------- /jmx-scraper/src/test/resources/validConfig.properties: -------------------------------------------------------------------------------- 1 | otel.jmx.service.url=service:jmx:rmi:///jndi/rmi://myhost:12345/jmxrmi 2 | otel.jmx.config=/my/scraping-config.yaml 3 | otel.jmx.target.system=jvm,cassandra 4 | otel.metrics.exporter=otlp 5 | otel.metric.export.interval=1000 6 | otel.exporter.otlp.endpoint=https://myotlpendpoint 7 | otel.jmx.username=myUser\n\ 8 | name 9 | otel.jmx.password=myPassw\\ord 10 | otel.jmx.remote.profile=SASL/DIG\EST-MD5 11 | otel.jmx.realm=myRealm 12 | otel.resource.attributes=one=two,three=four 13 | javax.net.ssl.keyStore=/my/key/store 14 | javax.net.ssl.keyStorePassword=abc123 15 | javax.net.ssl.keyStoreType=JKS 16 | javax.net.ssl.trustStore=/my/trust/store 17 | javax.net.ssl.trustStorePassword=def456 18 | javax.net.ssl.trustStoreType=JKS 19 | -------------------------------------------------------------------------------- /jmx-scraper/test-app/README.md: -------------------------------------------------------------------------------- 1 | # test-app 2 | 3 | This is a test CLI application that is only used for integration tests. 4 | The goal of this application is to publish custom MBeans in JMX and then allow end-to-end testing. 5 | -------------------------------------------------------------------------------- /jmx-scraper/test-app/build.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | id("otel.java-conventions") 3 | 4 | application 5 | } 6 | 7 | description = "JMX metrics scraper - test application" 8 | 9 | tasks { 10 | jar { 11 | manifest { 12 | attributes["Main-Class"] = "io.opentelemetry.contrib.jmxscraper.testapp.TestApp" 13 | } 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /jmx-scraper/test-app/src/main/java/io/opentelemetry/contrib/jmxscraper/testapp/TestAppMxBean.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright The OpenTelemetry Authors 3 | * SPDX-License-Identifier: Apache-2.0 4 | */ 5 | 6 | package io.opentelemetry.contrib.jmxscraper.testapp; 7 | 8 | import javax.management.MXBean; 9 | 10 | @MXBean 11 | @SuppressWarnings("unused") 12 | public interface TestAppMxBean { 13 | 14 | int getIntValue(); 15 | 16 | void stopApp(); 17 | } 18 | -------------------------------------------------------------------------------- /jmx-scraper/test-webapp/README.md: -------------------------------------------------------------------------------- 1 | # test-webapp 2 | 3 | This is a test web application that is only used for integration tests when metrics are published 4 | only when an application is deployed to the container, for example with Wildfly session metrics. 5 | -------------------------------------------------------------------------------- /jmx-scraper/test-webapp/build.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | id("otel.java-conventions") 3 | 4 | war 5 | } 6 | 7 | description = "JMX metrics scraper - test web application" 8 | 9 | dependencies { 10 | compileOnly("jakarta.servlet:jakarta.servlet-api:5.0.0") 11 | } 12 | -------------------------------------------------------------------------------- /jmx-scraper/test-webapp/src/main/java/io/opentelemetry/contrib/jmxscraper/testwebapp/SimpleServlet.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright The OpenTelemetry Authors 3 | * SPDX-License-Identifier: Apache-2.0 4 | */ 5 | 6 | package io.opentelemetry.contrib.jmxscraper.testwebapp; 7 | 8 | import jakarta.servlet.http.HttpServlet; 9 | import jakarta.servlet.http.HttpServletRequest; 10 | import jakarta.servlet.http.HttpServletResponse; 11 | import java.io.IOException; 12 | import java.io.PrintWriter; 13 | 14 | public class SimpleServlet extends HttpServlet { 15 | 16 | private static final long serialVersionUID = 3726145372238690099L; 17 | 18 | @Override 19 | protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws IOException { 20 | try (PrintWriter out = resp.getWriter()) { 21 | out.write("hello!"); 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /jmx-scraper/test-webapp/src/main/webapp/WEB-INF/web.xml: -------------------------------------------------------------------------------- 1 | 6 | 7 | servlet_name 8 | io.opentelemetry.contrib.jmxscraper.testwebapp.SimpleServlet 9 | 10 | 11 | servlet_name 12 | /* 13 | 14 | 15 | -------------------------------------------------------------------------------- /kafka-exporter/README.md: -------------------------------------------------------------------------------- 1 | # Exporting SpanData to Kafka 2 | 3 | This module contains `KafkaSpanExporter`, which is an implementation of the `io.opentelemetry.sdk.trace.export.SpanExporter` interface. 4 | 5 | `KafkaSpanExporter` can be used for sending `SpanData` to a Kafka topic. 6 | 7 | ## Usage 8 | 9 | In order to instantiate a `KafkaSpanExporter`, you either need to pass a Kafka `Producer` or the configuration of a Kafka `Producer` together with key and value serializers. 10 | You also need to pass the topic to which the SpanData need to be sent. 11 | For a sample usage, see `KafkaSpanExporterIntegrationTest`. 12 | 13 | ## Component owners 14 | 15 | - [Alessandro Vermeulen](https://github.com/spockz) 16 | - [Vincent Free](https://github.com/vincentfree) 17 | 18 | Learn more about component owners in [component_owners.yml](../.github/component_owners.yml). 19 | -------------------------------------------------------------------------------- /kafka-exporter/src/main/java/io/opentelemetry/contrib/kafka/SpanDataDeserializer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright The OpenTelemetry Authors 3 | * SPDX-License-Identifier: Apache-2.0 4 | */ 5 | 6 | package io.opentelemetry.contrib.kafka; 7 | 8 | import com.google.protobuf.InvalidProtocolBufferException; 9 | import io.opentelemetry.proto.collector.trace.v1.ExportTraceServiceRequest; 10 | import java.util.Objects; 11 | import org.apache.kafka.common.errors.SerializationException; 12 | import org.apache.kafka.common.serialization.Deserializer; 13 | 14 | public class SpanDataDeserializer implements Deserializer { 15 | @SuppressWarnings("NullAway") 16 | @Override 17 | public ExportTraceServiceRequest deserialize(String topic, byte[] data) { 18 | if (Objects.isNull(data)) { 19 | return null; 20 | } 21 | try { 22 | return ExportTraceServiceRequest.parseFrom(data); 23 | } catch (InvalidProtocolBufferException e) { 24 | throw new SerializationException("Error while deserializing data", e); 25 | } 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /kafka-exporter/src/test/java/io/opentelemetry/contrib/kafka/TestUtil.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright The OpenTelemetry Authors 3 | * SPDX-License-Identifier: Apache-2.0 4 | */ 5 | 6 | package io.opentelemetry.contrib.kafka; 7 | 8 | import io.opentelemetry.api.trace.SpanContext; 9 | import io.opentelemetry.api.trace.SpanKind; 10 | import io.opentelemetry.sdk.testing.trace.TestSpanData; 11 | import io.opentelemetry.sdk.trace.data.SpanData; 12 | import io.opentelemetry.sdk.trace.data.StatusData; 13 | import java.util.concurrent.TimeUnit; 14 | 15 | public class TestUtil { 16 | private TestUtil() {} 17 | 18 | public static SpanData makeBasicSpan(String spanName) { 19 | return TestSpanData.builder() 20 | .setHasEnded(true) 21 | .setSpanContext(SpanContext.getInvalid()) 22 | .setName(spanName) 23 | .setKind(SpanKind.SERVER) 24 | .setStartEpochNanos(TimeUnit.SECONDS.toNanos(100) + 100) 25 | .setStatus(StatusData.ok()) 26 | .setEndEpochNanos(TimeUnit.SECONDS.toNanos(200) + 200) 27 | .setTotalRecordedLinks(0) 28 | .setTotalRecordedEvents(0) 29 | .build(); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /maven-extension/docs/images/jenkins-maven-execution-trace-jaeger.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/open-telemetry/opentelemetry-java-contrib/0a37bb9ed29bf9d8fea2d64114ddb2566b7aae80/maven-extension/docs/images/jenkins-maven-execution-trace-jaeger.png -------------------------------------------------------------------------------- /maven-extension/docs/images/maven-execution-trace-jaeger.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/open-telemetry/opentelemetry-java-contrib/0a37bb9ed29bf9d8fea2d64114ddb2566b7aae80/maven-extension/docs/images/maven-execution-trace-jaeger.png -------------------------------------------------------------------------------- /maven-extension/src/main/java/io/opentelemetry/maven/AutoConfigureUtil2.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright The OpenTelemetry Authors 3 | * SPDX-License-Identifier: Apache-2.0 4 | */ 5 | 6 | package io.opentelemetry.maven; 7 | 8 | import io.opentelemetry.sdk.autoconfigure.AutoConfiguredOpenTelemetrySdk; 9 | import io.opentelemetry.sdk.resources.Resource; 10 | import java.lang.reflect.InvocationTargetException; 11 | import java.lang.reflect.Method; 12 | 13 | /** Utility class to use the {@link AutoConfiguredOpenTelemetrySdk}. */ 14 | public class AutoConfigureUtil2 { 15 | 16 | private AutoConfigureUtil2() {} 17 | 18 | /** 19 | * Returns the {@link Resource} that was autoconfigured. 20 | * 21 | *

Inspired by {@link 22 | * io.opentelemetry.sdk.autoconfigure.internal.AutoConfigureUtil#getConfig(AutoConfiguredOpenTelemetrySdk)} 23 | */ 24 | public static Resource getResource( 25 | AutoConfiguredOpenTelemetrySdk autoConfiguredOpenTelemetrySdk) { 26 | try { 27 | Method method = AutoConfiguredOpenTelemetrySdk.class.getDeclaredMethod("getResource"); 28 | method.setAccessible(true); 29 | return (Resource) method.invoke(autoConfiguredOpenTelemetrySdk); 30 | } catch (NoSuchMethodException | InvocationTargetException | IllegalAccessException e) { 31 | throw new IllegalStateException( 32 | "Error calling getResource on AutoConfiguredOpenTelemetrySdk", e); 33 | } 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /maven-extension/src/main/java/io/opentelemetry/maven/MavenGoal.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright The OpenTelemetry Authors 3 | * SPDX-License-Identifier: Apache-2.0 4 | */ 5 | 6 | package io.opentelemetry.maven; 7 | 8 | import com.google.auto.value.AutoValue; 9 | import org.apache.maven.plugin.MojoExecution; 10 | 11 | @AutoValue 12 | public abstract class MavenGoal { 13 | public static MavenGoal create(String groupId, String artifactId, String goal) { 14 | return new AutoValue_MavenGoal(groupId, artifactId, goal); 15 | } 16 | 17 | public static MavenGoal create(MojoExecution mojoExecution) { 18 | return create( 19 | mojoExecution.getGroupId(), mojoExecution.getArtifactId(), mojoExecution.getGoal()); 20 | } 21 | 22 | abstract String groupId(); 23 | 24 | abstract String artifactId(); 25 | 26 | abstract String goal(); 27 | 28 | @Override 29 | public final String toString() { 30 | return "MavenGoal{ " 31 | + groupId() 32 | + ":" 33 | + MavenUtils.getPluginArtifactIdShortName(artifactId()) 34 | + ":" 35 | + goal() 36 | + "}"; 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /maven-extension/src/main/java/io/opentelemetry/maven/MavenUtils.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright The OpenTelemetry Authors 3 | * SPDX-License-Identifier: Apache-2.0 4 | */ 5 | 6 | package io.opentelemetry.maven; 7 | 8 | import org.apache.maven.plugin.MojoExecution; 9 | 10 | final class MavenUtils { 11 | private MavenUtils() {} 12 | 13 | /** 14 | * Shorten plugin identifiers. 15 | * 16 | *

Examples: 17 | * 18 | *

    19 | *
  • maven-clean-plugin -> clean 20 | *
  • sisu-maven-plugin -> sisu 21 | *
  • spotbugs-maven-plugin -> spotbugs 22 | *
23 | * 24 | * @param pluginArtifactId the artifact ID of the mojo {@link MojoExecution#getArtifactId()} 25 | * @return shortened name 26 | */ 27 | static String getPluginArtifactIdShortName(String pluginArtifactId) { 28 | if (pluginArtifactId.endsWith("-maven-plugin")) { 29 | return pluginArtifactId.substring(0, pluginArtifactId.length() - "-maven-plugin".length()); 30 | } else if (pluginArtifactId.startsWith("maven-") && pluginArtifactId.endsWith("-plugin")) { 31 | return pluginArtifactId.substring( 32 | "maven-".length(), pluginArtifactId.length() - "-plugin".length()); 33 | } else { 34 | return pluginArtifactId; 35 | } 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /maven-extension/src/main/java/io/opentelemetry/maven/StringUtils.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright The OpenTelemetry Authors 3 | * SPDX-License-Identifier: Apache-2.0 4 | */ 5 | 6 | package io.opentelemetry.maven; 7 | 8 | final class StringUtils { 9 | 10 | private StringUtils() {} 11 | 12 | /** Copy org.apache.commons.lang3.StringUtils#isBlank(java.lang.CharSequence) */ 13 | public static boolean isBlank(String str) { 14 | int strLen; 15 | if (str == null || (strLen = str.length()) == 0) { 16 | return true; 17 | } 18 | for (int i = 0; i < strLen; i++) { 19 | if (Character.isWhitespace(str.charAt(i)) == false) { 20 | return false; 21 | } 22 | } 23 | return true; 24 | } 25 | 26 | /** Copy org.apache.commons.lang3.StringUtils#isNotBlank(java.lang.CharSequence) */ 27 | public static boolean isNotBlank(String str) { 28 | return !isBlank(str); 29 | } 30 | 31 | /** 32 | * Copy org.apache.commons.lang3.StringUtils#defaultIfBlank(java.lang.CharSequence, 33 | * java.lang.CharSequence) 34 | */ 35 | public static String defaultIfBlank(String str, String defaultStr) { 36 | return isBlank(str) ? defaultStr : str; 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /maven-extension/src/main/java/io/opentelemetry/maven/ToUpperCaseTextMapGetter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright The OpenTelemetry Authors 3 | * SPDX-License-Identifier: Apache-2.0 4 | */ 5 | 6 | package io.opentelemetry.maven; 7 | 8 | import io.opentelemetry.context.propagation.TextMapGetter; 9 | import java.util.Locale; 10 | import java.util.Map; 11 | import java.util.Set; 12 | import javax.annotation.Nonnull; 13 | import javax.annotation.Nullable; 14 | 15 | final class ToUpperCaseTextMapGetter implements TextMapGetter> { 16 | @Override 17 | public Set keys(Map environmentVariables) { 18 | return environmentVariables.keySet(); 19 | } 20 | 21 | @Override 22 | @Nullable 23 | public String get(@Nullable Map environmentVariables, @Nonnull String key) { 24 | return environmentVariables == null 25 | ? null 26 | : environmentVariables.get(key.toUpperCase(Locale.ROOT)); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /maven-extension/src/main/java/io/opentelemetry/maven/handler/MojoGoalExecutionHandler.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright The OpenTelemetry Authors 3 | * SPDX-License-Identifier: Apache-2.0 4 | */ 5 | 6 | package io.opentelemetry.maven.handler; 7 | 8 | import io.opentelemetry.api.trace.SpanBuilder; 9 | import io.opentelemetry.maven.MavenGoal; 10 | import java.util.List; 11 | import org.apache.maven.execution.ExecutionEvent; 12 | 13 | public interface MojoGoalExecutionHandler { 14 | 15 | default void enrichSpan(SpanBuilder spanBuilder, ExecutionEvent executionEvent) {} 16 | 17 | List getSupportedGoals(); 18 | } 19 | -------------------------------------------------------------------------------- /maven-extension/src/main/java/io/opentelemetry/maven/handler/package-info.java: -------------------------------------------------------------------------------- 1 | @ParametersAreNonnullByDefault 2 | package io.opentelemetry.maven.handler; 3 | 4 | import javax.annotation.ParametersAreNonnullByDefault; 5 | -------------------------------------------------------------------------------- /maven-extension/src/main/java/io/opentelemetry/maven/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright The OpenTelemetry Authors 3 | * SPDX-License-Identifier: Apache-2.0 4 | */ 5 | 6 | @ParametersAreNonnullByDefault 7 | package io.opentelemetry.maven; 8 | 9 | import javax.annotation.ParametersAreNonnullByDefault; 10 | -------------------------------------------------------------------------------- /maven-extension/src/main/java/io/opentelemetry/maven/resources/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright The OpenTelemetry Authors 3 | * SPDX-License-Identifier: Apache-2.0 4 | */ 5 | 6 | @ParametersAreNonnullByDefault 7 | package io.opentelemetry.maven.resources; 8 | 9 | import javax.annotation.ParametersAreNonnullByDefault; 10 | -------------------------------------------------------------------------------- /maven-extension/src/main/resources/META-INF/maven/extension.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | io.opentelemetry.api 5 | io.opentelemetry.api.* 6 | io.opentelemetry.api.baggage 7 | io.opentelemetry.api.baggage.propagation 8 | io.opentelemetry.api.common 9 | io.opentelemetry.api.internal 10 | io.opentelemetry.api.metrics 11 | io.opentelemetry.api.trace 12 | io.opentelemetry.context 13 | io.opentelemetry.context.propagation 14 | 15 | 16 | -------------------------------------------------------------------------------- /maven-extension/src/main/resources/META-INF/services/io.opentelemetry.maven.handler.MojoGoalExecutionHandler: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /maven-extension/src/main/resources/META-INF/services/io.opentelemetry.sdk.autoconfigure.spi.ResourceProvider: -------------------------------------------------------------------------------- 1 | io.opentelemetry.maven.resources.MavenResourceProvider 2 | -------------------------------------------------------------------------------- /maven-extension/src/main/resources/META-INF/sisu/javax.inject.Named: -------------------------------------------------------------------------------- 1 | io.opentelemetry.maven.OpenTelemetrySdkService 2 | io.opentelemetry.maven.OtelLifecycleParticipant 3 | io.opentelemetry.maven.SpanRegistry 4 | -------------------------------------------------------------------------------- /maven-extension/src/test/java/io/opentelemetry/maven/AutoConfigureUtil2Test.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright The OpenTelemetry Authors 3 | * SPDX-License-Identifier: Apache-2.0 4 | */ 5 | 6 | package io.opentelemetry.maven; 7 | 8 | import io.opentelemetry.sdk.autoconfigure.AutoConfiguredOpenTelemetrySdk; 9 | import java.lang.reflect.Method; 10 | import org.junit.jupiter.api.Test; 11 | 12 | class AutoConfigureUtil2Test { 13 | 14 | /** 15 | * Verify the reflection call works with the current version of AutoConfiguredOpenTelemetrySdk. 16 | * 17 | * @throws NoSuchMethodException if the method does not exist 18 | */ 19 | @Test 20 | void test_getResource() throws NoSuchMethodException { 21 | Method method = AutoConfiguredOpenTelemetrySdk.class.getDeclaredMethod("getResource"); 22 | method.setAccessible(true); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /maven-extension/src/test/java/io/opentelemetry/maven/MavenUtilsTests.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright The OpenTelemetry Authors 3 | * SPDX-License-Identifier: Apache-2.0 4 | */ 5 | 6 | package io.opentelemetry.maven; 7 | 8 | import static org.assertj.core.api.Assertions.assertThat; 9 | 10 | import org.junit.jupiter.api.Test; 11 | 12 | public class MavenUtilsTests { 13 | 14 | @Test 15 | public void getPluginArtifactIdShortName_builtinPluginName() { 16 | String actual = MavenUtils.getPluginArtifactIdShortName("maven-clean-plugin"); 17 | String expected = "clean"; 18 | assertThat(actual).isEqualTo(expected); 19 | } 20 | 21 | @Test 22 | public void getPluginArtifactIdShortName_thirdPartyPluginName() { 23 | String actual = MavenUtils.getPluginArtifactIdShortName("spotbugs-maven-plugin"); 24 | String expected = "spotbugs"; 25 | assertThat(actual).isEqualTo(expected); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /maven-extension/src/test/java/io/opentelemetry/maven/SpanRegistryTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright The OpenTelemetry Authors 3 | * SPDX-License-Identifier: Apache-2.0 4 | */ 5 | 6 | package io.opentelemetry.maven; 7 | 8 | import static org.assertj.core.api.Assertions.assertThat; 9 | 10 | import io.opentelemetry.api.OpenTelemetry; 11 | import io.opentelemetry.api.trace.Span; 12 | import io.opentelemetry.api.trace.Tracer; 13 | import org.junit.jupiter.api.Test; 14 | 15 | public class SpanRegistryTest { 16 | 17 | /** MVND reuses the same Maven process and thus the Span Registry is reused. */ 18 | @Test 19 | public void testSpanRegistryReuseWhenUsingMvnDaemon() { 20 | SpanRegistry spanRegistry = new SpanRegistry(); 21 | 22 | Tracer tracer = OpenTelemetry.noop().getTracer("test"); 23 | Span firstRootSpan = tracer.spanBuilder("com.example:my-jar-1.1.0-SNAPSHOT").startSpan(); 24 | spanRegistry.setRootSpan(firstRootSpan); 25 | Span firstRemovedRootSpan = spanRegistry.removeRootSpan(); 26 | assertThat(firstRemovedRootSpan).isEqualTo(firstRootSpan); 27 | 28 | Span secondRootSpan = tracer.spanBuilder("com.example:my-jar-2.1.0-SNAPSHOT").startSpan(); 29 | spanRegistry.setRootSpan(secondRootSpan); 30 | Span secondRemovedSpan = spanRegistry.removeRootSpan(); 31 | assertThat(secondRemovedSpan).isEqualTo(secondRootSpan); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /maven-extension/src/test/java/io/opentelemetry/maven/handler/MojoGoalExecutionHandlerConfigurationTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright The OpenTelemetry Authors 3 | * SPDX-License-Identifier: Apache-2.0 4 | */ 5 | 6 | package io.opentelemetry.maven.handler; 7 | 8 | import static org.assertj.core.api.Assertions.assertThat; 9 | 10 | import io.opentelemetry.maven.MavenGoal; 11 | import io.opentelemetry.maven.OtelExecutionListener; 12 | import java.util.Map; 13 | import org.junit.jupiter.api.Test; 14 | 15 | public class MojoGoalExecutionHandlerConfigurationTest { 16 | 17 | @Test 18 | public void mojoGoalExecutionHandlers() { 19 | Map actual = 20 | MojoGoalExecutionHandlerConfiguration.loadMojoGoalExecutionHandler( 21 | OtelExecutionListener.class.getClassLoader()); 22 | assertThat(actual.size()).isEqualTo(5); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /maven-extension/src/test/java/io/opentelemetry/maven/resources/MavenResourceProviderTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright The OpenTelemetry Authors 3 | * SPDX-License-Identifier: Apache-2.0 4 | */ 5 | 6 | package io.opentelemetry.maven.resources; 7 | 8 | import static org.assertj.core.api.Assertions.assertThat; 9 | 10 | import org.junit.jupiter.api.Test; 11 | 12 | class MavenResourceProviderTest { 13 | 14 | @Test 15 | void testGetMavenVersion() { 16 | String mavenVersion = MavenResourceProvider.getMavenRuntimeVersion(); 17 | assertThat(mavenVersion).isEqualTo("3.5.0"); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /maven-extension/src/test/resources/projects/jar/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 4.0.0 5 | 6 | io.opentelemetry.contrib.maven 7 | test-jar 8 | 1.0-SNAPSHOT 9 | 10 | 11 | UTF-8 12 | 13 | 14 | 15 | 16 | releases 17 | https://maven.example.com/repository/maven-releases/ 18 | 19 | 20 | snapshots 21 | https://maven.example.com/repository/maven-snapshots/ 22 | 23 | 24 | -------------------------------------------------------------------------------- /maven-extension/src/test/resources/projects/jib_2/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 4.0.0 5 | 6 | io.opentelemetry.contrib.maven 7 | test-jib-2 8 | 1.0-SNAPSHOT 9 | 10 | 11 | UTF-8 12 | 13 | 14 | 15 | 16 | com.google.cloud.tools 17 | jib-maven-plugin 18 | 3.4.5 19 | 20 | 21 | gcr.io/my-gcp-project/my-app 22 | gcr 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | releases 32 | https://maven.example.com/repository/maven-releases/ 33 | 34 | 35 | snapshots 36 | https://maven.example.com/repository/maven-snapshots/ 37 | 38 | 39 | -------------------------------------------------------------------------------- /maven-extension/src/test/resources/projects/snyk_1/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 4.0.0 5 | 6 | io.opentelemetry.contrib.maven 7 | test-snyk-1 8 | 1.0-SNAPSHOT 9 | 10 | 11 | UTF-8 12 | 13 | 14 | 15 | 16 | io.snyk 17 | snyk-maven-plugin 18 | 2.3.0 19 | 20 | ${snyk.token} 21 | 22 | --all-projects 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | releases 31 | https://maven.example.com/repository/maven-releases/ 32 | 33 | 34 | snapshots 35 | https://maven.example.com/repository/maven-snapshots/ 36 | 37 | 38 | -------------------------------------------------------------------------------- /maven-extension/src/test/resources/projects/springboot_1/src/main/java/io/opentelemetry/contrib/maven/test/springboot/SpringbootTestApplication.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright The OpenTelemetry Authors 3 | * SPDX-License-Identifier: Apache-2.0 4 | */ 5 | 6 | package io.opentelemetry.contrib.maven.test.springboot; 7 | 8 | import org.springframework.boot.SpringApplication; 9 | import org.springframework.boot.autoconfigure.SpringBootApplication; 10 | 11 | @SpringBootApplication 12 | public class SpringbootTestApplication { 13 | 14 | public static void main(String[] args) { 15 | SpringApplication.run(SpringbootTestApplication.class, args); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /maven-extension/src/test/resources/projects/springboot_1/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /maven-extension/src/test/resources/projects/springboot_1/src/test/java/io/opentelemetry/contrib/maven/test/springboot/SpringbootTestApplicationTests.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright The OpenTelemetry Authors 3 | * SPDX-License-Identifier: Apache-2.0 4 | */ 5 | 6 | package io.opentelemetry.contrib.maven.test.springboot; 7 | 8 | import org.junit.jupiter.api.Test; 9 | import org.springframework.boot.test.context.SpringBootTest; 10 | 11 | @SpringBootTest 12 | class SpringbootTestApplicationTests { 13 | 14 | @Test 15 | void contextLoads() {} 16 | } 17 | -------------------------------------------------------------------------------- /maven-extension/src/test/resources/projects/springboot_2/src/main/java/io/opentelemetry/contrib/maven/test/springboot/SpringbootTestApplication.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright The OpenTelemetry Authors 3 | * SPDX-License-Identifier: Apache-2.0 4 | */ 5 | 6 | package io.opentelemetry.contrib.maven.test.springboot; 7 | 8 | import org.springframework.boot.SpringApplication; 9 | import org.springframework.boot.autoconfigure.SpringBootApplication; 10 | 11 | @SpringBootApplication 12 | public class SpringbootTestApplication { 13 | 14 | public static void main(String[] args) { 15 | SpringApplication.run(SpringbootTestApplication.class, args); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /maven-extension/src/test/resources/projects/springboot_2/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /maven-extension/src/test/resources/projects/springboot_2/src/test/java/io/opentelemetry/contrib/maven/test/springboot/SpringbootTestApplicationTests.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright The OpenTelemetry Authors 3 | * SPDX-License-Identifier: Apache-2.0 4 | */ 5 | 6 | package io.opentelemetry.contrib.maven.test.springboot; 7 | 8 | import org.junit.jupiter.api.Test; 9 | import org.springframework.boot.test.context.SpringBootTest; 10 | 11 | @SpringBootTest 12 | class SpringbootTestApplicationTests { 13 | 14 | @Test 15 | void contextLoads() {} 16 | } 17 | -------------------------------------------------------------------------------- /micrometer-meter-provider/build.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | id("otel.java-conventions") 3 | id("otel.publish-conventions") 4 | } 5 | 6 | description = "OpenTelemetry Micrometer MeterProvider" 7 | otelJava.moduleName.set("io.opentelemetry.contrib.metrics.micrometer") 8 | 9 | dependencies { 10 | api("io.opentelemetry:opentelemetry-api") 11 | api("io.opentelemetry:opentelemetry-sdk-metrics") 12 | api("io.opentelemetry:opentelemetry-api-incubator") 13 | 14 | compileOnly("io.micrometer:micrometer-core:1.5.0") // do not auto-update this version 15 | compileOnly("io.opentelemetry:opentelemetry-sdk-extension-autoconfigure") 16 | 17 | annotationProcessor("com.google.auto.service:auto-service") 18 | compileOnly("com.google.auto.service:auto-service-annotations") 19 | 20 | annotationProcessor("com.google.auto.value:auto-value") 21 | compileOnly("com.google.auto.value:auto-value-annotations") 22 | 23 | testImplementation("io.micrometer:micrometer-core:1.15.0") 24 | } 25 | 26 | testing { 27 | suites { 28 | val integrationTest by registering(JvmTestSuite::class) { 29 | dependencies { 30 | implementation("io.micrometer:micrometer-registry-prometheus:1.15.0") 31 | } 32 | } 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /micrometer-meter-provider/src/main/java/io/opentelemetry/contrib/metrics/micrometer/CallbackRegistrar.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright The OpenTelemetry Authors 3 | * SPDX-License-Identifier: Apache-2.0 4 | */ 5 | 6 | package io.opentelemetry.contrib.metrics.micrometer; 7 | 8 | public interface CallbackRegistrar extends AutoCloseable { 9 | CallbackRegistration registerCallback(Runnable runnable); 10 | 11 | @Override 12 | void close(); 13 | } 14 | -------------------------------------------------------------------------------- /micrometer-meter-provider/src/main/java/io/opentelemetry/contrib/metrics/micrometer/CallbackRegistration.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright The OpenTelemetry Authors 3 | * SPDX-License-Identifier: Apache-2.0 4 | */ 5 | 6 | package io.opentelemetry.contrib.metrics.micrometer; 7 | 8 | import io.opentelemetry.api.metrics.ObservableDoubleCounter; 9 | import io.opentelemetry.api.metrics.ObservableDoubleGauge; 10 | import io.opentelemetry.api.metrics.ObservableDoubleUpDownCounter; 11 | import io.opentelemetry.api.metrics.ObservableLongCounter; 12 | import io.opentelemetry.api.metrics.ObservableLongGauge; 13 | import io.opentelemetry.api.metrics.ObservableLongUpDownCounter; 14 | 15 | /** Helper interface representing any of the observable instruments. */ 16 | @FunctionalInterface 17 | public interface CallbackRegistration 18 | extends ObservableLongCounter, 19 | ObservableDoubleCounter, 20 | ObservableLongUpDownCounter, 21 | ObservableDoubleUpDownCounter, 22 | ObservableLongGauge, 23 | ObservableDoubleGauge, 24 | AutoCloseable { 25 | 26 | /** 27 | * Remove the callback registered via {@code buildWithCallback(Consumer)}. After this is called, 28 | * the callback won't be invoked on future collections. Subsequent calls to {@link #close()} have 29 | * no effect. 30 | */ 31 | @Override 32 | void close(); 33 | } 34 | -------------------------------------------------------------------------------- /micrometer-meter-provider/src/main/java/io/opentelemetry/contrib/metrics/micrometer/internal/Constants.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright The OpenTelemetry Authors 3 | * SPDX-License-Identifier: Apache-2.0 4 | */ 5 | 6 | package io.opentelemetry.contrib.metrics.micrometer.internal; 7 | 8 | import io.micrometer.core.instrument.Tag; 9 | 10 | /** 11 | * Constants for common Micrometer {@link Tag} names for the OpenTelemetry instrumentation scope. 12 | * 13 | *

This class is internal and is hence not for public use. Its APIs are unstable and can change 14 | * at any time. 15 | */ 16 | public final class Constants { 17 | public static final String OTEL_INSTRUMENTATION_NAME = "otel.instrumentation.name"; 18 | public static final String OTEL_INSTRUMENTATION_VERSION = "otel.instrumentation.version"; 19 | public static final Tag UNKNOWN_INSTRUMENTATION_VERSION_TAG = 20 | Tag.of(OTEL_INSTRUMENTATION_VERSION, "unknown"); 21 | 22 | private Constants() {} 23 | } 24 | -------------------------------------------------------------------------------- /micrometer-meter-provider/src/main/java/io/opentelemetry/contrib/metrics/micrometer/internal/MemoizingSupplier.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright The OpenTelemetry Authors 3 | * SPDX-License-Identifier: Apache-2.0 4 | */ 5 | 6 | package io.opentelemetry.contrib.metrics.micrometer.internal; 7 | 8 | import java.util.function.Supplier; 9 | import javax.annotation.Nullable; 10 | 11 | /** 12 | * Delegating implementation of {@link Supplier Supplier} that ensures that the {@link 13 | * Supplier#get()} method is called at most once and the result is memoized for subsequent 14 | * invocations. 15 | * 16 | *

This class is internal and is hence not for public use. Its APIs are unstable and can change 17 | * at any time. 18 | */ 19 | public final class MemoizingSupplier implements Supplier { 20 | private final Supplier delegate; 21 | private volatile boolean initialized; 22 | @Nullable private volatile T cachedResult; 23 | 24 | public MemoizingSupplier(Supplier delegate) { 25 | this.delegate = delegate; 26 | } 27 | 28 | @Override 29 | @SuppressWarnings("NullAway") 30 | public T get() { 31 | T result = cachedResult; 32 | if (!initialized) { 33 | synchronized (this) { 34 | if (!initialized) { 35 | result = delegate.get(); 36 | cachedResult = result; 37 | initialized = true; 38 | return result; 39 | } 40 | } 41 | } 42 | return result; 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /micrometer-meter-provider/src/main/java/io/opentelemetry/contrib/metrics/micrometer/internal/instruments/AbstractGauge.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright The OpenTelemetry Authors 3 | * SPDX-License-Identifier: Apache-2.0 4 | */ 5 | 6 | package io.opentelemetry.contrib.metrics.micrometer.internal.instruments; 7 | 8 | import io.micrometer.core.instrument.Gauge; 9 | import io.opentelemetry.api.common.Attributes; 10 | import io.opentelemetry.contrib.metrics.micrometer.internal.state.InstrumentState; 11 | import java.util.Map; 12 | import java.util.concurrent.ConcurrentHashMap; 13 | 14 | abstract class AbstractGauge extends AbstractInstrument { 15 | private final Map gaugeMap = new ConcurrentHashMap<>(); 16 | 17 | protected AbstractGauge(InstrumentState instrumentState) { 18 | super(instrumentState); 19 | } 20 | 21 | protected final void record(Attributes attributes, double value) { 22 | gaugeMap.computeIfAbsent(effectiveAttributes(attributes), this::createAsyncGauge).set(value); 23 | } 24 | 25 | private AtomicDoubleCounter createAsyncGauge(Attributes attributes) { 26 | AtomicDoubleCounter counter = new AtomicDoubleCounter(); 27 | Gauge.builder(name(), counter, AtomicDoubleCounter::current) 28 | .description(description()) 29 | .baseUnit(unit()) 30 | .tags(attributesToTags(attributes)) 31 | .register(meterRegistry()); 32 | return counter; 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /micrometer-meter-provider/src/main/java/io/opentelemetry/contrib/metrics/micrometer/internal/instruments/package-info.java: -------------------------------------------------------------------------------- 1 | /** Implementations of OpenTelemetry instruments delegating to Micrometer meters. */ 2 | @ParametersAreNonnullByDefault 3 | package io.opentelemetry.contrib.metrics.micrometer.internal.instruments; 4 | 5 | import javax.annotation.ParametersAreNonnullByDefault; 6 | -------------------------------------------------------------------------------- /micrometer-meter-provider/src/main/java/io/opentelemetry/contrib/metrics/micrometer/internal/state/MeterProviderSharedState.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright The OpenTelemetry Authors 3 | * SPDX-License-Identifier: Apache-2.0 4 | */ 5 | 6 | package io.opentelemetry.contrib.metrics.micrometer.internal.state; 7 | 8 | import io.micrometer.core.instrument.MeterRegistry; 9 | import io.opentelemetry.contrib.metrics.micrometer.CallbackRegistrar; 10 | import io.opentelemetry.contrib.metrics.micrometer.CallbackRegistration; 11 | import java.util.function.Supplier; 12 | 13 | /** 14 | * State for a meter provider. 15 | * 16 | *

This class is internal and is hence not for public use. Its APIs are unstable and can change 17 | * at any time. 18 | */ 19 | public final class MeterProviderSharedState { 20 | private final Supplier meterRegistrySupplier; 21 | private final CallbackRegistrar callbackRegistrar; 22 | 23 | public MeterProviderSharedState( 24 | Supplier meterRegistrySupplier, CallbackRegistrar callbackRegistrar) { 25 | this.meterRegistrySupplier = meterRegistrySupplier; 26 | this.callbackRegistrar = callbackRegistrar; 27 | } 28 | 29 | public MeterRegistry meterRegistry() { 30 | return meterRegistrySupplier.get(); 31 | } 32 | 33 | public CallbackRegistration registerCallback(Runnable callback) { 34 | return callbackRegistrar.registerCallback(callback); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /micrometer-meter-provider/src/main/java/io/opentelemetry/contrib/metrics/micrometer/internal/state/package-info.java: -------------------------------------------------------------------------------- 1 | /** Internal state for metrics. */ 2 | @ParametersAreNonnullByDefault 3 | package io.opentelemetry.contrib.metrics.micrometer.internal.state; 4 | 5 | import javax.annotation.ParametersAreNonnullByDefault; 6 | -------------------------------------------------------------------------------- /micrometer-meter-provider/src/main/java/io/opentelemetry/contrib/metrics/micrometer/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * A Micrometer implementation of metrics. 3 | * 4 | * @see io.opentelemetry.contrib.metrics.micrometer.MicrometerMeterProvider 5 | */ 6 | @ParametersAreNonnullByDefault 7 | package io.opentelemetry.contrib.metrics.micrometer; 8 | 9 | import javax.annotation.ParametersAreNonnullByDefault; 10 | -------------------------------------------------------------------------------- /micrometer-meter-provider/src/test/java/io/opentelemetry/contrib/metrics/micrometer/TestCallbackRegistrar.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright The OpenTelemetry Authors 3 | * SPDX-License-Identifier: Apache-2.0 4 | */ 5 | 6 | package io.opentelemetry.contrib.metrics.micrometer; 7 | 8 | import java.util.List; 9 | 10 | public class TestCallbackRegistrar implements CallbackRegistrar, Runnable { 11 | 12 | private final List callbacks; 13 | 14 | public TestCallbackRegistrar(List callbacks) { 15 | this.callbacks = callbacks; 16 | } 17 | 18 | @Override 19 | public CallbackRegistration registerCallback(Runnable callback) { 20 | callbacks.add(callback); 21 | return () -> callbacks.remove(callback); 22 | } 23 | 24 | @Override 25 | public void close() { 26 | callbacks.clear(); 27 | } 28 | 29 | @Override 30 | public void run() { 31 | for (Runnable callback : callbacks) { 32 | callback.run(); 33 | } 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /micrometer-meter-provider/src/test/java/io/opentelemetry/contrib/metrics/micrometer/internal/MemoizingSupplierTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright The OpenTelemetry Authors 3 | * SPDX-License-Identifier: Apache-2.0 4 | */ 5 | 6 | package io.opentelemetry.contrib.metrics.micrometer.internal; 7 | 8 | import static org.assertj.core.api.Assertions.assertThat; 9 | import static org.mockito.Mockito.times; 10 | import static org.mockito.Mockito.verify; 11 | import static org.mockito.Mockito.verifyNoInteractions; 12 | import static org.mockito.Mockito.verifyNoMoreInteractions; 13 | import static org.mockito.Mockito.when; 14 | 15 | import java.util.function.Supplier; 16 | import org.junit.jupiter.api.Test; 17 | import org.junit.jupiter.api.extension.ExtendWith; 18 | import org.mockito.Mock; 19 | import org.mockito.junit.jupiter.MockitoExtension; 20 | 21 | @ExtendWith(MockitoExtension.class) 22 | class MemoizingSupplierTest { 23 | 24 | @Mock Supplier supplier; 25 | 26 | @Test 27 | void callsGetOnlyOnce() { 28 | when(supplier.get()).thenReturn("RESULT"); 29 | 30 | Supplier underTest = new MemoizingSupplier<>(supplier); 31 | 32 | verifyNoInteractions(supplier); 33 | 34 | assertThat(underTest.get()).isEqualTo("RESULT"); 35 | verify(supplier, times(1)).get(); 36 | 37 | assertThat(underTest.get()).isEqualTo("RESULT"); 38 | verifyNoMoreInteractions(supplier); 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /micrometer-meter-provider/src/test/java/io/opentelemetry/contrib/metrics/micrometer/internal/instruments/RandomUtils.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright The OpenTelemetry Authors 3 | * SPDX-License-Identifier: Apache-2.0 4 | */ 5 | 6 | package io.opentelemetry.contrib.metrics.micrometer.internal.instruments; 7 | 8 | import java.util.concurrent.ThreadLocalRandom; 9 | import java.util.stream.Stream; 10 | 11 | final class RandomUtils { 12 | 13 | @SuppressWarnings("StreamToIterable") 14 | static Iterable randomDoubles(long size, double origin, double bound) { 15 | Stream stream = ThreadLocalRandom.current().doubles(size, origin, bound).boxed(); 16 | 17 | return stream::iterator; 18 | } 19 | 20 | @SuppressWarnings("StreamToIterable") 21 | static Iterable randomLongs(long size, long origin, long bound) { 22 | Stream stream = ThreadLocalRandom.current().longs(size, origin, bound).boxed(); 23 | 24 | return stream::iterator; 25 | } 26 | 27 | private RandomUtils() {} 28 | } 29 | -------------------------------------------------------------------------------- /noop-api/README.md: -------------------------------------------------------------------------------- 1 | # OpenTelemetry Noop API 2 | 3 | An implementation of `OpenTelemetry` that is completely no-op. Unlike `OpenTelemetry#noop()`, this 4 | implementation does not support in-process context propagation at all. This means that no objects 5 | are allocated nor {@link ThreadLocal}s used in an application using this implementation. 6 | 7 | ## Component owners 8 | 9 | - [Jack Berg](https://github.com/jack-berg), New Relic 10 | 11 | Learn more about component owners in [component_owners.yml](../.github/component_owners.yml). 12 | -------------------------------------------------------------------------------- /noop-api/build.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | id("otel.java-conventions") 3 | id("otel.publish-conventions") 4 | } 5 | 6 | description = "OpenTelemetry Noop API" 7 | otelJava.moduleName.set("io.opentelemetry.contrib.noopapi") 8 | 9 | dependencies { 10 | api("io.opentelemetry:opentelemetry-api") 11 | } 12 | -------------------------------------------------------------------------------- /noop-api/src/main/resources/META-INF/services/io.opentelemetry.context.ContextStorageProvider: -------------------------------------------------------------------------------- 1 | io.opentelemetry.contrib.noopapi.NoopContextStorageProvider 2 | -------------------------------------------------------------------------------- /opamp-client/README.md: -------------------------------------------------------------------------------- 1 | # OpAMP Client 2 | 3 | Java implementation of the OpAMP 4 | client [spec](https://github.com/open-telemetry/opamp-spec/blob/main/specification.md). 5 | 6 | ## Component owners 7 | 8 | - [Cesar Munoz](https://github.com/LikeTheSalad), Elastic 9 | - [Jack Shirazi](https://github.com/jackshirazi), Elastic 10 | 11 | Learn more about component owners in [component_owners.yml](../.github/component_owners.yml). 12 | -------------------------------------------------------------------------------- /opamp-client/src/main/java/io/opentelemetry/opamp/client/internal/response/MessageData.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright The OpenTelemetry Authors 3 | * SPDX-License-Identifier: Apache-2.0 4 | */ 5 | 6 | package io.opentelemetry.opamp.client.internal.response; 7 | 8 | import com.google.auto.value.AutoValue; 9 | import io.opentelemetry.opamp.client.internal.OpampClient; 10 | import javax.annotation.Nullable; 11 | import opamp.proto.AgentRemoteConfig; 12 | 13 | /** 14 | * Data class provided in {@link OpampClient.Callbacks#onMessage(OpampClient, MessageData)} with 15 | * Server's provided status changes. 16 | */ 17 | @AutoValue 18 | public abstract class MessageData { 19 | @Nullable 20 | public abstract AgentRemoteConfig getRemoteConfig(); 21 | 22 | public static Builder builder() { 23 | return new AutoValue_MessageData.Builder(); 24 | } 25 | 26 | @AutoValue.Builder 27 | public abstract static class Builder { 28 | public abstract Builder setRemoteConfig(AgentRemoteConfig remoteConfig); 29 | 30 | public abstract MessageData build(); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /processors/build.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | id("otel.java-conventions") 3 | id("otel.publish-conventions") 4 | } 5 | 6 | description = "Tools to intercept and process signals globally." 7 | otelJava.moduleName.set("io.opentelemetry.contrib.processors") 8 | 9 | java { 10 | sourceCompatibility = JavaVersion.VERSION_1_8 11 | targetCompatibility = JavaVersion.VERSION_1_8 12 | } 13 | 14 | dependencies { 15 | api("io.opentelemetry:opentelemetry-sdk") 16 | compileOnly("io.opentelemetry:opentelemetry-sdk-extension-autoconfigure-spi") 17 | compileOnly("io.opentelemetry:opentelemetry-api-incubator") 18 | 19 | // For EventToSpanEventBridge 20 | implementation("io.opentelemetry:opentelemetry-exporter-otlp-common") 21 | implementation("com.fasterxml.jackson.core:jackson-core") 22 | 23 | testImplementation("io.opentelemetry:opentelemetry-api-incubator") 24 | testImplementation("io.opentelemetry:opentelemetry-sdk-testing") 25 | testImplementation("io.opentelemetry:opentelemetry-sdk-extension-autoconfigure") 26 | testImplementation("io.opentelemetry:opentelemetry-sdk-extension-incubator") 27 | testImplementation("io.opentelemetry:opentelemetry-exporter-logging") 28 | } 29 | -------------------------------------------------------------------------------- /processors/src/main/java/io/opentelemetry/contrib/eventbridge/internal/EventToSpanEventBridgeComponentProvider.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright The OpenTelemetry Authors 3 | * SPDX-License-Identifier: Apache-2.0 4 | */ 5 | 6 | package io.opentelemetry.contrib.eventbridge.internal; 7 | 8 | import io.opentelemetry.api.incubator.config.DeclarativeConfigProperties; 9 | import io.opentelemetry.contrib.eventbridge.EventToSpanEventBridge; 10 | import io.opentelemetry.sdk.autoconfigure.spi.internal.ComponentProvider; 11 | import io.opentelemetry.sdk.logs.LogRecordProcessor; 12 | 13 | /** 14 | * Declarative configuration SPI implementation for {@link EventToSpanEventBridge}. 15 | * 16 | *

This class is internal and is hence not for public use. Its APIs are unstable and can change 17 | * at any time. 18 | */ 19 | public class EventToSpanEventBridgeComponentProvider 20 | implements ComponentProvider { 21 | 22 | @Override 23 | public Class getType() { 24 | return LogRecordProcessor.class; 25 | } 26 | 27 | @Override 28 | public String getName() { 29 | return "event_to_span_event_bridge"; 30 | } 31 | 32 | @Override 33 | public LogRecordProcessor create(DeclarativeConfigProperties config) { 34 | return EventToSpanEventBridge.create(); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /processors/src/main/java/io/opentelemetry/contrib/filter/FilteringLogRecordProcessor.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright The OpenTelemetry Authors 3 | * SPDX-License-Identifier: Apache-2.0 4 | */ 5 | 6 | package io.opentelemetry.contrib.filter; 7 | 8 | import io.opentelemetry.context.Context; 9 | import io.opentelemetry.sdk.logs.LogRecordProcessor; 10 | import io.opentelemetry.sdk.logs.ReadWriteLogRecord; 11 | import io.opentelemetry.sdk.logs.data.LogRecordData; 12 | import java.util.function.Predicate; 13 | 14 | public class FilteringLogRecordProcessor implements LogRecordProcessor { 15 | 16 | public final LogRecordProcessor delegate; 17 | public final Predicate predicate; 18 | 19 | public FilteringLogRecordProcessor( 20 | LogRecordProcessor delegate, Predicate predicate) { 21 | this.delegate = delegate; 22 | this.predicate = predicate; 23 | } 24 | 25 | @Override 26 | public void onEmit(Context context, ReadWriteLogRecord readWriteLogRecord) { 27 | if (predicate.test(readWriteLogRecord.toLogRecordData())) { 28 | delegate.onEmit(context, readWriteLogRecord); 29 | } 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /processors/src/main/java/io/opentelemetry/contrib/interceptor/InterceptableLogRecordExporter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright The OpenTelemetry Authors 3 | * SPDX-License-Identifier: Apache-2.0 4 | */ 5 | 6 | package io.opentelemetry.contrib.interceptor; 7 | 8 | import io.opentelemetry.contrib.interceptor.api.Interceptor; 9 | import io.opentelemetry.sdk.common.CompletableResultCode; 10 | import io.opentelemetry.sdk.logs.data.LogRecordData; 11 | import io.opentelemetry.sdk.logs.export.LogRecordExporter; 12 | import java.util.Collection; 13 | 14 | /** Intercepts logs before delegating them to the real exporter. */ 15 | public final class InterceptableLogRecordExporter implements LogRecordExporter { 16 | private final LogRecordExporter delegate; 17 | private final Interceptor interceptor; 18 | 19 | public InterceptableLogRecordExporter( 20 | LogRecordExporter delegate, Interceptor interceptor) { 21 | this.delegate = delegate; 22 | this.interceptor = interceptor; 23 | } 24 | 25 | @Override 26 | public CompletableResultCode export(Collection logs) { 27 | return delegate.export(interceptor.interceptAll(logs)); 28 | } 29 | 30 | @Override 31 | public CompletableResultCode flush() { 32 | return delegate.flush(); 33 | } 34 | 35 | @Override 36 | public CompletableResultCode shutdown() { 37 | return delegate.shutdown(); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /processors/src/main/java/io/opentelemetry/contrib/interceptor/InterceptableSpanExporter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright The OpenTelemetry Authors 3 | * SPDX-License-Identifier: Apache-2.0 4 | */ 5 | 6 | package io.opentelemetry.contrib.interceptor; 7 | 8 | import io.opentelemetry.contrib.interceptor.api.Interceptor; 9 | import io.opentelemetry.sdk.common.CompletableResultCode; 10 | import io.opentelemetry.sdk.trace.data.SpanData; 11 | import io.opentelemetry.sdk.trace.export.SpanExporter; 12 | import java.util.Collection; 13 | 14 | /** Intercepts spans before delegating them to the real exporter. */ 15 | public final class InterceptableSpanExporter implements SpanExporter { 16 | private final SpanExporter delegate; 17 | private final Interceptor interceptor; 18 | 19 | public InterceptableSpanExporter(SpanExporter delegate, Interceptor interceptor) { 20 | this.delegate = delegate; 21 | this.interceptor = interceptor; 22 | } 23 | 24 | @Override 25 | public CompletableResultCode export(Collection spans) { 26 | return delegate.export(interceptor.interceptAll(spans)); 27 | } 28 | 29 | @Override 30 | public CompletableResultCode flush() { 31 | return delegate.flush(); 32 | } 33 | 34 | @Override 35 | public CompletableResultCode shutdown() { 36 | return delegate.shutdown(); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /processors/src/main/java/io/opentelemetry/contrib/interceptor/api/Interceptor.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright The OpenTelemetry Authors 3 | * SPDX-License-Identifier: Apache-2.0 4 | */ 5 | 6 | package io.opentelemetry.contrib.interceptor.api; 7 | 8 | import java.util.ArrayList; 9 | import java.util.Collection; 10 | import java.util.List; 11 | import javax.annotation.Nullable; 12 | 13 | /** 14 | * Intercepts a signal before it gets exported. The signal can get updated and/or filtered out based 15 | * on each interceptor implementation. 16 | */ 17 | public interface Interceptor { 18 | 19 | /** 20 | * Intercepts a signal. 21 | * 22 | * @param item The signal object. 23 | * @return The received signal modified (or null for excluding this signal from getting exported). 24 | * If there's no operation needed to be done for a specific signal, it should be returned as 25 | * is. 26 | */ 27 | @Nullable 28 | T intercept(T item); 29 | 30 | /** Intercepts a collection of signals. */ 31 | default Collection interceptAll(Collection items) { 32 | List result = new ArrayList<>(); 33 | 34 | for (T item : items) { 35 | T intercepted = intercept(item); 36 | if (intercepted != null) { 37 | result.add(intercepted); 38 | } 39 | } 40 | 41 | return result; 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /processors/src/main/java/io/opentelemetry/contrib/interceptor/common/ComposableInterceptor.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright The OpenTelemetry Authors 3 | * SPDX-License-Identifier: Apache-2.0 4 | */ 5 | 6 | package io.opentelemetry.contrib.interceptor.common; 7 | 8 | import io.opentelemetry.contrib.interceptor.api.Interceptor; 9 | import java.util.concurrent.CopyOnWriteArrayList; 10 | import javax.annotation.Nullable; 11 | 12 | /** Allows to run an item through a list of interceptors in the order they were added. */ 13 | public final class ComposableInterceptor implements Interceptor { 14 | private final CopyOnWriteArrayList> interceptors = new CopyOnWriteArrayList<>(); 15 | 16 | public void add(Interceptor interceptor) { 17 | interceptors.addIfAbsent(interceptor); 18 | } 19 | 20 | @Nullable 21 | @Override 22 | public T intercept(T item) { 23 | T intercepted = item; 24 | for (Interceptor interceptor : interceptors) { 25 | intercepted = interceptor.intercept(intercepted); 26 | if (intercepted == null) { 27 | break; 28 | } 29 | } 30 | return intercepted; 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /processors/src/main/resources/META-INF/services/io.opentelemetry.sdk.autoconfigure.spi.internal.ComponentProvider: -------------------------------------------------------------------------------- 1 | io.opentelemetry.contrib.eventbridge.internal.EventToSpanEventBridgeComponentProvider 2 | -------------------------------------------------------------------------------- /processors/src/test/java/io/opentelemetry/contrib/eventbridge/internal/EventToSpanBridgeComponentProviderTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright The OpenTelemetry Authors 3 | * SPDX-License-Identifier: Apache-2.0 4 | */ 5 | 6 | package io.opentelemetry.contrib.eventbridge.internal; 7 | 8 | import static org.assertj.core.api.Assertions.assertThat; 9 | 10 | import io.opentelemetry.sdk.OpenTelemetrySdk; 11 | import io.opentelemetry.sdk.extension.incubator.fileconfig.DeclarativeConfiguration; 12 | import java.io.ByteArrayInputStream; 13 | import java.nio.charset.StandardCharsets; 14 | import org.junit.jupiter.api.Test; 15 | 16 | class EventToSpanBridgeComponentProviderTest { 17 | 18 | @Test 19 | void endToEnd() { 20 | String yaml = 21 | "file_format: 0.4\n" 22 | + "logger_provider:\n" 23 | + " processors:\n" 24 | + " - event_to_span_event_bridge:\n"; 25 | 26 | OpenTelemetrySdk openTelemetrySdk = 27 | DeclarativeConfiguration.parseAndCreate( 28 | new ByteArrayInputStream(yaml.getBytes(StandardCharsets.UTF_8))); 29 | 30 | assertThat(openTelemetrySdk.getSdkLoggerProvider().toString()) 31 | .matches("SdkLoggerProvider\\{.*logRecordProcessor=EventToSpanEventBridge\\{}.*}"); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /prometheus-client-bridge/README.md: -------------------------------------------------------------------------------- 1 | # Prometheus client bridge 2 | 3 | This module can be used to bridge OpenTelemetry metrics into the `prometheus-simpleclient` library. 4 | 5 | Currently only registers with the CollectorRegistry's `defaultRegistry`. 6 | 7 | * Build it with `./gradlew :prometheus-simpleclient-bridge:build` 8 | 9 | ## Usage 10 | 11 | ``` 12 | sdkMeterProvider.registerMetricReader(PrometheusCollector.create()); 13 | ``` 14 | 15 | ## Component owners 16 | 17 | - [John Watson](https://github.com/jkwatson), Verta.ai 18 | 19 | Learn more about component owners in [component_owners.yml](../.github/component_owners.yml). 20 | -------------------------------------------------------------------------------- /prometheus-client-bridge/build.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | id("otel.java-conventions") 3 | id("otel.publish-conventions") 4 | } 5 | 6 | description = "Prometheus client bridge" 7 | otelJava.moduleName.set("io.opentelemetry.contrib.metrics.prometheus.clientbridge") 8 | 9 | dependencies { 10 | api("io.opentelemetry:opentelemetry-sdk-metrics") 11 | implementation("io.prometheus:simpleclient") 12 | 13 | testImplementation("com.google.guava:guava") 14 | testImplementation("io.prometheus:simpleclient_httpserver") 15 | } 16 | -------------------------------------------------------------------------------- /resource-providers/README.md: -------------------------------------------------------------------------------- 1 | 2 | # Resource Providers 3 | 4 | This module contains various `ResourceProvider` implementations. 5 | 6 | ## AppServerServiceNameProvider 7 | 8 | This `ResourceProvider` will delegate to a collection of helpers that attempt 9 | to populate the `service.name` resource attribute based on the runtime configuration 10 | of an app server. This is useful when a user has not yet specified the `service.name` 11 | resource attribute manually. 12 | 13 | This `ResourceProvider` supports `.ear` and `.war` archives as well as exploded directory 14 | versions of each. For `.war` files, it attempts to parse the `` element 15 | from `WEB-INF/web.xml`. For `.ear` files the `` element of `META-INF/application.xml`. 16 | 17 | It is capable of detecting common scenarios among the popular application servers listed below: 18 | 19 | * Apache Tomcat 20 | * Apache TomEE 21 | * Eclipse Jetty 22 | * GlassFish 23 | * IBM Websphere 24 | * IBM Websphere Liberty 25 | * Wildfly 26 | 27 | ## Component owners 28 | 29 | - [Jason Plumb](https://github.com/breedx-splk), Splunk 30 | - [Mateusz Rzeszutek](https://github.com/mateuszrzeszutek), Splunk 31 | - [Lauri Tulmin](https://github.com/laurit), Splunk 32 | 33 | Learn more about component owners in [component_owners.yml](../.github/component_owners.yml). 34 | -------------------------------------------------------------------------------- /resource-providers/build.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | id("otel.java-conventions") 3 | id("otel.publish-conventions") 4 | } 5 | 6 | description = "Contributed ResourceProviders" 7 | otelJava.moduleName.set("io.opentelemetry.contrib.resourceproviders") 8 | 9 | dependencies { 10 | annotationProcessor("com.google.auto.service:auto-service") 11 | 12 | compileOnly("com.google.auto.service:auto-service") 13 | compileOnly("io.opentelemetry:opentelemetry-api") 14 | compileOnly("io.opentelemetry:opentelemetry-sdk") 15 | compileOnly("io.opentelemetry:opentelemetry-sdk-extension-autoconfigure") 16 | compileOnly("io.opentelemetry:opentelemetry-sdk-extension-autoconfigure-spi") 17 | compileOnly("io.opentelemetry.semconv:opentelemetry-semconv") 18 | testImplementation("io.opentelemetry.semconv:opentelemetry-semconv") 19 | testImplementation("com.google.auto.service:auto-service") 20 | testImplementation("io.opentelemetry:opentelemetry-sdk-extension-autoconfigure") 21 | } 22 | -------------------------------------------------------------------------------- /resource-providers/src/main/java/io/opentelemetry/contrib/resourceproviders/AppServer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright The OpenTelemetry Authors 3 | * SPDX-License-Identifier: Apache-2.0 4 | */ 5 | 6 | package io.opentelemetry.contrib.resourceproviders; 7 | 8 | import java.nio.file.Path; 9 | import javax.annotation.Nullable; 10 | 11 | /** 12 | * An interface that represents a single kind of application server and its specific configuration. 13 | */ 14 | interface AppServer { 15 | 16 | /** Path to directory to be scanned for deployments. */ 17 | @Nullable 18 | Path getDeploymentDir() throws Exception; 19 | 20 | /** 21 | * Returns a single class that, when present, determines that the given application server is 22 | * active/running. 23 | */ 24 | @Nullable 25 | Class getServerClass(); 26 | 27 | /** 28 | * Implementations for app servers that do not support ear files should override this method and 29 | * return false; 30 | */ 31 | default boolean supportsEar() { 32 | return true; 33 | } 34 | 35 | /** Use to ignore default applications that are bundled with the app server. */ 36 | default boolean isValidAppName(Path path) { 37 | return true; 38 | } 39 | 40 | /** Use to ignore default applications that are bundled with the app server. */ 41 | default boolean isValidResult(Path path, @Nullable String result) { 42 | return true; 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /resource-providers/src/main/java/io/opentelemetry/contrib/resourceproviders/GlassfishAppServer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright The OpenTelemetry Authors 3 | * SPDX-License-Identifier: Apache-2.0 4 | */ 5 | 6 | package io.opentelemetry.contrib.resourceproviders; 7 | 8 | import java.nio.file.Path; 9 | import java.nio.file.Paths; 10 | import javax.annotation.Nullable; 11 | 12 | class GlassfishAppServer implements AppServer { 13 | 14 | private static final String SERVICE_CLASS_NAME = "com.sun.enterprise.glassfish.bootstrap.ASMain"; 15 | private final ResourceLocator locator; 16 | 17 | GlassfishAppServer(ResourceLocator locator) { 18 | this.locator = locator; 19 | } 20 | 21 | @Nullable 22 | @Override 23 | public Path getDeploymentDir() { 24 | String instanceRoot = System.getProperty("com.sun.aas.instanceRoot"); 25 | if (instanceRoot == null) { 26 | return null; 27 | } 28 | 29 | // besides autodeploy directory it is possible to deploy applications through admin console and 30 | // asadmin script, to detect those we would need to parse config/domain.xml 31 | return Paths.get(instanceRoot, "autodeploy"); 32 | } 33 | 34 | @Override 35 | @Nullable 36 | public Class getServerClass() { 37 | return locator.findClass(SERVICE_CLASS_NAME); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /resource-providers/src/main/java/io/opentelemetry/contrib/resourceproviders/ResourceLocator.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright The OpenTelemetry Authors 3 | * SPDX-License-Identifier: Apache-2.0 4 | */ 5 | 6 | package io.opentelemetry.contrib.resourceproviders; 7 | 8 | import java.net.URL; 9 | import javax.annotation.Nullable; 10 | 11 | interface ResourceLocator { 12 | 13 | @Nullable 14 | Class findClass(String className); 15 | 16 | URL getClassLocation(Class clazz); 17 | } 18 | -------------------------------------------------------------------------------- /resource-providers/src/main/java/io/opentelemetry/contrib/resourceproviders/ServiceNameDetector.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright The OpenTelemetry Authors 3 | * SPDX-License-Identifier: Apache-2.0 4 | */ 5 | 6 | package io.opentelemetry.contrib.resourceproviders; 7 | 8 | import javax.annotation.Nullable; 9 | 10 | /** 11 | * Functional interface for implementations that know how to detect a service name for a specific 12 | * application server type. 13 | */ 14 | interface ServiceNameDetector { 15 | @Nullable 16 | String detect() throws Exception; 17 | } 18 | -------------------------------------------------------------------------------- /resource-providers/src/main/java/io/opentelemetry/contrib/resourceproviders/WebSphereAppServer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright The OpenTelemetry Authors 3 | * SPDX-License-Identifier: Apache-2.0 4 | */ 5 | 6 | package io.opentelemetry.contrib.resourceproviders; 7 | 8 | import java.nio.file.Path; 9 | import javax.annotation.Nullable; 10 | 11 | class WebSphereAppServer implements AppServer { 12 | 13 | private static final String SERVER_CLASS_NAME = "com.ibm.wsspi.bootstrap.WSPreLauncher"; 14 | private final ResourceLocator locator; 15 | 16 | WebSphereAppServer(ResourceLocator locator) { 17 | this.locator = locator; 18 | } 19 | 20 | @Override 21 | public boolean isValidAppName(Path path) { 22 | // query.ear is bundled with websphere 23 | String name = path.getFileName().toString(); 24 | return !"query.ear".equals(name); 25 | } 26 | 27 | @Nullable 28 | @Override 29 | public Path getDeploymentDir() { 30 | // not used 31 | return null; 32 | } 33 | 34 | @Nullable 35 | @Override 36 | public Class getServerClass() { 37 | return locator.findClass(SERVER_CLASS_NAME); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /runtime-attach/runtime-attach-core/README.md: -------------------------------------------------------------------------------- 1 | # Runtime attachment core 2 | 3 | This core attachment component exists as a separate library here for distributions of the 4 | [OpenTelemetry Java agent](https://github.com/open-telemetry/opentelemetry-java-instrumentation), 5 | to help them to build their own runtime attach component that attaches their distribution. 6 | -------------------------------------------------------------------------------- /runtime-attach/runtime-attach-core/build.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | id("otel.java-conventions") 3 | id("otel.publish-conventions") 4 | } 5 | 6 | description = "To help in create an OpenTelemetry distro able to runtime attach an OpenTelemetry Java Instrumentation agent" 7 | otelJava.moduleName.set("io.opentelemetry.contrib.attach.core") 8 | 9 | dependencies { 10 | implementation("net.bytebuddy:byte-buddy-agent:1.17.5") 11 | 12 | // Used by byte-buddy but not brought in as a transitive dependency. 13 | compileOnly("com.google.code.findbugs:annotations") 14 | } 15 | -------------------------------------------------------------------------------- /runtime-attach/runtime-attach-core/src/main/java/io/opentelemetry/contrib/attach/core/RuntimeAttachException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright The OpenTelemetry Authors 3 | * SPDX-License-Identifier: Apache-2.0 4 | */ 5 | 6 | package io.opentelemetry.contrib.attach.core; 7 | 8 | /** 9 | * Exception that gets thrown if a problem occurs during the attachment of the OpenTelemetry agent. 10 | */ 11 | public final class RuntimeAttachException extends RuntimeException { 12 | 13 | private static final long serialVersionUID = 1982913847038355735L; 14 | 15 | private RuntimeAttachException() {} 16 | 17 | RuntimeAttachException(String message) { 18 | super(message); 19 | } 20 | 21 | RuntimeAttachException(String message, Throwable cause) { 22 | super(message, cause); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /runtime-attach/runtime-attach/src/main/java/io/opentelemetry/contrib/attach/RuntimeAttach.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright The OpenTelemetry Authors 3 | * SPDX-License-Identifier: Apache-2.0 4 | */ 5 | 6 | package io.opentelemetry.contrib.attach; 7 | 8 | import io.opentelemetry.contrib.attach.core.CoreRuntimeAttach; 9 | 10 | /** This class allows you to attach the OpenTelemetry Java agent at runtime. */ 11 | public final class RuntimeAttach { 12 | 13 | /** 14 | * Attach the OpenTelemetry Java agent to the current JVM. The attachment must be requested at the 15 | * beginning of the main method. 16 | */ 17 | @SuppressWarnings("MemberName") 18 | public static void attachJavaagentToCurrentJvm() { 19 | 20 | CoreRuntimeAttach distroRuntimeAttach = new CoreRuntimeAttach("/otel-agent.jar"); 21 | 22 | distroRuntimeAttach.attachJavaagentToCurrentJvm(); 23 | } 24 | 25 | private RuntimeAttach() {} 26 | } 27 | -------------------------------------------------------------------------------- /runtime-attach/runtime-attach/src/test/java/io/opentelemetry/contrib/attach/AbstractAttachmentTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright The OpenTelemetry Authors 3 | * SPDX-License-Identifier: Apache-2.0 4 | */ 5 | 6 | package io.opentelemetry.contrib.attach; 7 | 8 | import io.opentelemetry.javaagent.shaded.io.opentelemetry.api.trace.Span; 9 | import org.junit.jupiter.api.BeforeAll; 10 | 11 | public class AbstractAttachmentTest { 12 | 13 | @BeforeAll 14 | static void disableMainThreadCheck() { 15 | System.setProperty("otel.javaagent.testing.runtime-attach.main-method-check", "false"); 16 | } 17 | 18 | boolean isAttached() { 19 | return Span.current().getSpanContext().isValid(); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /runtime-attach/runtime-attach/src/test/java/io/opentelemetry/contrib/attach/AgentDisabledByEnvironmentVariableTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright The OpenTelemetry Authors 3 | * SPDX-License-Identifier: Apache-2.0 4 | */ 5 | 6 | package io.opentelemetry.contrib.attach; 7 | 8 | import static org.assertj.core.api.Assertions.assertThat; 9 | 10 | import io.opentelemetry.instrumentation.annotations.WithSpan; 11 | import org.junit.jupiter.api.Test; 12 | 13 | public class AgentDisabledByEnvironmentVariableTest extends AbstractAttachmentTest { 14 | 15 | @Test 16 | void shouldNotAttachWhenAgentDisabledWithEnvVariable() { 17 | RuntimeAttach.attachJavaagentToCurrentJvm(); 18 | verifyNoAttachment(); 19 | } 20 | 21 | @WithSpan 22 | void verifyNoAttachment() { 23 | assertThat(isAttached()).as("Agent should not be attached").isFalse(); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /runtime-attach/runtime-attach/src/test/java/io/opentelemetry/contrib/attach/AgentDisabledBySystemPropertyTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright The OpenTelemetry Authors 3 | * SPDX-License-Identifier: Apache-2.0 4 | */ 5 | 6 | package io.opentelemetry.contrib.attach; 7 | 8 | import static org.assertj.core.api.Assertions.assertThat; 9 | 10 | import io.opentelemetry.instrumentation.annotations.WithSpan; 11 | import org.junit.jupiter.api.Test; 12 | 13 | public class AgentDisabledBySystemPropertyTest extends AbstractAttachmentTest { 14 | 15 | @Test 16 | void shouldNotAttachWhenAgentDisabledWithProperty() { 17 | RuntimeAttach.attachJavaagentToCurrentJvm(); 18 | verifyNoAttachment(); 19 | } 20 | 21 | @WithSpan 22 | void verifyNoAttachment() { 23 | assertThat(isAttached()).as("Agent should not be attached").isFalse(); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /runtime-attach/runtime-attach/src/test/java/io/opentelemetry/contrib/attach/RunTimeAttachBasicTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright The OpenTelemetry Authors 3 | * SPDX-License-Identifier: Apache-2.0 4 | */ 5 | 6 | package io.opentelemetry.contrib.attach; 7 | 8 | import static org.assertj.core.api.Assertions.assertThat; 9 | 10 | import io.opentelemetry.instrumentation.annotations.WithSpan; 11 | import org.junit.jupiter.api.Test; 12 | 13 | public class RunTimeAttachBasicTest extends AbstractAttachmentTest { 14 | 15 | @Test 16 | void shouldAttach() { 17 | RuntimeAttach.attachJavaagentToCurrentJvm(); 18 | verifyAttachment(); 19 | } 20 | 21 | @WithSpan 22 | void verifyAttachment() { 23 | assertThat(isAttached()).as("Agent should be attached").isTrue(); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /samplers/build.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | id("otel.java-conventions") 3 | id("otel.publish-conventions") 4 | } 5 | 6 | description = "Sampler which makes its decision based on semantic attributes values" 7 | otelJava.moduleName.set("io.opentelemetry.contrib.sampler") 8 | 9 | dependencies { 10 | api("io.opentelemetry:opentelemetry-sdk") 11 | 12 | compileOnly("io.opentelemetry:opentelemetry-sdk-extension-autoconfigure-spi") 13 | compileOnly("io.opentelemetry:opentelemetry-api-incubator") 14 | compileOnly("io.opentelemetry:opentelemetry-sdk-extension-incubator") 15 | 16 | testImplementation("io.opentelemetry.semconv:opentelemetry-semconv-incubating") 17 | testImplementation("io.opentelemetry:opentelemetry-sdk-extension-autoconfigure") 18 | testImplementation("io.opentelemetry:opentelemetry-sdk-extension-incubator") 19 | } 20 | -------------------------------------------------------------------------------- /samplers/src/main/java/io/opentelemetry/contrib/sampler/LinksParentAlwaysOnSamplerProvider.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright The OpenTelemetry Authors 3 | * SPDX-License-Identifier: Apache-2.0 4 | */ 5 | 6 | package io.opentelemetry.contrib.sampler; 7 | 8 | import io.opentelemetry.sdk.autoconfigure.spi.ConfigProperties; 9 | import io.opentelemetry.sdk.autoconfigure.spi.traces.ConfigurableSamplerProvider; 10 | import io.opentelemetry.sdk.trace.samplers.Sampler; 11 | 12 | public class LinksParentAlwaysOnSamplerProvider implements ConfigurableSamplerProvider { 13 | @Override 14 | public Sampler createSampler(ConfigProperties config) { 15 | return LinksBasedSampler.create(Sampler.parentBased(Sampler.alwaysOn())); 16 | } 17 | 18 | @Override 19 | public String getName() { 20 | return "linksbased_parentbased_always_on"; 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /samplers/src/main/resources/META-INF/services/io.opentelemetry.sdk.autoconfigure.spi.internal.ComponentProvider: -------------------------------------------------------------------------------- 1 | io.opentelemetry.contrib.sampler.internal.RuleBasedRoutingSamplerComponentProvider 2 | -------------------------------------------------------------------------------- /samplers/src/main/resources/META-INF/services/io.opentelemetry.sdk.autoconfigure.spi.traces.ConfigurableSamplerProvider: -------------------------------------------------------------------------------- 1 | io.opentelemetry.contrib.sampler.LinksParentAlwaysOnSamplerProvider 2 | -------------------------------------------------------------------------------- /span-stacktrace/build.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | id("otel.java-conventions") 3 | id("otel.publish-conventions") 4 | } 5 | 6 | description = "OpenTelemetry Java span stacktrace capture module" 7 | otelJava.moduleName.set("io.opentelemetry.contrib.stacktrace") 8 | 9 | dependencies { 10 | annotationProcessor("com.google.auto.service:auto-service") 11 | compileOnly("com.google.auto.service:auto-service-annotations") 12 | 13 | api("io.opentelemetry:opentelemetry-sdk") 14 | testImplementation("io.opentelemetry:opentelemetry-sdk-testing") 15 | 16 | compileOnly("io.opentelemetry:opentelemetry-sdk-extension-autoconfigure") 17 | compileOnly("io.opentelemetry:opentelemetry-sdk-extension-autoconfigure-spi") 18 | testImplementation("io.opentelemetry:opentelemetry-sdk-extension-autoconfigure") 19 | testImplementation("io.opentelemetry:opentelemetry-sdk-extension-autoconfigure-spi") 20 | 21 | testImplementation("io.opentelemetry.semconv:opentelemetry-semconv-incubating") 22 | 23 | testAnnotationProcessor("com.google.auto.service:auto-service") 24 | testCompileOnly("com.google.auto.service:auto-service-annotations") 25 | 26 | testImplementation("io.opentelemetry:opentelemetry-exporter-logging") 27 | } 28 | -------------------------------------------------------------------------------- /version.gradle.kts: -------------------------------------------------------------------------------- 1 | val stableVersion = "1.48.0-SNAPSHOT" 2 | val alphaVersion = "1.48.0-alpha-SNAPSHOT" 3 | 4 | allprojects { 5 | if (findProperty("otel.stable") != "true") { 6 | version = alphaVersion 7 | } else { 8 | version = stableVersion 9 | } 10 | } 11 | --------------------------------------------------------------------------------