31 Ekim 2022 Pazartesi

OpenTelemetry Nedir?

OpenTelemetry Nedir?
Açıklaması şöyle. Yani Open Tracing ve OpenCensus projelerinin birleşmesinden ortaya çıkmıştır.
The OpenTelemetry website states that:

"OpenTelemetry is a collection of tools, APIs, and SDKs. Use it to instrument, generate, collect, and export telemetry data (metrics, logs, and traces) to help you analyze your software's performance and behavior."

OpenTelemetry was created by merging the popular OpenTracing and OpenCensus projects. It is a standard that integrates with many open source and commercial products written in many programming languages. Implementations of OpenTelemetry are in varying stages of maturity.

At its core, OpenTelemetry contains the Collector, a vendor-agnostic way to receive, process, and export telemetry data.
OpenTelemetry Nasıl Çalışır
- Uygulama OpenTelemetry SDK ile instrument edilir.
- Artık loglar bir OpenTelemetry Collector'a gönderilir. 
- Collector üzerinde gerekli filtrelemeler yapılır ve 
- Collector logları bir backend'e gönderir.
Şeklen şöyle


instrumentation-annotations
Maven
Şu satırı dahil ederiz
<dependency>
  <groupId>io.opentelemetry.instrumentation</groupId>
  <artifactId>opentelemetry-instrumentation-annotations</artifactId>
  <version>1.17.0-alpha</version>
</dependency>
Örnek
Şöyle yaparız
import io.opentelemetry.instrumentation.annotations.SpanAttribute
import io.opentelemetry.instrumentation.annotations.WithSpan

@WithSpan("ProductHandler.fetch")
suspend fun fetch(@SpanAttribute("id") id: Long): Result<Product> {
  ...
}
OpenTelemetry Backend Nedir?
OpenTelemetry Backend yazısına taşıdım

OpenTelemetry Operator
Şöyle yaparız
kubectl apply \
-f https://github.com/open-telemetry/opentelemetry-operator/releases/latest/download/opentelemetry-operator.yaml



30 Ekim 2022 Pazar

Jenkins Credentials

Örnek - token
Açıklaması şöyle
Go to Manage Jenkins-> Manage Credentials-> Choose Secret Text type credential and paste the token which is generated in Jfrog Platform and add ID and Description as artifactory-access-token

Örnek - Kullanıcı İsmi ve Şifre
Açıklaması şöyle
To publish an image to your repository you will need to add the credentials of your Docker Hub account to Jenkins, do so by navigating to Manage Jenkins > Manage Credentials > System > Global Credentials > Add Credentials. Add your credentials and give them an id that you will use later.
Şeklen şöyle




29 Ekim 2022 Cumartesi

Jenkins Global Tool Configuration

Giriş
Menü şöyle
Manage Jenkins > Global Tool Configuration
Node.Js ve Docker Kurulum
Açıklaması şöyle
Go back to the dashboard and then to Manage Jenkins > Global Tool Configuration. For both Docker and NodeJS, give it a name and select Install automatically, then select install from nodejs.org and from docker.com. Click Save/Apply.
Node.js şeklen şöyle

Docker şeklen şöyle


27 Ekim 2022 Perşembe

sqlline komutu

Giriş
MySQL için mysqlsh kullanılabilir

-d seçeneği
Kullanılacak JDBC sürücüsünü belirtir.
Örnek
Şöyle yaparız
$ ./sqlline -d com.hazelcast.jdbc.Driver -u jdbc:hazelcast://localhost:5701

25 Ekim 2022 Salı

Docker Compose ve Prometheus

Örnek
Şöyle yaparız
version: "3"
services:
  app:
    image: quiz-server:latest
    container_name: 'quiz-server'
    build:
      context: ./
      dockerfile: Dockerfile
    ports:
    - '8080:8080'
  prometheus:
    image: prom/prometheus
    container_name: 'prometheus'
    volumes:
    - ./monitor/:/etc/prometheus/
    ports:
    - '9090:9090'
  grafana:
    image: grafana/grafana
    container_name: 'grafana'
    ports:
    - '3000:3000'
    depends_on:
    - prometheus
