Skip to content

Java 25 Lambda with OTEL Metrics Exporter (Direct OTLP to New Relic) intermittently loses metric datapoints #1445

Description

@vidyarajsv

We are observing intermittent metric loss when using the AWS OTel Lambda Layer with a Java 25 Lambda runtime and Micrometer instrumentation.

A custom Micrometer counter is incremented once per successfully processed business event. During testing, the number of metric datapoints received by New Relic does not match the actual number of processed events or Lambda invocations.

For one test window:

we lost 5 metrics

we receive below error in the log :

[otel.javaagent 2026-08-28 04:34:07:301 +0000] [OkHttp https://otlp.nr-data.net/...] ERROR io.opentelemetry.exporter.otlp.internal.HttpExporter - Failed to export metrics. The request could not be executed.

java.io.InterruptedIOException: timeout

Caused by: java.io.IOException: Canceled

      AWS_LAMBDA_EXEC_WRAPPER: "/opt/otel-secret-wrapper.sh"
      ENVIRONMENT_TAG: !Ref 'EnvironmentTag'
      #  Service metadata
      OTEL_SERVICE_NAME: !Sub '${FunctionName}-${EnvironmentTag}'
      OTEL_INSTRUMENTATION_COMMON_DEFAULT_ENABLED: "false"
      OTEL_INSTRUMENTATION_AWS_LAMBDA_ENABLED: "true"
      OTEL_INSTRUMENTATION_AWS_SDK_ENABLED: "false"
      OTEL_INSTRUMENTATION_MICROMETER_ENABLED: "true"
      OTEL_AWS_SERVICE_EVENTS_FUNCTION_INSTRUMENT_ENABLED: "false"
      OTEL_METRICS_EXPORTER: "otlp"
      OTEL_TRACES_EXPORTER: "none"
      OTEL_LOGS_EXPORTER: "none"
      OTEL_EXPORTER_OTLP_PROTOCOL: "http/protobuf"
      OTEL_EXPORTER_OTLP_ENDPOINT: "https://otlp.nr-data.net"
      OTEL_RESOURCE_ATTRIBUTES: !Sub >-
        deployment.environment=${EnvironmentTag}
      # --- FIXED: FORCE SYNCHRONOUS AND INSTANT METRIC FLUSHES ---
      OTEL_JAVA_GLOBAL_AUTOCONFIGURE_ENABLED: "true"
      # Export interval aligned to Lambda invocation cadence. A 1-second interval
      # causes overlapping OkHttp requests in a VPC (DNS+TLS overhead), leading to
      # InterruptedIOException/Canceled errors and metric loss. 60 seconds gives each
      # export request room to complete before the next one starts. Timeouts are set
      # generously above typical VPC round-trip to New Relic (~1-2s) so requests are
      # not prematurely canceled by the retry interceptor.
      OTEL_METRIC_EXPORT_INTERVAL: "60000"
      OTEL_METRIC_EXPORT_TIMEOUT: "30000"
      OTEL_EXPORTER_OTLP_TIMEOUT: "30000"
      OTEL_EXPORTER_OTLP_METRICS_TEMPORALITY_PREFERENCE: "delta"
      JDK_JAVA_OPTIONS: "-XX:AOTMode=off"

Let me know what configuration we need to change

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions