Skip to content

Commit cd4f9b8

Browse files
committed
🎨 reformat + configure formatter
1 parent bb4ccee commit cd4f9b8

File tree

7 files changed

+37
-17
lines changed

7 files changed

+37
-17
lines changed

.editorconfig

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,10 @@ indent_size = 4
2121
max_line_length = 88
2222

2323
[*.rs]
24+
# https://github.com/rust-dev-tools/fmt-rfcs/blob/master/guide/guide.md
2425
indent_size = 4
25-
max_line_length = 100
26+
# officially the limit is 100, but we have long url (unsplittable) in comment
27+
max_line_length = 140
2628

2729
[{*.bazel,*.bzl,BUILD,WORKSPACE}]
2830
indent_size = 4

.gitignore

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -240,8 +240,3 @@ tags
240240
report/
241241

242242
tempo-data
243-
244-
245-
# Added by cargo
246-
247-
/target

.mega-linter.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,12 @@ APPLY_FIXES: all # all, none, or list of linter keys
77
DISABLE:
88
- COPYPASTE # Comment to enable checks of excessive copy-pastes
99
- SPELL # Comment to enable checks of spelling mistakes
10+
DISABLE_LINTERS:
11+
- MARKDOWN_MARKDOWN_LINK_CHECK
12+
- DOCKERFILE_DOCKERFILELINT
1013
SHOW_ELAPSED_TIME: true
1114
FILEIO_REPORTER: false
1215
# DISABLE_ERRORS: true # Uncomment if you want MegaLinter to detect errors but not block CI to pass
16+
FILTER_REGEX_EXCLUDE: "(\\.lock)|(\\.ndjson)|(\\.pdf)|(\\.csv)|(\\.zip)|(\\.tar)|(\\.ipynb)|(license.*)|(LICENSE.*)"
17+
SPELL_FILTER_REGEX_INCLUDE: '\\.md$'
18+
RUST_CLIPPY_ARGUMENTS: --workspace --all-features --all-targets -- --deny warnings --allow deprecated

examples/oltp/src/main.rs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,20 @@ use axum::extract::{Path, Query};
22
use axum::http::Method;
33
use axum::Extension;
44
use axum::{response::IntoResponse, routing::get, Router};
5-
use axum_tracing_opentelemetry::{opentelemetry_tracing_layer, CollectorKind, init_tracer};
6-
use std::net::SocketAddr;
5+
use axum_tracing_opentelemetry::{init_tracer, opentelemetry_tracing_layer, CollectorKind};
76
use serde_json::json;
7+
use std::net::SocketAddr;
88

99
fn init_tracing() {
1010
use tracing_subscriber::filter::EnvFilter;
1111
use tracing_subscriber::fmt::format::FmtSpan;
1212
use tracing_subscriber::layer::SubscriberExt;
1313

1414
// std::env::set_var("RUST_LOG", "info,kube=trace");
15-
std::env::set_var("RUST_LOG", std::env::var("RUST_LOG").unwrap_or("INFO".to_string()));
15+
std::env::set_var(
16+
"RUST_LOG",
17+
std::env::var("RUST_LOG").unwrap_or("INFO".to_string()),
18+
);
1619

1720
let otel_tracer = init_tracer(CollectorKind::Otlp).expect("setup of Tracer");
1821
let otel_layer = tracing_opentelemetry::layer().with_tracer(otel_tracer);
@@ -50,7 +53,8 @@ fn app() -> Router {
5053
// build our application with a route
5154
Router::new()
5255
.route("/health", get(health))
53-
// opentelemetry_tracing_layer setup `TraceLayer`, that is provided by tower-http so you have to add that as a dependency.
56+
// opentelemetry_tracing_layer setup `TraceLayer`,
57+
// that is provided by tower-http so you have to add that as a dependency.
5458
.layer(opentelemetry_tracing_layer())
5559
}
5660

mega-linter.sh

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#! /usr/bin/env bash
2+
3+
set -euo pipefail
4+
# set -x
5+
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" &>/dev/null && pwd)"
6+
IMAGE=megalinter/megalinter:v5
7+
8+
if [ -x "$(command -v nerdctl)" ]; then
9+
nerdctl run --pull always --rm -it -v "${SCRIPT_DIR}:/tmp/lint:rw" "$IMAGE"
10+
elif [ -x "$(command -v docker)" ]; then
11+
docker run --pull always --rm -it -v /var/run/docker.sock:/var/run/docker.sock:rw -v "${SCRIPT_DIR}:/tmp/lint:rw" "$IMAGE"
12+
else
13+
echo "runner not found: docker or nerdctl"
14+
exit 1
15+
fi

src/middleware.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,8 @@ fn extract_remote_context(headers: &http::HeaderMap) -> opentelemetry::Context {
234234
opentelemetry::global::get_text_map_propagator(|propagator| propagator.extract(&extractor))
235235
}
236236

237-
//HACK create a context with a trace_id (if not set) before call to `tracing_opentelemetry::OpenTelemetrySpanExt::set_parent`
237+
//HACK create a context with a trace_id (if not set) before call to
238+
// `tracing_opentelemetry::OpenTelemetrySpanExt::set_parent`
238239
// else trace_id is defined too late and the `info_span` log `trace_id: ""`
239240
// Use the default global tracer (named "") to start the trace
240241
fn create_context_with_trace(remote_context: opentelemetry::Context) -> opentelemetry::Context {

src/tools.rs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ pub fn init_tracer(kind: CollectorKind) -> Result<sdktrace::Tracer, TraceError>
1818
// use opentelemetry_otlp::WithExportConfig;
1919
use opentelemetry_semantic_conventions as semcov;
2020
let resource = Resource::new(vec![
21-
semcov::resource::SERVICE_NAME.string(env!("CARGO_PKG_NAME")), //TODO Replace with the name of your application
22-
semcov::resource::SERVICE_VERSION.string(env!("CARGO_PKG_VERSION")), //TODO Replace with the version of your application
21+
semcov::resource::SERVICE_NAME.string(env!("CARGO_PKG_NAME")),
22+
semcov::resource::SERVICE_VERSION.string(env!("CARGO_PKG_VERSION")),
2323
]);
2424

2525
match kind {
@@ -37,10 +37,7 @@ pub fn init_tracer(kind: CollectorKind) -> Result<sdktrace::Tracer, TraceError>
3737
// Or "OTEL_EXPORTER_JAEGER_ENDPOINT"
3838
// or now variable
3939
init_tracer_jaeger(resource)
40-
} // _ => {
41-
// //sdktrace::stdout::new_pipeline().install_simple()
42-
// Err(TraceError::Other(anyhow!("no config found").into()))
43-
// }
40+
}
4441
}
4542
}
4643

0 commit comments

Comments
 (0)