File tree Expand file tree Collapse file tree 5 files changed +99
-0
lines changed Expand file tree Collapse file tree 5 files changed +99
-0
lines changed Original file line number Diff line number Diff line change
1
+ name : Check deployed package
2
+
3
+ on :
4
+ push :
5
+ branches :
6
+ - main
7
+
8
+ jobs :
9
+ run-demo :
10
+ name : Run LogDash Demo
11
+ runs-on : ubuntu-latest
12
+
13
+ steps :
14
+ - name : Checkout repository
15
+ uses : actions/checkout@v3
16
+
17
+ - name : Make run script executable
18
+ run : chmod +x check-deployed-package/run.sh
19
+
20
+ - name : Run LogDash demo
21
+ env :
22
+ LOGDASH_API_KEY : ${{ secrets.LOGDASH_API_KEY }}
23
+ run : ./check-deployed-package/run.sh
Original file line number Diff line number Diff line change
1
+ FROM python:3.9-alpine
2
+
3
+ WORKDIR /app
4
+
5
+ RUN pip install logdash
6
+
7
+ COPY check-deployed-package/demo.py /app/
8
+
9
+ RUN chmod +x /app/demo.py
10
+
11
+ CMD ["python" , "./check.py" ]
Original file line number Diff line number Diff line change
1
+ # LogDash Python SDK Demo
2
+
3
+ Use command below to test if the published SDK works:
4
+
5
+ ```
6
+ LOGDASH_API_KEY=<your-api-key> ./check-deployed-package/run.sh
7
+ ```
Original file line number Diff line number Diff line change
1
+ #!/usr/bin/env python3
2
+ # -*- coding: utf-8 -*-
3
+
4
+ import os
5
+ import time
6
+ import pkg_resources
7
+
8
+ print ('=== LogDash SDK Demo ===' )
9
+
10
+ from logdash import create_logdash
11
+
12
+ try :
13
+ logdash_version = pkg_resources .get_distribution ("logdash" ).version
14
+ except :
15
+ logdash_version = "unknown"
16
+ print (f"Using logdash package version: { logdash_version } " )
17
+ print ()
18
+
19
+ api_key = os .environ .get ('LOGDASH_API_KEY' )
20
+ print (f"Using API Key: { api_key } " )
21
+
22
+ logdash = create_logdash ({
23
+ "api_key" : api_key ,
24
+ })
25
+
26
+ # Get the logger instance
27
+ logger = logdash .logger
28
+
29
+ # Get the metrics instance
30
+ metrics = logdash .metrics
31
+
32
+ # Log some messages
33
+ logger .log ('This is an info log' )
34
+ logger .error ('This is an error log' )
35
+
36
+ # Set and mutate metrics
37
+ metrics .set ('demo_users' , 42 )
38
+ metrics .mutate ('demo_counter' , 1 )
39
+
40
+ # Wait to ensure data is sent
41
+ time .sleep (1 )
Original file line number Diff line number Diff line change
1
+ #! /bin/sh
2
+ set -e
3
+
4
+ echo " Building LogDash demo Docker image (using published package)..."
5
+ docker build --no-cache -t logdash-python-demo -f check-deployed-package/Dockerfile .
6
+
7
+ echo
8
+ echo " Running LogDash demo..."
9
+ echo
10
+
11
+ # Run in non-interactive mode which works everywhere
12
+ docker run --rm \
13
+ -e LOGDASH_API_KEY=" ${LOGDASH_API_KEY} " \
14
+ logdash-python-demo
15
+
16
+ echo
17
+ echo " Demo completed!"
You can’t perform that action at this time.
0 commit comments