Skip to Content
基于Python的DevOps
book

基于Python的DevOps

by Noah Gift, Kennedy Behrman, Alfredo Deza, Grig Gheorghiu
March 2022
Intermediate to advanced
532 pages
9h 41m
Chinese
China Electric Power Press Ltd.
Content preview from 基于Python的DevOps
监控和日志
201
举个例子,假设我们在一个为网站伺服图像的小型
Python
应用中调用
AWS API
我们想监测度量数据的
Python
模块保存在
web/api/aws.py
中。正常情况下,这个路
径的命名空间可以选为
web.api.aws
,但是如果有多个生产应用服务器呢?倘若在
同一个命名空间下传送度量数据,则很难(几乎不可能)更改为其他方案。我们可
以改善一下,使用
{server_name}.web.api.aws
形式的命名空间识别不同的生产服
务器。
这样好多了!可是,你能发现新的问题吗?传送度量数据时,其会在命名空间末
尾添加一个名称。在计数器示例中,名称会变
{server_name}.web.api.aws.
counter
这是个问题,因为这个小型应用会多次调用
AWS
,如
S3
,而且以后可能
还需要与其他
AWS
服务通信。修复子元素的名称要比修复父元素的容易,这里只
需要开发人员尽可能精确地匹配要度量的模块。例如,如果
aws.py
文件中有个
S3
模块,那么就应该把它放入命名空间中,以便与其他部分区分开。这个命名空间的
子元素部分可以是
aws.s3
,而计数器的子元素部分则变成了
aws.s3.counter
命名空间中有很多变动部分,这可能会给人一种冗长的感觉,但很多成熟的度量服
务都允许简单组合,如“报告上一周位于东海岸的生产服务器中所有
S3
调用的平
均值”。很强大吧!
此外,还有一个潜在的问题。在生产环境和过渡环境中该怎么办呢?如果换到其他
虚拟机中开发和调试呢?这时,如果每个人都把开发设备称为 ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.

Read now

Unlock full access

More than 5,000 organizations count on O’Reilly

AirBnbBlueOriginElectronic ArtsHomeDepotNasdaqRakutenTata Consultancy Services

QuotationMarkO’Reilly covers everything we've got, with content to help us build a world-class technology community, upgrade the capabilities and competencies of our teams, and improve overall team performance as well as their engagement.
Julian F.
Head of Cybersecurity
QuotationMarkI wanted to learn C and C++, but it didn't click for me until I picked up an O'Reilly book. When I went on the O’Reilly platform, I was astonished to find all the books there, plus live events and sandboxes so you could play around with the technology.
Addison B.
Field Engineer
QuotationMarkI’ve been on the O’Reilly platform for more than eight years. I use a couple of learning platforms, but I'm on O'Reilly more than anybody else. When you're there, you start learning. I'm never disappointed.
Amir M.
Data Platform Tech Lead
QuotationMarkI'm always learning. So when I got on to O'Reilly, I was like a kid in a candy store. There are playlists. There are answers. There's on-demand training. It's worth its weight in gold, in terms of what it allows me to do.
Mark W.
Embedded Software Engineer

You might also like

解密金融数据

解密金融数据

Justin Pauley
写给系统管理员的Python脚本编程指南

写给系统管理员的Python脚本编程指南

Posts & Telecom Press, Ganesh Sanjiv Naik
数据科学中的实用统计学(第2版)

数据科学中的实用统计学(第2版)

Peter Bruce, Andrew Bruce, Peter Gedeck

Publisher Resources

ISBN: 9787519864415