Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
``sentry.sample_rate`` (optional)
Percentage of errors to report. (e.g. "37%")
``sentry.processors`` (optional)
Comma-delimited list of fully qualified names of processor classes
to apply to events before sending to Sentry.
Example usage::
error_reporter_from_config(app_config, __name__)
:param raw_config: The application configuration which should have
settings for the error reporter.
:param module_name: ``__name__`` of the root module of the application.
"""
cfg = config.parse_config(
raw_config,
{
"sentry": {
"dsn": config.Optional(config.String, default=None),
"site": config.Optional(config.String, default=None),
"environment": config.Optional(config.String, default=None),
"include_paths": config.Optional(config.String, default=None),
"exclude_paths": config.Optional(config.String, default=None),
"ignore_exceptions": config.Optional(config.TupleOf(config.String), default=[]),
"sample_rate": config.Optional(config.Percent, default=1),
"processors": config.Optional(
config.TupleOf(config.String),
default=["raven.processors.SanitizePasswordsProcessor"],
),
}
},
``path``: the path to the secrets file generated by the secrets fetcher daemon.
:param app_config: The application configuration which should have
settings for the secrets store.
:param timeout: How long, in seconds, to block instantiation waiting
for the secrets data to become available (defaults to not blocking).
:param prefix: Specifies the prefix used to filter keys. Defaults
to "secrets."
:param backoff: retry backoff time for secrets file watcher. Defaults to
None, which is mapped to DEFAULT_FILEWATCHER_BACKOFF.
"""
assert prefix.endswith(".")
config_prefix = prefix[:-1]
cfg = config.parse_config(
app_config,
{
config_prefix: {
"path": config.Optional(config.String, default="/var/local/secrets.json"),
"backoff": config.Optional(config.Timespan),
}
},
)
options = getattr(cfg, config_prefix)
if options.backoff:
backoff = options.backoff.total_seconds()
else:
backoff = None
# pylint: disable=maybe-no-member
Number of worker threads for span processing.
``tracing.span_batch_interval`` (optional)
Wait time for span processing in seconds.
``tracing.num_conns`` (optional)
Pool size for remote recorder connection pool.
``tracing.sample_rate`` (optional)
Percentage of unsampled requests to record traces for (e.g. "37%")
:param raw_config: The application configuration which should have settings
for the tracing client.
:param log_if_unconfigured: When the client is not configured, should
trace spans be logged or discarded silently?
:return: A configured client.
"""
cfg = config.parse_config(
raw_config,
{
"tracing": {
"service_name": config.String,
"endpoint": config.Optional(config.Endpoint),
"queue_name": config.Optional(config.String),
"max_span_queue_size": config.Optional(config.Integer, default=50000),
"num_span_workers": config.Optional(config.Integer, default=5),
"span_batch_interval": config.Optional(
config.Timespan, default=config.Timespan("500 milliseconds")
),
"num_conns": config.Optional(config.Integer, default=100),
"sample_rate": config.Optional(
config.Fallback(config.Percent, config.Float), default=0.1
),
}
def make_server(server_config: Dict[str, str], listener: socket.socket, app: Any) -> StreamServer:
"""Make a gevent server for WSGI apps."""
# pylint: disable=maybe-no-member
cfg = config.parse_config(
server_config,
{
"handler": config.Optional(config.String, default=None),
"max_concurrency": config.Optional(config.Integer),
"stop_timeout": config.Optional(
config.TimespanWithLegacyFallback, default=datetime.timedelta(seconds=10)
),
},
)
if cfg.max_concurrency is not None:
logger.warning(
"The max_concurrency setting is deprecated for WSGI servers. See https://git.io/Jeywc."
)
pool = Pool(size=cfg.max_concurrency)
action="store_true",
help="only run the fetcher once rather than as a daemon",
)
args = arg_parser.parse_args()
if args.debug:
level = logging.DEBUG
else:
level = logging.INFO
logging.basicConfig(format="%(asctime)s:%(levelname)s:%(message)s", level=level)
parser = configparser.RawConfigParser()
parser.read_file(args.config_file)
fetcher_config = dict(parser.items("secret-fetcher"))
cfg = config.parse_config(
fetcher_config,
{
"vault": {
"url": config.String,
"role": config.String,
"auth_type": config.Optional(
config.OneOf(**VaultClientFactory.auth_types()),
default=VaultClientFactory.auth_types()["aws"],
),
"mount_point": config.Optional(config.String, default="aws-ec2"),
},
"output": {
"path": config.Optional(config.String, default="/var/local/secrets.json"),
"owner": config.Optional(config.UnixUser, default=0),
"group": config.Optional(config.UnixGroup, default=0),
"mode": config.Optional(config.Integer(base=8), default=0o400), # type: ignore
args = arg_parser.parse_args()
if args.debug:
level = logging.DEBUG
else:
level = logging.INFO
logging.basicConfig(level=level, format="%(message)s")
# quiet kazoo's verbose logs a bit
logging.getLogger("kazoo").setLevel(logging.WARNING)
parser = configparser.RawConfigParser()
parser.read_file(args.config_file)
watcher_config = dict(parser.items("live-data"))
cfg = config.parse_config(
watcher_config,
{
"nodes": config.DictOf(
{
"source": config.String,
"dest": config.String,
"owner": config.Optional(config.UnixUser),
"group": config.Optional(config.UnixGroup),
"mode": config.Optional(config.Integer(base=8), default=0o400), # type: ignore
}
)
},
)
# pylint: disable=maybe-no-member
nodes = cfg.nodes.values()
(Optional) A comma-delimited list of paths to secrets in the secrets
store that contain ZooKeeper authentication credentials. Secrets should
be of the "simple" type and contain ``username:password``.
``zookeeper.timeout``
(Optional) A time span of how long to wait for each connection attempt.
The client will attempt forever to reconnect on connection loss.
:param secrets: A secrets store object
:param raw_config: The application configuration which should have
settings for the ZooKeeper client.
:param read_only: Whether or not to allow connections to read-only
ZooKeeper servers.
"""
full_cfg = config.parse_config(
app_config,
{
"zookeeper": {
"hosts": config.String,
"credentials": config.Optional(config.TupleOf(config.String), default=[]),
"timeout": config.Optional(config.Timespan, default=config.Timespan("5 seconds")),
}
},
)
# pylint: disable=maybe-no-member
cfg = full_cfg.zookeeper
auth_data = []
for path in cfg.credentials:
credentials = secrets.get_simple(path)