<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <parent>
        <groupId>io.last9</groupId>
        <artifactId>vertx-otel-autoconfigure</artifactId>
    <version>2.4.0</version>
    </parent>

    <artifactId>vertx-otel-core</artifactId>
    <packaging>jar</packaging>

    <properties>
        <!-- vertx-otel-core is an internal module — it gets shaded into the two published JARs.
             It is published to Maven Central only because the central-publishing-maven-plugin
             bundles all staged artifacts regardless of skipPublishing=true. Consumers should
             depend on vertx4-rxjava3-otel-autoconfigure or vertx3-rxjava2-otel-autoconfigure
             instead, which include all required classes. -->
        <maven.deploy.skip>true</maven.deploy.skip>
    </properties>

    <name>Vert.x OTel Core</name>
    <description>
        Shared OpenTelemetry utilities: SDK auto-configuration, Logback MDC trace injection.
        No Vert.x dependency — used by both Vert.x 3 and Vert.x 4 modules.
    </description>

    <dependencies>
        <!-- OpenTelemetry SDK Auto-Configure -->
        <dependency>
            <groupId>io.opentelemetry</groupId>
            <artifactId>opentelemetry-sdk-extension-autoconfigure</artifactId>
        </dependency>

        <!-- OpenTelemetry OTLP Exporter -->
        <dependency>
            <groupId>io.opentelemetry</groupId>
            <artifactId>opentelemetry-exporter-otlp</artifactId>
        </dependency>

        <!-- OkHttp HTTP sender for OTLP export.
             Replaces sender-jdk (which requires Java 11's HttpClient) so the agent
             works on Java 8. OkHttp 4.x targets Java 8 bytecode.
             Shaded as io.last9.internal.okhttp3 to avoid conflicts with customer
             fat JARs that bundle their own OkHttp (e.g. Retrofit). -->
        <dependency>
            <groupId>io.opentelemetry</groupId>
            <artifactId>opentelemetry-exporter-sender-okhttp</artifactId>
        </dependency>

        <!-- OpenTelemetry Semantic Conventions -->
        <dependency>
            <groupId>io.opentelemetry.semconv</groupId>
            <artifactId>opentelemetry-semconv</artifactId>
        </dependency>

        <!-- OpenTelemetry Logback Appender (for log export via OTLP) -->
        <dependency>
            <groupId>io.opentelemetry.instrumentation</groupId>
            <artifactId>opentelemetry-logback-appender-1.0</artifactId>
            <version>${opentelemetry-instrumentation.version}-alpha</version>
        </dependency>

        <!-- OpenTelemetry Logback MDC (for trace_id/span_id injection) -->
        <dependency>
            <groupId>io.opentelemetry.instrumentation</groupId>
            <artifactId>opentelemetry-logback-mdc-1.0</artifactId>
            <version>${opentelemetry-instrumentation.version}-alpha</version>
        </dependency>

        <!-- JVM runtime metrics: memory, GC, threads, CPU, class-loading -->
        <dependency>
            <groupId>io.opentelemetry.instrumentation</groupId>
            <artifactId>opentelemetry-runtime-telemetry-java8</artifactId>
            <version>${opentelemetry-instrumentation.version}-alpha</version>
        </dependency>

        <!-- Process/host/OS resource providers (process.pid, host.name, os.type, etc.).
             Registers ProcessResourceProvider, HostResourceProvider, OsResourceProvider via SPI
             so autoconfigure picks them up without manual attribute building. -->
        <dependency>
            <groupId>io.opentelemetry.instrumentation</groupId>
            <artifactId>opentelemetry-resources</artifactId>
            <version>${opentelemetry-instrumentation.version}-alpha</version>
        </dependency>

        <!-- Cloud resource detectors (AWS EC2/ECS/EKS, GCP GCE/GKE) REMOVED.
             Their IMDS/metadata HTTP calls during SDK init use OkHttp, whose orphaned
             thread pools interfere with the JDK HttpClient used by the OTLP trace
             exporter — causing traces to silently fail while metrics continue working.
             Cloud attributes should be added by the OTel Collector's resourcedetection
             processor instead (resourcedetection/ec2, resourcedetection/gcp).
             See: https://github.com/open-telemetry/opentelemetry-java-contrib/issues/1351 -->

        <!-- Logging -->
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-api</artifactId>
        </dependency>
        <dependency>
            <groupId>ch.qos.logback</groupId>
            <artifactId>logback-classic</artifactId>
            <scope>provided</scope>
        </dependency>
    </dependencies>

    <!-- Skip Central Portal publishing for this internal-only module. -->
    <profiles>
        <profile>
            <id>release</id>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.sonatype.central</groupId>
                        <artifactId>central-publishing-maven-plugin</artifactId>
                        <version>0.6.0</version>
                        <extensions>true</extensions>
                        <configuration>
                            <skipPublishing>true</skipPublishing>
                        </configuration>
                    </plugin>
                </plugins>
            </build>
        </profile>
    </profiles>

    <build>
        <plugins>
            <!-- Compile to Java 8 so the agent works on Java 8 JVMs.
                 OkHttp sender (replacing sender-jdk) satisfies the only Java 11 dependency. -->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <configuration>
                    <release>8</release>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-jar-plugin</artifactId>
                <configuration>
                    <archive>
                        <manifestEntries>
                            <Automatic-Module-Name>io.last9.tracing.otel</Automatic-Module-Name>
                        </manifestEntries>
                    </archive>
                </configuration>
            </plugin>
        </plugins>
    </build>
</project>
