Skip to content

Commit 0b00b61

Browse files
Merge branch 'main' into shippingservice-fix-context-prop
2 parents 69a35e4 + 9ffee33 commit 0b00b61

File tree

22 files changed

+307
-38
lines changed

22 files changed

+307
-38
lines changed

.github/workflows/assign-reviewers.yml

+1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ on:
1212

1313
jobs:
1414
assign-reviewers:
15+
if: github.repository == 'open-telemetry/opentelemetry-demo'
1516
runs-on: ubuntu-latest
1617
steps:
1718
- uses: dyladan/component-owners@main

.github/workflows/build-images.yml

+1
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ on:
2121

2222
jobs:
2323
build_and_push_images:
24+
if: github.repository == 'open-telemetry/opentelemetry-demo'
2425
runs-on: ubuntu-latest
2526
permissions:
2627
contents: read

.github/workflows/gradle-wrapper-validation.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,4 @@ jobs:
1515
steps:
1616
- uses: actions/checkout@v4
1717

18-
- uses: gradle/wrapper-validation-action@v2.1.1
18+
- uses: gradle/wrapper-validation-action@v2.1.2

.github/workflows/label-pr.yml

+59
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
# Copyright The OpenTelemetry Authors
2+
# SPDX-License-Identifier: Apache-2.0
3+
# adds a label to a pull request if certain files are changed
4+
name: Label Pull Requests
5+
6+
on:
7+
pull_request:
8+
types: [opened, synchronize, reopened]
9+
10+
jobs:
11+
label:
12+
runs-on: ubuntu-latest
13+
steps:
14+
- name: Checkout
15+
uses: actions/checkout@v2
16+
17+
- name: Check for changed files
18+
id: file_changes
19+
uses: dorny/paths-filter@v2
20+
with:
21+
list-files: shell
22+
filters: |
23+
docsUpdateRequired:
24+
- 'src/flagd/**'
25+
helmUpdateRequired:
26+
- '.env'
27+
- 'docker-compose*.yml'
28+
- 'src/flagd/**'
29+
- 'src/grafana/**'
30+
- 'src/otelcollector/**'
31+
- 'src/prometheus/**'
32+
33+
- name: "Add Label: docs-update-required"
34+
if: steps.file_changes.outputs.docsUpdateRequired == 'true'
35+
uses: actions/github-script@v7
36+
with:
37+
github-token: ${{secrets.GITHUB_TOKEN}}
38+
script: |
39+
const issue_number = context.issue.number;
40+
github.issues.addLabels({
41+
issue_number: issue_number,
42+
owner: context.repo.owner,
43+
repo: context.repo.repo,
44+
labels: ['docs-update-required']
45+
})
46+
47+
- name: "Add Label: helm-update-required"
48+
if: steps.file_changes.outputs.helmUpdateRequired == 'true'
49+
uses: actions/github-script@v7
50+
with:
51+
github-token: ${{secrets.GITHUB_TOKEN}}
52+
script: |
53+
const issue_number = context.issue.number;
54+
github.issues.addLabels({
55+
issue_number: issue_number,
56+
owner: context.repo.owner,
57+
repo: context.repo.repo,
58+
labels: ['helm-update-required']
59+
})

.github/workflows/release.yml

+1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ on:
99
jobs:
1010
build_and_push_images:
1111
uses: ./.github/workflows/build-images.yml
12+
if: github.repository == 'open-telemetry/opentelemetry-demo'
1213
with:
1314
push: true
1415
version: ${{ github.event.release.tag_name }}

CHANGELOG.md

