Skip to content

Commit

Permalink
Update README and add more pre-commit checks (#694)
Browse files Browse the repository at this point in the history
  • Loading branch information
lucacome authored Oct 18, 2024
1 parent 67c062a commit be64203
Show file tree
Hide file tree
Showing 18 changed files with 217 additions and 121 deletions.
67 changes: 33 additions & 34 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
---
Language: Cpp
Language: Cpp
# BasedOnStyle: Google
AccessModifierOffset: -1
AlignAfterOpenBracket: Align
AlignConsecutiveAssignments: false
AlignConsecutiveDeclarations: false
AlignEscapedNewlinesLeft: true
AlignOperands: true
AlignOperands: true
AlignTrailingComments: true
AllowAllParametersOfDeclarationOnNextLine: true
AllowShortBlocksOnASingleLine: false
Expand All @@ -21,49 +21,49 @@ AlwaysBreakTemplateDeclarations: true
BinPackArguments: true
BinPackParameters: true
BraceWrapping:
AfterClass: false
AfterControlStatement: false
AfterEnum: false
AfterFunction: false
AfterNamespace: false
AfterObjCDeclaration: false
AfterStruct: false
AfterUnion: false
BeforeCatch: false
BeforeElse: false
IndentBraces: false
AfterClass: false
AfterControlStatement: false
AfterEnum: false
AfterFunction: false
AfterNamespace: false
AfterObjCDeclaration: false
AfterStruct: false
AfterUnion: false
BeforeCatch: false
BeforeElse: false
IndentBraces: false
BreakBeforeBinaryOperators: None
BreakBeforeBraces: Attach
BreakBeforeTernaryOperators: true
BreakConstructorInitializersBeforeComma: false
BreakAfterJavaFieldAnnotations: false
BreakStringLiterals: true
ColumnLimit: 80
CommentPragmas: '^ IWYU pragma:'
ColumnLimit: 80
CommentPragmas: "^ IWYU pragma:"
ConstructorInitializerAllOnOneLineOrOnePerLine: true
ConstructorInitializerIndentWidth: 4
ContinuationIndentWidth: 4
Cpp11BracedListStyle: true
DerivePointerAlignment: true
DisableFormat: false
DisableFormat: false
ExperimentalAutoDetectBinPacking: false
ForEachMacros: [ foreach, Q_FOREACH, BOOST_FOREACH ]
ForEachMacros: [foreach, Q_FOREACH, BOOST_FOREACH]
IncludeCategories:
- Regex: '^<.*\.h>'
Priority: 1
- Regex: '^<.*'
Priority: 2
- Regex: '.*'
Priority: 3
IncludeIsMainRegex: '([-_](test|unittest))?$'
- Regex: '^<.*\.h>'
Priority: 1
- Regex: "^<.*"
Priority: 2
- Regex: ".*"
Priority: 3
IncludeIsMainRegex: "([-_](test|unittest))?$"
IndentCaseLabels: true
IndentWidth: 2
IndentWidth: 2
IndentWrappedFunctionNames: false
JavaScriptQuotes: Leave
JavaScriptWrapImports: true
KeepEmptyLinesAtTheStartOfBlocks: false
MacroBlockBegin: ''
MacroBlockEnd: ''
MacroBlockBegin: ""
MacroBlockEnd: ""
MaxEmptyLinesToKeep: 1
NamespaceIndentation: None
ObjCBlockIndentWidth: 2
Expand All @@ -76,23 +76,22 @@ PenaltyBreakString: 1000
PenaltyExcessCharacter: 1000000
PenaltyReturnTypeOnItsOwnLine: 200
PointerAlignment: Left
ReflowComments: true
SortIncludes: true
ReflowComments: true
SortIncludes: true
SpaceAfterCStyleCast: false
SpaceAfterTemplateKeyword: true
SpaceBeforeAssignmentOperators: true
SpaceBeforeParens: ControlStatements
SpaceInEmptyParentheses: false
SpacesBeforeTrailingComments: 2
SpacesInAngles: false
SpacesInAngles: false
SpacesInContainerLiterals: true
SpacesInCStyleCastParentheses: false
SpacesInParentheses: false
SpacesInSquareBrackets: false
Standard: Auto
TabWidth: 8
UseTab: Never
...
Standard: Auto
TabWidth: 8
UseTab: Never
---
Language: JavaScript
SpacesInContainerLiterals: false
Expand Down
21 changes: 11 additions & 10 deletions .github/labeler.yml
Original file line number Diff line number Diff line change
@@ -1,28 +1,29 @@
change:
- head-branch: ['^change/']
- head-branch: ["^change/"]

enhancement:
- head-branch: ['^feature/', '^feat/', '^enhancement/', '^enh/']
- head-branch: ["^feature/", "^feat/", "^enhancement/", "^enh/"]

bug:
- head-branch: ['^fix/', '^bug/']
- head-branch: ["^fix/", "^bug/"]

chore:
- head-branch: ['^chore/']
- head-branch: ["^chore/"]

documentation:
- head-branch: ['^docs/', '^doc/']
- head-branch: ["^docs/", "^doc/"]
- changed-files:
- any-glob-to-any-file: '**/*.md'
- any-glob-to-any-file: "**/*.md"

dependencies:
- head-branch: ['^deps/', '^dep/', '^dependabot/', 'pre-commit-ci-update-config']
- head-branch:
["^deps/", "^dep/", "^dependabot/", "pre-commit-ci-update-config"]

tests:
- any:
- head-branch: ['^tests/', '^test/']
- head-branch: ["^tests/", "^test/"]
- changed-files:
- any-glob-to-any-file: 'test/**/*'
- any-glob-to-any-file: "test/**/*"
- all:
- changed-files:
- all-globs-to-all-files: '!test/requirements.txt'
- all-globs-to-all-files: "!test/requirements.txt"
18 changes: 18 additions & 0 deletions .markdownlint-cli2.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Rule configuration.
# For rule descriptions and how to fix: https://github.com/DavidAnson/markdownlint/tree/main#rules--aliases
config:
ul-style:
style: dash
no-duplicate-heading:
siblings_only: true
line-length:
line_length: 120
code_blocks: false
tables: false

# Define glob expressions to ignore
ignores:
- ".github/"

# Fix any fixable errors
fix: true
19 changes: 19 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,34 @@ repos:
- id: no-commit-to-branch
- id: requirements-txt-fixer
- id: fix-byte-order-marker
- id: detect-private-key

- repo: https://github.com/asottile/pyupgrade
rev: v3.18.0
hooks:
- id: pyupgrade

- repo: https://github.com/PyCQA/isort
rev: 5.13.2
hooks:
- id: isort

- repo: https://github.com/psf/black
rev: 24.10.0
hooks:
- id: black

- repo: https://github.com/gitleaks/gitleaks
rev: v8.21.0
hooks:
- id: gitleaks

- repo: https://github.com/DavidAnson/markdownlint-cli2
rev: v0.14.0
hooks:
- id: markdownlint-cli2

- repo: https://github.com/adrienverge/yamllint.git
rev: v1.35.1
hooks:
- id: yamllint
16 changes: 16 additions & 0 deletions .yamllint.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
---
ignore-from-file: .gitignore

extends: default

rules:
comments:
min-spaces-from-content: 1
comments-indentation: enable
document-start: disable
line-length:
max: 120
ignore: |
.github/
truthy:
check-keys: false
73 changes: 39 additions & 34 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,34 +1,40 @@
nginx-opentracing
-----------------
# NGINX plugin for OpenTracing

[![Docker](https://github.com/opentracing-contrib/nginx-opentracing/actions/workflows/docker.yml/badge.svg)](https://github.com/opentracing-contrib/nginx-opentracing/actions/workflows/docker.yml)
[![GitHub release (laßtest SemVer)](https://img.shields.io/github/v/release/opentracing-contrib/nginx-opentracing?logo=github&sort=semver)](https://github.com/opentracing-contrib/nginx-opentracing/releases/latest)
![GitHub all releases](https://img.shields.io/github/downloads/opentracing-contrib/nginx-opentracing/total?logo=github)
![GitHub release (latest by SemVer)](https://img.shields.io/github/downloads/opentracing-contrib/nginx-opentracing/latest/total?sort=semver&logo=github)
[![Docker Pulls](https://img.shields.io/docker/pulls/opentracing/nginx-opentracing.svg)](https://hub.docker.com/r/opentracing/nginx-opentracing/)

Enable requests served by nginx for distributed tracing via [The OpenTracing Project](http://opentracing.io).

Dependencies
------------
## Dependencies

- The [C++ OpenTracing Library](https://github.com/opentracing/opentracing-cpp)
- A C++ OpenTracing Tracer. It currently works with
[Jaeger](https://github.com/jaegertracing/cpp-client),
[Zipkin](https://github.com/rnburn/zipkin-cpp-opentracing),
[LightStep](https://github.com/lightstep/lightstep-tracer-cpp), or
[Datadog](https://github.com/DataDog/dd-opentracing-cpp/).
[Jaeger](https://github.com/jaegertracing/cpp-client),
[Zipkin](https://github.com/rnburn/zipkin-cpp-opentracing),
[LightStep](https://github.com/lightstep/lightstep-tracer-cpp), or
[Datadog](https://github.com/DataDog/dd-opentracing-cpp/).
- Source for [Nginx 1.9.13 or later](http://nginx.org/).

Installation
------------
## Installation

For `linux-x86_64`, pre-compiled binaries are provided for the supported versions of NGINX.
These can be dropped into existing NGINX installations provided that NGINX was compiled with
the `--with-compat` option. See [example/trivial/ubuntu-x86_64](example/trivial/ubuntu-x86_64) for an
example of how to set it up.
the `--with-compat` option.
See [example/trivial/ubuntu-x86_64](example/trivial/ubuntu-x86_64) for an example of how to set it up.

Otherwise, nginx-opentracing can be used from the [Docker image](https://github.com/opentracing-contrib/nginx-opentracing#docker)
or [built from source](https://github.com/opentracing-contrib/nginx-opentracing#building-from-source).

Otherwise, nginx-opentracing can be used from the [Docker image](https://github.com/opentracing-contrib/nginx-opentracing#docker) or
[built from source](https://github.com/opentracing-contrib/nginx-opentracing#building-from-source).
## Getting Started

Getting Started
---------------
First, write a configuration for the tracer used. Below's an example of what
a Jaeger configuration might look like:

/etc/jaeger-nginx-config.json

```json
{
"service_name": "nginx",
Expand All @@ -55,7 +61,8 @@ See the vendor documentation for details on what options are available.

You can then set up NGINX for distributed tracing by adding the following to
nginx.conf:
```

```nginx
# Load the OpenTracing dynamic module.
load_module modules/ngx_http_opentracing_module.so;
Expand Down Expand Up @@ -99,8 +106,8 @@ See [Tutorial](doc/Tutorial.md) for a more complete example,
[Reference](doc/Reference.md) for a list of available OpenTracing-related
directives.

Docker
------
## Docker

A docker image `opentracing/nginx-opentracing` is provided to support using nginx with OpenTracing
in a manner analogous to the [nginx Docker image](https://hub.docker.com/_/nginx/).
See [here](example/) for examples of how to use it.
Expand All @@ -124,18 +131,17 @@ docker build \

Other build arguments

* `OPENTRACING_CPP_VERSION`
* `JAEGER_CPP_VERSION`
* `GRPC_VERSION`
- `OPENTRACING_CPP_VERSION`
- `JAEGER_CPP_VERSION`
- `GRPC_VERSION`

Building From Source
--------------------
## Building From Source

```
$ tar zxvf nginx-1.9.x.tar.gz
$ cd nginx-1.9.x
$ ./configure --add-dynamic-module=/absolute/path/to/nginx-opentracing/opentracing
$ make && sudo make install
```bash
tar zxvf nginx-1.9.x.tar.gz
cd nginx-1.9.x
./configure --add-dynamic-module=/absolute/path/to/nginx-opentracing/opentracing
make && sudo make install
```

You will also need to install a C++ tracer for either
Expand All @@ -145,7 +151,7 @@ You will also need to install a C++ tracer for either
or [Zipkin](https://github.com/rnburn/zipkin-cpp-opentracing).
For linux x86-64, portable binary plugins are available:

```
```bash
# Jaeger
wget https://github.com/jaegertracing/jaeger-client-cpp/releases/download/v0.4.2/libjaegertracing_plugin.linux_amd64.so -O /usr/local/lib/libjaegertracing_plugin.so

Expand All @@ -162,11 +168,10 @@ wget -O - https://github.com/DataDog/dd-opentracing-cpp/releases/download/v0.3.0
Make sure the nginx module for opentracing and a tracer plugin were built against the same version of [C++ OpenTracing Library](https://github.com/opentracing/opentracing-cpp).
By default [Opentracing v1.6.0](https://github.com/opentracing/opentracing-cpp/releases/tag/v1.6.0) is used.

Testing
--------
## Testing

Run tests on local machine requires `pyenv` and tested against version 3.8.5.

```shell
$ make test
```bash
make test
```
13 changes: 7 additions & 6 deletions doc/Reference.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
Directives
----------
# Reference

## Directives

### `opentracing`

Expand Down Expand Up @@ -75,7 +76,8 @@ of the span for an NGINX location block.
- **default**: `on`
- **context**: `http`, `server`, `location`

Enables or disables using OpenTracing spans from incoming requests as parent for created ones. Might be disabled for security reasons.
Enables or disables using OpenTracing spans from incoming requests as parent for created ones.
Might be disabled for security reasons.

### `opentracing_tag`

Expand All @@ -85,10 +87,9 @@ Enables or disables using OpenTracing spans from incoming requests as parent for
Sets a [tag](https://github.com/opentracing/specification/blob/master/specification.md#set-a-span-tag)
with the given `key` and `value` for an NGINX span.

Variables
---------
## Variables

### `opentracing_context_`*name*
### `opentracing_context_`_name_

Expands to the a value of the active span context; the last part of the variable
name is the span context's header converted to lower case with dashes replaced by
Expand Down
Loading

0 comments on commit be64203

Please sign in to comment.