Giter Site home page Giter Site logo

build-on-aws / instrumenting-java-apps-using-opentelemetry Goto Github PK

View Code? Open in Web Editor NEW
50.0 26.0 43.0 1.94 MB

Microservice written in Java that shows how to instrument applications using OpenTelemetry, to produce telemetry data for traces and metrics. Also how to switch the observability backend without code changes.

License: MIT No Attribution

Dockerfile 8.54% Shell 14.28% Java 77.18%
grafana java metrics observability opentelemetry prometheus tracing opentelemetry-collector cloud-watch aws-x-ray grafana-tempo otlp

instrumenting-java-apps-using-opentelemetry's Issues

Grafana throwing broken pipe error.

I am following the YouTube playlist. At this moment, I am at the Sending generated traces to Grafana Tempo section. But I am stuck at a point where Grafana is throwing this error,

grafana | logger=context userId=0 orgId=1 uname= t=2023-09-07T[06:41:37](https://www.youtube.com/watch?v=V5GtJRZtZ90&t=24097s).619090527Z level=error msg="Request error" error="Context.HTML:write tcp 127.0.0.1:3000->127.0.0.1:55340: write: broken pipe".

This error has been continuously thrown. Apart from that, another log is being printed on the console, that is,

tempo | level=info ts=2023-09-07T07:25:29.394063056Z caller=compactor.go:101 msg="starting compaction cycle" tenantID=single-tenant offset=0 tempo | level=info ts=2023-09-07T07:25:29.394119656Z caller=compactor.go:107 msg="compaction cycle complete. No more blocks to compact" tenantID=single-tenant

In one reply to a youtube comment, you suggested changing the latest to a specific version inside the docker-compose file. I already did that but nothing is fixed.

It would be great if you could help me out.

Here is the docker compose file of mine,

version: '3.0'

services:

  collector:
    image: otel/opentelemetry-collector:latest
    container_name: collector
    hostname: collector
    depends_on:
      tempo:
        condition: service_healthy
      prometheus:
        condition: service_healthy
    command: ["--config=/etc/collector-config.yaml"]
    volumes:
      - ./collector-config-local.yaml:/etc/collector-config.yaml
    ports:
      - "5555:5555"
      - "6666:6666"

  tempo:
    image: grafana/tempo:1.5.0
    command: [ "-search.enabled=true", "-config.file=/etc/tempo.yaml" ]
    container_name: tempo
    hostname: tempo
    volumes:
      - ./o11y-backend/tempo-config.yaml:/etc/tempo.yaml
      - ./o11y-backend/tempo-overrides.yaml:/etc/overrides.yaml
      - ./tempo-data:/tmp/tempo
    ports:
      - "3200:3200"
      - "4317:4317"
    healthcheck:
      interval: 5s
      retries: 10
      test: wget --no-verbose --tries=1 --spider http://localhost:3200/status || exit 1

  prometheus:
    image: prom/prometheus:v2.39.2
    container_name: prometheus
    hostname: prometheus
    command:
      - --config.file=/etc/prometheus.yaml
      - --web.enable-remote-write-receiver
      - --enable-feature=exemplar-storage
    volumes:
      - ./o11y-backend/prometheus.yaml:/etc/prometheus.yaml
    ports:
      - "9090:9090"
    healthcheck:
      interval: 5s
      retries: 10
      test: wget --no-verbose --tries=1 --spider http://localhost:9090/status || exit 1

  grafana:
    image: grafana/grafana:9.2.2
    container_name: grafana
    hostname: grafana
    depends_on:
      tempo:
        condition: service_healthy
      prometheus:
        condition: service_healthy
    volumes:
      - ./o11y-backend/grafana-bootstrap.ini:/etc/grafana/grafana.ini
      - ./o11y-backend/grafana-datasources.yaml:/etc/grafana/provisioning/datasources/datasources.yaml
    environment:
      - GF_AUTH_ANONYMOUS_ENABLED=true
      - GF_AUTH_ANONYMOUS_ORG_ROLE=Admin
      - GF_AUTH_DISABLE_LOGIN_FORM=true
    ports:
      - "3000:3000"
    healthcheck:
      interval: 5s
      retries: 10
      test: wget --no-verbose --tries=1 --spider http://localhost:3000 || exit 1

networks:
  default:
    name: inst-java-apps-using-otel 

Support for Java 11

Thank you for this outstanding tutorial.

I am restricted to Java 11 for now. To do this I made simple updates to 2 files: pom.xml and HelloAppController.java.

pom.xml

Replace 17 with 11.

           <maven.compiler.release>11</maven.compiler.release>
           :
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.11.0</version>
                <configuration>
                    <release>${maven.compiler.release}</release>
                </configuration>
            </plugin>

HelloAppController.java

Replace private record Response (String message) {...}

with

    public class Response {
        String message;
        public Response(String message) {
            Objects.requireNonNull(message);
            this.message = message;
        }
        public boolean isValid() {
            return true;
        }
        public String getMessage() { return this.message; }

      @Override
      public boolean equals(Object obj) {
        if (obj == this) return true;
        if (obj == null || obj.getClass() != this.getClass()) return false;
        Response that = (Response) obj;
        return this.message == that.message;
      }

      @Override
      public int hashCode() {
        return Objects.hash(message);
      }

      @Override
      public String toString() {
        return this.message;
      }
    }

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.