+8
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,14 @@ the release.
4343
([#1448](https://github.com/open-telemetry/opentelemetry-demo/pull/1448))
4444
* [cartservice] update .NET to .NET 8.0.3
4545
([#1460](https://github.com/open-telemetry/opentelemetry-demo/pull/1460))
46+
* [adservice] add adServiceManualGC feature flag
47+
([#1463](https://github.com/open-telemetry/opentelemetry-demo/pull/1463))
48+
* [frontendproxy] remove deprecated start_child_span option
49+
([#1469](https://github.com/open-telemetry/opentelemetry-demo/pull/1469))
50+
* [currency] fix metric name
51+
([#1470](https://github.com/open-telemetry/opentelemetry-demo/pull/1470))
52+
* [frontend] disable instrumentation-fs library
53+
([#1473](https://github.com/open-telemetry/opentelemetry-demo/pull/1473))
4654

4755
## 1.8.0
4856

ide-gen-proto.sh

-1
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,6 @@ gen_proto_dotnet cartservice
7171
gen_proto_go checkoutservice
7272
# gen_proto_cpp currencyservice
7373
# gen_proto_ruby emailservice
74-
gen_proto_elixir featureflagservice
7574
gen_proto_ts frontend
7675
gen_proto_js paymentservice
7776
gen_proto_go productcatalogservice

kubernetes/opentelemetry-demo.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -3214,7 +3214,7 @@ data:
32143214
"type": "prometheus",
32153215
"uid": "webstore-metrics"
32163216
},
3217-
"description": "Sent by Exporter\notelcol_exporter_send_failed_spans",
3217+
"description": "Sent by Exporter\notelcol_exporter_send_failed_metric_points",
32183218
"fieldConfig": {
32193219
"defaults": {
32203220
"color": {

src/accountingservice/go.mod

+2-2
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@ require (
99
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.24.0
1010
go.opentelemetry.io/otel/sdk v1.24.0
1111
go.opentelemetry.io/otel/trace v1.24.0
12-
google.golang.org/grpc v1.62.0
12+
google.golang.org/grpc v1.62.1
1313
google.golang.org/grpc/cmd/protoc-gen-go-grpc v1.3.0
14-
google.golang.org/protobuf v1.32.0
14+
google.golang.org/protobuf v1.33.0
1515
)
1616

1717
require (

src/accountingservice/go.sum

+4-4
Original file line numberDiff line numberDiff line change
@@ -134,14 +134,14 @@ google.golang.org/genproto/googleapis/api v0.0.0-20240125205218-1f4bbc51befe h1:
134134
google.golang.org/genproto/googleapis/api v0.0.0-20240125205218-1f4bbc51befe/go.mod h1:4jWUdICTdgc3Ibxmr8nAJiiLHwQBY0UI0XZcEMaFKaA=
135135
google.golang.org/genproto/googleapis/rpc v0.0.0-20240125205218-1f4bbc51befe h1:bQnxqljG/wqi4NTXu2+DJ3n7APcEA882QZ1JvhQAq9o=
136136
google.golang.org/genproto/googleapis/rpc v0.0.0-20240125205218-1f4bbc51befe/go.mod h1:PAREbraiVEVGVdTZsVWjSbbTtSyGbAgIIvni8a8CD5s=
137-
google.golang.org/grpc v1.62.0 h1:HQKZ/fa1bXkX1oFOvSjmZEUL8wLSaZTjCcLAlmZRtdk=
138-
google.golang.org/grpc v1.62.0/go.mod h1:IWTG0VlJLCh1SkC58F7np9ka9mx/WNkjl4PGJaiq+QE=
137+
google.golang.org/grpc v1.62.1 h1:B4n+nfKzOICUXMgyrNd19h/I9oH0L1pizfk1d4zSgTk=
138+
google.golang.org/grpc v1.62.1/go.mod h1:IWTG0VlJLCh1SkC58F7np9ka9mx/WNkjl4PGJaiq+QE=
139139
google.golang.org/grpc/cmd/protoc-gen-go-grpc v1.3.0 h1:rNBFJjBCOgVr9pWD7rs/knKL4FRTKgpZmsRfV214zcA=
140140
google.golang.org/grpc/cmd/protoc-gen-go-grpc v1.3.0/go.mod h1:Dk1tviKTvMCz5tvh7t+fh94dhmQVHuCt2OzJB3CTW9Y=
141141
google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw=
142142
google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
143-
google.golang.org/protobuf v1.32.0 h1:pPC6BG5ex8PDFnkbrGU3EixyhKcQ2aDuBS36lqK/C7I=
144-
google.golang.org/protobuf v1.32.0/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos=
143+
google.golang.org/protobuf v1.33.0 h1:uNO2rsAINq/JlFpSdYEKIZ0uKD/R9cpdv0T+yoGwGmI=
144+
google.golang.org/protobuf v1.33.0/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos=
145145
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
146146
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
147147
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=

src/adservice/src/main/java/oteldemo/AdService.java

+20-4
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
import oteldemo.Demo.Ad;
3535
import oteldemo.Demo.AdRequest;
3636
import oteldemo.Demo.AdResponse;
37+
import oteldemo.problempattern.GarbageCollectionTrigger;
3738
import dev.openfeature.contrib.providers.flagd.FlagdOptions;
3839
import dev.openfeature.contrib.providers.flagd.FlagdProvider;
3940
import dev.openfeature.sdk.Client;
@@ -127,6 +128,9 @@ private enum AdResponseType {
127128

128129
private static class AdServiceImpl extends oteldemo.AdServiceGrpc.AdServiceImplBase {
129130

131+
private static final String ADSERVICE_FAILURE = "adServiceFailure";
132+
private static final String ADSERVICE_MANUAL_GC_FEATURE_FLAG = "adServiceManualGc";
133+
130134
private AdServiceImpl() {}
131135

132136
/**
@@ -177,8 +181,14 @@ public void getAds(AdRequest req, StreamObserver<AdResponse> responseObserver) {
177181
Attributes.of(
178182
adRequestTypeKey, adRequestType.name(), adResponseTypeKey, adResponseType.name()));
179183

180-
if (checkAdFailure()) {
181-
throw new StatusRuntimeException(Status.RESOURCE_EXHAUSTED);
184+
if (getFeatureFlagEnabled(ADSERVICE_FAILURE)) {
185+
throw new StatusRuntimeException(Status.UNAVAILABLE);
186+
}
187+
188+
if (getFeatureFlagEnabled(ADSERVICE_MANUAL_GC_FEATURE_FLAG)) {
189+
logger.warn("Feature Flag " + ADSERVICE_MANUAL_GC_FEATURE_FLAG + " enabled, performing a manual gc now");
190+
GarbageCollectionTrigger gct = new GarbageCollectionTrigger();
191+
gct.doExecute();
182192
}
183193

184194
AdResponse reply = AdResponse.newBuilder().addAllAds(allAds).build();
@@ -193,12 +203,18 @@ public void getAds(AdRequest req, StreamObserver<AdResponse> responseObserver) {
193203
}
194204
}
195205

196-
boolean checkAdFailure() {
206+
/**
207+
* Retrieves the status of a feature flag from the Feature Flag service.
208+
*
209+
* @param ff The name of the feature flag to retrieve.
210+
* @return {@code true} if the feature flag is enabled, {@code false} otherwise or in case of errors.
211+
*/
212+
boolean getFeatureFlagEnabled(String ff) {
197213
Client client = OpenFeatureAPI.getInstance().getClient();
198214
// TODO: Plumb the actual session ID from the frontend via baggage?
199215
UUID uuid = UUID.randomUUID();
200216
client.setEvaluationContext(new MutableContext().add("session", uuid.toString()));
201-
Boolean boolValue = client.getBooleanValue("adServiceFailure", false);
217+
Boolean boolValue = client.getBooleanValue(ff, false);
202218
return boolValue;
203219
}
204220
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
/*
2+
* Copyright The OpenTelemetry Authors
3+
* SPDX-License-Identifier: Apache-2.0
4+
*/
5+
6+
package oteldemo.problempattern;
7+
8+
import java.lang.management.ManagementFactory;
9+
import java.util.concurrent.TimeUnit;
10+
11+
import org.apache.logging.log4j.LogManager;
12+
import org.apache.logging.log4j.Logger;
13+
14+
/**
15+
* The GarbageCollectionTrigger class is responsible for triggering manual garbage collection
16+
* at specified intervals to simulate memory pressure and measure the impact on performance.
17+
*/
18+
public class GarbageCollectionTrigger {
19+
private static final Logger logger = LogManager.getLogger(GarbageCollectionTrigger.class.getName());
20+
21+
private final long gc_delay;
22+
private final int finalize_delay;
23+
private final int maxObjects;
24+
25+
private long lastGC = 0;
26+
27+
private final MemoryUtils memUtils;
28+
29+
/**
30+
* Constructs a new GarbageCollectionTrigger with default values.
31+
*/
32+
public GarbageCollectionTrigger() {
33+
memUtils = new MemoryUtils(ManagementFactory.getMemoryMXBean());
34+
gc_delay = TimeUnit.SECONDS.toMillis(10);
35+
finalize_delay = 500;
36+
maxObjects = 500000;
37+
}
38+
39+
/**
40+
* Triggers manual garbage collection at specified intervals and measures the impact on performance.
41+
* It creates Entry objects to fill up memory and initiates garbage collection.
42+
*/
43+
public void doExecute() {
44+
if (System.currentTimeMillis() - lastGC > gc_delay) {
45+
logger.info("Triggering a manual garbage collection, next one in " + (gc_delay/1000) + " seconds.");
46+
// clear old data, we want to clear old Entry objects, because their finalization is expensive
47+
System.gc();
48+
49+
long total = 0;
50+
for (int i = 0; i < 10; i++) {
51+
while (memUtils.getHeapUsage() < 0.9 && memUtils.getObjectPendingFinalizationCount() < maxObjects) {
52+
new Entry();
53+
}
54+
long start = System.currentTimeMillis();
55+
System.gc();
56+
total += System.currentTimeMillis() - start;
57+
}
58+
logger.info("The artificially triggered GCs took: " + total + " ms");
59+
lastGC = System.currentTimeMillis();
60+
}
61+
62+
}
63+
64+
/**
65+
* The Entry class represents objects created for the purpose of triggering garbage collection.
66+
*/
67+
private class Entry {
68+
/**
69+
* Overrides the finalize method to introduce a delay, simulating finalization during garbage collection.
70+
*
71+
* @throws Throwable If an exception occurs during finalization.
72+
*/
73+
@SuppressWarnings("removal")
74+
@Override
75+
protected void finalize() throws Throwable {
76+
TimeUnit.MILLISECONDS.sleep(finalize_delay);
77+
super.finalize();
78+
}
79+
}
80+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
/*
2+
* Copyright The OpenTelemetry Authors
3+
* SPDX-License-Identifier: Apache-2.0
4+
*/
5+
6+
package oteldemo.problempattern;
7+
8+
import java.lang.management.MemoryMXBean;
9+
import java.lang.management.MemoryUsage;
10+
import org.apache.logging.log4j.LogManager;
11+
import org.apache.logging.log4j.Logger;
12+
13+
14+
/**
15+
* This class provides JVM heap related utility methods.
16+
*/
17+
public class MemoryUtils {
18+
19+
private static final Logger logger = LogManager.getLogger(MemoryUtils.class.getName());
20+
21+
private static final long NO_HEAP_LIMIT = -1;
22+
23+
private final MemoryMXBean memoryBean;
24+
25+
/**
26+
* @param memoryBean defines which {@link MemoryMXBean} is to use
27+
*/
28+
public MemoryUtils(MemoryMXBean memoryBean) {
29+
this.memoryBean = memoryBean;
30+
}
31+
32+
33+
/**
34+
* @return The current heap usage as a decimal number between 0.0 and 1.0.
35+
* That is, if the returned value is 0.85, 85% of the max heap is used.
36+
*
37+
* If no max heap is set, the method returns -1.0.
38+
*/
39+
public double getHeapUsage() {
40+
MemoryUsage heapProps = memoryBean.getHeapMemoryUsage();
41+
long heapUsed = heapProps.getUsed();
42+
long heapMax = heapProps.getMax();
43+
44+
if (heapMax == NO_HEAP_LIMIT) {
45+
if (logger.isDebugEnabled()) {
46+
logger.debug("No maximum heap is set");
47+
}
48+
return NO_HEAP_LIMIT;
49+
}
50+
51+
52+
double heapUsage = (double) heapUsed / heapMax;
53+
if (logger.isDebugEnabled()) {
54+
logger.debug("Current heap usage is {0} percent" + (heapUsage * 100));
55+
}
56+
return heapUsage;
57+
}
58+
59+
/**
60+
* see {@link MemoryMXBean#getObjectPendingFinalizationCount()}
61+
*/
62+
public int getObjectPendingFinalizationCount() {
63+
return memoryBean.getObjectPendingFinalizationCount();
64+
}
65+
}

src/checkoutservice/go.mod

+5-5
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ go 1.22.0
55
require (
66
github.com/IBM/sarama v1.42.1
77
github.com/google/uuid v1.6.0
8+
github.com/open-feature/go-sdk v1.10.0
9+
github.com/open-feature/go-sdk-contrib/hooks/open-telemetry v0.3.1
10+
github.com/open-feature/go-sdk-contrib/providers/flagd v0.1.22
811
github.com/sirupsen/logrus v1.9.3
912
go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.49.0
1013
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.49.0
@@ -15,9 +18,9 @@ require (
1518
go.opentelemetry.io/otel/sdk v1.24.0
1619
go.opentelemetry.io/otel/sdk/metric v1.24.0
1720
go.opentelemetry.io/otel/trace v1.24.0
18-
google.golang.org/grpc v1.62.0
21+
google.golang.org/grpc v1.62.1
1922
google.golang.org/grpc/cmd/protoc-gen-go-grpc v1.3.0
20-
google.golang.org/protobuf v1.32.0
23+
google.golang.org/protobuf v1.33.0
2124
)
2225

2326
require (
@@ -59,9 +62,6 @@ require (
5962
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
6063
github.com/modern-go/reflect2 v1.0.2 // indirect
6164
github.com/open-feature/flagd/core v0.7.4 // indirect
62-
github.com/open-feature/go-sdk v1.10.0 // indirect
63-
github.com/open-feature/go-sdk-contrib/hooks/open-telemetry v0.3.1 // indirect
64-
github.com/open-feature/go-sdk-contrib/providers/flagd v0.1.22 // indirect
6565
github.com/open-feature/schemas v0.2.8 // indirect
6666
github.com/pierrec/lz4/v4 v4.1.21 // indirect
6767
github.com/rcrowley/go-metrics v0.0.0-20201227073835-cf1acfcdf475 // indirect

0 commit comments

Comments
 (0)