Giter VIP home page Giter VIP logo

simon-microservice's Introduction

Simon's Microservice for OpenTelemetry & Kafka Enablement Demo

JavaScript Style Guide

PROGRAMMER ARE THE NEW ROCK STARS

"Code is expensive to change, but design is cheaper to change, and requirements are even cheaper to change." - Daniel T. Barr

DO NOT UNDERESTIMATE THE POWER OF A PROGRAMMER.

"We who cut mere stones must always be envisioning cathedrals." - Quarry worker's creed


To Add

  • GitHub Actions
  • SonarCloud
  • Synk
  • Aspecto
  • Confluent Cloud Span, Logs & Metrics
  • Apache Kafka Local
  • AWS MSK
  • Code Coverage
  • GitHub Codespace
  • Jetbrains Webstorm
  • Jetbrains Spaces
  • Capella Full Text Search
  • Capella Vector Search
  • Caching (redis)

Tracing Code for Node.js (Aspecto Version)

"use strict";

//OpenTelemetry
const { Resource } = require("@opentelemetry/resources");
const {
  SemanticResourceAttributes,
} = require("@opentelemetry/semantic-conventions");
const { SimpleSpanProcessor } = require("@opentelemetry/sdk-trace-base");
const { NodeTracerProvider } = require("@opentelemetry/sdk-trace-node");
const { trace } = require("@opentelemetry/api");

//exporter
const {
  OTLPTraceExporter,
} = require("@opentelemetry/exporter-trace-otlp-http");

//instrumentations
const {
  getNodeAutoInstrumentations,
} = require("@opentelemetry/auto-instrumentations-node");
const {
  ExpressInstrumentation,
} = require("opentelemetry-instrumentation-express");
const {
  MongoDBInstrumentation,
} = require("@opentelemetry/instrumentation-mongodb");
const { HttpInstrumentation } = require("@opentelemetry/instrumentation-http");
const { registerInstrumentations } = require("@opentelemetry/instrumentation");
const {
  KafkaJsInstrumentation,
} = require("opentelemetry-instrumentation-kafkajs");

module.exports = (serviceName) => {
  const exporter = new OTLPTraceExporter({
    url: "https://collector.aspecto.io/v1/traces",
    headers: {
      Authorization: process.env.ASPECTO_API_KEY,
    },
  });

  const provider = new NodeTracerProvider({
    resource: new Resource({
      [SemanticResourceAttributes.SERVICE_NAME]: serviceName,
    }),
  });
  provider.addSpanProcessor(new SimpleSpanProcessor(exporter));

  provider.register();

  registerInstrumentations({
    instrumentations: [
      getNodeAutoInstrumentations(),
      new KafkaJsInstrumentation({}),
      new ExpressInstrumentation({
        requestHook: (span, requestInfo) => {
          span.setAttribute(
            "http.request.body",
            JSON.stringify(requestInfo.req.body)
          );
        },
      }),
      new MongoDBInstrumentation(),
    ],
    tracerProvider: provider,
  });

  return trace.getTracer(serviceName);
};

Siobytes


Silicon Valley - Write code like a normal human being

Always blue, always blue, always blue...

Click on the video below

Letting AI do the coding

simon-microservice's People

Contributors

zx8086 avatar snyk-bot avatar

Stargazers

Bruno Gomes avatar

Watchers

 avatar

Forkers

siobytes

simon-microservice's Issues

Mainly for Kafka Topic Creation

Describe the bug
A clear and concise description of what the bug is.

To Reproduce
Steps to reproduce the behavior:

  1. Go to '...'
  2. Click on '....'
  3. Scroll down to '....'
  4. See error

Expected behavior
A clear and concise description of what you expected to happen.

Screenshots
If applicable, add screenshots to help explain your problem.

Desktop (please complete the following information):

  • OS: [e.g. iOS]
  • Browser [e.g. chrome, safari]
  • Version [e.g. 22]

Smartphone (please complete the following information):

  • Device: [e.g. iPhone6]
  • OS: [e.g. iOS8.1]
  • Browser [e.g. stock browser, safari]
  • Version [e.g. 22]

Additional context
Add any other context about the problem here.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.