Report user agent
Some checks failed
continuous-integration/drone Build is failing

This commit is contained in:
Lauri Võsandi 2022-09-04 09:01:22 +03:00
parent 937859c60d
commit 76c99bd568

View File

@ -29,6 +29,9 @@ print("Running with following targets:")
for name, url in targets:
print(url)
GIT_COMMIT = os.getenv("GIT_COMMIT", "null")
GIT_COMMIT_TIMESTAMP = os.getenv("GIT_COMMIT_TIMESTAMP", "null")
counter_dropped_bytes = Counter(
"camtiler_client_dropped_bytes",
"Bytes that were not not handled or part of actual JPEG frames")
@ -54,6 +57,13 @@ counter_errors = Counter(
"camtiler_errors",
"Upstream connection errors",
["exception"])
gauge_build_info = Gauge(
"docker_build_info",
"Build info",
["git_commit", "git_commit_timestamp"])
gauge_build_info.labels(
GIT_COMMIT,
GIT_COMMIT_TIMESTAMP).set(1)
app = Sanic("camtiler")
@ -143,9 +153,15 @@ async def client_connect(name, resp):
async def client(name, url):
print("Opening upstream connection to %s" % url)
kwargs = dict(
headers = {
"User-Agent": "camtiler/%s" % GIT_COMMIT_TIMESTAMP
},
skip_auto_headers = True,
timeout = aiohttp.ClientTimeout(connect=5, sock_read=2))
while True:
app.ctx.frames[name] = None
async with aiohttp.ClientSession(timeout=aiohttp.ClientTimeout(connect=5, sock_read=2)) as session:
async with aiohttp.ClientSession(**kwargs) as session:
try:
async with session.get(url) as resp:
await client_connect(name, resp)