Skip to content

Commit 8f1b733

Browse files
committed
Merge branch 'master' of github.com:bitwarden/contributing-docs into ps/migrations
* 'master' of github.com:bitwarden/contributing-docs: (37 commits) chore(deps): update dependency cspell to v7.3.7 (#206) [PM-4161] Fix build command on README.md (#207) Fixed typo in csharp.md (#180) Update our EDD process documentation (#166) chore(deps): update actions/checkout action to v4.1.0 (#204) chore(deps): lock file maintenance (#205) fix(deps): update npm minor to v2.4.3 (#203) use dash when running self-hosted dotnet profile (#202) chore(deps): update actions/checkout action to v4 (#191) chore(deps): lock file maintenance (#201) chore(deps): update npm minor (#195) fix(deps): update dependency docusaurus-lunr-search to v3 (#200) setup_secrets: Pass `-clear` as switch (#194) Update KeyConnector docs for ARM Macs (#171) Lock file maintenance (#193) Update dependency cspell to v7.3.5 (#192) Update dependency ubuntu to v22 (#174) Update gh minor (#181) Feature flag documentation updates and mentions about new local override capabilities (#187) Update npm minor (#188) ... # Conflicts: # custom-words.txt # docs/contributing/database-migrations/edd.mdx # docs/contributing/database-migrations/index.md
2 parents f02a3b2 + 29d4462 commit 8f1b733

29 files changed

+2337
-2989
lines changed

.github/CODEOWNERS

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
# https://docs.github.com/en/repositories/managing-your-repositorys-settings-and-features/customizing-your-repository/about-code-owners
66

77
# Leads for all reviews of documentation.
8-
* @bitwarden/team-leads-eng
8+
* @bitwarden/tech-leads
99

1010
# DevOps for Actions and other workflow changes.
1111
.github/workflows @bitwarden/dept-devops

.github/workflows/build.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,13 @@ defaults:
1515
jobs:
1616
lint:
1717
name: Build
18-
runs-on: ubuntu-20.04
18+
runs-on: ubuntu-22.04
1919
steps:
2020
- name: Checkout repo
21-
uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3
21+
uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0
2222

2323
- name: Set up Node
24-
uses: actions/setup-node@e33196f7422957bea03ed53f6fbb155025ffc7b8 # v3.7.0
24+
uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d # v3.8.1
2525
with:
2626
cache: "npm"
2727
cache-dependency-path: "**/package-lock.json"

.github/workflows/lint.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,13 @@ defaults:
1515
jobs:
1616
lint:
1717
name: Lint
18-
runs-on: ubuntu-20.04
18+
runs-on: ubuntu-22.04
1919
steps:
2020
- name: Checkout repo
21-
uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3
21+
uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0
2222

2323
- name: Set up Node
24-
uses: actions/setup-node@e33196f7422957bea03ed53f6fbb155025ffc7b8 # v3.7.0
24+
uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d # v3.8.1
2525
with:
2626
cache: "npm"
2727
cache-dependency-path: "**/package-lock.json"

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ reflected live without having to restart the server.
2323
## Build
2424

2525
```bash
26-
npm build
26+
npm run build
2727
```
2828

2929
This command generates static content into the `build` directory and can be served using any static

custom-words.txt

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
# Custom dictionary for spellchecking
2-
# Before adding a word here, consider whether you can put it in a single (`) or multiline (```) code snippet instead,
3-
# as they are automatically ignored by the spellchecker
1+
# Custom dictionary for spellchecking. Before adding a word here, consider whether you can put
2+
# it in a single (`) or multiline (```) code snippet instead, as they are automatically ignored
3+
# by the spellchecker. Please keep the list sorted alphabetically.
44

55
Bitwarden
66
bytemark
@@ -30,6 +30,7 @@ oktapreview
3030
Omnisharp
3131
onboarded
3232
opid
33+
OTLP
3334
passcode
3435
passwordless
3536
pinentry
@@ -41,6 +42,7 @@ roadmaps
4142
SCIM
4243
SDET
4344
SDLC
45+
Serilog
4446
signtool
4547
signup
4648
sprocs
Lines changed: 121 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,121 @@
1+
---
2+
adr: "0020"
3+
status: In progress
4+
date: 2023-07-13
5+
tags: [server]
6+
---
7+
8+
# 0020 - Observability with OpenTelemetry
9+
10+
<AdrTable frontMatter={frontMatter}></AdrTable>
11+
12+
## Context and Problem Statement
13+
14+
Along with the maturation of the codebase over the years, the number of users on the platform has
15+
also grown significantly and more insight is needed into how services are performing at a
16+
fine-grained level. External profilers can certainly be attached in any running environment, but the
17+
platform itself needs to offer internal metrics not just to support self-hosted customers running
18+
the product but to enable engineers to improve it and tackle performance issues with solid data and
19+
evidence as to what and why something should change.
20+
21+
## Considered Options
22+
23+
:::note
24+
25+
Bitwarden currently uses [Datadog][dd] as its monitoring tool and desires to increase its usage by
26+
engineers across the board to improve what we deliver.
27+
28+
:::
29+
30+
- **Maintain current observability options** - Expect those running the platform to configure what
31+
they need outside of it for log collection and profiling / monitoring.
32+
- **Extend the platform to specifically support Datadog** - [Tracing for Datadog][ddtracer] exists
33+
in package form and could be coded into application startup. Datadog-specific signals and metrics
34+
can be collected via code and sent to the platform.
35+
- **Implement native instrumentation** - Add logic via what's available from
36+
[`System.Diagnostics`][native] for custom instrumentation, and expect profiling to be configured
37+
per the first option above.
38+
- **Use open observability standards** - Utilize [OpenTelemetry][otel] and emit signals on the
39+
console as well as utilize its own eventing approach for instrumentation and metrics data.
40+
41+
## Decision Outcome
42+
43+
Chosen option: **Use open observability standards**.
44+
45+
A strong alternative exists in just using native instrumentation, and not tying the platform to the
46+
implementation of any specific ecosystem -- even an open standard like OpenTelemetry. .NET closely
47+
supports OpenTelemetry metric collection integration but the desired power will be in how that data
48+
is used via output mechanisms like OTLP. A profiler attached to running components is independent of
49+
the availability of metrics via other means such as collection by an agent.
50+
51+
Accessibility to metrics via configuration wins out over the expectation to set up and manage a
52+
profiler.
53+
54+
### Positive Consequences
55+
56+
- Console logging of metrics, if desired for use, fits well into container and orchestration tools,
57+
and said environments can install agents for their collection.
58+
- No new dependencies that are merely aligned with the Bitwarden-specific cloud and its service
59+
providers.
60+
- Components can be monitored with far more detail and lead to future improvements.
61+
- Use of an open standard like OpenTelemetry creates future flexibility for monitoring and
62+
observability to grow with the expansion of that ecosystem, examples being the OTLP export vs.
63+
just console logging.
64+
65+
### Negative Consequences
66+
67+
- Addition of the OpenTelemetry dependency across all services.
68+
- Proprietary profiler implementations may offer signal information that OpenTelemetry can't,
69+
including automatic instrumentation.
70+
- With the capability to capture signals within the platform comes the burden of needing to maintain
71+
clear policies around not capturing sensitive data.
72+
73+
### Plan
74+
75+
.NET Core's `System.Diagnostics` library supports the emission of metrics compatible with
76+
OpenTelemetry, and traces and metrics within the platform will become available on the console and
77+
via OTLP export. Configuration will be provided to turn either on or off with new application
78+
settings e.g.:
79+
80+
```json
81+
{
82+
"OpenTelemetry": {
83+
"UseTracingExporter": "Console",
84+
"UseMetricsExporter": "Console",
85+
"Otlp": {
86+
"Endpoint": "http://localhost:4318"
87+
}
88+
}
89+
}
90+
```
91+
92+
Console and OTLP options will be available for the metrics and tracing export, along with the
93+
ability to specify a gRPC or HTTP endpoint for OTLP. Segmentation of activities will continue to be
94+
made using the configurable `ProjectName`.
95+
96+
The initial implementation will provide default instrumentation details coming from ASP.NET Core and
97+
any used HTTP clients. Within Bitwarden the automatic instrumentation (profiler) may be explored at
98+
a future date but a code-first solution is desired to allow for more control and less setup during
99+
installation. It is expected that local processes will ingest logs / exports as desired.
100+
101+
Software development lifecycle enhancements will be made to clarify best practices and review
102+
requirements for logging or monitoring changes. A [deep dive](/architecture/deep-dives) will be
103+
added on logging and monitoring to showcase patterns for adding signal collection in code. Only
104+
component runtime signals will be collected to start; no application payloads such as input and
105+
output data will be collected in signals.
106+
107+
Over time and where needed, application logic to track custom [signals][otelsignals] (activities and
108+
meters) will be approached for deeper insights, especially in critical code paths. Standards will be
109+
developed and documented in the above deep dive on how to approach metric collection, without also
110+
collecting sensitive information. Core utility classes will be developed that establish a
111+
centralization of OpenTelemetry usage and make use in components easier and generic.
112+
113+
Observability functionality will be moved to a new shared library -- separate from the core -- for
114+
host-oriented utilities. This library will be distributed as a NuGet package so that local `server`
115+
projects as well as new, independent repositories for services can receive the benefits.
116+
117+
[dd]: https://www.datadoghq.com/
118+
[ddtracer]: https://www.nuget.org/packages/Datadog.Trace.Bundle
119+
[native]: https://learn.microsoft.com/en-us/dotnet/core/diagnostics/metrics-instrumentation
120+
[otel]: https://opentelemetry.io/
121+
[otelsignals]: https://opentelemetry.io/docs/concepts/signals/
Lines changed: 131 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,131 @@
1+
---
2+
adr: "0021"
3+
status: In progress
4+
date: 2023-07-13
5+
tags: [server]
6+
---
7+
8+
# 0021 - Logging to Standard Output
9+
10+
<AdrTable frontMatter={frontMatter}></AdrTable>
11+
12+
## Context and Problem Statement
13+
14+
As the server platform has matured so have the various logging extensions to support additional use
15+
cases and customer requests. [Serilog][serilog] is in place via shared "core" logic for all
16+
services, initiated at startup, and over time additional "sinks" for specific use cases have been
17+
added with their needed configuration and downstream dependencies, increasing the size of the core
18+
library footprint.
19+
20+
Maintenance needs have grown to keep sink dependencies up to date and more are desired to be added.
21+
Some of the presently-available sinks have very little use and / or better alternatives now exist.
22+
There is a growing list of conditions on how and when to use certain types of structured logging.
23+
Service-specific configuration, predicates, and filters are in place making it difficult to know
24+
what will be logged and when.
25+
26+
## Considered Options
27+
28+
:::note
29+
30+
Bitwarden currently uses [Datadog][dd] as its monitoring tool and desires to increase its usage by
31+
engineers across the board to improve what we deliver.
32+
33+
:::
34+
35+
- **Maintain current logging options** - Support what is available today for logging methods and
36+
expect those running the platform to configure what they need outside of it for log collection.
37+
- **Extend the platform to specifically support Datadog** - A Serilog sink [exists][ddsink] and the
38+
platform can send logs directly to Datadog.
39+
- **Consolidate logging providers** - Announce deprecation and migration plans for sinks not aligned
40+
with core needs and center on standard output for logs.
41+
42+
## Decision Outcome
43+
44+
Chosen option: **Consolidate logging providers**.
45+
46+
Given long-term plans to adopt a more flexible shared (hosting extensions) library that can be used
47+
across services either as a project (server monolith) reference or NuGet package (and as a reference
48+
architecture), using Serilog as a way to extend native logging capabilities is beneficial. Details
49+
around how Serilog is implemented along with its advanced inputs and outputs can be extracted away
50+
into the shared library and driven at consuming applications via configuration.
51+
52+
### Positive Consequences
53+
54+
- Streamlined logging experience across components.
55+
- Standard output logging fits well into container and orchestration tools.
56+
- Elimination of several third-party dependencies and their maintenance, as well as global settings.
57+
- No new dependencies that are merely aligned with the Bitwarden-specific cloud and its service
58+
providers.
59+
60+
### Negative Consequences
61+
62+
- A small number of users will need to migrate to standard output or similar ingestion of logs.
63+
- The Admin Portal log browsing function will leave (if configured) in favor of using whatever is
64+
configured for log processing.
65+
66+
### Plan
67+
68+
Using standard support policies, release notes will include a mention that three Serilog sinks will
69+
be removed:
70+
71+
- CosmosDb
72+
- Sentry
73+
- Syslog
74+
75+
The remaining sinks -- core functionality of Serilog -- will continue to be supported:
76+
77+
- Console
78+
- File
79+
80+
While the Serilog [console sink][serilogconsole] is currently an implicit dependency with what's
81+
provided for ASP.NET Core, it will be explicitly referenced.
82+
83+
Solutions exist for users to shift processing of logs for the removed sinks to standard output or
84+
file and retain their integration. Admin Portal users can similarly continue to use CosmosDb for log
85+
retention, but it is suggested that application monitoring that's available be used instead that
86+
should in essentially all cases be able to receive and process standard output logs.
87+
88+
Cloud installations -- including Bitwarden's own -- will shift to configuration via environment
89+
variables or otherwise to utilize structured standard output logs for processing explicitly with
90+
[Serilog configuration][serilogconfig] e.g.:
91+
92+
```json
93+
{
94+
"Serilog": {
95+
"Using": ["Serilog.Sinks.Console"],
96+
"MinimumLevel": "Verbose",
97+
"WriteTo": [{ "Name": "Console" }],
98+
"Enrich": ["FromLogContext"],
99+
"Properties": {
100+
"Project": "BitwardenProjectName"
101+
}
102+
}
103+
}
104+
```
105+
106+
This will allow better usage of `appsettings.json` and a richer developer experience. Existing
107+
built-in [.NET Core logging][netcorelogging] will continue to be available if desired, but the
108+
recommendation will be to move to a Serilog configuration.
109+
110+
Code cleanup will be performed around Serilog usage, such as:
111+
112+
- Removal of overuse of inclusion predicates that complicate (or sometimes block) effective log
113+
output, for example in the uses of `AddSerilog` in place today at each consuming application.
114+
- Alignment with .NET Core and Serilog best practices on [initialization][seriloginit] and usage of
115+
Serilog itself.
116+
- Improvements in logging initialization reliability and working with configuration issues, as well
117+
as more resilient tear-down when a component stops / ends.
118+
- Removal of the above-deprecated sinks, in the final release of the support window.
119+
120+
Logging functionality will be moved to a new shared library -- separate from the core project -- as
121+
mentioned above for host-oriented utilities. This library will be distributed as a NuGet package so
122+
that local `server` projects as well as new, independent repositories for services can receive the
123+
benefits.
124+
125+
[serilog]: https://serilog.net/
126+
[dd]: https://www.datadoghq.com/
127+
[ddsink]: https://www.nuget.org/packages/serilog.sinks.datadog.logs
128+
[serilogconsole]: https://www.nuget.org/packages/serilog.sinks.console
129+
[serilogconfig]: https://www.nuget.org/packages/Serilog.Settings.Configuration/
130+
[netcorelogging]: https://learn.microsoft.com/en-us/dotnet/core/extensions/logging
131+
[seriloginit]: https://github.com/serilog/serilog-aspnetcore#two-stage-initialization

docs/contributing/code-style/csharp.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ this naming convention:
5151
## Constructors
5252

5353
- Multiple **constructors** should be separated by a newline (empty line between)
54-
- Constructors with multiple arguments should have arguments should be included 1 per line
54+
- Constructors with multiple arguments should have 1 argument listed per line
5555
- Empty constructors, when necessary, should be all 1-line, i.e., `public ClassName() { }`
5656

5757
## Control Blocks

0 commit comments

Comments
 (0)