- Notifications
You must be signed in to change notification settings - Fork 454
Description
Key information
- RFC PR: feat: introduce namespace in logger and tracer #152 (leave this empty)
- Related issue(s), if known:
- Area: Tracer and Logger
- Meet tenets: Yes
Summary
Although the Logger and Tracer don't actually need a namespace in order to be functional it would help with consistency and it will improve the way how you can query the traces or log lines, for example:
Let say you would have 3 Lambda's working in the same namespace all doing their own little responsibility.
A Logger
example of that would be: you are not able to group the log events using CloudWatch Insights or an ELK stack because they don't share the namespace. If we add the namespace to the structured log event you can query on the namespace name and receive the lines from service1, service2 and service3 all together.
A Tracer
example of that would be: You want to gain some insights into a specific component/namespace if the traces were annotated with the service and namespace you are able to query all traces in a specific namespace/service.
Motivation
One major driver is consistency and the ability to group things logically in CloudWatch and the X-Ray console.
Proposal
Introduce a POWERTOOLS_NAMESPACE
environment variable and add the ability to set it in the constructor for all core components. The behavior change I was looking at is as followed:
- Tracer, add the namespace and service as an annotation to the main handler segment.
- Logger, add the namespace to the structured log next to the service.
- Metrics, if a
POWERTOOLS_METRICS_NAMESPACE
is set use that else fallback on thePOWERTOOLS_NAMESPACE
Drawbacks
- Namespace currently has a 1 to 1 meaning in how CloudWatch Metrics uses a namespace adding this might make that a bit vaguer.
- What if the namespace is not set? Currently for the
Metrics
it fallback toNone
(Looks like thatMetrics
require a namespace anyhow so that is an interesting one)
Rationale and alternatives
- What other designs have been considered? Why not them?, Including the "namespace" in the service name but if you use env variable you will get
[Namespace] | [Namespace]/[Service]
in your CloudWatch metrics. - What is the impact of not doing this?, less flexibility in finding log events an traces.
Unresolved questions
- Is
namespace
a good term for this as X-Ray and CloudWatch also knows the concept of namespaces so it might be confusing?
Metadata
Metadata
Assignees
Labels
Type
Projects
Status