Skip to content

Commit

Permalink
Add GHA example (#29)
Browse files Browse the repository at this point in the history
Add GHA example
  • Loading branch information
krzko authored Jul 14, 2022
1 parent 92e50a7 commit 36d01be
Show file tree
Hide file tree
Showing 8 changed files with 79 additions and 5 deletions.
1 change: 1 addition & 0 deletions examples/github_actions/simple.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#
73 changes: 73 additions & 0 deletions examples/github_actions/strategy_matrix.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
name: github-actions-strategy-matrix
on:
push:

env:
OTEL_EXPORTER_OTEL_ENDPOINT: https://otelcol.domain
# OTEL_LOG_LEVEL: debug
OTEL_SH_LIB_PATH: opentelemetry-shell/library

jobs:
opentelemetry-shell:
runs-on: [ubuntu-latest]
outputs:
OTEL_TRACE_ID: ${{ steps.init-otel-sh.outputs.OTEL_TRACE_ID }}
steps:
- name: ✨ Checkout krzko/opentelemetry-shell
uses: actions/checkout@v2
with:
repository: krzko/opentelemetry-shell
path: './opentelemetry-shell'
- name: 🚦 Initialise OpenTelemetry Shell
id: init-otel-sh
run: |
. opentelemetry-shell/library/otel_traces.sh
trace_id=$(generate_uuid 16)
echo "::set-output name=OTEL_TRACE_ID::${trace_id}"
log_info "TraceId: ${trace_id}"
awesome-job:
needs:
- opentelemetry-shell
runs-on: [ubuntu-latest]
strategy:
matrix:
service: [foo, bar]
env:
OTEL_TRACE_ID: ${{ needs.opentelemetry-shell.outputs.OTEL_TRACE_ID }}
steps:
- name: ✨ Checkout
uses: actions/checkout@v2
- name: ✨ Checkout krzko/opentelemetry-shell
uses: actions/checkout@v2
with:
repository: krzko/opentelemetry-shell
path: './opentelemetry-shell'
- name: ⛏ Work
run: |
. opentelemetry-shell/library/otel_traces.sh
otel_trace_start_parent_span echo ${{ matrix.service }}
otel_trace_start_child_span sleep 1
otel_trace_start_child_span sleep 2
- name: ✅ Push success metric
if: success()
run: |
. opentelemetry-shell/library/otel_metrics.sh
otel_metrics_push_gauge "ko.wal.ski/${GITHUB_REPOSITORY}/workflow/is_failed" \
"If the workflow was successful." \
"By" \
"workflow_name" \
"${GITHUB_WORKFLOW}" \
0 \
int
- name: ❌ Push failure metric
if: failure()
run: |
. opentelemetry-shell/library/otel_metrics.sh
otel_metrics_push_gauge "ko.wal.ski/${GITHUB_REPOSITORY}/workflow/is_failed" \
"If the workflow was successful." \
"By" \
"workflow_name" \
"${GITHUB_WORKFLOW}" \
1 \
int
Empty file added examples/jenkins/.keep
Empty file.
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ custom_resource_attributes=(
service_version="0.0.1-dev"

# Export library path
export OTEL_SH_LIB_PATH="../library"
export OTEL_SH_LIB_PATH="../../library"

# Import functions
. "${OTEL_SH_LIB_PATH}/otel_metrics.sh"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ custom_resource_attributes=(
service_version="0.0.1-dev"

# Export library path
export OTEL_SH_LIB_PATH="../library"
export OTEL_SH_LIB_PATH="../../library"

# Import functions
. "${OTEL_SH_LIB_PATH}/otel_metrics.sh"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ custom_resource_attributes=(
service_version="0.0.1-dev"

# Export library path
export OTEL_SH_LIB_PATH="../library"
export OTEL_SH_LIB_PATH="../../library"

# Import functions
. "${OTEL_SH_LIB_PATH}/otel_traces.sh"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ custom_resource_attributes=(
service_version="0.0.1-dev"

# Export library path
export OTEL_SH_LIB_PATH="../library"
export OTEL_SH_LIB_PATH="../../library"

# Import functions
. "${OTEL_SH_LIB_PATH}/otel_traces.sh"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ custom_resource_attributes=(
service_version="0.0.1-dev"

# Export library path
export OTEL_SH_LIB_PATH="../library"
export OTEL_SH_LIB_PATH="../../library"

# Import functions
. "${OTEL_SH_LIB_PATH}/otel_traces.sh"
Expand Down

0 comments on commit 36d01be

Please sign in to comment.