Örnek
Şöyle yaparız
services:
  prometheus:
      image: prom/prometheus:v2.35.0
      network_mode: host
      container_name: prometheus
      restart: unless-stopped
      volumes:
        - ./data/prometheus/config:/etc/prometheus/
      command:
        - "--config.file=/etc/prometheus/prometheus.yaml"
Örnek
Şöyle yaparız
version: "3.8"

services:
  prometheus:
    container_name: prometheus
    image: prom/prometheus:v2.44.0
    user: root
    volumes:
      - ./prometheus:/etc/prometheus
    command:
      - --config.file=/etc/prometheus/prometheus-config.yaml
      - --log.level=debug
    ports:
      - "9090:9090"
    networks:
      - prometheus-network

networks:
 prometheus-network:
./prometheus/prometheus-config.yaml dosyası Prometheus tarafından /etc/prometheus/prometheus-config.yaml olarak görülür

node_exporter
node_exporter ile işletim sistemini de izlemek mümkün. 
Örnek 
Şöyle yaparız
version: "3.9"

services:
  microservices_postgresql:
    image: postgres:latest
    container_name: microservices_postgresql
    expose:
      - "5432"
    ports:
      - "5432:5432"
    restart: always
    environment:
      - POSTGRES_USER=postgres
      - POSTGRES_PASSWORD=postgres
      - POSTGRES_DB=bank_accounts
      - POSTGRES_HOST=5432
    command: -p 5432
    volumes:
      - ./docker_data/microservices_pgdata:/var/lib/postgresql/data
    networks: [ "microservices" ]

  redis:
    image: redis:latest
    container_name: microservices_redis
    ports:
      - "6379:6379"
    restart: always
    networks: [ "microservices" ]

  prometheus:
    image: prom/prometheus:latest
    container_name: prometheus
    ports:
      - "9090:9090"
    command:
      - --config.file=/etc/prometheus/prometheus.yml
    volumes:
      - ./monitoring/prometheus.yml:/etc/prometheus/prometheus.yml:ro
    networks: [ "microservices" ]

  node_exporter:
    container_name: microservices_node_exporter
    restart: always
    image: prom/node-exporter
    ports:
      - '9101:9100'
    networks: [ "microservices" ]

  grafana:
    container_name: microservices_grafana
    restart: always
    image: grafana/grafana
    ports:
      - '3000:3000'
    networks: [ "microservices" ]

  zipkin:
    image: openzipkin/zipkin:latest
    restart: always
    container_name: microservices_zipkin
    ports:
      - "9411:9411"
    networks: [ "microservices" ]


networks:
  microservices:
    name: microservices

21 Ekim 2022 Cuma

Google Cloud - Google Cloud Storage

GCS kullanan yazılımları test etmek için TestContainers kullanılabilir. Bir örnek burada. Açıklaması şöyle
Google Cloud offers a series of emulators for Testcontainers, such as an emulator for BigQuery or PubSub. Unfortunately, an emulator for Google Cloud Storage is not available.

However, fsouza, a GitHub user, generously made an Open Source library for emulating Google Cloud Storage API.
Create a Bucket
Açıklaması şöyle
From the left menu, go to Cloud Storage and then you can create a bucket.
Şeklen şöyle


Service account
Google Cloud Storage'a erişmek için Service Account lazım. Şöyle yaparız
- Click on the left menu and IAM & Admin -> Service Accounts

- Click on the CREATE SERVICE ACCOUNT


- Now you can fill in the required details.
- Then click on the created service account email.
- Then click on KEYS -> ADD KEY -> Create new key as below.


- Then it will ask about the key type, choose JSON and the key will be downloaded. This is required for the Spring Boot service.