Skip to content

Conversation

chgl
Copy link
Contributor

@chgl chgl commented Aug 18, 2022

This adds the https://github.com/open-telemetry/opentelemetry-java-instrumentation agent jar to the container to allow tracing and metrics export without any code changes.

It can be enabled by setting the following environment variables:

      JAVA_OPTS: "-javaagent:/var/lib/ohdsi/webapi/opentelemetry-javaagent.jar"
      OTEL_TRACES_EXPORTER: "jaeger"
      OTEL_METRICS_EXPORTER: "prometheus"
      OTEL_LOGS_EXPORTER: "none"
      OTEL_SERVICE_NAME: "ohdsi-webapi"
      OTEL_EXPORTER_JAEGER_ENDPOINT: "http://jaeger:14250"

see https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/sdk-environment-variables.md for details on the settings.

Here's a complete Docker Compose setup:

services:
  db:
    image: docker.io/library/postgres:14.5@sha256:f8816ada742348e1adfcec5c2a180b675bf6e4a294e0feb68bd70179451e1242
    environment:
      POSTGRES_PASSWORD: postgres
      POSTGRES_DB: ohdsi

  jaeger:
    image: docker.io/jaegertracing/all-in-one:1.37@sha256:60ab2e6b0682f79a4e42b2bd2526ac4de80a3a7a1ef136c71dc0cb85e9c50f46
    ports:
      - 127.0.0.1:16686:16686

  webapi:
    image: docker.io/library/webapi:latest
    ports:
      - 127.0.0.1:8080:8080
      - 127.0.0.1:9464:9464
    environment:
      DATASOURCE_DRIVERCLASSNAME: org.postgresql.Driver
      DATASOURCE_OHDSI_SCHEMA: ohdsi
      DATASOURCE_PASSWORD: postgres
      DATASOURCE_URL: jdbc:postgresql://db:5432/ohdsi
      DATASOURCE_USERNAME: postgres
      FLYWAY_DATASOURCE_DRIVERCLASSNAME: org.postgresql.Driver
      FLYWAY_DATASOURCE_PASSWORD: postgres
      FLYWAY_DATASOURCE_URL: jdbc:postgresql://db:5432/ohdsi
      FLYWAY_DATASOURCE_USERNAME: postgres
      FLYWAY_PLACEHOLDERS_OHDSISCHEMA: ohdsi
      FLYWAY_SCHEMAS: ohdsi
      SECURITY_CORS_ENABLED: "false"
      SPRING_BATCH_REPOSITORY_TABLEPREFIX: ohdsi.BATCH_
      SPRING_JPA_PROPERTIES_HIBERNATE_DEFAULT_SCHEMA: ohdsi
      SPRING_JPA_PROPERTIES_HIBERNATE_DIALECT: org.hibernate.dialect.PostgreSQLDialect
      JAVA_OPTS: "-javaagent:/var/lib/ohdsi/webapi/opentelemetry-javaagent.jar"
      OTEL_TRACES_EXPORTER: "jaeger"
      OTEL_METRICS_EXPORTER: "prometheus"
      OTEL_LOGS_EXPORTER: "none"
      OTEL_SERVICE_NAME: "ohdsi-webapi"
      OTEL_EXPORTER_JAEGER_ENDPOINT: "http://jaeger:14250"

Closes #2066

Copy link
Contributor

@leeevans leeevans left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@leeevans leeevans merged commit 1189ceb into OHDSI:master Sep 11, 2022
@chgl chgl deleted the added-otel-java-agent branch September 11, 2022 19:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Consider adding the OpenTelemetry Java Agent for auto-instrumenting the service
2 participants