-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 66302da
Showing
18 changed files
with
569 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
name: build | ||
on: | ||
- push | ||
jobs: | ||
build: | ||
runs-on: ubuntu-22.04 | ||
name: Build | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Build | ||
run: ./build.sh build | ||
release: | ||
if: startsWith(github.ref, 'refs/tags/v') | ||
name: Release | ||
needs: build | ||
runs-on: ubuntu-22.04 | ||
permissions: | ||
contents: write | ||
packages: write | ||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v4 | ||
- name: Login to GitHub Container Registry | ||
uses: docker/login-action@v3 | ||
with: | ||
registry: ghcr.io | ||
username: ${{ github.actor }} | ||
password: ${{ secrets.GITHUB_TOKEN }} | ||
- name: Release | ||
run: ./build.sh release | ||
- name: Release binary artifact | ||
uses: ncipollo/release-action@v1 | ||
with: | ||
bodyFile: dist/release-notes.md | ||
token: ${{ secrets.GITHUB_TOKEN }} |
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,4 @@ | ||
bin/ | ||
obj/ | ||
tmp/ | ||
*.sln |
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,19 @@ | ||
{ | ||
"cSpell.words": [ | ||
"ASPNETCORE", | ||
"Edsger", | ||
"Heemstra", | ||
"opentelemetry", | ||
"opsi", | ||
"OTEL", | ||
"otlp", | ||
"Petroski", | ||
"Pravin", | ||
"Sipley", | ||
"Skroob", | ||
"Spaceballs", | ||
"traceparent", | ||
"tracestate", | ||
"wireshark" | ||
] | ||
} |
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,68 @@ | ||
# About | ||
|
||
[![Build](https://github.com/rgl/opentelemetry-dotnet-playground/actions/workflows/build.yml/badge.svg)](https://github.com/rgl/opentelemetry-dotnet-playground/actions/workflows/build.yml) | ||
|
||
This is a [OpenTelemetry .NET](https://github.com/open-telemetry/opentelemetry-dotnet) playground. | ||
|
||
The following components are used: | ||
|
||
![components](components.png) | ||
|
||
# Usage (Ubuntu 22.04) | ||
|
||
```bash | ||
# create the environment defined in docker-compose.yml | ||
# and leave it running in the background. | ||
docker compose up -d --build | ||
|
||
# show running containers. | ||
docker compose ps | ||
|
||
# show logs. | ||
docker compose logs | ||
|
||
# open a container network interface in wireshark. | ||
./wireshark.sh quotes | ||
|
||
# open the quotes service swagger. | ||
xdg-open http://localhost:8000/swagger | ||
|
||
# make a request. | ||
http \ | ||
--verbose \ | ||
http://localhost:8000/quote | ||
|
||
# make a failing request. | ||
http \ | ||
--verbose \ | ||
http://localhost:8000/quote?opsi=opsi | ||
|
||
# make a request that includes a parent trace. | ||
# NB the dotnet trace id will be set to the traceparent trace id. | ||
# NB the tracestate does not seem to be stored or propagated anywhere. | ||
http \ | ||
--verbose \ | ||
http://localhost:8000/quote \ | ||
traceparent:00-f1f1f1f1f1f1f1f1f1f1f1f1f1f1f1f1-2f2f2f2f2f2f2f2f-01 \ | ||
tracestate:x.client.state=example | ||
|
||
# open aspire dashboard (metrics/traces/logs). | ||
xdg-open http://localhost:18888 | ||
|
||
# destroy the environment. | ||
docker compose down --remove-orphans --volumes --timeout=0 | ||
``` | ||
|
||
# Notes | ||
|
||
* .NET uses the [Activity class](https://docs.microsoft.com/en-us/dotnet/api/system.diagnostics.activity?view=net-8.0) to encapsulate the [W3C Trace Context](https://www.w3.org/TR/trace-context/). | ||
* The Activity `Id` property contains to the [W3C `traceparent` header value](https://www.w3.org/TR/trace-context/#traceparent-header). | ||
* It looks alike `00-98d483b6d0e3a6d012b11e23737faa50-6ac18089ab13c12e-01`. | ||
* It has four fields: `version`, `trace-id`, `parent-id` (aka `span-id`), and `trace-flags`. | ||
|
||
# Reference | ||
|
||
* [W3C Trace Context](https://www.w3.org/TR/trace-context/). | ||
* [opentelemetry-dotnet repository](https://github.com/open-telemetry/opentelemetry-dotnet). | ||
* [OpenTelemetry in .NET documentation](https://opentelemetry.io/docs/languages/net/). | ||
* [OpenTelemetry.Exporter.OpenTelemetryProtocol Environment Variables](https://github.com/open-telemetry/opentelemetry-dotnet/tree/main/src/OpenTelemetry.Exporter.OpenTelemetryProtocol#environment-variables). |
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,76 @@ | ||
#!/bin/bash | ||
set -euxo pipefail | ||
|
||
GITHUB_REPOSITORY="${GITHUB_REPOSITORY:-rgl/opentelemetry-dotnet-playground}" | ||
|
||
QUOTES_SOURCE_URL="https://github.com/$GITHUB_REPOSITORY" | ||
if [[ "${GITHUB_REF:-v0.0.0-dev}" =~ \/v([0-9]+(\.[0-9]+)+(-.+)?) ]]; then | ||
QUOTES_VERSION="${BASH_REMATCH[1]}" | ||
else | ||
QUOTES_VERSION='0.0.0-dev' | ||
fi | ||
QUOTES_REVISION="${GITHUB_SHA:-0000000000000000000000000000000000000000}" | ||
QUOTES_TITLE="$(basename "$GITHUB_REPOSITORY")" | ||
QUOTES_DESCRIPTION="$(perl -ne 'print $1 if /\<Description\>(.+)\<\/Description\>/' <quotes/Quotes.csproj)" | ||
QUOTES_LICENSE='ISC' | ||
QUOTES_AUTHOR_NAME="$(perl -ne 'print $1 if /\<Company\>(.+)\<\/Company\>/' <quotes/Quotes.csproj)" | ||
QUOTES_VENDOR="$QUOTES_AUTHOR_NAME" | ||
|
||
function set-metadata { | ||
sed -i -E "s,(\<Version\>).+(\</Version\>),\1$QUOTES_VERSION\2,g" quotes/Quotes.csproj | ||
} | ||
|
||
function build { | ||
set-metadata | ||
docker compose build | ||
} | ||
|
||
function release { | ||
set-metadata | ||
pushd quotes | ||
local image="ghcr.io/$GITHUB_REPOSITORY:$QUOTES_VERSION" | ||
local image_created="$(date --utc '+%Y-%m-%dT%H:%M:%S.%NZ')" | ||
docker build \ | ||
--label "org.opencontainers.image.created=$image_created" \ | ||
--label "org.opencontainers.image.source=$QUOTES_SOURCE_URL" \ | ||
--label "org.opencontainers.image.version=$QUOTES_VERSION" \ | ||
--label "org.opencontainers.image.revision=$QUOTES_REVISION" \ | ||
--label "org.opencontainers.image.title=$QUOTES_TITLE" \ | ||
--label "org.opencontainers.image.description=$QUOTES_DESCRIPTION" \ | ||
--label "org.opencontainers.image.licenses=$QUOTES_LICENSE" \ | ||
--label "org.opencontainers.image.vendor=$QUOTES_VENDOR" \ | ||
--label "org.opencontainers.image.authors=$QUOTES_AUTHOR_NAME" \ | ||
-t "$image" \ | ||
. | ||
docker push "$image" | ||
popd | ||
install -d dist | ||
cat >dist/release-notes.md <<EOF | ||
# Container image | ||
[$QUOTES_SOURCE_URL/pkgs/container/$QUOTES_TITLE]($QUOTES_SOURCE_URL/pkgs/container/$QUOTES_TITLE) | ||
\`\`\`bash | ||
docker pull $image | ||
\`\`\` | ||
EOF | ||
echo "$image" | ||
} | ||
|
||
function main { | ||
local command="$1"; shift | ||
case "$command" in | ||
build) | ||
build "$@" | ||
;; | ||
release) | ||
release "$@" | ||
;; | ||
*) | ||
echo "ERROR: Unknown command $command" | ||
exit 1 | ||
;; | ||
esac | ||
} | ||
|
||
main "$@" |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,78 @@ | ||
<?xml version="1.0" encoding="UTF-8" standalone="no"?> | ||
<diagram program="umlet" version="15.1"> | ||
<zoom_level>10</zoom_level> | ||
<element> | ||
<id>UMLClass</id> | ||
<coordinates> | ||
<x>350</x> | ||
<y>280</y> | ||
<w>190</w> | ||
<h>110</h> | ||
</coordinates> | ||
<panel_attributes><<dashboard>> | ||
<<metrics>> | ||
<<traces>> | ||
<<logs>> | ||
aspire-dashboard</panel_attributes> | ||
<additional_attributes/> | ||
</element> | ||
<element> | ||
<id>UMLClass</id> | ||
<coordinates> | ||
<x>350</x> | ||
<y>410</y> | ||
<w>190</w> | ||
<h>70</h> | ||
</coordinates> | ||
<panel_attributes><<service>> | ||
quotes</panel_attributes> | ||
<additional_attributes/> | ||
</element> | ||
<element> | ||
<id>Relation</id> | ||
<coordinates> | ||
<x>150</x> | ||
<y>410</y> | ||
<w>220</w> | ||
<h>40</h> | ||
</coordinates> | ||
<panel_attributes>r1=http://localhost:8000 | ||
lt=()-</panel_attributes> | ||
<additional_attributes>10.0;20.0;200.0;20.0</additional_attributes> | ||
</element> | ||
<element> | ||
<id>Relation</id> | ||
<coordinates> | ||
<x>150</x> | ||
<y>280</y> | ||
<w>220</w> | ||
<h>40</h> | ||
</coordinates> | ||
<panel_attributes>r1=http://localhost:18888 | ||
lt=()-</panel_attributes> | ||
<additional_attributes>10.0;20.0;200.0;20.0</additional_attributes> | ||
</element> | ||
<element> | ||
<id>Relation</id> | ||
<coordinates> | ||
<x>530</x> | ||
<y>350</y> | ||
<w>330</w> | ||
<h>110</h> | ||
</coordinates> | ||
<panel_attributes>lt=-(</panel_attributes> | ||
<additional_attributes>10.0;90.0;310.0;90.0;310.0;20.0;290.0;20.0</additional_attributes> | ||
</element> | ||
<element> | ||
<id>Relation</id> | ||
<coordinates> | ||
<x>530</x> | ||
<y>350</y> | ||
<w>290</w> | ||
<h>40</h> | ||
</coordinates> | ||
<panel_attributes>r2=http://aspire-dashboard:18889 | ||
lt=-()</panel_attributes> | ||
<additional_attributes>10.0;20.0;270.0;20.0</additional_attributes> | ||
</element> | ||
</diagram> |
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,25 @@ | ||
# see https://github.com/compose-spec/compose-spec/blob/master/spec.md | ||
# see https://github.com/opencontainers/image-spec/blob/master/annotations.md | ||
services: | ||
aspire-dashboard: | ||
# see https://mcr.microsoft.com/product/dotnet/nightly/aspire-dashboard/about | ||
# see https://github.com/dotnet/dotnet-docker/issues/5128 | ||
# see https://github.com/dotnet/aspire/issues/2248#issuecomment-1947902486 | ||
image: mcr.microsoft.com/dotnet/nightly/aspire-dashboard:8.0.0-preview.4 | ||
ports: | ||
# web ui. | ||
- 18888:18888 | ||
# otlp grpc. | ||
#- 18889:18889 | ||
restart: on-failure | ||
quotes: | ||
build: quotes | ||
environment: | ||
- OTEL_EXPORTER_OTLP_ENDPOINT=http://aspire-dashboard:18889 | ||
- OTEL_EXPORTER_OTLP_PROTOCOL=grpc | ||
- ASPNETCORE_URLS=http://+:8000 | ||
ports: | ||
# http api. | ||
# http://localhost:8000 | ||
- 8000:8000 | ||
restart: on-failure |
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,4 @@ | ||
bin/ | ||
obj/ | ||
out/ | ||
.*/ |
Oops, something went wrong.