From 314d6da84504384d574464a3cff8b25bf415021c Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Fri, 2 Feb 2024 17:01:09 +0000 Subject: [PATCH 1/4] chore(deps): update github-actions --- .github/workflows/benchmarks.yaml | 2 +- .github/workflows/buf.yaml | 2 +- .github/workflows/ci.yaml | 10 +++++----- .github/workflows/schedule.yaml | 2 +- .github/workflows/scorecards.yaml | 2 +- 5 files changed, 9 insertions(+), 9 deletions(-) diff --git a/.github/workflows/benchmarks.yaml b/.github/workflows/benchmarks.yaml index 6043dfd..64864c1 100644 --- a/.github/workflows/benchmarks.yaml +++ b/.github/workflows/benchmarks.yaml @@ -37,7 +37,7 @@ jobs: run: dotnet run -c Release --project=src/Vfps.Benchmarks - name: Store benchmark result - uses: benchmark-action/github-action-benchmark@70405016b032d44f409e4b1b451c40215cbe2393 # v1.18.0 + uses: benchmark-action/github-action-benchmark@cc9ac13ce81036c9b67fcfe2cb95ca366684b9ea # v1.19.3 with: name: PseudonymGeneratorBenchmarks tool: "benchmarkdotnet" diff --git a/.github/workflows/buf.yaml b/.github/workflows/buf.yaml index 08a3bba..0c7214d 100644 --- a/.github/workflows/buf.yaml +++ b/.github/workflows/buf.yaml @@ -17,7 +17,7 @@ jobs: steps: - uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3 - - uses: bufbuild/buf-setup-action@382440cdb8ec7bc25a68d7b4711163d95f7cc3aa # v1.28.1 + - uses: bufbuild/buf-setup-action@88db93f5d74ffa329bb43e42aa95cd822697d214 # v1.29.0 with: github_token: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 14cfc51..895d3da 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -13,7 +13,7 @@ permissions: read-all jobs: build: - uses: miracum/.github/.github/workflows/standard-build.yaml@402d475fc7f49888381ea1090ddc2004ac8a8e59 # v1.5.3 + uses: miracum/.github/.github/workflows/standard-build.yaml@d312bc78e5a4ab6bafc71979f80962177abc6336 # v1.5.7 permissions: contents: read id-token: write @@ -68,7 +68,7 @@ jobs: thresholds: "50 50" - name: Add Coverage PR Comment - uses: marocchino/sticky-pull-request-comment@efaaab3fd41a9c3de579aba759d2552635e590fd # v2.8.0 + uses: marocchino/sticky-pull-request-comment@331f8f5b4215f0445d3c07b4967662a32a2d3e31 # v2.9.0 if: ${{ github.event_name == 'pull_request' }} with: recreate: true @@ -164,7 +164,7 @@ jobs: } >> ghz-output.md - name: Append sticky comment with ghz output - uses: marocchino/sticky-pull-request-comment@efaaab3fd41a9c3de579aba759d2552635e590fd # v2.8.0 + uses: marocchino/sticky-pull-request-comment@331f8f5b4215f0445d3c07b4967662a32a2d3e31 # v2.9.0 if: ${{ github.event_name == 'pull_request' }} with: append: true @@ -291,7 +291,7 @@ jobs: } >> iter8-output.md - name: Append sticky comment with iter8 report - uses: marocchino/sticky-pull-request-comment@efaaab3fd41a9c3de579aba759d2552635e590fd # v2.8.0 + uses: marocchino/sticky-pull-request-comment@331f8f5b4215f0445d3c07b4967662a32a2d3e31 # v2.9.0 if: ${{ github.event_name == 'pull_request' }} with: append: true @@ -320,7 +320,7 @@ jobs: kind-cluster-dump.txt lint: - uses: miracum/.github/.github/workflows/standard-lint.yaml@402d475fc7f49888381ea1090ddc2004ac8a8e59 # v1.5.3 + uses: miracum/.github/.github/workflows/standard-lint.yaml@d312bc78e5a4ab6bafc71979f80962177abc6336 # v1.5.7 permissions: contents: read pull-requests: write diff --git a/.github/workflows/schedule.yaml b/.github/workflows/schedule.yaml index b829807..4635ad9 100644 --- a/.github/workflows/schedule.yaml +++ b/.github/workflows/schedule.yaml @@ -10,7 +10,7 @@ permissions: read-all jobs: schedule: - uses: miracum/.github/.github/workflows/standard-schedule.yaml@402d475fc7f49888381ea1090ddc2004ac8a8e59 # v1.5.3 + uses: miracum/.github/.github/workflows/standard-schedule.yaml@d312bc78e5a4ab6bafc71979f80962177abc6336 # v1.5.7 permissions: contents: read issues: write diff --git a/.github/workflows/scorecards.yaml b/.github/workflows/scorecards.yaml index ecca0a5..e1edcf1 100644 --- a/.github/workflows/scorecards.yaml +++ b/.github/workflows/scorecards.yaml @@ -68,6 +68,6 @@ jobs: # Upload the results to GitHub's code scanning dashboard. - name: "Upload to code-scanning" - uses: github/codeql-action/upload-sarif@8b7fcbfac2aae0e6c24d9f9ebd5830b1290b18e4 # v2.23.0 + uses: github/codeql-action/upload-sarif@2f93e4319b2f04a2efc38fa7f78bd681bc3f7b2f # v2.23.2 with: sarif_file: results.sarif From 75b43755c98994c7fa3df47298e31e6c8f163ae1 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Fri, 2 Feb 2024 17:01:12 +0000 Subject: [PATCH 2/4] chore(deps): update github-actions --- .github/workflows/benchmarks.yaml | 2 +- .github/workflows/buf.yaml | 2 +- .github/workflows/build-grpc-utils-image.yaml | 12 ++++++------ .github/workflows/ci.yaml | 18 +++++++++--------- .github/workflows/nightly-chaos.yaml | 6 +++--- .github/workflows/release-please.yaml | 2 +- .github/workflows/scorecards.yaml | 6 +++--- 7 files changed, 24 insertions(+), 24 deletions(-) diff --git a/.github/workflows/benchmarks.yaml b/.github/workflows/benchmarks.yaml index 6043dfd..396a3ae 100644 --- a/.github/workflows/benchmarks.yaml +++ b/.github/workflows/benchmarks.yaml @@ -24,7 +24,7 @@ jobs: pull-requests: write steps: - name: Checkout - uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3 + uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4 with: fetch-depth: 0 diff --git a/.github/workflows/buf.yaml b/.github/workflows/buf.yaml index 08a3bba..69f8758 100644 --- a/.github/workflows/buf.yaml +++ b/.github/workflows/buf.yaml @@ -15,7 +15,7 @@ jobs: contents: read pull-requests: write steps: - - uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3 + - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4 - uses: bufbuild/buf-setup-action@382440cdb8ec7bc25a68d7b4711163d95f7cc3aa # v1.28.1 with: diff --git a/.github/workflows/build-grpc-utils-image.yaml b/.github/workflows/build-grpc-utils-image.yaml index 31aa82e..75cc088 100644 --- a/.github/workflows/build-grpc-utils-image.yaml +++ b/.github/workflows/build-grpc-utils-image.yaml @@ -20,23 +20,23 @@ jobs: contents: read steps: - name: Checkout - uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3 + uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4 - name: Container meta for the gRPC utils image id: container_grpc_utils_meta - uses: docker/metadata-action@818d4b7b91585d195f67373fd9cb0332e31a7175 # v4 + uses: docker/metadata-action@8e5442c4ef9f78752691e2d8f8d19755c6f78e81 # v5 with: images: | ghcr.io/${{ github.repository }}-grpc-utils - name: Set up QEMU - uses: docker/setup-qemu-action@2b82ce82d56a2a04d2637cd93a637ae1b359c0a7 # v2 + uses: docker/setup-qemu-action@68827325e0b33c7199eb31dd4e31fbe9023e06e3 # v3 - name: Set up Docker Buildx - uses: docker/setup-buildx-action@885d1462b80bc1c1c7f0b00334ad271f09369c55 # v2 + uses: docker/setup-buildx-action@f95db51fddba0c2d1ec667646a06c2ce06100226 # v3 - name: Login to GitHub Container Registry - uses: docker/login-action@465a07811f14bebb1938fbed4728c6a1ff8901fc # v2 + uses: docker/login-action@343f7c4344506bcbf9b4de18042ae17996df046d # v3 if: ${{ github.event_name != 'pull_request' }} with: registry: ghcr.io @@ -44,7 +44,7 @@ jobs: password: ${{ secrets.GITHUB_TOKEN }} - name: Build and push gRPC utils image - uses: docker/build-push-action@1104d471370f9806843c095c1db02b5a90c5f8b6 # v3 + uses: docker/build-push-action@4a13e500e55cf31b7a5d59a38ab2040ab0f42f56 # v5 with: push: ${{ github.event_name != 'pull_request' }} tags: ${{ steps.container_grpc_utils_meta.outputs.tags }} diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 14cfc51..b0577e9 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -36,7 +36,7 @@ jobs: pull-requests: write steps: - name: Download test image - uses: actions/download-artifact@9bc31d5ccc31df68ecc42ccf4149144866c47d8a # v3.0.2 + uses: actions/download-artifact@6b208ae046db98c579e8a3aa621ab581ff575935 # v4.1.1 with: name: test-image path: /tmp @@ -84,11 +84,11 @@ jobs: pull-requests: write steps: - name: Checkout - uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3 + uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4 - name: Download container image if: ${{ github.event_name == 'pull_request' }} - uses: actions/download-artifact@9bc31d5ccc31df68ecc42ccf4149144866c47d8a # v3.0.2 + uses: actions/download-artifact@6b208ae046db98c579e8a3aa621ab581ff575935 # v4.1.1 with: name: container-image path: /tmp @@ -185,11 +185,11 @@ jobs: - build steps: - name: Checkout - uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3 + uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4 - name: Download container image if: ${{ github.event_name == 'pull_request' }} - uses: actions/download-artifact@9bc31d5ccc31df68ecc42ccf4149144866c47d8a # v3.0.2 + uses: actions/download-artifact@6b208ae046db98c579e8a3aa621ab581ff575935 # v4.1.1 with: name: container-image path: /tmp @@ -222,7 +222,7 @@ jobs: pull-requests: write steps: - name: Checkout - uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3 + uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4 - name: install iter8 cli env: @@ -240,7 +240,7 @@ jobs: - name: Download container image if: ${{ github.event_name == 'pull_request' }} - uses: actions/download-artifact@9bc31d5ccc31df68ecc42ccf4149144866c47d8a # v3.0.2 + uses: actions/download-artifact@6b208ae046db98c579e8a3aa621ab581ff575935 # v4.1.1 with: name: container-image path: /tmp @@ -299,7 +299,7 @@ jobs: - name: Upload report if: always() - uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32 # v3.1.3 + uses: actions/upload-artifact@26f96dfa697d77e81fd5907df203aa23a56210a8 # v4.3.0 with: name: iter8-report.html path: | @@ -313,7 +313,7 @@ jobs: - name: Upload cluster dump if: always() - uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32 # v3.1.3 + uses: actions/upload-artifact@26f96dfa697d77e81fd5907df203aa23a56210a8 # v4.3.0 with: name: kind-cluster-dump.txt path: | diff --git a/.github/workflows/nightly-chaos.yaml b/.github/workflows/nightly-chaos.yaml index a46769f..5f14ab7 100644 --- a/.github/workflows/nightly-chaos.yaml +++ b/.github/workflows/nightly-chaos.yaml @@ -15,12 +15,12 @@ jobs: runs-on: ubuntu-22.04 steps: - name: Checkout - uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3 + uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4 with: fetch-depth: 0 - name: Set up Docker Buildx - uses: docker/setup-buildx-action@885d1462b80bc1c1c7f0b00334ad271f09369c55 # v2 + uses: docker/setup-buildx-action@f95db51fddba0c2d1ec667646a06c2ce06100226 # v3 - name: Install Task uses: arduino/setup-task@e26d8975574116b0097a1161e0fe16ba75d84c1c # v1.0.3 @@ -38,7 +38,7 @@ jobs: - name: Upload cluster dump if: always() - uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32 # v3.1.3 + uses: actions/upload-artifact@26f96dfa697d77e81fd5907df203aa23a56210a8 # v4.3.0 with: name: kind-cluster-dump.txt path: | diff --git a/.github/workflows/release-please.yaml b/.github/workflows/release-please.yaml index f6cc521..1124c78 100644 --- a/.github/workflows/release-please.yaml +++ b/.github/workflows/release-please.yaml @@ -15,7 +15,7 @@ jobs: pull-requests: write steps: - - uses: google-github-actions/release-please-action@db8f2c60ee802b3748b512940dde88eabd7b7e01 # v3.7.13 + - uses: google-github-actions/release-please-action@cc61a07e2da466bebbc19b3a7dd01d6aecb20d1e # v4.0.2 with: token: ${{ secrets.MIRACUM_BOT_SEMANTIC_RELEASE_TOKEN }} release-type: simple diff --git a/.github/workflows/scorecards.yaml b/.github/workflows/scorecards.yaml index ecca0a5..de781d6 100644 --- a/.github/workflows/scorecards.yaml +++ b/.github/workflows/scorecards.yaml @@ -33,7 +33,7 @@ jobs: steps: - name: "Checkout code" - uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3.6.0 + uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 with: persist-credentials: false @@ -60,7 +60,7 @@ jobs: # Upload the results as artifacts (optional). Commenting out will disable uploads of run results in SARIF # format to the repository Actions tab. - name: "Upload artifact" - uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32 # v3.1.3 + uses: actions/upload-artifact@26f96dfa697d77e81fd5907df203aa23a56210a8 # v4.3.0 with: name: SARIF file path: results.sarif @@ -68,6 +68,6 @@ jobs: # Upload the results to GitHub's code scanning dashboard. - name: "Upload to code-scanning" - uses: github/codeql-action/upload-sarif@8b7fcbfac2aae0e6c24d9f9ebd5830b1290b18e4 # v2.23.0 + uses: github/codeql-action/upload-sarif@b7bf0a3ed3ecfa44160715d7c442788f65f0f923 # v3.23.2 with: sarif_file: results.sarif From efa9cae712ecc4fa37292daaa15798c9147cf86f Mon Sep 17 00:00:00 2001 From: chgl Date: Fri, 2 Feb 2024 18:09:10 +0100 Subject: [PATCH 3/4] ci: update actions --- .github/workflows/benchmarks.yaml | 2 +- .github/workflows/buf.yaml | 2 +- .github/workflows/build-grpc-utils-image.yaml | 2 +- .github/workflows/ci.yaml | 14 +++++++------- .github/workflows/nightly-chaos.yaml | 2 +- .github/workflows/release-please.yaml | 2 +- 6 files changed, 12 insertions(+), 12 deletions(-) diff --git a/.github/workflows/benchmarks.yaml b/.github/workflows/benchmarks.yaml index 0560dcc..d28d0d4 100644 --- a/.github/workflows/benchmarks.yaml +++ b/.github/workflows/benchmarks.yaml @@ -24,7 +24,7 @@ jobs: pull-requests: write steps: - name: Checkout - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4 + uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 with: fetch-depth: 0 diff --git a/.github/workflows/buf.yaml b/.github/workflows/buf.yaml index c66cf12..bcec469 100644 --- a/.github/workflows/buf.yaml +++ b/.github/workflows/buf.yaml @@ -15,7 +15,7 @@ jobs: contents: read pull-requests: write steps: - - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4 + - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 - uses: bufbuild/buf-setup-action@88db93f5d74ffa329bb43e42aa95cd822697d214 # v1.29.0 with: diff --git a/.github/workflows/build-grpc-utils-image.yaml b/.github/workflows/build-grpc-utils-image.yaml index 75cc088..6b00047 100644 --- a/.github/workflows/build-grpc-utils-image.yaml +++ b/.github/workflows/build-grpc-utils-image.yaml @@ -20,7 +20,7 @@ jobs: contents: read steps: - name: Checkout - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4 + uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 - name: Container meta for the gRPC utils image id: container_grpc_utils_meta diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index baaf181..b4088f1 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -38,7 +38,7 @@ jobs: - name: Download test image uses: actions/download-artifact@6b208ae046db98c579e8a3aa621ab581ff575935 # v4.1.1 with: - name: test-image + name: ${{ needs.build.outputs.image-slug }}-test path: /tmp - name: Load test image @@ -84,13 +84,13 @@ jobs: pull-requests: write steps: - name: Checkout - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4 + uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 - name: Download container image if: ${{ github.event_name == 'pull_request' }} uses: actions/download-artifact@6b208ae046db98c579e8a3aa621ab581ff575935 # v4.1.1 with: - name: container-image + name: ${{ needs.build.outputs.image-slug }} path: /tmp - name: Load image @@ -185,13 +185,13 @@ jobs: - build steps: - name: Checkout - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4 + uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 - name: Download container image if: ${{ github.event_name == 'pull_request' }} uses: actions/download-artifact@6b208ae046db98c579e8a3aa621ab581ff575935 # v4.1.1 with: - name: container-image + name: ${{ needs.build.outputs.image-slug }} path: /tmp - name: Load image @@ -222,7 +222,7 @@ jobs: pull-requests: write steps: - name: Checkout - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4 + uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 - name: install iter8 cli env: @@ -242,7 +242,7 @@ jobs: if: ${{ github.event_name == 'pull_request' }} uses: actions/download-artifact@6b208ae046db98c579e8a3aa621ab581ff575935 # v4.1.1 with: - name: container-image + name: ${{ needs.build.outputs.image-slug }} path: /tmp - name: Load image into KinD diff --git a/.github/workflows/nightly-chaos.yaml b/.github/workflows/nightly-chaos.yaml index 5f14ab7..d0bb5a5 100644 --- a/.github/workflows/nightly-chaos.yaml +++ b/.github/workflows/nightly-chaos.yaml @@ -15,7 +15,7 @@ jobs: runs-on: ubuntu-22.04 steps: - name: Checkout - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4 + uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 with: fetch-depth: 0 diff --git a/.github/workflows/release-please.yaml b/.github/workflows/release-please.yaml index 1124c78..f6cc521 100644 --- a/.github/workflows/release-please.yaml +++ b/.github/workflows/release-please.yaml @@ -15,7 +15,7 @@ jobs: pull-requests: write steps: - - uses: google-github-actions/release-please-action@cc61a07e2da466bebbc19b3a7dd01d6aecb20d1e # v4.0.2 + - uses: google-github-actions/release-please-action@db8f2c60ee802b3748b512940dde88eabd7b7e01 # v3.7.13 with: token: ${{ secrets.MIRACUM_BOT_SEMANTIC_RELEASE_TOKEN }} release-type: simple From 97403b8b91b8cf08e24e3407f20c0bf851d31afc Mon Sep 17 00:00:00 2001 From: chgl Date: Fri, 2 Feb 2024 18:15:19 +0100 Subject: [PATCH 4/4] chore: re-formatted --- .../PseudonymGeneratorBenchmarks.cs | 2 +- src/Vfps.StressTests/StressTests.cs | 8 +- .../ControllerTests/FhirControllerTests.cs | 12 +- .../ServiceTests/NamespaceServiceTests.cs | 9 +- .../ServiceTests/PseudonymServiceTests.cs | 20 +-- src/Vfps.Tests/WebAppTests/TestFactory.cs | 4 +- src/Vfps/Data/PseudonymContext.cs | 10 +- src/Vfps/Data/PseudonymRepository.cs | 3 +- src/Vfps/Fhir/FhirController.cs | 74 ++++---- .../20221207170557_InitialCreate.cs | 128 +++++++------- src/Vfps/Program.cs | 162 ++++++++---------- src/Vfps/Services/NamespaceService.cs | 41 ++--- src/Vfps/Services/PseudonymService.cs | 38 ++-- .../Tracing/TracingConfigurationExtensions.cs | 35 ++-- 14 files changed, 239 insertions(+), 307 deletions(-) diff --git a/src/Vfps.Benchmarks/PseudonymGeneratorBenchmarks.cs b/src/Vfps.Benchmarks/PseudonymGeneratorBenchmarks.cs index 412804d..5cc69ef 100644 --- a/src/Vfps.Benchmarks/PseudonymGeneratorBenchmarks.cs +++ b/src/Vfps.Benchmarks/PseudonymGeneratorBenchmarks.cs @@ -20,5 +20,5 @@ public string HexEncodedSha256HashGenerator() => sha256HashGenerator.GeneratePseudonym("test", 64); [Benchmark] - public string Uuid4HashGenerator() => uuid4Generator.GeneratePseudonym("test", 36); + public string Uuid4Generator() => uuid4Generator.GeneratePseudonym("test", 36); } diff --git a/src/Vfps.StressTests/StressTests.cs b/src/Vfps.StressTests/StressTests.cs index b098056..0a6967d 100644 --- a/src/Vfps.StressTests/StressTests.cs +++ b/src/Vfps.StressTests/StressTests.cs @@ -109,11 +109,9 @@ public void RunStressSimulation() } catch (RpcException exc) when (exc.StatusCode == StatusCode.AlreadyExists) { - context - .Logger - .Warning( - $"Namespace {namespaceRequest.Name} already exists. Continuing anyway." - ); + context.Logger.Warning( + $"Namespace {namespaceRequest.Name} already exists. Continuing anyway." + ); } }) .WithWarmUpDuration(TimeSpan.FromSeconds(5)) diff --git a/src/Vfps.Tests/ControllerTests/FhirControllerTests.cs b/src/Vfps.Tests/ControllerTests/FhirControllerTests.cs index de71b62..dd420ac 100644 --- a/src/Vfps.Tests/ControllerTests/FhirControllerTests.cs +++ b/src/Vfps.Tests/ControllerTests/FhirControllerTests.cs @@ -32,9 +32,7 @@ public async Task CreatePseudonym_WithEmptyBody_ShouldReturnErrorOutcome() response .Should() .BeOfType() - .Which - .Value - .Should() + .Which.Value.Should() .BeOfType(); } @@ -46,9 +44,7 @@ public async Task CreatePseudonym_WithNull_ShouldReturnErrorOutcome() response .Should() .BeOfType() - .Which - .Value - .Should() + .Which.Value.Should() .BeOfType(); } @@ -77,9 +73,7 @@ public async Task CreatePseudonym_WithExistingNamespaceRequested_ShouldSucceed() var parameterResponse = response .Should() .BeOfType() - .Which - .Value - .Should() + .Which.Value.Should() .BeOfType() .Which; diff --git a/src/Vfps.Tests/ServiceTests/NamespaceServiceTests.cs b/src/Vfps.Tests/ServiceTests/NamespaceServiceTests.cs index 77ca4be..b740f4a 100644 --- a/src/Vfps.Tests/ServiceTests/NamespaceServiceTests.cs +++ b/src/Vfps.Tests/ServiceTests/NamespaceServiceTests.cs @@ -144,8 +144,7 @@ public async Task Delete_WithNamespaceContainingPseudonyms_ShouldDeleteNamespace } var pseudonymCount = await InMemoryPseudonymContext - .Pseudonyms - .AsNoTracking() + .Pseudonyms.AsNoTracking() .Where(p => p.NamespaceName == createRequest.Name) .CountAsync(); @@ -156,15 +155,13 @@ public async Task Delete_WithNamespaceContainingPseudonyms_ShouldDeleteNamespace await sut.Delete(deleteRequest, TestServerCallContext.Create()); InMemoryPseudonymContext - .Namespaces - .AsNoTracking() + .Namespaces.AsNoTracking() .Where(n => n.Name == deleteRequest.Name) .Should() .BeEmpty(); pseudonymCount = await InMemoryPseudonymContext - .Pseudonyms - .AsNoTracking() + .Pseudonyms.AsNoTracking() .Where(p => p.NamespaceName == createRequest.Name) .CountAsync(); diff --git a/src/Vfps.Tests/ServiceTests/PseudonymServiceTests.cs b/src/Vfps.Tests/ServiceTests/PseudonymServiceTests.cs index 2496ce9..823cdd5 100644 --- a/src/Vfps.Tests/ServiceTests/PseudonymServiceTests.cs +++ b/src/Vfps.Tests/ServiceTests/PseudonymServiceTests.cs @@ -64,11 +64,9 @@ public async Task Create_ShouldSaveNewPseudonym() response.Pseudonym.PseudonymValue.Should().NotBeNull(request.OriginalValue); InMemoryPseudonymContext - .Pseudonyms - .Should() - .Contain( - p => - p.OriginalValue == request.OriginalValue && p.NamespaceName == request.Namespace + .Pseudonyms.Should() + .Contain(p => + p.OriginalValue == request.OriginalValue && p.NamespaceName == request.Namespace ); } @@ -101,24 +99,21 @@ public async Task Create_CalledMultipleTimesWithTheSameOriginalValue_ShouldOnlyS var response = await sut.Create(request, TestServerCallContext.Create()); var firstCreatedPseudonym = response.Pseudonym.PseudonymValue; InMemoryPseudonymContext - .Pseudonyms - .Where(p => p.NamespaceName == request.Namespace) + .Pseudonyms.Where(p => p.NamespaceName == request.Namespace) .Should() .HaveCount(1); response = await sut.Create(request, TestServerCallContext.Create()); response.Pseudonym.PseudonymValue.Should().Be(firstCreatedPseudonym); InMemoryPseudonymContext - .Pseudonyms - .Where(p => p.NamespaceName == request.Namespace) + .Pseudonyms.Where(p => p.NamespaceName == request.Namespace) .Should() .HaveCount(1); response = await sut.Create(request, TestServerCallContext.Create()); response.Pseudonym.PseudonymValue.Should().Be(firstCreatedPseudonym); InMemoryPseudonymContext - .Pseudonyms - .Where(p => p.NamespaceName == request.Namespace) + .Pseudonyms.Where(p => p.NamespaceName == request.Namespace) .Should() .HaveCount(1); } @@ -256,8 +251,7 @@ public async Task List_WithMoreItemsThanPageSize_ShouldReturnAllPseudonymsViaPag } InMemoryPseudonymContext - .Pseudonyms - .Where(p => p.NamespaceName == namespaceName) + .Pseudonyms.Where(p => p.NamespaceName == namespaceName) .Count() .Should() .Be(pseudonymsToCreateCount); diff --git a/src/Vfps.Tests/WebAppTests/TestFactory.cs b/src/Vfps.Tests/WebAppTests/TestFactory.cs index 9de47ec..9bfee00 100644 --- a/src/Vfps.Tests/WebAppTests/TestFactory.cs +++ b/src/Vfps.Tests/WebAppTests/TestFactory.cs @@ -35,8 +35,8 @@ internal static class ServiceCollectionExtensions public static void RemoveDbContext(this IServiceCollection services) where T : DbContext { - var descriptor = services.SingleOrDefault( - d => d.ServiceType == typeof(DbContextOptions) + var descriptor = services.SingleOrDefault(d => + d.ServiceType == typeof(DbContextOptions) ); if (descriptor != null) services.Remove(descriptor); diff --git a/src/Vfps/Data/PseudonymContext.cs b/src/Vfps/Data/PseudonymContext.cs index 1ee98f1..1c5b8ae 100644 --- a/src/Vfps/Data/PseudonymContext.cs +++ b/src/Vfps/Data/PseudonymContext.cs @@ -33,12 +33,10 @@ protected override void OnModelCreating(ModelBuilder modelBuilder) foreach (var entityType in modelBuilder.Model.GetEntityTypes()) { var properties = entityType - .ClrType - .GetProperties() - .Where( - p => - p.PropertyType == typeof(DateTimeOffset) - || p.PropertyType == typeof(DateTimeOffset?) + .ClrType.GetProperties() + .Where(p => + p.PropertyType == typeof(DateTimeOffset) + || p.PropertyType == typeof(DateTimeOffset?) ); foreach (var property in properties) { diff --git a/src/Vfps/Data/PseudonymRepository.cs b/src/Vfps/Data/PseudonymRepository.cs index 21612f2..0e66d07 100644 --- a/src/Vfps/Data/PseudonymRepository.cs +++ b/src/Vfps/Data/PseudonymRepository.cs @@ -74,8 +74,7 @@ public PseudonymRepository(PseudonymContext context) using (UpsertDuration.NewTimer()) { var pseudonyms = await Context - .Pseudonyms - .FromSqlRaw( + .Pseudonyms.FromSqlRaw( UpsertCommand, pseudonym.NamespaceName, pseudonym.OriginalValue, diff --git a/src/Vfps/Fhir/FhirController.cs b/src/Vfps/Fhir/FhirController.cs index dd309af..5baf709 100644 --- a/src/Vfps/Fhir/FhirController.cs +++ b/src/Vfps/Fhir/FhirController.cs @@ -51,16 +51,14 @@ public async Task CreatePseudonym( if (parametersResource is null) { var outcome = new OperationOutcome(); - outcome - .Issue - .Add( - new OperationOutcome.IssueComponent - { - Severity = OperationOutcome.IssueSeverity.Error, - Code = OperationOutcome.IssueType.Processing, - Diagnostics = "Received malformed or missing resource" - } - ); + outcome.Issue.Add( + new OperationOutcome.IssueComponent + { + Severity = OperationOutcome.IssueSeverity.Error, + Code = OperationOutcome.IssueType.Processing, + Diagnostics = "Received malformed or missing resource" + } + ); logger.LogError("Bad Request: received request body is empty."); return BadRequest(outcome); } @@ -71,17 +69,15 @@ public async Task CreatePseudonym( if (namespaceName is null || originalValue is null) { var outcome = new OperationOutcome(); - outcome - .Issue - .Add( - new OperationOutcome.IssueComponent - { - Severity = OperationOutcome.IssueSeverity.Error, - Code = OperationOutcome.IssueType.Processing, - Diagnostics = - "namespace and/or originalValue are missing in the Parameters request object" - } - ); + outcome.Issue.Add( + new OperationOutcome.IssueComponent + { + Severity = OperationOutcome.IssueSeverity.Error, + Code = OperationOutcome.IssueType.Processing, + Diagnostics = + "namespace and/or originalValue are missing in the Parameters request object" + } + ); return BadRequest(outcome); } @@ -89,16 +85,14 @@ public async Task CreatePseudonym( if (@namespace is null) { var outcome = new OperationOutcome(); - outcome - .Issue - .Add( - new OperationOutcome.IssueComponent - { - Severity = OperationOutcome.IssueSeverity.Error, - Code = OperationOutcome.IssueType.Processing, - Diagnostics = $"the namespace '{namespaceName}' could not be found." - } - ); + outcome.Issue.Add( + new OperationOutcome.IssueComponent + { + Severity = OperationOutcome.IssueSeverity.Error, + Code = OperationOutcome.IssueType.Processing, + Diagnostics = $"the namespace '{namespaceName}' could not be found." + } + ); return NotFound(outcome); } @@ -132,16 +126,14 @@ public async Task CreatePseudonym( if (upsertedPseudonym is null) { var outcome = new OperationOutcome(); - outcome - .Issue - .Add( - new OperationOutcome.IssueComponent - { - Severity = OperationOutcome.IssueSeverity.Error, - Code = OperationOutcome.IssueType.Processing, - Diagnostics = "failed to store the pseudonym after several retries" - } - ); + outcome.Issue.Add( + new OperationOutcome.IssueComponent + { + Severity = OperationOutcome.IssueSeverity.Error, + Code = OperationOutcome.IssueType.Processing, + Diagnostics = "failed to store the pseudonym after several retries" + } + ); return StatusCode(500, outcome); } diff --git a/src/Vfps/Migrations/20221207170557_InitialCreate.cs b/src/Vfps/Migrations/20221207170557_InitialCreate.cs index 551a9c4..04ba292 100644 --- a/src/Vfps/Migrations/20221207170557_InitialCreate.cs +++ b/src/Vfps/Migrations/20221207170557_InitialCreate.cs @@ -13,42 +13,41 @@ protected override void Up(MigrationBuilder migrationBuilder) { migrationBuilder.CreateTable( name: "namespaces", - columns: table => - new - { - name = table.Column(type: "text", nullable: false), - description = table.Column(type: "text", nullable: true), - pseudonymgenerationmethod = table.Column( - name: "pseudonym_generation_method", - type: "integer", - nullable: false - ), - pseudonymlength = table.Column( - name: "pseudonym_length", - type: "bigint", - nullable: false - ), - pseudonymprefix = table.Column( - name: "pseudonym_prefix", - type: "text", - nullable: true - ), - pseudonymsuffix = table.Column( - name: "pseudonym_suffix", - type: "text", - nullable: true - ), - createdat = table.Column( - name: "created_at", - type: "timestamp with time zone", - nullable: false - ), - lastupdatedat = table.Column( - name: "last_updated_at", - type: "timestamp with time zone", - nullable: false - ) - }, + columns: table => new + { + name = table.Column(type: "text", nullable: false), + description = table.Column(type: "text", nullable: true), + pseudonymgenerationmethod = table.Column( + name: "pseudonym_generation_method", + type: "integer", + nullable: false + ), + pseudonymlength = table.Column( + name: "pseudonym_length", + type: "bigint", + nullable: false + ), + pseudonymprefix = table.Column( + name: "pseudonym_prefix", + type: "text", + nullable: true + ), + pseudonymsuffix = table.Column( + name: "pseudonym_suffix", + type: "text", + nullable: true + ), + createdat = table.Column( + name: "created_at", + type: "timestamp with time zone", + nullable: false + ), + lastupdatedat = table.Column( + name: "last_updated_at", + type: "timestamp with time zone", + nullable: false + ) + }, constraints: table => { table.PrimaryKey("pk_namespaces", x => x.name); @@ -57,35 +56,34 @@ protected override void Up(MigrationBuilder migrationBuilder) migrationBuilder.CreateTable( name: "pseudonyms", - columns: table => - new - { - originalvalue = table.Column( - name: "original_value", - type: "text", - nullable: false - ), - namespacename = table.Column( - name: "namespace_name", - type: "text", - nullable: false - ), - pseudonymvalue = table.Column( - name: "pseudonym_value", - type: "text", - nullable: false - ), - createdat = table.Column( - name: "created_at", - type: "timestamp with time zone", - nullable: false - ), - lastupdatedat = table.Column( - name: "last_updated_at", - type: "timestamp with time zone", - nullable: false - ) - }, + columns: table => new + { + originalvalue = table.Column( + name: "original_value", + type: "text", + nullable: false + ), + namespacename = table.Column( + name: "namespace_name", + type: "text", + nullable: false + ), + pseudonymvalue = table.Column( + name: "pseudonym_value", + type: "text", + nullable: false + ), + createdat = table.Column( + name: "created_at", + type: "timestamp with time zone", + nullable: false + ), + lastupdatedat = table.Column( + name: "last_updated_at", + type: "timestamp with time zone", + nullable: false + ) + }, constraints: table => { table.PrimaryKey( diff --git a/src/Vfps/Program.cs b/src/Vfps/Program.cs index b803816..6dcb5df 100644 --- a/src/Vfps/Program.cs +++ b/src/Vfps/Program.cs @@ -22,93 +22,79 @@ builder.Services.AddGrpcReflection(); builder.Services.AddHealthChecks().AddDbContextCheck().ForwardToPrometheus(); -builder - .Services - .AddMetricServer( - options => options.Port = builder.Configuration.GetValue("MetricsPort", 8082) - ); +builder.Services.AddMetricServer(options => + options.Port = builder.Configuration.GetValue("MetricsPort", 8082) +); -builder - .Services - .AddSwaggerGen(c => - { - c.SwaggerDoc( - "v1", - new OpenApiInfo +builder.Services.AddSwaggerGen(c => +{ + c.SwaggerDoc( + "v1", + new OpenApiInfo + { + Title = "VFPS FHIR and gRPC JSON-transcoded API", + Version = "v1", + Description = "A very fast and resource-efficient pseudonym service.", + License = new OpenApiLicense { - Title = "VFPS FHIR and gRPC JSON-transcoded API", - Version = "v1", - Description = "A very fast and resource-efficient pseudonym service.", - License = new OpenApiLicense - { - Name = "Apache-2.0", + Name = "Apache-2.0", #pragma warning disable S1075 // URIs should not be hardcoded - Url = new Uri("https://www.apache.org/licenses/LICENSE-2.0") + Url = new Uri("https://www.apache.org/licenses/LICENSE-2.0") #pragma warning restore S1075 // URIs should not be hardcoded - }, - } - ); - - var filePath = Path.Combine(AppContext.BaseDirectory, "Vfps.xml"); - c.IncludeXmlComments(filePath); - c.IncludeGrpcXmlComments(filePath, includeControllerXmlComments: true); - c.UseInlineDefinitionsForEnums(); - }); - -builder - .Services - .AddDbContext( - (isp, options) => - { - var config = isp.GetService()!; + }, + } + ); - var backingStore = - config.GetValue("Pseudonymization:BackingStore") - ?? throw new InvalidOperationException( - "Failed to get backing store config. Make sure Pseudonymization:BackingStore is set" - ); + var filePath = Path.Combine(AppContext.BaseDirectory, "Vfps.xml"); + c.IncludeXmlComments(filePath); + c.IncludeGrpcXmlComments(filePath, includeControllerXmlComments: true); + c.UseInlineDefinitionsForEnums(); +}); - var connString = - config.GetConnectionString(backingStore) - ?? throw new InvalidOperationException( - $"Failed to get connection string for '{backingStore}' backing store" - ); +builder.Services.AddDbContext( + (isp, options) => + { + var config = isp.GetService()!; - switch (backingStore.ToLowerInvariant()) - { - case "postgresql": - options.UseNpgsql(connString); - break; - default: - throw new InvalidOperationException( - $"Unsupported backing store specified: {backingStore}" - ); - } + var backingStore = + config.GetValue("Pseudonymization:BackingStore") + ?? throw new InvalidOperationException( + "Failed to get backing store config. Make sure Pseudonymization:BackingStore is set" + ); + + var connString = + config.GetConnectionString(backingStore) + ?? throw new InvalidOperationException( + $"Failed to get connection string for '{backingStore}' backing store" + ); + + switch (backingStore.ToLowerInvariant()) + { + case "postgresql": + options.UseNpgsql(connString); + break; + default: + throw new InvalidOperationException( + $"Unsupported backing store specified: {backingStore}" + ); } - ); + } +); builder.Services.AddSingleton(); var cacheConfig = new CacheConfig(); builder.Configuration.GetSection("Pseudonymization:Caching").Bind(cacheConfig); -var isNamespaceCachingEnabled = builder - .Configuration - .GetValue("Pseudonymization:Caching:Namespaces:IsEnabled", false); +var isNamespaceCachingEnabled = builder.Configuration.GetValue( + "Pseudonymization:Caching:Namespaces:IsEnabled", + false +); if (isNamespaceCachingEnabled) { - builder - .Services - .AddSingleton( - _ => - new MemoryCache( - new MemoryCacheOptions - { - TrackStatistics = true, - SizeLimit = cacheConfig.SizeLimit - } - ) - ); + builder.Services.AddSingleton(_ => new MemoryCache( + new MemoryCacheOptions { TrackStatistics = true, SizeLimit = cacheConfig.SizeLimit } + )); builder.Services.AddSingleton(_ => cacheConfig); builder.Services.AddScoped(); } @@ -117,23 +103,15 @@ builder.Services.AddScoped(); } -var isPseudonymCachingEnabled = builder - .Configuration - .GetValue("Pseudonymization:Caching:Pseudonyms:IsEnabled", false); +var isPseudonymCachingEnabled = builder.Configuration.GetValue( + "Pseudonymization:Caching:Pseudonyms:IsEnabled", + false +); if (isPseudonymCachingEnabled) { - builder - .Services - .TryAddSingleton( - _ => - new MemoryCache( - new MemoryCacheOptions - { - TrackStatistics = true, - SizeLimit = cacheConfig.SizeLimit - } - ) - ); + builder.Services.TryAddSingleton(_ => new MemoryCache( + new MemoryCacheOptions { TrackStatistics = true, SizeLimit = cacheConfig.SizeLimit } + )); builder.Services.TryAddSingleton(_ => cacheConfig); builder.Services.AddScoped(); } @@ -150,13 +128,11 @@ builder.Services.AddHostedService(); -builder - .Services - .AddControllers(options => - { - options.InputFormatters.Insert(0, new FhirInputFormatter()); - options.OutputFormatters.Insert(0, new FhirOutputFormatter()); - }); +builder.Services.AddControllers(options => +{ + options.InputFormatters.Insert(0, new FhirInputFormatter()); + options.OutputFormatters.Insert(0, new FhirOutputFormatter()); +}); // Tracing var isTracingEnabled = builder.Configuration.GetValue("Tracing:IsEnabled", false); diff --git a/src/Vfps/Services/NamespaceService.cs b/src/Vfps/Services/NamespaceService.cs index a3eec37..18da95d 100644 --- a/src/Vfps/Services/NamespaceService.cs +++ b/src/Vfps/Services/NamespaceService.cs @@ -131,9 +131,10 @@ public override async Task Delete( ServerCallContext context ) { - var @namespace = await Context - .Namespaces - .FindAsync(request.Name, context.CancellationToken); + var @namespace = await Context.Namespaces.FindAsync( + request.Name, + context.CancellationToken + ); if (@namespace is null) { var metadata = new Metadata { { "Namespace", request.Name } }; @@ -162,26 +163,22 @@ ServerCallContext context ) { var namespaces = await Context - .Namespaces - .AsNoTracking() + .Namespaces.AsNoTracking() // TODO: should really use auto-mapper or some other even a custom Namespace.FromDto() method. - .Select( - n => - new Namespace - { - Description = n.Description, - Name = n.Name, - PseudonymGenerationMethod = n.PseudonymGenerationMethod, - PseudonymLength = n.PseudonymLength, - PseudonymPrefix = n.PseudonymPrefix, - PseudonymSuffix = n.PseudonymSuffix, - Meta = new Meta - { - CreatedAt = Timestamp.FromDateTimeOffset(n.CreatedAt), - LastUpdatedAt = Timestamp.FromDateTimeOffset(n.LastUpdatedAt) - } - } - ) + .Select(n => new Namespace + { + Description = n.Description, + Name = n.Name, + PseudonymGenerationMethod = n.PseudonymGenerationMethod, + PseudonymLength = n.PseudonymLength, + PseudonymPrefix = n.PseudonymPrefix, + PseudonymSuffix = n.PseudonymSuffix, + Meta = new Meta + { + CreatedAt = Timestamp.FromDateTimeOffset(n.CreatedAt), + LastUpdatedAt = Timestamp.FromDateTimeOffset(n.LastUpdatedAt) + } + }) .ToListAsync(context.CancellationToken); var response = new NamespaceServiceGetAllResponse(); diff --git a/src/Vfps/Services/PseudonymService.cs b/src/Vfps/Services/PseudonymService.cs index 0d2551b..5a64f5b 100644 --- a/src/Vfps/Services/PseudonymService.cs +++ b/src/Vfps/Services/PseudonymService.cs @@ -120,11 +120,8 @@ ServerCallContext context ) { var pseudonym = await Context - .Pseudonyms - .Where( - p => - p.NamespaceName == request.Namespace - && p.PseudonymValue == request.PseudonymValue + .Pseudonyms.Where(p => + p.NamespaceName == request.Namespace && p.PseudonymValue == request.PseudonymValue ) .FirstOrDefaultAsync(); if (pseudonym is null) @@ -193,26 +190,22 @@ ServerCallContext context var offset = requestPaginationToken.Offset; var pseudonyms = await Context - .Pseudonyms - .Where(pseudonym => pseudonym.NamespaceName == request.Namespace) + .Pseudonyms.Where(pseudonym => pseudonym.NamespaceName == request.Namespace) .Where(pseudonym => pseudonym.CreatedAt <= createdOnOrBefore) .OrderByDescending(pseudonym => pseudonym.CreatedAt) .Skip(offset) .Take(pageSize) - .Select( - pseudonym => - new Pseudonym - { - Namespace = pseudonym.NamespaceName, - OriginalValue = pseudonym.OriginalValue, - PseudonymValue = pseudonym.PseudonymValue, - Meta = new Meta - { - CreatedAt = Timestamp.FromDateTimeOffset(pseudonym.CreatedAt), - LastUpdatedAt = Timestamp.FromDateTimeOffset(pseudonym.LastUpdatedAt), - }, - } - ) + .Select(pseudonym => new Pseudonym + { + Namespace = pseudonym.NamespaceName, + OriginalValue = pseudonym.OriginalValue, + PseudonymValue = pseudonym.PseudonymValue, + Meta = new Meta + { + CreatedAt = Timestamp.FromDateTimeOffset(pseudonym.CreatedAt), + LastUpdatedAt = Timestamp.FromDateTimeOffset(pseudonym.LastUpdatedAt), + }, + }) .ToListAsync(); var paginationToken = new PseudonymListPaginationToken @@ -238,8 +231,7 @@ ServerCallContext context if (request.IncludeTotalSize) { response.TotalSize = await Context - .Pseudonyms - .Where(n => n.NamespaceName == request.Namespace) + .Pseudonyms.Where(n => n.NamespaceName == request.Namespace) .LongCountAsync(); } diff --git a/src/Vfps/Tracing/TracingConfigurationExtensions.cs b/src/Vfps/Tracing/TracingConfigurationExtensions.cs index 7a3b6f6..6289a93 100644 --- a/src/Vfps/Tracing/TracingConfigurationExtensions.cs +++ b/src/Vfps/Tracing/TracingConfigurationExtensions.cs @@ -19,9 +19,10 @@ public static WebApplicationBuilder AddTracing(this WebApplicationBuilder builde var serviceName = builder.Configuration.GetValue("Tracing:ServiceName", assembly.Name) ?? "vfps"; - var rootSamplerType = builder - .Configuration - .GetValue("Tracing:RootSampler", "AlwaysOnSampler"); + var rootSamplerType = builder.Configuration.GetValue( + "Tracing:RootSampler", + "AlwaysOnSampler" + ); var samplingRatio = builder.Configuration.GetValue("Tracing:SamplingProbability", 0.1d); Sampler rootSampler = rootSamplerType switch @@ -33,15 +34,13 @@ public static WebApplicationBuilder AddTracing(this WebApplicationBuilder builde }; builder - .Services - .AddOpenTelemetry() - .ConfigureResource( - r => - r.AddService( - serviceName: serviceName, - serviceVersion: assemblyVersion, - serviceInstanceId: Environment.MachineName - ) + .Services.AddOpenTelemetry() + .ConfigureResource(r => + r.AddService( + serviceName: serviceName, + serviceVersion: assemblyVersion, + serviceInstanceId: Environment.MachineName + ) ) .WithTracing(tracingBuilder => { @@ -64,19 +63,17 @@ public static WebApplicationBuilder AddTracing(this WebApplicationBuilder builde { case "jaeger": tracingBuilder.AddJaegerExporter(); - builder - .Services - .Configure( - builder.Configuration.GetSection("Tracing:Jaeger") - ); + builder.Services.Configure( + builder.Configuration.GetSection("Tracing:Jaeger") + ); break; case "otlp": var endpoint = builder.Configuration.GetValue("Tracing:Otlp:Endpoint") ?? ""; - tracingBuilder.AddOtlpExporter( - otlpOptions => otlpOptions.Endpoint = new Uri(endpoint) + tracingBuilder.AddOtlpExporter(otlpOptions => + otlpOptions.Endpoint = new Uri(endpoint) ); break; }