Skip to content

Commit

Permalink
Merge branch 'main' into chore-jsonlint
Browse files Browse the repository at this point in the history
  • Loading branch information
julianocosta89 authored Mar 13, 2024
2 parents 2c4dac9 + def3a4c commit df42fd5
Show file tree
Hide file tree
Showing 8 changed files with 72 additions and 28 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ the release.

## Unreleased

* [loadgenerator] emit logs via OTLP
([#1446](https://github.com/open-telemetry/opentelemetry-demo/pull/1446))
* [frontend] reset quantity when new product selected
([#1447](https://github.com/open-telemetry/opentelemetry-demo/pull/1447))
* [featureflag] deprecate in favor of flagd
([#1338](https://github.com/open-telemetry/opentelemetry-demo/pull/1388))
* [checkoutservice] add producer interceptor for tracing
Expand All @@ -29,6 +33,8 @@ the release.
([#1427](https://github.com/open-telemetry/opentelemetry-demo/pull/1427))
* [chore] - Update Telemetry Components
([#1440](https://github.com/open-telemetry/opentelemetry-demo/pull/1440))
* [Frontend-proxy] Add restart policy to compose file
([#1448](https://github.com/open-telemetry/opentelemetry-demo/pull/1448))

## 1.8.0

Expand Down
1 change: 1 addition & 0 deletions docker-compose.minimal.yml
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,7 @@ services:
resources:
limits:
memory: 50M
restart: unless-stopped
ports:
- "${ENVOY_PORT}:${ENVOY_PORT}"
- 10000:10000
Expand Down
1 change: 1 addition & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,7 @@ services:
resources:
limits:
memory: 50M
restart: unless-stopped
ports:
- "${ENVOY_PORT}:${ENVOY_PORT}"
- 10000:10000
Expand Down
34 changes: 20 additions & 14 deletions src/accountingservice/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,26 @@
# SPDX-License-Identifier: Apache-2.0


FROM golang:1.22.0-alpine AS builder
RUN apk update && apk add --no-cache make protobuf-dev
RUN go install google.golang.org/protobuf/cmd/protoc-gen-go@latest
RUN go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@latest

WORKDIR /usr/src/app/

COPY ./src/accountingservice/ ./
COPY ./pb/ ./pb

RUN protoc -I ./pb ./pb/demo.proto --go_out=./ --go-grpc_out=./
RUN go build -o /go/bin/accountingservice/

# -----------------------------------------------------------------------------
FROM golang:1.22-alpine AS builder

WORKDIR /usr/src/app

RUN apk update \
&& apk add --no-cache make protobuf-dev

RUN --mount=type=cache,target=/go/pkg/mod/ \
--mount=type=bind,source=./src/accountingservice/go.sum,target=go.sum \
--mount=type=bind,source=./src/accountingservice/go.mod,target=go.mod \
--mount=type=bind,source=./src/accountingservice/tools.go,target=tools.go \
go mod download \
&& go list -e -f '{{range .Imports}}{{.}} {{end}}' tools.go | CGO_ENABLED=0 xargs go install -mod=readonly

RUN --mount=type=cache,target=/go/pkg/mod/ \
--mount=type=cache,target=/root/.cache/go-build \
--mount=type=bind,rw,source=./src/accountingservice,target=. \
--mount=type=bind,rw,source=./pb,target=./pb \
protoc -I ./pb ./pb/demo.proto --go_out=./ --go-grpc_out=./ \
&& go build -ldflags "-s -w" -o /go/bin/accountingservice/ ./

FROM alpine

Expand Down
6 changes: 5 additions & 1 deletion src/frontend/pages/product/[productId]/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import { NextPage } from 'next';
import Image from 'next/image';
import { useRouter } from 'next/router';
import { useCallback, useState } from 'react';
import { useCallback, useState, useEffect } from 'react';
import { useQuery } from '@tanstack/react-query';
import Ad from '../../../components/Ad';
import Footer from '../../../components/Footer';
Expand Down Expand Up @@ -32,6 +32,10 @@ const ProductDetail: NextPage = () => {
const { selectedCurrency } = useCurrency();
const productId = query.productId as string;

useEffect(() => {
setQuantity(1);
}, [productId]);

const {
data: {
name,
Expand Down
2 changes: 1 addition & 1 deletion src/loadgenerator/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,4 @@ COPY ./src/loadgenerator/people.json .
ENV LOCUST_PLAYWRIGHT=1
ENV PLAYWRIGHT_BROWSERS_PATH=/opt/pw-browsers
RUN playwright install --with-deps chromium
ENTRYPOINT locust
ENTRYPOINT locust --skip-log-setup
27 changes: 26 additions & 1 deletion src/loadgenerator/locustfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@
import os
import random
import uuid
import logging
import sys
from pythonjsonlogger import jsonlogger
from locust import HttpUser, task, between
from locust_plugins.users.playwright import PlaywrightUser, pw, PageWithRetry, event

Expand All @@ -23,8 +26,30 @@
from opentelemetry.instrumentation.requests import RequestsInstrumentor
from opentelemetry.instrumentation.system_metrics import SystemMetricsInstrumentor
from opentelemetry.instrumentation.urllib3 import URLLib3Instrumentor
from opentelemetry._logs import set_logger_provider
from opentelemetry.exporter.otlp.proto.grpc._log_exporter import (
OTLPLogExporter,
)
from opentelemetry.sdk._logs import LoggerProvider, LoggingHandler
from opentelemetry.sdk._logs.export import BatchLogRecordProcessor
from opentelemetry.sdk.resources import Resource
from playwright.async_api import Route, Request

logger_provider = LoggerProvider(resource=Resource.create(
{
"service.name": "loadgenerator",
}
),)
set_logger_provider(logger_provider)

exporter = OTLPLogExporter(insecure=True)
logger_provider.add_log_record_processor(BatchLogRecordProcessor(exporter))
handler = LoggingHandler(level=logging.INFO, logger_provider=logger_provider)

# Attach OTLP handler to locust logger
logging.getLogger().addHandler(handler)
logging.getLogger().setLevel(logging.INFO)

exporter = OTLPMetricExporter(insecure=True)
set_meter_provider(MeterProvider([PeriodicExportingMetricReader(exporter)]))

Expand All @@ -37,6 +62,7 @@
RequestsInstrumentor().instrument()
SystemMetricsInstrumentor().instrument()
URLLib3Instrumentor().instrument()
logging.info("Instrumentation complete")

categories = [
"binoculars",
Expand Down Expand Up @@ -64,7 +90,6 @@
people_file = open('people.json')
people = json.load(people_file)


class WebsiteUser(HttpUser):
wait_time = between(1, 10)

Expand Down
23 changes: 12 additions & 11 deletions src/loadgenerator/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,17 @@ locust==2.18.2
locust_plugins==3.4.0
markupsafe==2.1.3
msgpack==1.0.7
opentelemetry-api==1.22.0
opentelemetry-exporter-otlp-proto-grpc==1.22.0
opentelemetry-instrumentation==0.43b0
opentelemetry-instrumentation-jinja2==0.43b0
opentelemetry-instrumentation-requests==0.43b0
opentelemetry-instrumentation-system-metrics==0.43b0
opentelemetry-instrumentation-urllib3==0.43b0
opentelemetry-proto==1.22.0
opentelemetry-sdk==1.22.0
opentelemetry-semantic-conventions==0.43b0
opentelemetry-util-http==0.43b0
opentelemetry-api==1.23.0
opentelemetry-exporter-otlp-proto-grpc==1.23.0
opentelemetry-instrumentation==0.44b0
opentelemetry-instrumentation-jinja2==0.44b0
opentelemetry-instrumentation-requests==0.44b0
opentelemetry-instrumentation-system-metrics==0.44b0
opentelemetry-instrumentation-urllib3==0.44b0
opentelemetry-proto==1.23.0
opentelemetry-sdk==1.23.0
opentelemetry-semantic-conventions==0.44b0
opentelemetry-util-http==0.44b0
protobuf==4.25.0
psutil==5.9.6
pyzmq==25.1.1
Expand All @@ -42,3 +42,4 @@ werkzeug==3.0.1
wrapt==1.16.0
zope-event==5.0
zope-interface==6.1
python-json-logger==2.0.7

0 comments on commit df42fd5

Please sign in to comment.