-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Generate random errors in cartservice (#824)
* Generate random errors from cart service * Update migration script? * Update changelog * Update changelog * Add Copyright to FeatureFlagHelper.cs --------- Co-authored-by: Carter Socha <43380952+cartersocha@users.noreply.github.com> Co-authored-by: Juliano Costa <julianocosta89@outlook.com>
- Loading branch information
1 parent
8222db7
commit 02a91d4
Showing
6 changed files
with
67 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
// Copyright The OpenTelemetry Authors | ||
// SPDX-License-Identifier: Apache-2.0 | ||
using System; | ||
using System.Threading.Tasks; | ||
using Oteldemo; | ||
|
||
namespace cartservice.featureflags; | ||
|
||
public class FeatureFlagHelper | ||
{ | ||
private readonly static Random Random = new Random(); | ||
private readonly FeatureFlagService.FeatureFlagServiceClient _featureFlagServiceClient; | ||
|
||
public FeatureFlagHelper() | ||
{ | ||
var featureFlagServiceUri = new Uri($"http://{Environment.GetEnvironmentVariable("FEATURE_FLAG_GRPC_SERVICE_ADDR")}"); | ||
var channel = Grpc.Net.Client.GrpcChannel.ForAddress(featureFlagServiceUri); | ||
_featureFlagServiceClient = new FeatureFlagService.FeatureFlagServiceClient(channel); | ||
} | ||
|
||
public async Task<bool> GenerateCartError() | ||
{ | ||
if (Random.Next(10) != 1) | ||
{ | ||
return false; | ||
} | ||
|
||
var getFlagRequest = new GetFlagRequest { Name = "cartServiceFailure" }; | ||
var getFlagResponse = await _featureFlagServiceClient.GetFlagAsync(getFlagRequest); | ||
return getFlagResponse.Flag.Enabled; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters