Skip to content

Commit

Permalink
chore: ESLINT enhancement (#127)
Browse files Browse the repository at this point in the history
Signed-off-by: Said Sef <[email protected]>

chore: moved ESLint configuration to file

chore: package version bump
  • Loading branch information
saidsef authored Apr 14, 2024
1 parent 322f265 commit b1de224
Show file tree
Hide file tree
Showing 5 changed files with 155 additions and 98 deletions.
24 changes: 19 additions & 5 deletions .eslintrc.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,26 @@
env:
browser: true
commonjs: true
node: true
commonjs: false
es2021: true
jest: true
extends: eslint:recommended
parserOptions:
ecmaVersion: latest
sourceType: module
rules: {}
rules:
"prefer-const": ["error", { "ignoreReadBeforeAssign": true }]
arrow-spacing: ["error", { "before": true, "after": true }]
computed-property-spacing: ["error", "never"]
eol-last: ["error", "always"]
no-compare-neg-zero: "error"
no-tabs: ["error", { allowIndentationTabs: true }]
no-trailing-spaces: "error"
no-unused-vars: "error"
no-whitespace-before-property: "error"
object-curly-spacing: ["error", "never"]
quotes: ["warn", "single"]
rest-spread-spacing: ["error", "always"]
semi: ["warn", "always"]
space-before-blocks: "error"
template-curly-spacing: "error"
overrides:
- files: ["*.js", "*.mjs"]
- files: [ "libs/index.mjs"]
4 changes: 3 additions & 1 deletion .github/workflows/pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,10 @@ jobs:
node-version: ${{ matrix.node }}
- name: Node Version
run: node --version
- name: NPM Rebuild
- name: NPM Install
run: npm ci
- name: NPM ESLint
run: npm run lint
- name: NPM Test
run: npm run test

Expand Down
34 changes: 17 additions & 17 deletions libs/index.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -16,20 +16,20 @@
* limitations under the License.
*/

import { CompositePropagator, W3CBaggagePropagator, W3CTraceContextPropagator } from '@opentelemetry/core';
import { registerInstrumentations } from '@opentelemetry/instrumentation';
import { NodeTracerProvider } from '@opentelemetry/sdk-trace-node';
import { BatchSpanProcessor } from '@opentelemetry/sdk-trace-base';
import { OTLPTraceExporter } from '@opentelemetry/exporter-trace-otlp-grpc';
import { HttpInstrumentation } from '@opentelemetry/instrumentation-http';
import { ExpressInstrumentation } from '@opentelemetry/instrumentation-express';
import { diag, DiagConsoleLogger, DiagLogLevel } from '@opentelemetry/api';
import { Resource } from '@opentelemetry/resources';
import { SemanticResourceAttributes } from '@opentelemetry/semantic-conventions';
import { AwsInstrumentation } from '@opentelemetry/instrumentation-aws-sdk';
import { PinoInstrumentation } from '@opentelemetry/instrumentation-pino';
import { DnsInstrumentation } from '@opentelemetry/instrumentation-dns';
import { B3Propagator, B3InjectEncoding } from '@opentelemetry/propagator-b3';
import {CompositePropagator, W3CBaggagePropagator, W3CTraceContextPropagator} from '@opentelemetry/core';
import {registerInstrumentations} from '@opentelemetry/instrumentation';
import {NodeTracerProvider} from '@opentelemetry/sdk-trace-node';
import {BatchSpanProcessor} from '@opentelemetry/sdk-trace-base';
import {OTLPTraceExporter} from '@opentelemetry/exporter-trace-otlp-grpc';
import {HttpInstrumentation} from '@opentelemetry/instrumentation-http';
import {ExpressInstrumentation} from '@opentelemetry/instrumentation-express';
import {diag, DiagConsoleLogger, DiagLogLevel} from '@opentelemetry/api';
import {Resource} from '@opentelemetry/resources';
import {SemanticResourceAttributes} from '@opentelemetry/semantic-conventions';
import {AwsInstrumentation} from '@opentelemetry/instrumentation-aws-sdk';
import {PinoInstrumentation} from '@opentelemetry/instrumentation-pino';
import {DnsInstrumentation} from '@opentelemetry/instrumentation-dns';
import {B3Propagator, B3InjectEncoding} from '@opentelemetry/propagator-b3';

diag.setLogger(new DiagConsoleLogger(), DiagLogLevel.INFO);

Expand All @@ -55,7 +55,7 @@ diag.setLogger(new DiagConsoleLogger(), DiagLogLevel.INFO);
* be used to create and export spans for tracing various operations within
* the service.
*/
export async function setupTracing (serviceName, appName="application", endpoint=null) {
export async function setupTracing (serviceName, appName='application', endpoint=null) {
const provider = new NodeTracerProvider({
resource: new Resource({
[SemanticResourceAttributes.SERVICE_NAME]: serviceName,
Expand All @@ -79,7 +79,7 @@ export async function setupTracing (serviceName, appName="application", endpoint
const ignoreIncomingRequestHook = (req) => {
const isStaticAsset = !!req.url.match(/^\/metrics|\/healthz.*$/);
return isStaticAsset;
}
};

// Register instrumentations
registerInstrumentations({
Expand Down Expand Up @@ -108,7 +108,7 @@ export async function setupTracing (serviceName, appName="application", endpoint
// Initialize the tracer provider
provider.register({
propagator: new CompositePropagator({
propagators: [new W3CBaggagePropagator(), new W3CTraceContextPropagator(), new B3Propagator({ injectEncoding: B3InjectEncoding.MULTI_HEADER })],
propagators: [new W3CBaggagePropagator(), new W3CTraceContextPropagator(), new B3Propagator({injectEncoding: B3InjectEncoding.MULTI_HEADER})],
})});

// Return the tracer for the service
Expand Down
Loading

0 comments on commit b1de224

Please sign in to comment.