Skip to content

Commit

Permalink
Imageprovider (#1462)
Browse files Browse the repository at this point in the history
* [Imageprovider] Create Nginx service to host images, add instrumentation to it

Signed-off-by: krisztian.klucsik <[email protected]>

* add missing OTEL_RESOURCE_ATTRIBUTES flags

* adjust otel config

* fix leading /

---------

Signed-off-by: krisztian.klucsik <[email protected]>
Co-authored-by: Austin Parker <[email protected]>
  • Loading branch information
klucsik and austinlparker authored Apr 4, 2024
1 parent 59cdb0a commit 06023dd
Show file tree
Hide file tree
Showing 19 changed files with 137 additions and 0 deletions.
4 changes: 4 additions & 0 deletions .env
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,10 @@ FRONTEND_HOST=frontend
ENVOY_PORT=8080
FRONTEND_PROXY_ADDR=frontend-proxy:${ENVOY_PORT}

# Image Provider
IMAGE_PROVIDER_HOST=imageprovider
IMAGE_PROVIDER_PORT=8081

# Load Generator
LOCUST_WEB_PORT=8089
LOCUST_USERS=10
Expand Down
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ the release.
([#1470](https://github.com/open-telemetry/opentelemetry-demo/pull/1470))
* [frontend] disable instrumentation-fs library
([#1473](https://github.com/open-telemetry/opentelemetry-demo/pull/1473))
* [Imageprovider] Create Nginx service to host images, add instrumentation to it
([#1462](https://github.com/open-telemetry/opentelemetry-demo/pull/1462))

## 1.8.0

Expand Down
31 changes: 31 additions & 0 deletions docker-compose.minimal.yml
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,8 @@ services:
condition: service_started
otelcol:
condition: service_started
imageprovider:
condition: service_started
logging: *logging

# Frontend Proxy (Envoy)
Expand Down Expand Up @@ -256,6 +258,8 @@ services:
- GRAFANA_SERVICE_HOST
- JAEGER_SERVICE_PORT
- JAEGER_SERVICE_HOST
- IMAGE_PROVIDER_HOST
- IMAGE_PROVIDER_PORT
- OTEL_COLLECTOR_HOST
- OTEL_COLLECTOR_PORT_GRPC
- OTEL_COLLECTOR_PORT_HTTP
Expand All @@ -271,6 +275,33 @@ services:
grafana:
condition: service_started

# Imageprovider
imageprovider:
image: ${IMAGE_NAME}:${DEMO_VERSION}-imageprovider
container_name: imageprovider
build:
context: ./
dockerfile: ./src/imageprovider/Dockerfile
cache_from:
- ${IMAGE_NAME}:${IMAGE_VERSION}-imageprovider
deploy:
resources:
limits:
memory: 120M
restart: unless-stopped
ports:
- "${IMAGE_PROVIDER_PORT}"
environment:
- IMAGE_PROVIDER_PORT
- OTEL_COLLECTOR_HOST
- OTEL_COLLECTOR_PORT_GRPC
- OTEL_SERVICE_NAME=imageprovider
- OTEL_RESOURCE_ATTRIBUTES
depends_on:
otelcol:
condition: service_started
logging: *logging

# Load Generator
loadgenerator:
image: ${IMAGE_NAME}:${DEMO_VERSION}-loadgenerator
Expand Down
31 changes: 31 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,8 @@ services:
condition: service_started
otelcol:
condition: service_started
imageprovider:
condition: service_started
logging: *logging

# Frontend Proxy (Envoy)
Expand Down Expand Up @@ -336,6 +338,8 @@ services:
- JAEGER_SERVICE_PORT
- JAEGER_SERVICE_HOST
- OTEL_COLLECTOR_HOST
- IMAGE_PROVIDER_HOST
- IMAGE_PROVIDER_PORT
- OTEL_COLLECTOR_PORT_GRPC
- OTEL_COLLECTOR_PORT_HTTP
- OTEL_RESOURCE_ATTRIBUTES
Expand All @@ -350,6 +354,33 @@ services:
grafana:
condition: service_started

# Imageprovider
imageprovider:
image: ${IMAGE_NAME}:${DEMO_VERSION}-imageprovider
container_name: imageprovider
build:
context: ./
dockerfile: ./src/imageprovider/Dockerfile
cache_from:
- ${IMAGE_NAME}:${IMAGE_VERSION}-imageprovider
deploy:
resources:
limits:
memory: 120M
restart: unless-stopped
ports:
- "${IMAGE_PROVIDER_PORT}"
environment:
- IMAGE_PROVIDER_PORT
- OTEL_COLLECTOR_HOST
- OTEL_COLLECTOR_PORT_GRPC
- OTEL_SERVICE_NAME=imageprovider
- OTEL_RESOURCE_ATTRIBUTES
depends_on:
otelcol:
condition: service_started
logging: *logging

# Load Generator
loadgenerator:
image: ${IMAGE_NAME}:${DEMO_VERSION}-loadgenerator
Expand Down
14 changes: 14 additions & 0 deletions src/frontendproxy/envoy.tmpl.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ static_resources:
route: { cluster: jaeger }
- match: { prefix: "/grafana" }
route: { cluster: grafana }
- match: { prefix: "/images/" }
route: { cluster: imageprovider, prefix_rewrite: "/" }
- match: { prefix: "/" }
route: { cluster: frontend }
http_filters:
Expand Down Expand Up @@ -94,6 +96,18 @@ static_resources:
socket_address:
address: ${FRONTEND_HOST}
port_value: ${FRONTEND_PORT}
- name: imageprovider
type: STRICT_DNS
lb_policy: ROUND_ROBIN
load_assignment:
cluster_name: imageprovider
endpoints:
- lb_endpoints:
- endpoint:
address:
socket_address:
address: ${IMAGE_PROVIDER_HOST}
port_value: ${IMAGE_PROVIDER_PORT}
- name: loadgen
type: STRICT_DNS
lb_policy: ROUND_ROBIN
Expand Down
23 changes: 23 additions & 0 deletions src/imageprovider/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Copyright The OpenTelemetry Authors
# SPDX-License-Identifier: Apache-2.0

FROM nginx:1.25.3

RUN apt-get update ; apt-get install lsb-release --no-install-recommends --no-install-suggests -y

# This file is needed for nginx-module-otel to be found.
RUN echo "deb [signed-by=/usr/share/keyrings/nginx-archive-keyring.gpg] http://nginx.org/packages/mainline/debian `lsb_release -cs` nginx" | tee /etc/apt/sources.list.d/nginx.list

RUN apt-get update ; apt-get install nginx-module-otel --no-install-recommends --no-install-suggests -y

RUN mkdir /static
COPY src/imageprovider/static /static

EXPOSE ${IMAGE_PROVIDER_PORT}

STOPSIGNAL SIGQUIT

COPY src/imageprovider/nginx.conf.template /nginx.conf.template

# Start nginx
CMD ["/bin/sh" , "-c" , "envsubst '$OTEL_COLLECTOR_HOST $IMAGE_PROVIDER_PORT $OTEL_COLLECTOR_PORT_GRPC $OTEL_SERVICE_NAME' < /nginx.conf.template > /etc/nginx/nginx.conf && cat /etc/nginx/nginx.conf && exec nginx -g 'daemon off;'"]
32 changes: 32 additions & 0 deletions src/imageprovider/nginx.conf.template
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
load_module modules/ngx_otel_module.so;

events {
worker_connections 1024;
}

http {
otel_exporter {
endpoint ${OTEL_COLLECTOR_HOST}:${OTEL_COLLECTOR_PORT_GRPC};
}
otel_trace on;
otel_trace_context propagate;
otel_service_name ${OTEL_SERVICE_NAME};
otel_span_name imageprovider;


include mime.types;
sendfile on;
server {
listen ${IMAGE_PROVIDER_PORT};
listen [::]:${IMAGE_PROVIDER_PORT};

resolver 127.0.0.11;
autoindex off;

server_name _;
server_tokens off;

root /static;
gzip_static on;
}
}
File renamed without changes

0 comments on commit 06023dd

Please sign in to comment.