Created
September 2, 2022 02:13
-
-
Save sgsharma/3043a43393c767aa3b20fee15448d58e to your computer and use it in GitHub Desktop.
Sample Flask app
This file contains hidden or 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
| from collections import namedtuple | |
| from random import choice | |
| from apig_wsgi import make_lambda_handler | |
| from flask import Flask, jsonify | |
| Tax = namedtuple("Tax", ("sales_tax", "state")) | |
| taxes = [ | |
| Tax(9, "California"), | |
| Tax(6, "Washington"), | |
| Tax(8, "Oregon"), | |
| Tax(7, "Colorado"), | |
| Tax(5, "Idaho") | |
| ] | |
| app = Flask(__name__) | |
| @app.route("/", methods=["GET"]) | |
| def index(): | |
| return jsonify(status=200, message='Hello World!') | |
| @app.route("/tax", methods=["GET"]) | |
| def get_random_quote(): | |
| return jsonify(choice(taxes)._asdict()) | |
| lambda_handler = make_lambda_handler(app, binary_support=None, non_binary_content_type_prefixes=None) |
This file contains hidden or 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
| # Set an environemnt variable 'OPENTELEMETRY_COLLECTOR_CONFIG_FILE' to | |
| # '/var/task/collector.yaml' | |
| receivers: | |
| otlp: | |
| protocols: | |
| grpc: | |
| http: | |
| exporters: | |
| logging: | |
| loglevel: debug | |
| otlp: | |
| endpoint: "api.honeycomb.io:443" | |
| headers: | |
| # You can find your Honeycomb API key under Environment settings | |
| "x-honeycomb-team": "<YOUR-API-KEY>" | |
| service: | |
| pipelines: | |
| traces: | |
| receivers: [otlp] | |
| exporters: [otlp, logging] |
This file contains hidden or 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
| apig-wsgi==2.15.0 | |
| click==8.1.3 | |
| Flask==2.2.2 | |
| importlib-metadata==4.12.0 | |
| itsdangerous==2.1.2 | |
| Jinja2==3.1.2 | |
| MarkupSafe==2.1.1 | |
| Werkzeug==2.2.2 | |
| zipp==3.8.1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment